From 82313541a6cb7f20856577ae0d8a5981024930d3 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Thu, 3 Oct 2024 19:45:15 -0400 Subject: [PATCH] eliminate code smells --- .../ActionScheduler_WPCLI_QueueRunner.php | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php b/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php index 4c5d9c2d6..0a975b7ba 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php @@ -9,13 +9,25 @@ */ class ActionScheduler_WPCLI_QueueRunner extends ActionScheduler_Abstract_QueueRunner { - /** @var array */ + /** + * Claimed actions. + * + * @var array + */ protected $actions; - /** @var ActionScheduler_ActionClaim */ + /** + * ActionScheduler_ActionClaim instance. + * + * @var ActionScheduler_ActionClaim + */ protected $claim; - /** @var \cli\progress\Bar */ + /** + * Progress bar instance. + * + * @var \cli\progress\Bar + */ protected $progress_bar; /** @@ -39,8 +51,6 @@ public function __construct( ActionScheduler_Store $store = null, ActionSchedule /** * Set up the Queue before processing. * - * @author Jeremy Pry - * * @param int $batch_size The batch size to process. * @param array $hooks The hooks being used to filter the actions claimed in this batch. * @param string $group The group of actions to claim with this batch. @@ -72,8 +82,6 @@ public function setup( $batch_size, $hooks = array(), $group = '', $force = fals /** * Add our hooks to the appropriate actions. - * - * @author Jeremy Pry */ protected function add_hooks() { add_action( 'action_scheduler_before_execute', array( $this, 'before_execute' ) ); @@ -83,8 +91,6 @@ protected function add_hooks() { /** * Set up the WP CLI progress bar. - * - * @author Jeremy Pry */ protected function setup_progress_bar() { $count = count( $this->actions ); @@ -98,8 +104,6 @@ protected function setup_progress_bar() { /** * Process actions in the queue. * - * @author Jeremy Pry - * * @param string $context Optional runner context. Default 'WP CLI'. * * @return int The number of actions processed. @@ -109,7 +113,7 @@ public function run( $context = 'WP CLI' ) { $this->setup_progress_bar(); foreach ( $this->actions as $action_id ) { // Error if we lost the claim. - if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $this->claim->get_id() ) ) ) { + if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $this->claim->get_id() ), true ) ) { WP_CLI::warning( __( 'The claim has been lost. Aborting current batch.', 'action-scheduler' ) ); break; } @@ -129,8 +133,6 @@ public function run( $context = 'WP CLI' ) { /** * Handle WP CLI message when the action is starting. * - * @author Jeremy Pry - * * @param int $action_id Action ID. */ public function before_execute( $action_id ) { @@ -141,8 +143,6 @@ public function before_execute( $action_id ) { /** * Handle WP CLI message when the action has completed. * - * @author Jeremy Pry - * * @param int $action_id ActionID. * @param null|ActionScheduler_Action $action The instance of the action. Default to null for backward compatibility. */ @@ -158,8 +158,6 @@ public function after_execute( $action_id, $action = null ) { /** * Handle WP CLI message when the action has failed. * - * @author Jeremy Pry - * * @param int $action_id Action ID. * @param Exception $exception Exception. * @throws \WP_CLI\ExitException With failure message.