We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
(void)
1 parent 7722e84 commit d7c712eCopy full SHA for d7c712e
Zend/tests/attributes/nodiscard/suppress_cast_destructor.phpt
@@ -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