Skip to content

Commit 3bf4ccb

Browse files
committed
Add test for using first-class callable syntax inside annotations
See https://wiki.php.net/rfc/fcc_in_const_expr#examples
1 parent 1ae3ccb commit 3bf4ccb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/test/php/lang/ast/unittest/emit/CallableSyntaxTest.class.php

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/**
77
* Tests for first-class callable syntax
88
*
9+
* @see https://wiki.php.net/rfc/fcc_in_const_expr
910
* @see https://wiki.php.net/rfc/first_class_callable_syntax#proposal
1011
*/
1112
class CallableSyntaxTest extends EmittingTest {
@@ -182,4 +183,16 @@ public function __construct($value) { $this->value= $value; }
182183
}');
183184
Assert::equals($this, $f($this)->value);
184185
}
186+
187+
#[Test]
188+
public function inside_annotation() {
189+
$f= $this->run('use lang\Reflection; class %T {
190+
191+
#[Attr(strrev(...))]
192+
public function run() {
193+
return Reflection::of($this)->method("run")->annotation(Attr::class)->argument(0);
194+
}
195+
}');
196+
Assert::equals('cba', $f('abc'));
197+
}
185198
}

0 commit comments

Comments
 (0)