Skip to content

Commit

Permalink
Initial run of some more CS and first feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsoo committed Nov 14, 2023
1 parent a22a22d commit 449c46c
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 47 deletions.
1 change: 0 additions & 1 deletion admin/tracking/class-tracking-settings-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Verify_Indexable_Action_Factory implements Verify_Indexables_Action_Factor
'general',
'post-type-archives',
'term_links',
'post_links',
];

/**
Expand Down Expand Up @@ -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 ] );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/indexables/application/cron-verification-gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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.
*
Expand All @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 2 additions & 2 deletions src/indexables/domain/batch-size.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
);
Expand All @@ -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"
);
Expand Down
3 changes: 1 addition & 2 deletions src/indexables/domain/outdated-post-indexables-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -56,7 +56,6 @@ public function rewind(): void {
* @return Indexable
*/
public function current(): Indexable {

return $this->post_indexables_list[ $this->position ];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}

Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
*
Expand Down
2 changes: 0 additions & 2 deletions src/integrations/settings-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 449c46c

Please sign in to comment.