Skip to content

Commit 20f991c

Browse files
committed
Add a testcase for retrieving trait constants via Reflection
1 parent 34c412a commit 20f991c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Zend/tests/traits/constant_019.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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"

0 commit comments

Comments
 (0)