[php-src] Issue #9905: constant() behaves unpredictably when class attached to constant is undefined
| From: | AMRoche | Date: | Tue, 08 Nov 2022 15:06:08 +0000 |
| Subject: | [php-src] Issue #9905: constant() behaves unpredictably when class attached to constant is undefined | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242767@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9905
Author: AMRoche
### Description
The following code:
```php
<?php
try {
\constant("\ExistantClass::non_existant_constant");
} catch (\Throwable|\Error|\Exception $e) {
echo($e->getMessage());
}
```
Resulted in this output:
```
⇒ php test.php
PHP Fatal error: Class "ExistantClass" not found in /Users/alexroche/Desktop/test.php on
line 4
Fatal error: Class "ExistantClass" not found in /Users/alexroche/Desktop/test.php on line
4
```
But I expected this output instead:
```
"Error : Class "ExistantClass" not found"
```
(i.e. the error to be caught and the message to be echo'd - what that message is is purely
semantics)
### PHP Version
8.0.25, 8.1.12
### Operating System
_No response_