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
Class not found in PhpStorm for Entities that implement an interface in PHP 8 using attributes #5850
Comments
Thank you for your kind words! This has to have to do something with how PhpStorm executes PHPStan - it should be reproducible on the command line if you recreate how PhpStorm does it. I guess some tmp files are involved. |
Thanks for your quick reply!
I added
This idea never occurred to me as page "Discovering symbols" says: "By default, it looks for them in these two places: Analysed paths (files and directories)", so I never tried this before, because I thought adding "../src" once to my phpstan.neon (which is in a subfolder "build" thus "../") should be enough. Which it - kind of - is, so I still don't understand why adding this setting should make a difference only for entites that implement an interface, but: this seems to resolve my issue! (fingers crossed) |
I just made a small change that would make the Please test it now with dev-master or on Monday when PHPStan 1.0 is released :) Thank you! |
Works, thanks! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
I'm having a hard time finding the cause of the following issue: I migrated a project from PHP 7.4 to 8.0 and converted all route- and doctrine-annotations to attributes. The code works just fine, but I get "class not found"-issues from phpstan for all (doctrine-)entities that implement an interface when using attributes.
This does not only happen when using the entities as class-members but everywhere in the project:
Some strange things I found out:
I'm out of ideas here. Is it PhpStorm or my project-configuration, did something go wrong during the migration? Is this a bug in phpstan or phpstan-doctrine? Is this also related to some (missed) setting in the repository-classes?
I did endless searches for almost two days now, have tried everything I can think of that I may have missed during my migration, but to no avail.
Code snippet that reproduces the problem
https://phpstan.org/r/16989271-d54b-4fc8-9a08-2bff94418999
Note that this snippet only shows a (very reduced) part of my setup but does not reproduce the problem which seems somehow related to PhpStorm. The class "SomeObject" from the snippet would show as "not found" in my project.
Expected output
All entities should be found.
Did PHPStan help you today? Did it make you happy in any way?
Apart from the above issue phpstan (and rector) made the migration from PHP 7.4 to 8.0 a piece of cake :)
The text was updated successfully, but these errors were encountered: