Skip to content

[ErrorHandler] Fix strpos error when trying to call a method without a name #40019

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

Merged

Conversation

Deuchnord
Copy link

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets None (direct fix)
License MIT
Doc PR None

When running the following code:

class Foo
{
    // Some code here
}

$str = ''; // this should not happen, but for some reason, it did.
$foo->{$str}();

a fatal error occurs because the method name to execute is empty, but Symfony's error enhancer fails to parse it:

Error screenshot

In this PR, I propose a fix with a more clear error to inform the developer about what happened.

@nicolas-grekas nicolas-grekas changed the title Fix strpos error when trying to call a method without a name [ErrorHandler] Fix strpos error when trying to call a method without a name Jan 28, 2021
@nicolas-grekas
Copy link
Member

Oh, can you also please fix https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php?

@nicolas-grekas
Copy link
Member

Thank you @Deuchnord.

@nicolas-grekas nicolas-grekas force-pushed the fix-strpos-undefined-method-error branch from 888f66c to 66be87b Compare January 28, 2021 16:55
@nicolas-grekas nicolas-grekas merged commit 27fab22 into symfony:4.4 Jan 28, 2021
@Deuchnord Deuchnord deleted the fix-strpos-undefined-method-error branch January 28, 2021 17:42
@fabpot fabpot mentioned this pull request Feb 3, 2021
@fabpot fabpot mentioned this pull request Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants