From 449c46c890c290581b3d86ba95247389120a6578 Mon Sep 17 00:00:00 2001 From: Thijs van der Heijden Date: Tue, 14 Nov 2023 23:01:55 +0100 Subject: [PATCH] Initial run of some more CS and first feedback. --- admin/tracking/class-tracking-settings-data.php | 1 - .../actions/verify-indexable-action-factory.php | 6 ++---- ...fy-non-timestamp-indexables-command-handler.php | 1 - .../commands/verify-post-indexables-command.php | 1 - .../application/cron-verification-gate.php | 4 ++-- .../verification-cron-batch-handler.php | 6 +++--- .../verification-cron-schedule-handler.php | 4 ++-- src/indexables/domain/batch-size.php | 4 ++-- .../no-non-timestamped-objects-found-exception.php | 2 +- .../no-outdated-posts-found-exception.php | 2 +- .../no-verification-action-left-exception.php | 6 +++--- .../domain/outdated-post-indexables-list.php | 3 +-- .../actions/verify-general-indexables-action.php | 14 +++++++------- ...verify-post-type-archives-indexables-action.php | 1 - .../actions/verify-term-indexables-action.php | 5 ++--- .../outdated-post-indexables-repository.php | 1 - ...erification-posts-cron-callback-integration.php | 11 +---------- src/integrations/settings-integration.php | 2 -- 18 files changed, 27 insertions(+), 47 deletions(-) diff --git a/admin/tracking/class-tracking-settings-data.php b/admin/tracking/class-tracking-settings-data.php index baadded8630..7d4a7b5b82f 100644 --- a/admin/tracking/class-tracking-settings-data.php +++ b/admin/tracking/class-tracking-settings-data.php @@ -238,7 +238,6 @@ class WPSEO_Tracking_Settings_Data implements WPSEO_Collection { 'cron_verify_current_action', 'cron_verify_post_indexables_last_batch', 'cron_verify_non_timestamped_indexables_last_batch', - 'plugin_deactivated_at', ]; /** diff --git a/src/indexables/application/actions/verify-indexable-action-factory.php b/src/indexables/application/actions/verify-indexable-action-factory.php index 80eb2601f3a..36126e8ceb8 100644 --- a/src/indexables/application/actions/verify-indexable-action-factory.php +++ b/src/indexables/application/actions/verify-indexable-action-factory.php @@ -26,7 +26,6 @@ class Verify_Indexable_Action_Factory implements Verify_Indexables_Action_Factor 'general', 'post-type-archives', 'term_links', - 'post_links', ]; /** @@ -109,12 +108,11 @@ public function get( Current_Verification_Action $verification_action ): Verify_ * @throws No_Verification_Action_Left_Exception Throws when there are no verification actions left. * @return Current_Verification_Action */ - public function determine_next_verify_action( Current_Verification_Action $current_verification_action_object - ): Current_Verification_Action { + public function determine_next_verify_action( Current_Verification_Action $current_verification_action_object ): Current_Verification_Action { $current_verification_action = $current_verification_action_object->get_action(); if ( \in_array( $current_verification_action, self::VERIFICATION_MAPPING, true ) ) { - $key = array_search( $current_verification_action, self::VERIFICATION_MAPPING, true ); + $key = \array_search( $current_verification_action, self::VERIFICATION_MAPPING, true ); if ( isset( self::VERIFICATION_MAPPING[ ++$key ] ) ) { return new Current_Verification_Action( self::VERIFICATION_MAPPING[ $key ] ); } diff --git a/src/indexables/application/commands/verify-non-timestamp-indexables-command-handler.php b/src/indexables/application/commands/verify-non-timestamp-indexables-command-handler.php index 5a0c7f5cf8e..c104912359b 100644 --- a/src/indexables/application/commands/verify-non-timestamp-indexables-command-handler.php +++ b/src/indexables/application/commands/verify-non-timestamp-indexables-command-handler.php @@ -76,7 +76,6 @@ public function __construct( * @return void */ public function handle( Verify_Non_Timestamp_Indexables_Command $verify_non_timestamp_indexables_command ): void { - try { $verification_action = $this->verify_indexables_action_factory->get( $verify_non_timestamp_indexables_command->get_current_action() ); } catch ( Verify_Action_Not_Found_Exception $exception ) { diff --git a/src/indexables/application/commands/verify-post-indexables-command.php b/src/indexables/application/commands/verify-post-indexables-command.php index f4d784dd695..d4f469138d3 100644 --- a/src/indexables/application/commands/verify-post-indexables-command.php +++ b/src/indexables/application/commands/verify-post-indexables-command.php @@ -4,7 +4,6 @@ namespace Yoast\WP\SEO\Indexables\Application\Commands; use Yoast\WP\SEO\Indexables\Domain\Abstract_Indexables_Command; -use Yoast\WP\SEO\Indexables\Domain\Last_Batch_Count; /** * The Verify_Post_Indexables_Command class. diff --git a/src/indexables/application/cron-verification-gate.php b/src/indexables/application/cron-verification-gate.php index 87154cb6c28..5d4e9acfddc 100644 --- a/src/indexables/application/cron-verification-gate.php +++ b/src/indexables/application/cron-verification-gate.php @@ -26,11 +26,11 @@ public function __construct( Indexable_Helper $indexable_helper ) { } /** - * Determine whether cron verification of indexables should be performed. + * Determines whether cron verification of indexables should be performed. * * @return bool Should cron verification be performed. */ - public function should_verify_on_cron() { + public function should_verify_on_cron(): bool { if ( ! $this->indexable_helper->should_index_indexables() ) { return false; } diff --git a/src/indexables/application/verification-cron-batch-handler.php b/src/indexables/application/verification-cron-batch-handler.php index c2cae1b9b8f..626987091fb 100644 --- a/src/indexables/application/verification-cron-batch-handler.php +++ b/src/indexables/application/verification-cron-batch-handler.php @@ -28,7 +28,7 @@ public function __construct( Options_Helper $options_helper ) { } /** - * Gets the `cron_verify_post_indexables_last_batch` option + * Gets the `cron_verify_post_indexables_last_batch` option. * * @return int */ @@ -37,7 +37,7 @@ public function get_current_post_indexables_batch(): int { } /** - * Sets the `cron_verify_post_indexables_last_batch` option + * Sets the `cron_verify_post_indexables_last_batch` option. * * @param int $batch_count The batch count. * @@ -48,7 +48,7 @@ public function set_current_post_indexables_batch( int $batch_count ) { } /** - * Gets the `cron_verify_non_timestamped_indexables_last_batch` option + * Gets the `cron_verify_non_timestamped_indexables_last_batch` option. * * @return int */ diff --git a/src/indexables/application/verification-cron-schedule-handler.php b/src/indexables/application/verification-cron-schedule-handler.php index de5372eb34a..e64945592b3 100644 --- a/src/indexables/application/verification-cron-schedule-handler.php +++ b/src/indexables/application/verification-cron-schedule-handler.php @@ -10,12 +10,12 @@ class Verification_Cron_Schedule_Handler { /** - * The name of the CRON job. + * The name of the cron job. */ public const INDEXABLE_VERIFY_POST_INDEXABLES_NAME = 'wpseo_indexable_verify_post_indexables'; /** - * The name of the CRON job. + * The name of the cron job. */ public const INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME = 'wpseo_indexable_verify_non_timestamped_indexables'; diff --git a/src/indexables/domain/batch-size.php b/src/indexables/domain/batch-size.php index d6bd0fc64d3..9862c5233ba 100644 --- a/src/indexables/domain/batch-size.php +++ b/src/indexables/domain/batch-size.php @@ -35,11 +35,11 @@ public function get_batch_size(): int { /** * Checks if the batch is bigger than the count. * - * @param int|null $count The count to check. + * @param int $count The count to check. * * @return bool */ - public function should_keep_going( ?int $count ): bool { + public function should_keep_going( int $count ): bool { return $count >= $this->get_batch_size(); } } diff --git a/src/indexables/domain/exceptions/no-non-timestamped-objects-found-exception.php b/src/indexables/domain/exceptions/no-non-timestamped-objects-found-exception.php index 0454ab37b18..9a36219d51f 100644 --- a/src/indexables/domain/exceptions/no-non-timestamped-objects-found-exception.php +++ b/src/indexables/domain/exceptions/no-non-timestamped-objects-found-exception.php @@ -15,7 +15,7 @@ class No_Non_Timestamped_Objects_Found_Exception extends \Exception { * * @return No_Non_Timestamped_Objects_Found_Exception The exception. */ - public static function because_no_objects_queried() { + public static function because_no_objects_queried(): self { return new self( 'No objects found.' ); diff --git a/src/indexables/domain/exceptions/no-outdated-posts-found-exception.php b/src/indexables/domain/exceptions/no-outdated-posts-found-exception.php index a8700a73a4a..f0060adbf62 100644 --- a/src/indexables/domain/exceptions/no-outdated-posts-found-exception.php +++ b/src/indexables/domain/exceptions/no-outdated-posts-found-exception.php @@ -15,7 +15,7 @@ class No_Outdated_Posts_Found_Exception extends Exception { * * @return No_Outdated_Posts_Found_Exception The exception. */ - public static function because_no_outdated_posts_queried() { + public static function because_no_outdated_posts_queried(): self { return new self( 'No outdated posts found.' ); diff --git a/src/indexables/domain/exceptions/no-verification-action-left-exception.php b/src/indexables/domain/exceptions/no-verification-action-left-exception.php index 5e64df0981a..53348942794 100644 --- a/src/indexables/domain/exceptions/no-verification-action-left-exception.php +++ b/src/indexables/domain/exceptions/no-verification-action-left-exception.php @@ -6,14 +6,14 @@ /** * The No_Verification_Action_Left_Exception exception. */ -class No_Verification_Action_Left_Exception extends \Exception { +class No_Verification_Action_Left_Exception extends \Exception { /** * Named constructor to create this exception for when there are no verification actions left. * * @return No_Verification_Action_Left_Exception The exception. */ - public static function because_out_of_bounds() { + public static function because_out_of_bounds(): self { return new self( 'No verification actions left process is done.' ); @@ -26,7 +26,7 @@ public static function because_out_of_bounds() { * * @return No_Verification_Action_Left_Exception The exception. */ - public static function because_unidentified_action_given( $verification_action ) { + public static function because_unidentified_action_given( string $verification_action ): self { return new self( "The passed verification action $verification_action is not found" ); diff --git a/src/indexables/domain/outdated-post-indexables-list.php b/src/indexables/domain/outdated-post-indexables-list.php index f6593262129..a7b4eb5203e 100644 --- a/src/indexables/domain/outdated-post-indexables-list.php +++ b/src/indexables/domain/outdated-post-indexables-list.php @@ -37,7 +37,7 @@ public function __construct() { * * @return void */ - public function add_post_indexable( Indexable $post ) { + public function add_post_indexable( Indexable $post ): void { $this->post_indexables_list[] = $post; } @@ -56,7 +56,6 @@ public function rewind(): void { * @return Indexable */ public function current(): Indexable { - return $this->post_indexables_list[ $this->position ]; } diff --git a/src/indexables/infrastructure/actions/verify-general-indexables-action.php b/src/indexables/infrastructure/actions/verify-general-indexables-action.php index 507c1494272..9a6ef107777 100644 --- a/src/indexables/infrastructure/actions/verify-general-indexables-action.php +++ b/src/indexables/infrastructure/actions/verify-general-indexables-action.php @@ -28,6 +28,13 @@ class Verify_General_Indexables_Action implements Verify_Indexables_Action_Inter */ protected $indexable_builder; + /** + * The wp query. + * + * @var \wpdb $wpdb + */ + private $wpdb; + /** * The constructor. * @@ -39,13 +46,6 @@ public function __construct( Indexable_Repository $repository, Indexable_Builder $this->indexable_builder = $indexable_builder; } - /** - * The wp query. - * - * @var \wpdb $wpdb - */ - private $wpdb; - /** * Rebuilds the indexables for the general pages. * diff --git a/src/indexables/infrastructure/actions/verify-post-type-archives-indexables-action.php b/src/indexables/infrastructure/actions/verify-post-type-archives-indexables-action.php index ee290885666..43208a5eddf 100644 --- a/src/indexables/infrastructure/actions/verify-post-type-archives-indexables-action.php +++ b/src/indexables/infrastructure/actions/verify-post-type-archives-indexables-action.php @@ -57,7 +57,6 @@ public function __construct( Indexable_Builder $indexable_builder, Indexable_Repository $indexable_repository ) { - $this->post_type_helper = $post_type_helper; $this->indexable_builder = $indexable_builder; $this->indexable_repository = $indexable_repository; diff --git a/src/indexables/infrastructure/actions/verify-term-indexables-action.php b/src/indexables/infrastructure/actions/verify-term-indexables-action.php index 2bcef6b491a..3688563074e 100644 --- a/src/indexables/infrastructure/actions/verify-term-indexables-action.php +++ b/src/indexables/infrastructure/actions/verify-term-indexables-action.php @@ -64,7 +64,6 @@ public function re_build_indexables( Last_Batch_Count $last_batch_count, Batch_S $this->repository->build_by_id_and_type( (int) $term_id, 'term' ); } - return $batch_size->should_keep_going( \count( $term_ids ) ); } @@ -86,9 +85,9 @@ public function set_wpdb( \wpdb $wpdb ) { * @param int $limit The query limit. * @param int $batch_size The batch size for the queries. * - * @return string|null + * @return string */ - private function get_query( $limit, $batch_size ) { + private function get_query( int $limit, int $batch_size ) { $taxonomy_table = $this->wpdb->term_taxonomy; $public_taxonomies = $this->taxonomy->get_indexable_taxonomies(); diff --git a/src/indexables/infrastructure/outdated-post-indexables-repository.php b/src/indexables/infrastructure/outdated-post-indexables-repository.php index 0b99f71d1fc..390f10f1c65 100644 --- a/src/indexables/infrastructure/outdated-post-indexables-repository.php +++ b/src/indexables/infrastructure/outdated-post-indexables-repository.php @@ -76,7 +76,6 @@ public function get_outdated_post_indexables( ): Outdated_Post_Indexables_List { $indexable_table = Model::get_table_name( 'Indexable' ); - $post_types = $this->post_type_helper->get_indexable_post_types(); $excluded_post_statuses = $this->post_helper->get_excluded_post_statuses(); $query = $this->indexable_repository->query(); diff --git a/src/indexables/user-interface/verification-posts-cron-callback-integration.php b/src/indexables/user-interface/verification-posts-cron-callback-integration.php index 88656a91ee1..9730ea7849c 100644 --- a/src/indexables/user-interface/verification-posts-cron-callback-integration.php +++ b/src/indexables/user-interface/verification-posts-cron-callback-integration.php @@ -26,13 +26,6 @@ class Verification_Posts_Cron_Callback_Integration implements Integration_Interf */ private $cron_schedule_handler; - /** - * The options helper instance. - * - * @var Options_Helper $options_helper - */ - private $options_helper; - /** * The cron batch handler instance. * @@ -60,20 +53,17 @@ class Verification_Posts_Cron_Callback_Integration implements Integration_Interf * @param Cron_Verification_Gate $cron_verification_gate The cron verification * gate. * @param Verification_Cron_Schedule_Handler $cron_schedule_handler The cron schedule handler. - * @param Options_Helper $options_helper The options helper. * @param Verification_Cron_Batch_Handler $cron_batch_handler The cron batch handler. * @param Verify_Post_Indexables_Command_Handler $verify_post_indexables_command_handler The verify post indexables command handler. */ public function __construct( Cron_Verification_Gate $cron_verification_gate, Verification_Cron_Schedule_Handler $cron_schedule_handler, - Options_Helper $options_helper, Verification_Cron_Batch_Handler $cron_batch_handler, Verify_Post_Indexables_Command_Handler $verify_post_indexables_command_handler ) { $this->cron_verification_gate = $cron_verification_gate; $this->cron_schedule_handler = $cron_schedule_handler; - $this->options_helper = $options_helper; $this->cron_batch_handler = $cron_batch_handler; $this->verify_post_indexables_command_handler = $verify_post_indexables_command_handler; } @@ -102,6 +92,7 @@ public function start_verify_posts(): void { return; } + /** * Filter: 'Yoast\WP\SEO\post_verify_indexing_limit_size' - Adds the possibility to limit the number of items that are indexed when in cron action. * diff --git a/src/integrations/settings-integration.php b/src/integrations/settings-integration.php index fd961bb9ce5..b6ebe553de9 100644 --- a/src/integrations/settings-integration.php +++ b/src/integrations/settings-integration.php @@ -70,11 +70,9 @@ class Settings_Integration implements Integration_Interface { 'most_linked_ignore_list', 'least_linked_ignore_list', 'indexables_page_reading_list', - 'last_known_no_unindexed', 'cron_verify_current_action', 'cron_verify_post_indexables_last_batch', 'cron_verify_non_timestamped_indexables_last_batch', - 'plugin_deactivated_at', 'show_new_content_type_notification', 'new_post_types', 'new_taxonomies',