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() does not return the same exact ReflectionAttribute instance
3+ --FILE--
4+ <?php
5+
6+ #[Attribute]
7+ class Demo {
8+ public function __construct () {
9+ global $ originalInstance ;
10+ $ currentInstance = ReflectionAttribute::getCurrent ();
11+ assert ($ originalInstance !== $ currentInstance );
12+ echo "Name: \n" ;
13+ echo $ originalInstance ->name . ' -> ' . $ currentInstance ->name . "\n" ;
14+ echo "Args: \n" ;
15+ var_dump ($ originalInstance ->getArguments ());
16+ var_dump ($ currentInstance ->getArguments ());
17+ assert ($ originalInstance ->getArguments () === $ currentInstance ->getArguments ());
18+ }
19+ }
20+
21+ #[Demo("foo " , true , 123 )]
22+ class WithDemo {}
23+
24+ $ case = new ReflectionClass (WithDemo::class);
25+ $ originalInstance = $ case ->getAttributes ()[0 ];
26+ $ originalInstance ->newInstance ();
27+
28+ ?>
29+ --EXPECT--
30+ Name:
31+ Demo -> Demo
32+ Args:
33+ array(3) {
34+ [0]=>
35+ string(3) "foo"
36+ [1]=>
37+ bool(true)
38+ [2]=>
39+ int(123)
40+ }
41+ array(3) {
42+ [0]=>
43+ string(3) "foo"
44+ [1]=>
45+ bool(true)
46+ [2]=>
47+ int(123)
48+ }
You can’t perform that action at this time.
0 commit comments