PhpSpec\Runner\Maintainer\ErrorMaintainer::errorHandler PHP Method

errorHandler() final public method

This method used as custom error handler when step is running.
See also: set_error_handler()
final public errorHandler ( integer $level, string $message, string $file, integer $line ) : boolean
$level integer
$message string
$file string
$line integer
return boolean
    public final function errorHandler($level, $message, $file, $line)
    {
        $regex = '/^Argument (\\d)+ passed to (?:(?P<class>[\\w\\\\]+)::)?(\\w+)\\(\\)' . ' must (?:be an instance of|implement interface) ([\\w\\\\]+),(?: instance of)? ([\\w\\\\]+) given/';
        if (E_RECOVERABLE_ERROR === $level && preg_match($regex, $message, $matches)) {
            $class = $matches['class'];
            if (in_array('PhpSpec\\Specification', class_implements($class))) {
                return true;
            }
        }
        if (0 !== error_reporting()) {
            throw new ExampleException\ErrorException($level, $message, $file, $line);
        }
        // error reporting turned off or more likely suppressed with @
        return false;
    }