Skip to content

Commit

Permalink
Merge pull request #1132 from crstauf/phpcs/ActionScheduler_WPCLI_Sch…
Browse files Browse the repository at this point in the history
…eduler_command.php

PHPCS: `classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php`
  • Loading branch information
barryhughes authored Oct 25, 2024
2 parents f490160 + 3fb7af8 commit 901c67d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 4 additions & 12 deletions classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public function run( $args, $assoc_args ) {

$batches_completed = 0;
$actions_completed = 0;
$unlimited = $batches === 0;
if ( is_callable( [ ActionScheduler::store(), 'set_claim_filter' ] ) ) {
$unlimited = 0 === $batches;
if ( is_callable( array( ActionScheduler::store(), 'set_claim_filter' ) ) ) {
$exclude_groups = $this->parse_comma_separated_string( $exclude_groups );

if ( ! empty( $exclude_groups ) ) {
ActionScheduler::store()->set_claim_filter('exclude-groups', $exclude_groups );
ActionScheduler::store()->set_claim_filter( 'exclude-groups', $exclude_groups );
}
}

Expand Down Expand Up @@ -141,8 +141,6 @@ private function parse_comma_separated_string( $string ): array {
/**
* Print WP CLI message about how many actions are about to be processed.
*
* @author Jeremy Pry
*
* @param int $total Number of actions found.
*/
protected function print_total_actions( $total ) {
Expand All @@ -158,8 +156,6 @@ protected function print_total_actions( $total ) {
/**
* Print WP CLI message about how many batches of actions were processed.
*
* @author Jeremy Pry
*
* @param int $batches_completed Number of completed batches.
*/
protected function print_total_batches( $batches_completed ) {
Expand All @@ -175,11 +171,9 @@ protected function print_total_batches( $batches_completed ) {
/**
* Convert an exception into a WP CLI error.
*
* @author Jeremy Pry
*
* @param Exception $e The error object.
*
* @throws \WP_CLI\ExitException
* @throws \WP_CLI\ExitException Under some conditions WP CLI may throw an exception.
*/
protected function print_error( Exception $e ) {
WP_CLI::error(
Expand All @@ -194,8 +188,6 @@ protected function print_error( Exception $e ) {
/**
* Print a success message with the number of completed actions.
*
* @author Jeremy Pry
*
* @param int $actions_completed Number of completed actions.
*/
protected function print_success( $actions_completed ) {
Expand Down
4 changes: 4 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
<exclude-pattern>tests/*</exclude-pattern>
</rule>

<rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
<exclude-pattern>classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php</exclude-pattern>
</rule>

<rule ref="PEAR.NamingConventions.ValidClassName">
<exclude-pattern>classes/data-stores/ActionScheduler_wpPostStore.php</exclude-pattern>
<exclude-pattern>classes/ActionScheduler_wcSystemStatus.php</exclude-pattern>
Expand Down

0 comments on commit 901c67d

Please sign in to comment.