The return value of function %s() should either be used or intentionally ignored by casting it as (void)%S code¶
Description¶
.
Example¶
<?php
#[NoDiscard]
function foo() {
return 1;
}
foo();
?>
Literal Examples¶
The return value of function foo() should either be used or intentionally ignored by casting it as (void)
Solutions¶
Add the
(void)cast to the function call, so as to ignore the returned value.Store the result of the function call in a variable and use it.
Changed Behavior¶
This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.