From ee5b7ff06ff4075e8cf83b4d806604baec1985eb Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 12 Feb 2026 14:19:01 +0100 Subject: [PATCH 1/2] Fix newly reported PHPStan errors --- src/Cron_Event_Command.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Cron_Event_Command.php b/src/Cron_Event_Command.php index e3e74720..f7aeb719 100644 --- a/src/Cron_Event_Command.php +++ b/src/Cron_Event_Command.php @@ -185,20 +185,20 @@ public function schedule( $args, $assoc_args ) { WP_CLI::error( sprintf( "'%s' is not a valid datetime.", $next_run ) ); } - if ( ! empty( $recurrence ) ) { + $cron_args = $assoc_args; + ksort( $cron_args ); + $cron_args = array_values( $cron_args ); + if ( ! empty( $recurrence ) ) { $schedules = wp_get_schedules(); if ( ! isset( $schedules[ $recurrence ] ) ) { WP_CLI::error( sprintf( "'%s' is not a valid schedule name for recurrence.", $recurrence ) ); } - $event = wp_schedule_event( $timestamp, $recurrence, $hook, $assoc_args ); - + $event = wp_schedule_event( $timestamp, $recurrence, $hook, $cron_args ); } else { - - $event = wp_schedule_single_event( $timestamp, $hook, $assoc_args ); - + $event = wp_schedule_single_event( $timestamp, $hook, $cron_args ); } if ( false !== $event ) { From 7e58c59962bf71165b295633153e4c9b06ace0bf Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 13 Feb 2026 09:42:37 +0100 Subject: [PATCH 2/2] Solve with comment instead --- src/Cron_Event_Command.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Cron_Event_Command.php b/src/Cron_Event_Command.php index f7aeb719..848850c7 100644 --- a/src/Cron_Event_Command.php +++ b/src/Cron_Event_Command.php @@ -185,10 +185,6 @@ public function schedule( $args, $assoc_args ) { WP_CLI::error( sprintf( "'%s' is not a valid datetime.", $next_run ) ); } - $cron_args = $assoc_args; - ksort( $cron_args ); - $cron_args = array_values( $cron_args ); - if ( ! empty( $recurrence ) ) { $schedules = wp_get_schedules(); @@ -196,9 +192,13 @@ public function schedule( $args, $assoc_args ) { WP_CLI::error( sprintf( "'%s' is not a valid schedule name for recurrence.", $recurrence ) ); } - $event = wp_schedule_event( $timestamp, $recurrence, $hook, $cron_args ); + // WordPress expects a list bug we knowingly pass an associative array. + // @phpstan-ignore argument.type + $event = wp_schedule_event( $timestamp, $recurrence, $hook, $assoc_args ); } else { - $event = wp_schedule_single_event( $timestamp, $hook, $cron_args ); + // Ditto. + // @phpstan-ignore argument.type + $event = wp_schedule_single_event( $timestamp, $hook, $assoc_args ); } if ( false !== $event ) {