-
Notifications
You must be signed in to change notification settings - Fork 26
code quality: add PHPStan array shape for ability $properties
#20
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
Conversation
I don't have perms to rerun the failing CI, but since it's for WP6.7 which we're removing in #18 🤷 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #20 +/- ##
========================================
Coverage ? 90.66%
Complexity ? 99
========================================
Files ? 7
Lines ? 557
Branches ? 0
========================================
Hits ? 505
Misses ? 52
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's very useful addition 👍🏻
* execute_callback?: callable( array<string,mixed> $input): (mixed|\WP_Error), | ||
* permission_callback?: callable( ?array<string,mixed> $input ): bool, | ||
* meta?: array<string,mixed>, | ||
* ...<string, mixed> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything else gets ignored, do we need to list it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exaclty why it's here - this is the long-overdue syntax for partially sealed arrays.
Otherwise if users don't clean up their arrays (or more "justifiable" real world scenario: if extensions hook in their own custom args) they'll get errors about unsupported array values, when it doesn't matter because we only keep the ones we need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think it adds any value at the moment because it’s impossible to successfully pass more settings. It’ll rather change in the future when we add WP hooks.
What
This PR adds array shapes for the
$properties
array used bywp_register_ability()
WP_Abilities_Registry::register()
WP_Ability::__construct()
Why
To ensure both we and consumers are using the correct array shapes.
Additional Notes
php-stubs/wordpress-stubs
.