public static function run(callable $function)
    {
        set_error_handler(static function($severity, $message, $file, $line) {
            throw new \ErrorException($message, 0, $severity, $file, $line);
        });

        try {
            $result = $function();
        } finally {
            restore_error_handler();
        }

        return $result;
    }
public static function run(callable $function)
    {
        set_error_handler(static function($severity, $message, $file, $line) {
            throw new \ErrorException($message, 0, $severity, $file, $line);
        });

        try {
            $result = $function();
        } finally {
            restore_error_handler();
        }

        return $result;
    }
public static function run ( callable $ function ) { set_error_handler ( static function ( $ severity , $ message , $ file , $ line ) { throw new \ ErrorException ( $ message , 0 , $ severity , $ file , $ line ) ; } ) ; try { $ result = $ function ( ) ; } finally { restore_error_handler ( ) ; } return $ result ; }
Runs the given function, catching PHP errors and throwing exceptions.

@param callable $function The function to execute.

@return mixed The return value of the function.

@throws \ErrorException If a PHP error occurs.
Runs the given function catching PHP errors and throwing exceptions .