Skip to content
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

Fix problems reported by static analysis #19

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

szepeviktor
Copy link
Contributor

@szepeviktor szepeviktor commented Nov 29, 2023

Summary

@emilyatmobtown Please see individual comments.

Please consider introducing PHPStan in Alley.
https://github.com/alleyinteractive/.github/blob/main/.github/workflows/php-code-quality.yml#L7

if ( apply_filters( 'wp_theme_migrator_skip_during_cron', true, $this ) ) {
if ( apply_filters( 'wp_theme_migrator_skip_during_cron', true, $this->wp ) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we need a WP instance not a Controller

* @param Controller $this Controller instance.
* @param Controller $instance Controller instance.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameter naming

remove_action( 'registered_post_type', [ $this, 'add_post_type_query_vars' ], 10, 2 );
remove_action( 'registered_post_type', [ $this, 'add_post_type_query_vars' ], 10 );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only add_action has that last one

if ( false !== $post_type_object->query_var && $this->wp && is_post_type_viewable( $post_type_object ) ) {
if ( false !== $post_type_object->query_var && is_post_type_viewable( $post_type_object ) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->wp is always set in the constructor

}

return true;
return wp_get_theme( $theme )->exists();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wp_get_theme always returns a WP_Theme instance

Comment on lines -55 to +51
return wp_get_theme( $theme )?->get( 'Name' ) ?? '';
return wp_get_theme( $theme )->get( 'Name' ) ?: '';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the get method may return false but never null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant