Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow inherited magic method to still run with calling class #3719

Closed
wants to merge 2 commits into from

Conversation

bennothommo
Copy link
Contributor

If a static method cannot be resolved to the calling class, but the calling class has, or inherits, a __callStatic handler, this allows the __callStatic handler to be used with the calling class, and not the inherited class as would occur with reflection. This allows systems such as Laravel facades to still work.

Fixes #3716

If a static method cannot be resolved to the calling class, but the calling class has, or inherits, a `__callStatic` handler, this allows the `__callStatic` handler to be used with the calling class, and not the inherited class as would occur with reflection. This allows systems such as Laravel facades to still work.

Fixes twigphp#3716
@bennothommo
Copy link
Contributor Author

If this fix is acceptable, I'm happy to do a PR to the 2.x branch as well.

@LukeTowers
Copy link

@bennothommo are you able to add the test case that fails before this change and passes after too?

@bennothommo
Copy link
Contributor Author

bennothommo commented Jun 28, 2022

@LukeTowers if you mean my original test patch, that works irrespective of this fix. The issue only manifests when rendering the template. I'm not sure where to put that into a test.

@LukeTowers
Copy link

@stof @nicolas-grekas any guidance on tests for this PR?

@stof
Copy link
Member

stof commented Jun 28, 2022

We do have integration tests that render templates

@bennothommo
Copy link
Contributor Author

Found them - thanks @stof.

LukeTowers pushed a commit to wintercms/storm that referenced this pull request Jul 5, 2022
Temporary fix while waiting for twigphp/Twig#3719 to be merged.
@nicolas-grekas
Copy link
Contributor

Thanks for the PR. I've ported it to #3722

fabpot added a commit that referenced this pull request Aug 12, 2022
…s (bennothommo)

This PR was merged into the 2.x branch.

Discussion
----------

Allow inherited magic method to still run with calling class

This is #3719 ported to 2.x and improved a bit.

I also reported php/php-src#8932 because the underlying behavior of PHP is broken to me.

If a static method cannot be resolved to the calling class, but the calling class has, or inherits, a `__callStatic` handler, this allows the `__callStatic` handler to be used with the calling class, and not the inherited class as would occur with reflection. This allows systems such as Laravel facades to still work.

Fixes #3716

Commits
-------

d1457a4 Allow inherited magic method to still run with calling class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Aliased/extended classes may not be reflected correctly when creating filter expressions
4 participants