-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Debug] UndefinedMethodFatalErrorHandler - Handle anonymous classes #21010
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
Closed
SpacePossum
wants to merge
2
commits into
symfony:2.7
from
SpacePossum:2_7_bug_UndefinedMethodFatalErrorHandler_anonymous_class_without_methods
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could simply be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎
I think code should be as explicit as possible. Here we want to iterate methods if there are any. We don't want to cast the result to an array and iterate that and be depended on the result of the cast. To me it makes no sense that
(array) null
result in an empty array, I would expect an error. Another side effect of always casting is that it would be done even when not needed.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting to an array is something commonly used in the Symfony codebase, even in more critical paths where micro optimizations would matter more. To me the intention is clear, but I hear your arguments.
Also the issue here is more about
class@anonymous
not being a class name, which is whyget_class_methods
returnsnull
as a way to notify there is an issue with the function call, not as I first thought a PHP inconsistency due to an anonymous class without any method. You don't access the generated internal class name here nor the instance, so it's expected to getnull
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, micro optimizations are not needed here as it is already in error/exception path so fast execution is not that important.
Yes, sadly we cannot access the instance of the anonymous class here to figure out what methods are on there, so I guess this is the best we can do.
Let me know if the
array
cast is a deal breaker for the PR to be merged, always happy to agree to disagree and update a PR if the end-result is better than the current state :)