Bug #80305 [NEW]: Call with the splat operator ignores by reference requirements

From: Date: Sun, 01 Nov 2020 15:39:00 +0000
Subject: Bug #80305 [NEW]: Call with the splat operator ignores by reference requirements
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230054@lists.php.net to get a copy of this message
From: greedy dot ivan at gmail dot com Operating system: All PHP version: 7.4.12 Package: *General Issues Bug Type: Bug Bug description:Call with the splat operator ignores by reference requirements Description: ------------ 1. Passing arguments using the ... operator ignores requirements as to which arguments must be passed by reference. 2. Prevents warnings from subsequent calls that previously threw it (maybe it is some inner cache issue). https://3v4l.org/ksVmp Actually, there is a different behavior for 7.0, 7.3+, and 7.1 - 7.2. Test script: --------------- <?php $foo = function (int &$bar) { $bar++; }; $baz = 0; $args = [$baz]; call_user_func_array($foo, $args); echo $args[0]; call_user_func_array($foo, $args); echo $args[0]; $foo(...$args); echo $args[0]; call_user_func_array($foo, $args); echo $args[0]; call_user_func_array($foo, $args); echo $args[0]; Expected result: ---------------- Warning: Parameter 1 to {closure}() expected to be a reference, value given in /in/ksVmp on line 7 0 Warning: Parameter 1 to {closure}() expected to be a reference, value given in /in/ksVmp on line 10 0 Warning: Parameter 1 to {closure}() expected to be a reference, value given in /in/ksVmp on line 13 0 Warning: Parameter 1 to {closure}() expected to be a reference, value given in /in/ksVmp on line 16 0 Warning: Parameter 1 to {closure}() expected to be a reference, value given in /in/ksVmp on line 19 0 Actual result: -------------- Warning: Parameter 1 to {closure}() expected to be a reference, value given in /in/ksVmp on line 7 0 Warning: Parameter 1 to {closure}() expected to be a reference, value given in /in/ksVmp on line 10 0123 -- Edit bug report at https://bugs.php.net/bug.php?id=80305&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80305&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80305&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80305&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80305&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80305&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80305&r=support Expected behavior: https://bugs.php.net/fix.php?id=80305&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80305&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80305&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80305&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80305&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80305&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80305&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80305&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80305&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80305&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80305&r=mysqlcfg

« previous php.bugs (#230054) next »