[php-src] Issue #25028: #[\NoDiscard] with PHP function version of call_user_func() does not produce any warning.

From: Date: Thu, 29 Oct 2026 03:40:54 +0000
Subject: [php-src] Issue #25028: #[\NoDiscard] with PHP function version of call_user_func() does not produce any warning.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-253914@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/25028 Author: Girgias ### Description The following code: ```php <?php #[\NoDiscard] function test(): int { return 0; } if (random_int(1,1)) { $fn = 'call_user_func'; } else { $fn = 'nope'; } $fn('test'); ``` See: https://3v4l.org/V8TSN#v Resulted in this output: ``` ``` But I expected this output instead: ``` Warning: The return value of function test() should either be used or intentionally ignored by casting it as (void) in %s on line %d ``` The root cause is that there is no handling of a potential #[\NoDiscard] attribute in the PHP_FUNCTION(call_user_func) version. I'm guessing this also not handled in PHP_FUNCTION(call_user_func_array), PHP_FUNCTION(forward_static_call), and PHP_FUNCTION(forward_static_call_array). ### PHP Version ```plain PHP 8.5 and above ``` ### Operating System _No response_

« previous php.bugs (#253914) next »