code quality: add PHPStan array shape for ability $properties#20
code quality: add PHPStan array shape for ability $properties#20gziolo merged 3 commits intoWordPress:trunkfrom
$properties#20Conversation
|
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:
|
gziolo
left a comment
There was a problem hiding this comment.
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.
Everything else gets ignored, do we need to list it?
There was a problem hiding this comment.
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.
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
$propertiesarray 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.