File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
Zend/tests/attributes/constants Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,22 @@ Verify that named parameters can be passed to attributes on constants
33--FILE--
44<?php
55
6- #[MyAttribute(foo: "bar " )]
7- const EXAMPLE = 'Foo ' ;
6+ #[Attribute]
7+ class MyAttribute {
8+ public function __construct ($ first , $ second ) {
9+ echo "first: $ first \n" ;
10+ echo "second: $ second \n" ;
11+ }
12+ }
13+
14+ #[MyAttribute(second: "bar " , first: "foo " )]
15+ const EXAMPLE = 'ignored ' ;
816
917$ ref = new ReflectionConstant ('EXAMPLE ' );
1018$ attribs = $ ref ->getAttributes ();
1119var_dump ($ attribs );
1220var_dump ($ attribs [0 ]->getArguments ());
21+ $ attribs [0 ]->newInstance ();
1322
1423?>
1524--EXPECTF--
@@ -20,7 +29,11 @@ array(1) {
2029 string(11) "MyAttribute"
2130 }
2231}
23- array(1 ) {
24- ["foo "]=>
32+ array(2 ) {
33+ ["second "]=>
2534 string(3) "bar"
35+ ["first"]=>
36+ string(3) "foo"
2637}
38+ first: foo
39+ second: bar
You can’t perform that action at this time.
0 commit comments