dbalabka / dbalabka/php-enumeration
Autoloader bug when used with Doctrine and Annotations.
- Dominant language
- PHP
- Stars
- 53
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Doctrine is using manually `require_once` and if it happens Enum class to be in Entity folder - It bypasses the autoloader and __constructStatic is never called.
https://github.com/doctrine/persistence/blob/2.1.x/lib/Doctrine/Persistence/Mapping/Driver/AnnotationDriver.php#L234
I don't have idea how to fix it generally. For quick fix in my code i did intermediate class.
```php
final class EntityEnum extends NonEntityEnum
{
}
```
```php
abstract class NonEntityEnum extends Enumeration
{
public static EntityEnum $value;
protected static function initializeValues(): void
{
self::$value = new EntityEnum();
}
}
```
so when Doctrine `require_once 'EntityEnum.php';` it will lead autoloader to `NonEntityEnum` and it will call the constructStatic.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.