-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
PHPStan doesn't find the WP CLI stubs in scanFiles #8
Comments
Hello @devbanana ! Thank you for your report. The root of the problem is that we need WP-CLI stubs at all. As WP-CLI is not an OOP project we need WP-CLI stubs. In general |
BTW |
Thank you for your reply. Very odd, any idea what would cause it to run my code? Our project is a bit legacy but we're using composer for autoloading. Any pointers of where to look would be appreciated. |
OR it could be that PHPStan analyzes your command class earlier than loading stubs with |
Please share your PHPStan configuration file if you need further help. |
|
I'm seeing this too. Using My
It's definitely scanning the
|
Might be worth saying that I'm registering a command using the invokable syntax like this:
But I get the same if I do:
The
|
PHP is a tool for OOP code. In the OOP world you don't register functions nor methods. |
Thanks. I know about OOP. I think you've misunderstood though. Sorry if I wasn't clear. When I mentioned:
it was to demonstrate that PHPStan is definitely scanning the The actual issue is the same one the OP had.
I was just providing more information about my case to see if it helped understand why using There might be something that you need to document here as the current instructions in the README don't seem to work for some cases. P.S. Thanks for all you work making PHPStan work for WordPress 🙌 |
The readme says to include wp-cli-stubs.php (and the other files) under scanFiles. I have this:
But I have a class that extends WP_CLI_Command, and when analyzing that file I get:
Class WP_CLI_Command not found.
Only if I include it under bootstrapFiles does it work.
I'm not sure whether to report this on phpstan or here. Or if just something has changed not reflected in the documentation.
The text was updated successfully, but these errors were encountered: