-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Introduce PHPStan for Static Analysis #213
Conversation
@JJJ @spacedmonkey This would need (even with the downgrade) PHP 7.2 at least. |
@@ -11,7 +11,7 @@ | |||
* | |||
* @since 1.3.0 | |||
*/ | |||
class WP_MS_Network_Command extends WP_CLI_Command { |
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.
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/
@@ -260,7 +260,7 @@ public function list_( $args, $assoc_args ) { | |||
* @param array $assoc_args Associative CLI arguments. | |||
*/ | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that this should be a var and not a class member (PHPStan also didn't like it :-))
@@ -449,10 +449,6 @@ public function update_item( $request ) { | |||
} | |||
|
|||
if ( ! empty( $prepared_args ) ) { | |||
if ( is_wp_error( $prepared_args ) ) { |
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.
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. |
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 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-wordpress
as a dev dependency.phpstan.neon.dist
with an initial configuration.composer phpstan
) for easy execution.Next Iterations
Let me know your thoughts!