Skip to content

Fix call_user_func of a static method in PHP 8.6 - #227

Merged
anomiex merged 2 commits into
masterfrom
fix/call_user_func-static-method-php-8.6
Nov 9, 2026
Merged

anomiex merged 2 commits into
masterfrom
fix/call_user_func-static-method-php-8.6

Conversation

@anomiex

@anomiex anomiex commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

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.

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.
@anomiex
anomiex requested review from antecedent and jrfnl November 6, 2026 03:03
@anomiex anomiex self-assigned this Nov 6, 2026
@anomiex anomiex added the Bug label Nov 6, 2026

@jrfnl jrfnl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

@jrfnl jrfnl added this to the 2.2 Next milestone Nov 6, 2026
@anomiex

anomiex commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator Author

Sure, may as well merge them.

@anomiex
anomiex merged commit 340ea2e into master Nov 9, 2026
26 checks passed
@anomiex
anomiex deleted the fix/call_user_func-static-method-php-8.6 branch November 9, 2026 15:19
@jrfnl

jrfnl commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

@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 ?

@antecedent

antecedent commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

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.

@antecedent I believe it would be prudent to release again soonish to unblock projects getting ready for PHP 8.6.

I agree! I think the master branch is good to go for a new 2.2.x tag (and release) at this stage? #225 could remain scheduled for the next tag after that. Could @jrfnl or @anomiex also confirm that they see it this way?

@jrfnl

jrfnl commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

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.

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 master" for the pull request, with master including the changes from this PR, which would be an extra validation that all is fine for PHP 8.6 based on the currently known issues covered by the tests.

No biggie, but can sometimes just be that little bit of extra reassurance.

@antecedent I believe it would be prudent to release again soonish to unblock projects getting ready for PHP 8.6.

I agree! I think the master branch is good to go for a new 2.2.x tag (and release) at this stage? #225 could remain scheduled for the next tag after that. Could @jrfnl or @anomiex also confirm that they see it this way?

👍🏻 from me. Getting this change released is more important at this time what with the upcoming PHP 8.6 release.

@anomiex

anomiex commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

Could @jrfnl or @anomiex also confirm that they see it this way?

Sounds like a good plan to me too.

@antecedent

Copy link
Copy Markdown
Owner

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.

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 master" for the pull request, with master including the changes from this PR, which would be an extra validation that all is fine for PHP 8.6 based on the currently known issues covered by the tests.

No biggie, but can sometimes just be that little bit of extra reassurance.

@jrfnl Got it! Thanks for taking the time to explain this.

@antecedent

Copy link
Copy Markdown
Owner

Update: I added a tag (2.2.5) and published a release a moment ago.

@jrfnl

jrfnl commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Thank you @antecedent !

@jrfnl

jrfnl commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

@antecedent Might it be an idea to document the release process at some point ?

I've done this in other repos by adding a release-checklist.md file into the .github directory, like so:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants