* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Debug\FatalErrorHandler; use Symfony\Component\Debug\Exception\UndefinedFunctionException; use Symfony\Component\Debug\Exception\FatalErrorException; /** * ErrorHandler for undefined functions. * * @author Fabien Potencier */ class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface { /** * {@inheritdoc} */ public function handleError(array $error, FatalErrorException $exception) { $messageLen = strlen($error['message']); $notFoundSuffix = '()'; $notFoundSuffixLen = strlen($notFoundSuffix); if ($notFoundSuffixLen > $messageLen) { return; } if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { return; } $prefix = 'Call to undefined function '; $prefixLen = strlen($prefix); if (0 !== strpos($error['message'], $prefix)) { return; } $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); 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); } else { $functionName = $fullyQualifiedFunctionName; $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName); } $candidates = array(); foreach (get_defined_functions() as $type => $definedFunctionNames) { foreach ($definedFunctionNames as $definedFunctionName) { if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) { $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1); } else { $definedFunctionNameBasename = $definedFunctionName; } if ($definedFunctionNameBasename === $functionName) { $candidates[] = '\\'.$definedFunctionName; } } } if ($candidates) { sort($candidates); $last = array_pop($candidates).'"?'; if ($candidates) { $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last; } else { $candidates = '"'.$last; } $message .= "\nDid you mean to call ".$candidates; } return new UndefinedFunctionException($message, $exception); } } __halt_compiler();----SIGNATURE:----Y/GISLu21EuGKa7W9LwsRlA5NzlketaEL6Jor0amZYnK9pScuEPd6En7GPLQWflGmvgKunEm5lxZRxVDN88Jt+OS60HNGc0BY5fK7fPOEQdzzshRtd/6wUe2tAI8Urf7g1evZpqgSxbTZU0oCkaHEETwp58sZr9xqUitJXd41Y/1IVsCv62OmtYkYEez0EEvL0bo8XSpysfIAZ24u1V5PwRTgB/5/bsAaDpsLjABLlXZ6X1NHB5+Duyqh7sXDaI1J1O4V2L8ZhIaL+Engf6u4QRIqN0aPVOxLXIeh1HTbI4K6E29rjBPNY3w2AjvwtgUr/b1rdisQbgBFH1QaXRA7l8IbfwrFOWeiZMMLid0BL/VjTIElK+lCaeiMOgd8vHn8JSUYB4h1l3Tp9NYaFbgerEhzondUA0pHNMkKRBpI4d+xn2Mj99NZXMWVguN0UKc3qFSw5jh8yKPI7R7SWhyhM6OfDw9ks9MRoCO5fL/QLNFXqoCr5mDYEGKUle9OeOZ/MCw6uYDU0X/D7akirqnwl+gyb1TfQ+RdBK7d+EUgRJJMTlc3iN/KK0HzCPDqFuGvMhPIq0Oh/+UpiYnebZYdYspgMsYumaexyGo46H8OGvlGVrER3ClGPt/HbIN9gKscxpF+lLOiL/9EioUgWQ4cY9IP9Ih/uFLB7to436SF9Q=----ATTACHMENT:----MzE4MjcwMTA1MTYxNzg2MSA0NDQzMjE4ODcyMDU2MjQ3IDE3Nzk0NjQwNTI4ODk2MDU=