-
Notifications
You must be signed in to change notification settings - Fork 3
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 order in the generated stubs file doesn't allow them to be loaded properly #1
Comments
Hello! Glad to hear you've found a use for this. Can't believe I never tried to execute the generated stubs; I guess they worked for Psalm which was enough for me. I'll try to implement a fix this weekend. Of interest, your example code actually works fine (though it demonstrated your point). You need 2 levels of inheritance, both declared in the wrong order, for PHP to complain: class SubSubClass extends SubClass {}
class SubClass extends ParentClass {}
class ParentClass {} Coincidentally, there was just a Reddit post related to this. Anyway, thanks for reporting this issue! |
See: GiacoCorsiglia/php-stubs-generator#1 Also stops generating stubs for the default plugins.
Hi @zaantar, I've released an updated version of the WordPress stubs which fixes this issue along with several others. You can now run Could you let me know if this is enough for PHPStan? If not, one solution may be to initialize all stubbed global variables as |
Thank you a lot, @GiacoCorsiglia! I will play with PHPStan a bit more and let you know about my findings. |
Hi there, first of all, let me say that this is an awesome tool that has saved us a lot of time. So, thanks. :)
However, we've run into some issues when trying to use generated WordPress stubs together with PHPStan to analyze a WordPress plugin we're developing.
PHPStan, probably unlike other static analysis tools out there, is a bit less "static" and needs to actually load the php files in order to work.
That is not possible because the generated stub file contains things like this:
We need the parent class to be defined first, otherwise a PHP error occurrs when loading the file.
The text was updated successfully, but these errors were encountered: