psalm / psalm-plugin-symfony

Psalm Plugin for Symfony
MIT License
228 stars 53 forks source link

Uncaught Exception: Error Undefined constant DBTrait::REPOSITORY_CLASS #257

Closed mathroc closed 2 years ago

mathroc commented 2 years ago

Uncaught Exception: Error Undefined constant MyTrait::REPOSITORY_CLASS Emitted in /var/www/vendor/psalm/plugin-symfony/src/Handler/ContainerHandler.php:105

It's caused by this code:

trait DBTrait
{
    public function getDB(): ConnectionInterface
    {
            return self::$container->get(self::REPOSITORY_CLASS)->db();
    }
}

I don't know what the plugin should/can do in this case but at least it should not crash

seferov commented 2 years ago

@mathroc thanks for the report!

Could you please provide a test case in a separate scenario to reproduce the issue? You can add it and see examples here https://github.com/psalm/psalm-plugin-symfony/blob/master/tests/acceptance/acceptance/ContainerService.feature

I failed to reproduce it.

mathroc commented 2 years ago

well, I can't reproduce it anymore either :shrug: neither with the sample code from the issue description nor with the codebase it was crashing on before..

I'll close this issue and reopen it if it happens again