File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Evaluation order of initializers in class declaration
3
+ --FILE--
4
+ <?php
5
+
6
+ class Order {
7
+ public function __construct (int $ i ) {
8
+ echo "Creating $ i \n" ;
9
+ }
10
+ }
11
+
12
+ class A {
13
+ const C1 = new Order (1 );
14
+ public static $ s1 = new Order (3 );
15
+ public $ p1 = new Order (10 );
16
+ const C2 = new Order (2 );
17
+ public static $ s2 = new Order (4 );
18
+ public $ p2 = new Order (11 );
19
+ }
20
+ class B extends A {
21
+ const C3 = new Order (5 );
22
+ public static $ s3 = new Order (6 );
23
+ public $ p3 = new Order (12 );
24
+ }
25
+
26
+ echo "\n" ;
27
+ new A ;
28
+ echo "\n" ;
29
+ new B ;
30
+
31
+ ?>
32
+ --EXPECT--
33
+ Creating 1
34
+ Creating 2
35
+ Creating 3
36
+ Creating 4
37
+ Creating 5
38
+ Creating 6
39
+
40
+ Creating 10
41
+ Creating 11
42
+
43
+ Creating 10
44
+ Creating 11
45
+ Creating 12
You can’t perform that action at this time.
0 commit comments