-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
PropertyAccessDecorator should not accept callable strings #17993
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
Comments
Exactly this was changed in #15561. To me, the behavior could be unexpected in both ways. But since people can just pass a If you think we should revert that, we could just do it as a hotfix as well I assume. |
…ecorator ref symfony#17993. Handle edge cases where a callable string is passed to the `PropertyAccessDecorator` for choice list factories. Wrapping the callable string in a closure prevents a potential fatal error, since it may be called with the wrong arguments.
I just ran into this as a regression when upgrading my Symfony version. In my case I was accessing a property called I'd agree this is confusing behaviour. |
This PR was merged into the 3.1-dev branch. Discussion ---------- fix #17993 - Deprecated callable strings | Q | A | ------------- | --- | Branch | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | no | Fixed tickets | #17993 | License | MIT | Doc PR | Is this ok ? - [x] Rebase when #18057 is merged Commits ------- 191b495 fix #17993 - Deprecated callable strings
Right now, PropertyAccessDecorator treats callable strings as callables, not as strings. Consequently the following code does not behave as expected:
This code results in a fatal error. The
end()
function exists (is callable), hence the string is not treated as property path. Instead,end()
is called with invalid arguments. IMO there are very few cases where this would be the expected behavior, and even if, it could be solved by passing a closure:Treating callable strings as callables should be deprecated. I.e., all methods of PropertyAccessDecorator should trigger deprecation errors
if (is_string($value) && is_callable($value))
.The text was updated successfully, but these errors were encountered: