Skip to content

Commit 23acc24

Browse files
committed
[Debug] made order of suggestions predictable in error messages
1 parent 7affb71 commit 23acc24

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public function handleError(array $error, FatalErrorException $exception)
8080
}
8181

8282
if ($candidates) {
83+
sort($candidates);
8384
$message .= ' Did you mean to call: '.implode(', ', array_map(function ($val) {
8485
return '"'.$val.'"';
8586
}, $candidates)).'?';

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

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function handleError(array $error, FatalErrorException $exception)
4545
}
4646

4747
if ($candidates) {
48+
sort($candidates);
4849
$message .= sprintf(' Did you mean to call: "%s"?', implode('", "', $candidates));
4950
}
5051

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function provideUndefinedMethodData()
5959
'file' => 'foo.php',
6060
'message' => 'Call to undefined method SplObjectStorage::offsetFet()',
6161
),
62-
'Attempted to call method "offsetFet" on class "SplObjectStorage" in foo.php line 12. Did you mean to call: "offsetSet", "offsetUnset", "offsetGet"?',
62+
'Attempted to call method "offsetFet" on class "SplObjectStorage" in foo.php line 12. Did you mean to call: "offsetGet", "offsetSet", "offsetUnset"?',
6363
),
6464
);
6565
}

0 commit comments

Comments
 (0)