[php-src] Issue #9059: Covariant doesn't throw exception when non-existing class used

From: Date: Wed, 20 Jul 2022 08:05:27 +0000
Subject: [php-src] Issue #9059: Covariant doesn't throw exception when non-existing class used
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241953@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9059 Author: jakubtobiasz ### Description Background: doctrine/dbal version 2 had a class named Doctrine\DBAL\DBALException but it was renamed to Doctrine\DBAL\Exception in version 3. We've noticed using covariant in catch doesn't throw an exception that class not found. Is it expected behavior? The following code: ```php <?php try { throw new \Exception('hello'); } catch (\Exception|\My\Non\Existing\Exception $e) { echo "hello there"; } ``` Resulted in this output: ``` "hello there" ``` But I expected this output instead: ``` Fatal error: Class "\My\Non\Existing\Exception" not found ``` ### PHP Version 8.0+ ### Operating System _No response_

« previous php.bugs (#241953) next »