Repository navigation
Fix call_user_func of a static method in PHP 8.6 - #227
Conversation
PHP 8.6 has deprecated passing an object to `ReflectionMethod->invokeArgs()` if the method is static. An old fix for #99 is causing Patchwork to do this if a non-static method uses `call_user_func()` to call a static method, when other internals are redefined. Reflection can tell us whether the method we're calling is static for an easy fix to this issue while hopefully not breaking whatever was happening in #99.
jrfnl
left a comment
There was a problem hiding this comment.
No objections from my side. I've confirmed the tests fail without this fix and pass with the fix.
Nitpick: line 521-527 also deal with setting the $instance. Should those lines be moved into the try-catch and be combined with the fix on line 531-534 ?
Might make the code a little tidier and more straight-forward to read and understand.
For the record:
- The PHP 8.6 RFC proposing the deprecation
- The documentation of the relevant PHP methods:
- PHP 8.6 migration guide
|
Sure, may as well merge them. |
|
@antecedent I believe it would be prudent to release again soonish to unblock projects getting ready for PHP 8.6. Maybe include PR #229 still and release after ? Want me to rebase PR #229 ? |
Could you help me understand why a rebase could be necessary here? Not that I disagree; I suspect I am just missing some background to be able to follow. I did already merge #228 and #229 without (explicitly) rebasing, so this probably no longer matters in the narrow practical sense, but still I would like to be able to unpack this.
I agree! I think the |
The original CI run for #229 did not include the changes from this PR as it wasn't merge yet. The rebase would trigger a re-run of the CI jobs for PR #229 and that re-run would then run for a "merge against No biggie, but can sometimes just be that little bit of extra reassurance.
👍🏻 from me. Getting this change released is more important at this time what with the upcoming PHP 8.6 release. |
@jrfnl Got it! Thanks for taking the time to explain this. |
|
Update: I added a tag (2.2.5) and published a release a moment ago. |
|
Thank you @antecedent ! |
|
@antecedent Might it be an idea to document the release process at some point ? I've done this in other repos by adding a |
PHP 8.6 has deprecated passing an object to
ReflectionMethod->invokeArgs()if the method is static. An old fix for #99 is causing Patchwork to do this if a non-static method usescall_user_func()to call a static method, when other internals are redefined.Reflection can tell us whether the method we're calling is static for an easy fix to this issue while hopefully not breaking whatever was happening in #99.