* * 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\FatalErrorException; use Symfony\Component\Debug\Exception\UndefinedMethodException; /** * ErrorHandler for undefined methods. * * @author Grégoire Pineau */ class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface { /** * {@inheritdoc} */ public function handleError(array $error, FatalErrorException $exception) { preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches); if (!$matches) { return; } $className = $matches[1]; $methodName = $matches[2]; $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className); if (!class_exists($className) || null === $methods = get_class_methods($className)) { // failed to get the class or its methods on which an unknown method was called (for example on an anonymous class) return new UndefinedMethodException($message, $exception); } $candidates = array(); foreach ($methods as $definedMethodName) { $lev = levenshtein($methodName, $definedMethodName); if ($lev <= strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) { $candidates[] = $definedMethodName; } } 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 UndefinedMethodException($message, $exception); } } __halt_compiler();----SIGNATURE:----wte6EYjVNzYOzmU2FZ3mqQaH3tG/cIxQSWW5DEnCZYLcNbStFR+ecPLSZqOfpdMrHL7RkY7KizGInPj7L5+0iQERm1Vcn/2rP35z5CGWU635FUFuERmT4qYkYNZv5+38ZnxArjecRUbU80+WyjvpG5TgtqwR5I/NxEpIPNAX2JJxrsWC/3PUF4yd4k0mdkGcRmzPJMcF8gnKGTgbnObTrldosdR28q86vWDbLFLpPRij18lkIi42UowsPEp0qyTH+mdvtPvDezWP1AZO1n/H4XxDOhM8N67/9mzMVaKjdvV8/fqPAMx4W3VZzMB0wHK9F8o8U1S72pu1fM9RR7uEVTaKIJiNqm1g31JQucSyOLSw6KfTuveIomNjWt3smZbirGDiLS3qtZz7oQnSh0XNFDD4GGVukA9HNmvIuyy90D53Yv02zR8bqj7+qLu3TufqLt24sE3u0eBmJzAy3GgGcwxrOPZUsu2U/OReGPdx4ztu+dDAOSzNL+6RNa1o2r4FrIrMU9nIcuw43dnRWM5pkJrMTfsmL86286b7rTRPipTlIgP/G0SoynouE3kNViu7wibiq40qEakyXCzNUazPf5IedV30Gsj+Z61zjFBnzJQUDp/ksVT5XeCh1Rh7+cXJGn1rgMbHP3vueDzHtCmrVz3sVLsq2z+Un63RYbNgczc=----ATTACHMENT:----ODgxMDEwMTM4ODg0NTc0OCA4MjAwNDE1NDUwOTQyOTEyIDU1ODU4NTEyODg1MDQ2OTc=