8000 Handle anonymous class without methods correctly. · symfony/symfony@feedc5d · GitHub
[go: up one dir, main page]

Skip to content

Commit feedc5d

Browse files
committed
Handle anonymous class without methods correctly.
1 parent 948b44c commit feedc5d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ public function handleError(array $error, FatalErrorException $exception)
3636

3737
$message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
3838

39+
if (null === $methods = get_class_methods($className)) {
40+
return new UndefinedMethodException($message, $exception);
41+
}
42+
3943
$candidates = array();
40-
foreach (get_class_methods($className) as $definedMethodName) {
44+
foreach ($methods as $definedMethodName) {
4145
$lev = levenshtein($methodName, $definedMethodName);
4246
if ($lev <= strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) {
4347
$candidates[] = $definedMethodName;

src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ public function provideUndefinedMethodData()
6161
),
6262
"Attempted to call an undefined method named \"offsetFet\" of class \"SplObjectStorage\".\nDid you mean to call e.g. \"offsetGet\", \"offsetSet\" or \"offsetUnset\"?",
6363
),
64+
array(
65+
array(
66+
'type' => 1,
67+
'message' => 'Call to undefined method class@anonymous::test()',
68+
'file' => '/home/possum/work/symfony/test.php',
69+
'line' => 11,
70+
),
71+
'Attempted to call an undefined method named "test" of class "class@anonymous".'
72+
),
6473
);
6574
}
6675
}

0 commit comments

Comments
 (0)
0