-
Notifications
You must be signed in to change notification settings - Fork 18
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
Update wp hooks dependency renamed wp 6.0 and aliases #37
Update wp hooks dependency renamed wp 6.0 and aliases #37
Conversation
ea9914d
to
7b1c7ab
Compare
Let's get #41 merged and then update this PR to merge |
* update wp-hooks dependency to new name and new version * new wp-hooks version includes hooks for WP 6.0 * new wp-hooks include non-dynamic aliases for documented dynamic hooks, which allows for checking functions hooked on those dynamic hooks
new wp-hooks include non-dynamic aliases for documented dynamic hooks, which allows for checking functions hooked on those dynamic hooks
5a998e8
to
c010c79
Compare
@mcaskill currently waits for php-stubs/wp-cli-stubs#11, will merge once released there |
@kkmuffme what's the state of dynamic hooks? Either from WordPress core or from third-party plugins. Is there some way I can stub dynamic hooks? In my <plugins>
<pluginClass class="PsalmWordPress\Plugin">
<hooks>
<directory name="stubs/hooks" recursive="true" />
</hooks>
</pluginClass>
</plugins> And then I have {
"$schema": "https://raw.githubusercontent.com/wp-hooks/generator/0.9.0/schema.json",
"hooks": []
} So I'm familiar with how to stub out individual hooks, but curious what is the recommended approach for dynamic hooks specifically. Or if that's not yet implemented, just looking for a status update. Thanks! |
@paulshryock just fyi dynamic hooks work now with #49 |
Hi @kkmuffme, I've just tested #49 and created a small git repo. https://github.com/paulshryock/test-psalm-wordpress-latest/blob/main/src/functions.php composer show | grep psalm
humanmade/psalm-plugin-wordpress dev-v5-compatibility-and-features faab6d5 WordPress stubs and plugin for Psalm.
vimeo/psalm 5.16.0 A static analysis tool for finding errors in PHP applications I added several dynamic hooks:
And none of these throw a Psalm error! ❤️ But then I realized that it seems like dynamic hooks are not checked by Psalm at all, regardless of whether or not they are stubbed. For example, this third-party hook did throw a Psalm error ( But this dynamic third-party hook which is not stubbed does not throw a Psalm error, and this dynamic first-party hook which is not stubbed does not throw a Psalm error. Is this expected behavior? |
Please check again now and let me know if it works as expected for you now. |
Hi @kkmuffme, I upgraded to the latest commit. composer upgrade humanmade/psalm-plugin-wordpress
- "reference": "faab6d5e5ae4b1d7ed374ea040524121ed62ab29"
+ "reference": "2d71d096ac6e47354e381b2d110d754a8c311c47" 🥳 Now I get those two failures I was expecting:
And here's what I see in my text editor (as expected): This looks great! Thank you for the quick work on this; I feel this is an improved user experience. |
This also partially adds the dynamic hook checks requested in #12
It's possible to infer all dynamic hooks easily, but this requires a bit more changes I can only PR once my other PRs are merged to avoid having to rebase my PR and fixing tons of conflicts