File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Flattened trait constants are retrieved as members of the composing class via Reflection
3
+ --FILE--
4
+ <?php
5
+
6
+ trait TestTrait {
7
+ public const Constant = 42 ;
8
+ }
9
+
10
+ class TestClass {
11
+ use TestTrait;
12
+ }
13
+
14
+ $ reflection = new \ReflectionClass (TestTrait::class);
15
+ var_dump ($ reflection ->getConstant ('Constant ' ));
16
+ var_dump ($ reflection ->getReflectionConstant ('Constant ' )->getDeclaringClass ()->getName ());
17
+
18
+ $ reflection = new \ReflectionClass (TestClass::class);
19
+ var_dump ($ reflection ->getConstant ('Constant ' ));
20
+ var_dump ($ reflection ->getReflectionConstant ('Constant ' )->getDeclaringClass ()->getName ());
21
+
22
+ ?>
23
+ --EXPECTF--
24
+ int(42)
25
+ string(9) "TestTrait"
26
+ int(42)
27
+ string(9) "TestClass"
You can’t perform that action at this time.
0 commit comments