Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoloader bug when used with Doctrine and Annotations. #25

Open
Warxcell opened this issue Feb 1, 2021 · 3 comments
Open

Autoloader bug when used with Doctrine and Annotations. #25

Warxcell opened this issue Feb 1, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@Warxcell
Copy link

Warxcell commented Feb 1, 2021

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.

@Warxcell
Copy link
Author

Warxcell commented Feb 2, 2021

I discovered that this method usually break up randomly. so I ended up like that:

EntityEnum.php

<?php

declare(strict_types=1);

class_alias(NonEntityEnm::class, 'EntityEnum');

@dbalabka dbalabka added the bug Something isn't working label Feb 19, 2021
@dbalabka
Copy link
Owner

@Warxcell thanks for the bug report. I will find out how to solve it for you.

In general, I'm going to suspend the whole development of this repository but will keep updates for people who already using it. I've mentioned it here as well:
#17 (comment)

@Warxcell
Copy link
Author

I doubt it there is a fix for that. At least I couldn't figure it out. Just posted here to be known for everybody. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants