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;
}