Spot the bug in the warning handler

from Error handling
PHP 8.3.33 intermediate 4 min 2 issues to find

Find why a suppressed warning still throws and why later tests inherit this conversion policy.

php
<?php
function withStrictWarnings(callable $operation): mixed
{
    set_error_handler(
        static function (int $severity, string $message, string $file, int $line): bool {
            throw new ErrorException($message, 0, $severity, $file, $line);
        },
    );
    return $operation();
}
Open in playground
Report an error