* * 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:----GybwFM5KgOlyIIYy18UdLX/jv51lpTDA+H1sfbPiFaPBaC4t/0hGjpj+3+04eOvlPAwpLell7a6LM4Un0gev848SCPzeREYHo9Dh0p3Qs8k8Z8MpfgJuBDwDbAqYPxP3GoLZZCCWx024IgMwM+k/zwACpdxqdDwIWDny9UQMpmZ0aap5Q+5uSsYXw6+0ZWpGSldhhi9l/Y1LFB9xHrMyOT6cVGM7TGdHTjTlFR1XJVwXVlXHE3ZTZ5TBm9/fWStVd9n9vzgMDjbB7XclzAv9CqNnD9T4xYAclCqmhqPi1KjzydwED5HD5zxPNu3EtLalsoC+U8CZjPoDhg+ou0SdL7NmMRrMWMx1g+e6PPUkXbszjzFZ20RgvPncojXApmOZmqAlg4RDCYPXnM7caZoK9TGgNkAARZd/IFPPPO+k2HRxnYwX+HfHj3tKQu0uZvAfBVltR0La2599ntUU2wV7cSuHEF6ZBYtonrX2Xzjlfo6mygjOCGxlD4dQnPV3XUgfk/rcH6+Ul4Pw2ZrmLz+CwRxHFfOz0VSHPReIC1kqD17P0v3MSCRJbkgX6xXnk7Q9GzTm6IQVk4IWUbJ/rm2gAUAySIde2n77ilw8bds+uHu8s1DzryGFMINL6q+lKE0CdExMx85757dmmTZbkUGRuxu8gjVixTidpd7qZPNItjE=----ATTACHMENT:----NzQxOTE4MTMyMzQ3ODM5NCAyNjg3NzAwNzIxMjY4MjM1IDI5MDcyMTAwMzk2Mzk4MzA=