From 126f5562043ec9555e238def3a613ce5b0aa2367 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 3 Mar 2025 09:24:15 +0100 Subject: [PATCH] [ErrorHandler] Improve an error message --- .../ErrorEnhancer/UndefinedFunctionErrorEnhancer.php | 4 ++-- .../ErrorEnhancer/UndefinedFunctionErrorEnhancerTest.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedFunctionErrorEnhancer.php b/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedFunctionErrorEnhancer.php index e1d54ab899bf6..41d7af3a42b98 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedFunctionErrorEnhancer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedFunctionErrorEnhancer.php @@ -47,10 +47,10 @@ public function enhance(\Throwable $error): ?\Throwable if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) { $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1); $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex); - $message = \sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix); + $message = \sprintf('Attempted to call undefined function "%s" from namespace "%s".', $functionName, $namespacePrefix); } else { $functionName = $fullyQualifiedFunctionName; - $message = \sprintf('Attempted to call function "%s" from the global namespace.', $functionName); + $message = \sprintf('Attempted to call undefined function "%s" from the global namespace.', $functionName); } $candidates = []; diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedFunctionErrorEnhancerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedFunctionErrorEnhancerTest.php index f9474f7e7f58f..b5a0d91b55b7f 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedFunctionErrorEnhancerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/UndefinedFunctionErrorEnhancerTest.php @@ -39,19 +39,19 @@ public static function provideUndefinedFunctionData() return [ [ 'Call to undefined function test_namespaced_function()', - "Attempted to call function \"test_namespaced_function\" from the global namespace.\nDid you mean to call \"\\symfony\\component\\errorhandler\\tests\\errorenhancer\\test_namespaced_function\"?", + "Attempted to call undefined function \"test_namespaced_function\" from the global namespace.\nDid you mean to call \"\\symfony\\component\\errorhandler\\tests\\errorenhancer\\test_namespaced_function\"?", ], [ 'Call to undefined function Foo\\Bar\\Baz\\test_namespaced_function()', - "Attempted to call function \"test_namespaced_function\" from namespace \"Foo\\Bar\\Baz\".\nDid you mean to call \"\\symfony\\component\\errorhandler\\tests\\errorenhancer\\test_namespaced_function\"?", + "Attempted to call undefined function \"test_namespaced_function\" from namespace \"Foo\\Bar\\Baz\".\nDid you mean to call \"\\symfony\\component\\errorhandler\\tests\\errorenhancer\\test_namespaced_function\"?", ], [ 'Call to undefined function foo()', - 'Attempted to call function "foo" from the global namespace.', + 'Attempted to call undefined function "foo" from the global namespace.', ], [ 'Call to undefined function Foo\\Bar\\Baz\\foo()', - 'Attempted to call function "foo" from namespace "Foo\Bar\Baz".', + 'Attempted to call undefined function "foo" from namespace "Foo\Bar\Baz".', ], ]; }