Skip to content

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

* @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 ) ) {
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

* Runs when a request is migratable.
*
* @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

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 );
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

*/
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 ) ) {
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