Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request introduces a PHPStan configuration and adds comprehensive PHPDoc type hints to improve static analysis. Key changes include refactoring the diff_items logic to be more explicit, replacing manual WP_INSTALLING constant checks with the wp_installing() function, and correcting the casing of the RestCommand class instantiation. A regression was identified in inc/RestCommand.php where removing the reference operator from the $assoc_args parameter in get_formatter prevents the Formatter from correctly modifying the arguments array as expected by WP-CLI.
There was a problem hiding this comment.
Pull request overview
Adds an initial PHPStan configuration for the package and updates REST CLI runtime code with additional type checks/guards to satisfy higher static-analysis strictness.
Changes:
- Add
phpstan.neon.distwith level 9 analysis targetinginc/andwp-rest-cli.php, scanning WP-CLI sources and WordPress stubs. - Harden
Runnerroute discovery/registration with additional validation and updated debug/error messaging. - Add/adjust phpdoc types and runtime guards in
RestCommandfor safer handling of decoded JSON, CLI args, and REST responses.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| phpstan.neon.dist | Introduces baseline PHPStan configuration for the project. |
| inc/Runner.php | Adds stricter validation/typing around REST index parsing and route registration. |
| inc/RestCommand.php | Adds extensive type guards and phpdoc to reduce PHPStan findings and avoid notices. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $count = 0; | ||
| if ( isset( $assoc_args['count'] ) ) { | ||
| $count = is_numeric( $assoc_args['count'] ) ? (int) $assoc_args['count'] : 0; | ||
| } | ||
| unset( $assoc_args['count'] ); | ||
| $format = $assoc_args['format']; | ||
|
|
||
| $format = 'ids'; | ||
| if ( isset( $assoc_args['format'] ) ) { | ||
| $format = is_scalar( $assoc_args['format'] ) ? (string) $assoc_args['format'] : 'ids'; | ||
| } | ||
| unset( $assoc_args['format'] ); |
There was a problem hiding this comment.
generate_items() falls back to count=0 and format='ids' when assoc args are missing, but the command synopsis in Runner::register_route_commands() documents defaults of count=10 and format='progress'. Align these defaults (or explicitly rely on WP-CLI to inject synopsis defaults) to avoid surprising behavior when options aren’t provided.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.