-
Notifications
You must be signed in to change notification settings - Fork 10
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
TooManyArguments raised for apply_filters, do_action and others #6
Comments
Yes, in PHPStan services are for that purpose, I hope Psalm has a similar feature. |
You can write write a service for PHPStan - or similar for Psalm - that accepts multiple arguments for these functions. They are called plugins: https://github.com/vimeo/psalm/blob/master/docs/plugins.md |
I'm confused by your comments, @szepeviktor . The purpose of this repo is to plug in to static analysis tools like Psalm by providing stubs for the WordPress functions. There is a bug in the stubs in |
I agree this issue should be fixed in the stubs, although I appreciate you sharing your workaround @szepeviktor. The solution will probably be to automatically replace:
after the stubs are generated. Are there other functions which have this problem? Would be good to get them all. |
@GiacoCorsiglia That sounds good like a good approach. I also wonder if a better approach would be to fix the stubs generator itself so that it can detect when |
That's an interesting thought @Flimm, I didn't realize Psalm did that. The stubs generator currently ignores anything inside
Care might have to be taken in scenarios like Alas I don't have the time to do this at the moment (blame grad school), but I'd happily look at a PR... |
List of WordPress functions using
https://github.com/szepeviktor/phpstan-wordpress/blob/0.2.1/example/phpstan.neon.dist#L24-L30 |
Is seems to be resolved in WordPress v5.3 |
Take this test file:
Running Psalm with wordpress-stubs set up gives these errors:
Both
apply_filters
anddo_action
take an unlimited number of arguments, as they both callfunc_get_args
.It looks like the stubs for these functions are not correct:
The text was updated successfully, but these errors were encountered: