Description
It would be useful to add PHPStan static analysis support to this package and improve the code quality throughout the code base. This way the individual commands don't all have to set it up themselves and cause repetition.
After landing the initial implementation and working on improving some of the main packages, here are a couple of observations / enhancement suggestions for stronger typing:
- Add dynamic return type extension for
\WP_CLI\Utils\parse_url()
Such an extension already exists for\parse_url()
in PHPStan itself and\wp_parse_url()
in theszepeviktor/phpstan-wordpress
package (which is licensed under MIT, like WP-CLI). - Add extension to type
$args
and$assoc_args
based on the command's docblock.
I think this would be really powerful and would make docblock maintenance easier. Not sure it's possible though, see Changing method parameter types based on PHPDoc contents phpstan/phpstan#13058 - Add dynamic return type extension for
\WP_CLI\Utils\get_flag_value()
, which currently returnsmixed
. - Consider adopting
phpstan/phpstan-strict-rules
- Consider adopting
phpstan/phpstan-deprecation-rules
- Consider adopting
swissspidy/phpstan-no-private
- Consider adopting
phpstan/phpstan-phpunit
- Improve types for
\WP_CLI\Utils\iterator_map
Should use generics - Add dynamic return type extension for
\WP_CLI::runcommand()