summaryrefslogtreecommitdiff
path: root/Zend/tests/ctor_promotion_defaults.phpt
blob: 9999e8a539ce891e63353e2c6f0712840c0aa7c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--TEST--
Constructor promotion with default values
--FILE--
<?php

class Point {
    public function __construct(
        public float $x = 0.0,
        public float $y = 1.0,
        public float $z = 2.0
    ) {}
}

var_dump(new Point(10.0));
var_dump(new Point(10.0, 11.0));
var_dump(new Point(10.0, 11.0, 12.0));

?>
--EXPECT--
object(Point)#1 (3) {
  ["x"]=>
  float(10)
  ["y"]=>
  float(1)
  ["z"]=>
  float(2)
}
object(Point)#1 (3) {
  ["x"]=>
  float(10)
  ["y"]=>
  float(11)
  ["z"]=>
  float(2)
}
object(Point)#1 (3) {
  ["x"]=>
  float(10)
  ["y"]=>
  float(11)
  ["z"]=>
  float(12)
}