Skip to content

Autoloader bug when used with Doctrine and Annotations. #25

Open
@Warxcell

Description

@Warxcell

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.

final class EntityEnum extends NonEntityEnum
{
}
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions