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

Uncaught Exception: InvalidArgumentException Could not get class storage for doctrine\dbal\dbalexception #111

Open
ghost opened this issue Jan 30, 2022 · 5 comments

Comments

@ghost
Copy link

ghost commented Jan 30, 2022

psalm 4.19.0
weirdan/doctrine-psalm-plugin v2.2.0
Symfony 6.0.3
PHP 8.1

> ./vendor/bin/psalm --show-info=true
Target PHP version: 8.1 (inferred from composer.json)
Scanning files...
Analyzing files...

░░░░░░░░░░░░░░░░░░░░░░░░░░Uncaught Exception: InvalidArgumentException Could not get class storage for doctrine\dbal\dbalexception
Emitted in /Users/dmitriyrybin/PhpstormProjects/.../app/api/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:46
Stack trace in the forked worker:
#0 /Users/dmitriyrybin/PhpstormProjects/.../app/api/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/ClassLikes.php(628): Psalm\Internal\Provider\ClassLikeStorageProvider->get('Doctrine\\DBAL\\D...')
...

If I comment <pluginClass class="Weirdan\DoctrinePsalmPlugin\Plugin"/> in psalm.xml or downgrading weirdan/doctrine-psalm-plugin to v2.0.1 everything works fine

@orklah
Copy link
Collaborator

orklah commented Jan 30, 2022

DbalException was introduced on 2.1 here: v2.0.1...v2.1.0#diff-4c0849c859bac15c400cdc77fdcc69abd0de5d275cc99832b1c7fffd55e68d0dR75

Can you make sure you actually have it in your dependencies?

@ghost
Copy link
Author

ghost commented Jan 30, 2022

In my composer.json I have "doctrine/dbal": "^3.3" dependency and Doctrine\DBAL\Exception in vendor/doctrine/dbal/src

@orklah
Copy link
Collaborator

orklah commented Jan 30, 2022

Well, I'm not sure what is causing the issue, but as stubs are loaded before anything else, it's possible that we need to stub the exception too.

Care to propose a PR? :)

@ghost
Copy link
Author

ghost commented Mar 8, 2022

Seems, that I've found what is causing the issue. Simple code:

final class Repository extends ServiceEntityRepository {
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, Entity::class);
    }

    public function test(): void
    {
        $connection = $this->getEntityManager()->getConnection();
 
        $connection->executeStatement('SELECT 1');
    }
}

executeQuery instead of executeStatement works fine

@orklah
Copy link
Collaborator

orklah commented Mar 14, 2022

I guess stubbing the Exception as I was mentionning above should solve the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant