-
Notifications
You must be signed in to change notification settings - Fork 2
Fix problems reported by static analysis #19
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
base: develop
Are you sure you want to change the base?
Conversation
| * @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 ) ) { |
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 a Controller
| * 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 comment
The reason will be displayed to describe this comment to others. Learn more.
parameter naming
| 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 comment
The reason will be displayed to describe this comment to others. Learn more.
only add_action has that last one
| */ | ||
| 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 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(); |
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.
wp_get_theme always returns a WP_Theme instance
| return wp_get_theme( $theme )?->get( 'Name' ) ?? ''; | ||
| return wp_get_theme( $theme )->get( 'Name' ) ?: ''; |
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.
the get method may return false but never null
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