diff --git a/abilities/class-ability-get-alerts.php b/abilities/class-ability-get-alerts.php index 9045ce075..bfcc78f1f 100644 --- a/abilities/class-ability-get-alerts.php +++ b/abilities/class-ability-get-alerts.php @@ -99,16 +99,11 @@ public function get_output_schema() { public function execute( $input = null ) { $requested = isset( $input['status'] ) ? $input['status'] : 'any'; - switch ( $requested ) { - case 'enabled': - $statuses = array( Alerts::STATUS_ENABLED ); - break; - case 'disabled': - $statuses = array( Alerts::STATUS_DISABLED ); - break; - default: - $statuses = array( Alerts::STATUS_ENABLED, Alerts::STATUS_DISABLED ); - } + $statuses = match ( $requested ) { + 'enabled' => array( Alerts::STATUS_ENABLED ), + 'disabled' => array( Alerts::STATUS_DISABLED ), + default => array( Alerts::STATUS_ENABLED, Alerts::STATUS_DISABLED ), + }; $alerts = $this->plugin->alerts->get_alerts( $statuses ); diff --git a/classes/class-list-table.php b/classes/class-list-table.php index 858792407..e66b52e5c 100644 --- a/classes/class-list-table.php +++ b/classes/class-list-table.php @@ -1167,25 +1167,14 @@ public function screen_controls( $status, $args ) { * @return string setting name for that column */ public function get_column_excluded_setting_key( $column ) { - switch ( $column ) { - case 'connector': - $output = 'connectors'; - break; - case 'context': - $output = 'contexts'; - break; - case 'action': - $output = 'action'; - break; - case 'ip': - $output = 'ip_addresses'; - break; - case 'user_id': - $output = 'users'; - break; - default: - $output = false; - } + $output = match ( $column ) { + 'connector' => 'connectors', + 'context' => 'contexts', + 'action' => 'action', + 'ip' => 'ip_addresses', + 'user_id' => 'users', + default => false, + }; return $output; } diff --git a/rector.php b/rector.php index c644b2fdf..947e61b54 100644 --- a/rector.php +++ b/rector.php @@ -13,6 +13,7 @@ use Rector\Config\RectorConfig; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; +use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; use Rector\ValueObject\PhpVersion; @@ -41,7 +42,7 @@ ) ->withPhpVersion( PhpVersion::PHP_82 ) ->withCache( __DIR__ . '/artifacts/rector' ) - ->withRules( array() ) + ->withRules( array( ChangeSwitchToMatchRector::class ) ) ->withConfiguredRule( TypedPropertyFromAssignsRector::class, array( TypedPropertyFromAssignsRector::INLINE_PUBLIC => true )