[php-src] Issue #12008: static call in constant assigning has a php fatal error
| From: | remco-pc | Date: | Sun, 20 Aug 2023 19:51:31 +0000 |
| Subject: | [php-src] Issue #12008: static call in constant assigning has a php fatal error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245211@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12008
Author: remco-pc
### Description
The following error:
PHP Fatal error: Trait "R3m\Io\Node\Trait\BinarySearch" not found in
/Application/vendor/r3m/framework/src/App.php on line 67
that line
```php
const EVENT = App::NAMESPACE . '.' . Event::NAME; //on line 67
```
Where the error is in the Event.
the event class uses a trait:
```php
use R3m\Io\Node\Trait\Data; //on line 21 which should be preferable included in the error reporting
```
which has the usage on line
```php
use BinarySearch; //on line 23
Resulted in this output:
```
PHP Fatal error: Trait "R3m\Io\Node\Trait\BinarySearch" not found in
/Application/vendor/r3m/framework/src/App.php on line 67
```
But I expected this output instead:
```
PHP Fatal error: Trait "R3m\Io\Node\Trait\BinarySearch" not found in
/Application/vendor/r3m_io/node/src/Trait/Data.php on line 23
Trace:
include Event which defines the usage of the trait Data.
include App which defines the Event static
```
The a sidenode:
are you allowed to make constants in traits ? If not:
Calling a constant then you could get a performance win by perhaps not loading the traits in this
case (calling constants in defining constants).
### PHP Version
8.2.4
### Operating System
Debian 11.6