[php-src] Issue #21507: Confusing error message
[email protected] (exakat)
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <zI6B5U4syMGpQXj7FGNINSwoniM3zXIXBVuGufL3cds@main.internal.php.net> |
Issue: https://github.com/php/php-src/issues/21507
Author: exakat
### Description
The following code:
```php
<?php
class X {
const A = '1';
}
$c = 'b';
isset(X::{$c});
```
Resulted in this (valid) output:
```
atal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead)
```
but I cannot use ``null !== X::{$c}``, which also yields a Fatal Error.
With a constant, this message should recommend using 'defined()' instead, or on top of the current recommendation.
### PHP Version
```plain
Tested on PHP 8.5, but any version since 8.3
```
### Operating System
Not applicable.