File tree Expand file tree Collapse file tree
ext/reflection/tests/attribute_get_current Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ --TEST--
2+ ReflectionAttribute::getCurrent() allowed when attribute constructor comes from trait
3+ --FILE--
4+ <?php
5+
6+ trait DemoTrait {
7+ public function __construct ($ args ) {
8+ echo "In trait \n" ;
9+ echo __METHOD__ . "() \n" ;
10+ echo ReflectionAttribute::getCurrent ();
11+ }
12+ }
13+
14+ #[Attribute]
15+ class Demo {
16+ use DemoTrait;
17+ }
18+
19+ #[Demo("class " )]
20+ class WithDemo {
21+
22+ }
23+
24+ $ case = new ReflectionClass (WithDemo::class);
25+ echo $ case ;
26+ echo "\n" ;
27+ $ case ->getAttributes ()[0 ]->newInstance ();
28+
29+
30+ ?>
31+ --EXPECTF--
32+ Class [ <user> class WithDemo ] {
33+ @@ %s %d-%d
34+
35+ - Constants [0] {
36+ }
37+
38+ - Static properties [0] {
39+ }
40+
41+ - Static methods [0] {
42+ }
43+
44+ - Properties [0] {
45+ }
46+
47+ - Methods [0] {
48+ }
49+ }
50+
51+ In trait
52+ DemoTrait::__construct()
53+ Class [ <user> class WithDemo ] {
54+ @@ %s %d-%d
55+
56+ - Constants [0] {
57+ }
58+
59+ - Static properties [0] {
60+ }
61+
62+ - Static methods [0] {
63+ }
64+
65+ - Properties [0] {
66+ }
67+
68+ - Methods [0] {
69+ }
70+ }
You can’t perform that action at this time.
0 commit comments