assert() Throws Exception

assert() is the PHP native implementation of assertions. Until PHP 8.0, it would raise an error, while now, it throws an exception.

PHP code

<?php
// error handler function
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
        print __METHOD__;

    return true;
}

set_error_handler('myErrorHandler');

try {
        assert(false);
} catch (\Error $e) {
        print $e->getMessage();
}

?>

Before

myErrorHandler

After

assert(false)

PHP version change

This behavior changed in 8.0