Error: "uasort(): Argument #1 ($array) must be passed by reference, value given"
chrisvanpatten opened this issue · 4 comments
I have a standard uasort operation happening in a function that I'm testing. However, using uasort is triggering this error:
uasort(): Argument #1 ($array) must be passed by reference, value given
at vendor/antecedent/patchwork/src/CallRerouting.php:540
536▕ }
537▕ # Give the inspected arguments back to the *original* definition of the
538▕ # callback-taking function, e.g. \array_map(). This works given that the
539▕ # present patch is the innermost.
➜ 540▕ return call_user_func_array($function, $args);
541▕ });
542▕ }
543▕ }
544▕
Patchwork has uasort
in its default set of redefineable functions, but if I remove it from that list (in src/Config.php
) it works totally fine and the test doesn't fail. Is it maybe possible to remove a function from the default list in a project's patchwork.json
?
Looks like PHP 8 changed the behavior of debug_backtrace()
to no longer return references in its 'args'
. Probably that was the fix in https://bugs.php.net/bug.php?id=79108, although I haven't checked.
I've now verified that reverting the patch in https://bugs.php.net/bug.php?id=79108 restores the debug_backtrace()
behavior that Patchwork relies on.
What is the status of this issue? I'm experiencing issues using redefine with a callback with a parameter that is passed by reference. I'm using patchwork 2.1.21 and PHP 7.4.27
Stacktrace shows:
antecedent/patchwork/src/CallRerouting.php:285
function dispatchTo(callable $target)
{
return call_user_func_array($target, Stack\top('args'));
}
The bug described here only affected php 8, and appears to have been fixed in 2.1.13.
I'd recommend you try putting together a simple test case and file a new bug report.