-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,10 +105,10 @@ protected function set_migratability() { | |
/** | ||
* Skip migration checks while doing cron. | ||
* | ||
* @param bool $skip_during_cron Whether to skip. | ||
* @param WP_Theme_Migrator $this This WP_Theme_Migrator instance. | ||
* @param bool $skip_during_cron Whether to skip. | ||
* @param WP_Theme_Migrator_WP $instance This WP_Theme_Migrator instance. | ||
*/ | ||
if ( apply_filters( 'wp_theme_migrator_skip_during_cron', true, $this ) ) { | ||
if ( apply_filters( 'wp_theme_migrator_skip_during_cron', true, $this->wp ) ) { | ||
return; | ||
} | ||
} | ||
|
@@ -117,10 +117,10 @@ protected function set_migratability() { | |
/** | ||
* Skip migration checks while doing Ajax. | ||
* | ||
* @param bool $skip_during_ajax Whether to skip. | ||
* @param WP_Theme_Migrator $this This WP_Theme_Migrator instance. | ||
* @param bool $skip_during_ajax Whether to skip. | ||
* @param WP_Theme_Migrator_WP $instance This WP_Theme_Migrator instance. | ||
*/ | ||
if ( apply_filters( 'wp_theme_migrator_skip_during_ajax', true, $this ) ) { | ||
if ( apply_filters( 'wp_theme_migrator_skip_during_ajax', true, $this->wp ) ) { | ||
return; | ||
} | ||
} | ||
|
@@ -230,7 +230,7 @@ protected function check_migratability(): bool { | |
/** | ||
* Runs when a request is migratable. | ||
* | ||
* @param Controller $this Controller instance. | ||
* @param Controller $instance Controller instance. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. parameter naming |
||
*/ | ||
do_action( 'wp_theme_migrator_migrating', $this ); | ||
return true; | ||
|
@@ -240,7 +240,7 @@ protected function check_migratability(): bool { | |
/** | ||
* Runs when a request is not migratable. | ||
* | ||
* @param Controller $this Controller instance. | ||
* @param Controller $instance Controller instance. | ||
*/ | ||
do_action( 'wp_theme_migrator_not_migrating', $this ); | ||
|
||
|
@@ -252,7 +252,7 @@ protected function check_migratability(): bool { | |
*/ | ||
protected function stop_migrator() { | ||
remove_action( 'setup_theme', [ $this, 'run' ], 8 ); | ||
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 ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only |
||
} | ||
|
||
/** | ||
|
@@ -264,7 +264,7 @@ protected function stop_migrator() { | |
* @param \WP_Post_Type $post_type_object Arguments used to register the post type. | ||
*/ | ||
public function add_post_type_query_vars( $post_type, $post_type_object ) { | ||
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 ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
$this->wp->add_query_var( $post_type_object->query_var ); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,11 +31,7 @@ protected function is_valid_theme( string $theme ): bool { | |
} | ||
|
||
// Check that the theme exists. | ||
if ( false === ( wp_get_theme( $theme )?->exists() ?? false ) ) { | ||
return false; | ||
} | ||
|
||
return true; | ||
return wp_get_theme( $theme )->exists(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
/** | ||
|
@@ -52,7 +48,7 @@ protected function get_theme( string $theme, string $prop = '' ) { | |
|
||
switch ( $prop ) { | ||
case 'name': | ||
return wp_get_theme( $theme )?->get( 'Name' ) ?? ''; | ||
return wp_get_theme( $theme )->get( 'Name' ) ?: ''; | ||
Comment on lines
-55
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
default: | ||
return wp_get_theme( $theme ); | ||
} | ||
|
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.
Here we need a
WP
instance not aController