Skip to content

Commit

Permalink
fixup! Add (void) cast
Browse files Browse the repository at this point in the history
  • Loading branch information
TimWolla committed Jan 27, 2025
1 parent 7722e84 commit d7c712e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Zend/tests/attributes/nodiscard/suppress_cast_destructor.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
#[\NoDiscard]: Casting to (void) destroys the value.
--FILE--
<?php

class WithDestructor {
public function __destruct() {
echo __METHOD__, PHP_EOL;
}
}

#[\NoDiscard]
function test(): WithDestructor {
return new WithDestructor();
}

function do_it(): void {
echo "Before", PHP_EOL;

(void)test();

echo "After", PHP_EOL;
}

do_it();

?>
--EXPECT--
Before
WithDestructor::__destruct
After

0 comments on commit d7c712e

Please sign in to comment.