We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0502cfe commit de8362aCopy full SHA for de8362a
Zend/tests/constexpr/trait_evaluation.phpt
@@ -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