Skip to content

Commit a96398e

Browse files
committed
Add AST printing test
1 parent a75d04c commit a96398e

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
AST printing for closures in attributes
3+
--FILE--
4+
<?php
5+
6+
// Do not use `false &&` to fully evaluate the function / class definition.
7+
8+
try {
9+
\assert(
10+
!
11+
#[Attr(static function ($foo) {
12+
echo $foo;
13+
})]
14+
function () { }
15+
);
16+
} catch (Error $e) {
17+
echo $e->getMessage(), "\n";
18+
}
19+
20+
try {
21+
\assert(
22+
!
23+
new #[Attr(static function ($foo) {
24+
echo $foo;
25+
})]
26+
class {}
27+
);
28+
} catch (Error $e) {
29+
echo $e->getMessage(), "\n";
30+
}
31+
32+
?>
33+
--EXPECT--
34+
assert(!#[Attr(static function ($foo) {
35+
echo $foo;
36+
})] function () {
37+
})
38+
assert(!new #[Attr(static function ($foo) {
39+
echo $foo;
40+
})] class {
41+
})

0 commit comments

Comments
 (0)