Skip to content

Commit d7c712e

Browse files
committed
fixup! Add (void) cast
1 parent 7722e84 commit d7c712e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
#[\NoDiscard]: Casting to (void) destroys the value.
3+
--FILE--
4+
<?php
5+
6+
class WithDestructor {
7+
public function __destruct() {
8+
echo __METHOD__, PHP_EOL;
9+
}
10+
}
11+
12+
#[\NoDiscard]
13+
function test(): WithDestructor {
14+
return new WithDestructor();
15+
}
16+
17+
function do_it(): void {
18+
echo "Before", PHP_EOL;
19+
20+
(void)test();
21+
22+
echo "After", PHP_EOL;
23+
}
24+
25+
do_it();
26+
27+
?>
28+
--EXPECT--
29+
Before
30+
WithDestructor::__destruct
31+
After

0 commit comments

Comments
 (0)