debug_backtrace() can no longer extract arguments by reference in PHP 8
antecedent opened this issue · 1 comments
As of v2.1.12, Patchwork relies on debug_backtrace()
as a convenient means to access arguments anywhere on the call stack by reference. In #100, @anomiex notes that PHP 8 no longer allows this. As a result, redefinitions can only access the call-time argument list by value, even if the argument itself had been passed by reference.
At Patchwork, we have always aimed for the broadest possible coverage of redefinable types of callables. It then follows that a new way of transferring the arguments is necessary.
Short of any simple fixes, I propose that Patchwork's parser scan the argument list of every function, and that Patchwork\CodeManipulation\Actions\CallRerouting\injectCallInterceptionCode()
generate some of the interception code dynamically to account for argument names.
I shall now sketch a fix to verify that this is at all feasible, and if so, I will proceed to a more well-rounded fix that could be incorporated into the next release.
Judging by the passing test suite, this appears to be fixed.