public static function detect($callable, $mask = -1)
    {
        $error = null;
        set_error_handler(function ($type, $message, $file, $line) use ($error) {
            $error = new ErrorException($message, 0, $type, $file, $line);
        }, $mask);
        $callable();
        restore_error_handler();
        return $error;
    }
public static function detect($callable, $mask = -1)
    {
        $error = null;
        set_error_handler(function ($type, $message, $file, $line) use ($error) {
            $error = new ErrorException($message, 0, $type, $file, $line);
        }, $mask);
        $callable();
        restore_error_handler();
        return $error;
    }
public static function detect ( $ callable , $ mask = - 1 ) { $ error = null ; set_error_handler ( function ( $ type , $ message , $ file , $ line ) use ( $ error ) { $ error = new ErrorException ( $ message , 0 , $ type , $ file , $ line ) ; } , $ mask ) ; $ callable ( ) ; restore_error_handler ( ) ; return $ error ; }
Detect one or more PHP error messages and return the last one.

@param callable $callable
Function to catch error in.
@param int $mask
Error type mask, e.g. `E_ERROR | E_WARNING` to detect
errors or warnings. Default is -1 which catches everything.
@return string|null Last error message or null if no error was triggered.
Detect one or more PHP error messages and return the last one .