* * 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:----p43BG9VIa9d73m7mzdhBeFIXBvQ3JJZPZMd+ID5eYUyHaQoM7BFyJkJVkIAqwxk6mh3Uv3QIY0Qos2g1DyBz6Kzk/TizeDJX6elgeWLJqUtXWGvPPIRVJ+WlERQkyoXovxirIqdyOpcOBeoUgbuO70vOz4KC3LiEAap2j6tkkeeodsVJ4oQGxUTYJSqYd5JU7Z+C6WiZlZAhKd4LzM0hf6NTJmO8HtOrfe7WShu/sai7eLViXxIGHbVmww1vlcU//vr0HqCLdXu0Sp0+w+ymGfasONOgfLf2qNSgv7P25uddtDtf8vhCjIGYLK/Y6XGCmFDiB1wsuxjsLDb1CK1mpV/pBWKc7aIZl1fOHY00txdulhTXS63MUzb5+wFYGYR7/r+z7X9xd3rWf6MGBad447JaHCC58fyMrKYZvAH8Vv2fi6sq+gqkBrgTm1u7TJeztrs1m586Tv4NuNRoJW9amF9YTnpFKiFX0n/hnHrinLYoLdBac6E+UfvI66qKcC9+wdVT0JuH/AwwrwDIE6b8TbXyT7eL4hOWfzG7oMgH1I3Dw6McoyefAeVx53xD1WKMYj72t8VyE0NvATRhJnEU7QaVodmfZojYUej0Y4KmXTX5FJJQs0P4qxh87bnJm2WNvqvULzbI7D1Vy+ZjW6fWbms1bEGtGiv+gwAc/HEHY2I=----ATTACHMENT:----OTgzMjkxODcyNjc4NDcxMSA5MTQxMTU2ODc4Nzg0NzQgMzE1MjA2MDIyNTEzNTE4