Introduce PHPStan for Static Analysis#213
Conversation
|
@JJJ @spacedmonkey This would need (even with the downgrade) PHP 7.2 at least. |
| * | ||
| * @since 1.3.0 | ||
| */ | ||
| class WP_MS_Network_Command extends WP_CLI_Command { |
There was a problem hiding this comment.
Note: Historically, WP-CLI provided a base WP_CLI_Command class to extend, however extending this class is not required and will not change how your command behaves.
https://make.wordpress.org/cli/handbook/guides/commands-cookbook/
| */ | ||
| public function plugin( $args, $assoc_args ) { | ||
| $this->fetcher = new \WP_CLI\Fetchers\Plugin(); | ||
| $fetchers_plugin = new \WP_CLI\Fetchers\Plugin(); |
There was a problem hiding this comment.
I believe that this should be a var and not a class member (PHPStan also didn't like it :-))
| } | ||
|
|
||
| if ( ! empty( $prepared_args ) ) { | ||
| if ( is_wp_error( $prepared_args ) ) { |
There was a problem hiding this comment.
This is already sorted out at line 447.
|
@spacedmonkey I just added the GitHub action for PHPStan. This runs with PHP 7.2. |
|
#214 removes the blocker for this PR. |
spacedmonkey
left a comment
There was a problem hiding this comment.
I strongly recommeding doing a composer install and use the installed version of phpstan than using the existing action. That way all extensions are installed and same version on local as in CI.
I recommd following this guide on how to setup https://pascalbirchler.com/phpstan-wordpress/
The workflow has been changed now and is running as expected: https://github.com/lloc/wp-multi-network/actions/runs/13176556055/job/36777152590 |
This PR introduces PHPStan to improve static analysis for our codebase.
Changes in this PR
szepeviktor/phpstan-wordpressas a dev dependency.phpstan.neon.distwith an initial configuration.composer phpstan) for easy execution.Next Iterations
Let me know your thoughts!