Skip to content

Commit de8362a

Browse files
committed
Add test for trait behavior
1 parent 0502cfe commit de8362a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Initializers in traits should not be eagerly evaluated
3+
--FILE--
4+
<?php
5+
6+
class Order {
7+
public function __construct(string $class, int $i) {
8+
echo "Creating $class($i)\n";
9+
}
10+
}
11+
12+
trait T {
13+
public static $s = new Order(self::class, 1);
14+
public $p = new Order(self::class, 2);
15+
}
16+
17+
class C {
18+
use T;
19+
}
20+
new C;
21+
22+
// Lazy-evaluate illegal direct trait access.
23+
T::$s;
24+
25+
?>
26+
--EXPECT--
27+
Creating C(1)
28+
Creating C(2)
29+
Creating T(1)

0 commit comments

Comments
 (0)