Skip to content

Commit

Permalink
Add test for using first-class callable syntax inside annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Jan 25, 2025
1 parent 1ae3ccb commit 3bf4ccb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/php/lang/ast/unittest/emit/CallableSyntaxTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/**
* Tests for first-class callable syntax
*
* @see https://wiki.php.net/rfc/fcc_in_const_expr
* @see https://wiki.php.net/rfc/first_class_callable_syntax#proposal
*/
class CallableSyntaxTest extends EmittingTest {
Expand Down Expand Up @@ -182,4 +183,16 @@ public function __construct($value) { $this->value= $value; }
}');
Assert::equals($this, $f($this)->value);
}

#[Test]
public function inside_annotation() {
$f= $this->run('use lang\Reflection; class %T {
#[Attr(strrev(...))]
public function run() {
return Reflection::of($this)->method("run")->annotation(Attr::class)->argument(0);
}
}');
Assert::equals('cba', $f('abc'));
}
}

0 comments on commit 3bf4ccb

Please sign in to comment.