The NoDiscard attributeIntroductionThis attribute can be used to indicate that the return value of a function or a method should not be discarded. If the return value is not used in any way, a warning will be emitted. This is useful for functions where not checking the return value is likely to be a bug. To intentionally discard the return value of such a function, use (void) cast to suppress the warning.
Class synopsis
final
NoDiscard
/* Properties */
public
readonly
stringnull
$message;
/* Methods */
public __construct(stringnull
$message = null)Properties
ExamplesExample #1 Basic usage Output of the above example in PHP 8.5 is similar to: Warning: The return value of function bulk_process() should either be used or intentionally ignored by casting it as (void), as processing might fail for individual items Example #2 Intentionally discarding the return value See Also
|