<?php

declare(strict_types=1);

namespace PhpWA\Runtime;









final class SafeRuntime
{
    




    public static function call(callable $operation, $fallback = false)
    {
        $warning = null;
        set_error_handler(static function (int $severity, string $message) use (&$warning): bool {
            $warning = array('severity' => $severity, 'message' => $message);
            return true;
        });

        try {
            $result = $operation();
            return $warning === null ? $result : $fallback;
        } finally {
            restore_error_handler();
        }
    }

    private function __construct()
    {
    }
}
