From 2720a770e5bd809ebf4bd50d5db477ceb2ea1787 Mon Sep 17 00:00:00 2001 From: barryhughes <3594411+barryhughes@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:31:54 -0700 Subject: [PATCH] Make nullable parameters explicitly nullable (for improved compatibility with PHP 8.4 upwards). --- classes/ActionScheduler_QueueCleaner.php | 6 ++-- classes/ActionScheduler_QueueRunner.php | 10 +++--- .../ActionScheduler_WPCLI_QueueRunner.php | 8 ++--- .../ActionScheduler_Abstract_QueueRunner.php | 8 ++--- ...onScheduler_Abstract_RecurringSchedule.php | 2 +- classes/abstracts/ActionScheduler_Logger.php | 10 +++--- classes/abstracts/ActionScheduler_Store.php | 20 ++++++------ classes/actions/ActionScheduler_Action.php | 2 +- .../ActionScheduler_CanceledAction.php | 2 +- .../actions/ActionScheduler_NullAction.php | 2 +- .../data-stores/ActionScheduler_DBLogger.php | 8 ++--- .../data-stores/ActionScheduler_DBStore.php | 32 +++++++++---------- .../ActionScheduler_HybridStore.php | 10 +++--- .../ActionScheduler_wpCommentLogger.php | 8 ++--- .../ActionScheduler_wpPostStore.php | 30 ++++++++--------- .../ActionScheduler_DBStoreMigrator.php | 8 ++--- .../ActionScheduler_CronSchedule.php | 2 +- .../ActionScheduler_NullSchedule.php | 2 +- .../schedules/ActionScheduler_Schedule.php | 2 +- 19 files changed, 86 insertions(+), 86 deletions(-) diff --git a/classes/ActionScheduler_QueueCleaner.php b/classes/ActionScheduler_QueueCleaner.php index ff5173ae0..7029d0b21 100644 --- a/classes/ActionScheduler_QueueCleaner.php +++ b/classes/ActionScheduler_QueueCleaner.php @@ -39,10 +39,10 @@ class ActionScheduler_QueueCleaner { /** * ActionScheduler_QueueCleaner constructor. * - * @param ActionScheduler_Store $store The store instance. - * @param int $batch_size The batch size. + * @param ActionScheduler_Store|null $store The store instance. + * @param int $batch_size The batch size. */ - public function __construct( ActionScheduler_Store $store = null, $batch_size = 20 ) { + public function __construct( ?ActionScheduler_Store $store = null, $batch_size = 20 ) { $this->store = $store ? $store : ActionScheduler_Store::instance(); $this->batch_size = $batch_size; } diff --git a/classes/ActionScheduler_QueueRunner.php b/classes/ActionScheduler_QueueRunner.php index 2e2913898..13a71e796 100644 --- a/classes/ActionScheduler_QueueRunner.php +++ b/classes/ActionScheduler_QueueRunner.php @@ -47,12 +47,12 @@ public static function instance() { /** * ActionScheduler_QueueRunner constructor. * - * @param ActionScheduler_Store $store Store object. - * @param ActionScheduler_FatalErrorMonitor $monitor Monitor object. - * @param ActionScheduler_QueueCleaner $cleaner Cleaner object. - * @param ActionScheduler_AsyncRequest_QueueRunner $async_request Async request runner object. + * @param ActionScheduler_Store|null $store Store object. + * @param ActionScheduler_FatalErrorMonitor|null $monitor Monitor object. + * @param ActionScheduler_QueueCleaner|null $cleaner Cleaner object. + * @param ActionScheduler_AsyncRequest_QueueRunner|null $async_request Async request runner object. */ - public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null, ActionScheduler_AsyncRequest_QueueRunner $async_request = null ) { + public function __construct( ?ActionScheduler_Store $store = null, ?ActionScheduler_FatalErrorMonitor $monitor = null, ?ActionScheduler_QueueCleaner $cleaner = null, ?ActionScheduler_AsyncRequest_QueueRunner $async_request = null ) { parent::__construct( $store, $monitor, $cleaner ); if ( is_null( $async_request ) ) { diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php b/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php index 0a975b7ba..08cb0cd58 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php @@ -33,13 +33,13 @@ class ActionScheduler_WPCLI_QueueRunner extends ActionScheduler_Abstract_QueueRu /** * ActionScheduler_WPCLI_QueueRunner constructor. * - * @param ActionScheduler_Store $store Store object. - * @param ActionScheduler_FatalErrorMonitor $monitor Monitor object. - * @param ActionScheduler_QueueCleaner $cleaner Cleaner object. + * @param ActionScheduler_Store|null $store Store object. + * @param ActionScheduler_FatalErrorMonitor|null $monitor Monitor object. + * @param ActionScheduler_QueueCleaner|null $cleaner Cleaner object. * * @throws Exception When this is not run within WP CLI. */ - public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null ) { + public function __construct( ?ActionScheduler_Store $store = null, ?ActionScheduler_FatalErrorMonitor $monitor = null, ?ActionScheduler_QueueCleaner $cleaner = null ) { if ( ! ( defined( 'WP_CLI' ) && WP_CLI ) ) { /* translators: %s php class name */ throw new Exception( sprintf( __( 'The %s class can only be run within WP CLI.', 'action-scheduler' ), __CLASS__ ) ); diff --git a/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php b/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php index 574351a1e..1b51c3012 100644 --- a/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php +++ b/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php @@ -39,11 +39,11 @@ abstract class ActionScheduler_Abstract_QueueRunner extends ActionScheduler_Abst /** * ActionScheduler_Abstract_QueueRunner constructor. * - * @param ActionScheduler_Store $store Store object. - * @param ActionScheduler_FatalErrorMonitor $monitor Monitor object. - * @param ActionScheduler_QueueCleaner $cleaner Cleaner object. + * @param ActionScheduler_Store|null $store Store object. + * @param ActionScheduler_FatalErrorMonitor|null $monitor Monitor object. + * @param ActionScheduler_QueueCleaner|null $cleaner Cleaner object. */ - public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null ) { + public function __construct( ?ActionScheduler_Store $store = null, ?ActionScheduler_FatalErrorMonitor $monitor = null, ?ActionScheduler_QueueCleaner $cleaner = null ) { $this->created_time = microtime( true ); diff --git a/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php b/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php index 6cb9be313..60d09e917 100644 --- a/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php +++ b/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php @@ -41,7 +41,7 @@ abstract class ActionScheduler_Abstract_RecurringSchedule extends ActionSchedule * @param mixed $recurrence The data used to determine the schedule's recurrence. * @param DateTime|null $first (Optional) The date & time the first instance of this interval schedule ran. Default null, meaning this is the first instance. */ - public function __construct( DateTime $date, $recurrence, DateTime $first = null ) { + public function __construct( DateTime $date, $recurrence, ?DateTime $first = null ) { parent::__construct( $date ); $this->first_date = empty( $first ) ? $date : $first; $this->recurrence = $recurrence; diff --git a/classes/abstracts/ActionScheduler_Logger.php b/classes/abstracts/ActionScheduler_Logger.php index eedcf89a8..94ee2a93a 100644 --- a/classes/abstracts/ActionScheduler_Logger.php +++ b/classes/abstracts/ActionScheduler_Logger.php @@ -30,13 +30,13 @@ public static function instance() { /** * Create log entry. * - * @param string $action_id Action ID. - * @param string $message Log message. - * @param DateTime $date Log date. + * @param string $action_id Action ID. + * @param string $message Log message. + * @param DateTime|null $date Log date. * * @return string The log entry ID */ - abstract public function log( $action_id, $message, DateTime $date = null ); + abstract public function log( $action_id, $message, ?DateTime $date = null ); /** * Get action's log entry. @@ -215,7 +215,7 @@ public function log_ignored_action( $action_id, $context = '' ) { * @param string $action_id Action ID. * @param null|Exception $exception The exception which occurred when fetching the action. NULL by default for backward compatibility. */ - public function log_failed_fetch_action( $action_id, Exception $exception = null ) { + public function log_failed_fetch_action( $action_id, ?Exception $exception = null ) { if ( ! is_null( $exception ) ) { /* translators: %s: exception message */ diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index c89f6dbc4..bf6bc4294 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -37,7 +37,7 @@ abstract class ActionScheduler_Store extends ActionScheduler_Store_Deprecated { * * @return int The action ID */ - abstract public function save_action( ActionScheduler_Action $action, DateTime $scheduled_date = null ); + abstract public function save_action( ActionScheduler_Action $action, ?DateTime $scheduled_date = null ); /** * Get action. @@ -202,14 +202,14 @@ abstract public function get_date( $action_id ); /** * Make a claim. * - * @param int $max_actions Maximum number of actions to claim. - * @param DateTime $before_date Claim only actions schedule before the given date. Defaults to now. - * @param array $hooks Claim only actions with a hook or hooks. - * @param string $group Claim only actions in the given group. + * @param int $max_actions Maximum number of actions to claim. + * @param DateTime|null $before_date Claim only actions schedule before the given date. Defaults to now. + * @param array $hooks Claim only actions with a hook or hooks. + * @param string $group Claim only actions in the given group. * * @return ActionScheduler_ActionClaim */ - abstract public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' ); + abstract public function stake_claim( $max_actions = 10, ?DateTime $before_date = null, $hooks = array(), $group = '' ); /** * Get claim count. @@ -298,7 +298,7 @@ protected function validate_sql_comparator( $comparison_operator ) { * @param null|DateTime $scheduled_date Action's schedule date (optional). * @return string */ - protected function get_scheduled_date_string( ActionScheduler_Action $action, DateTime $scheduled_date = null ) { + protected function get_scheduled_date_string( ActionScheduler_Action $action, ?DateTime $scheduled_date = null ) { $next = is_null( $scheduled_date ) ? $action->get_schedule()->get_date() : $scheduled_date; if ( ! $next ) { @@ -313,11 +313,11 @@ protected function get_scheduled_date_string( ActionScheduler_Action $action, Da /** * Get the time MySQL formatted date/time string for an action's (next) scheduled date. * - * @param ActionScheduler_Action $action Action. - * @param null|DateTime $scheduled_date Action's scheduled date (optional). + * @param ActionScheduler_Action|null $action Action. + * @param null|DateTime $scheduled_date Action's scheduled date (optional). * @return string */ - protected function get_scheduled_date_string_local( ActionScheduler_Action $action, DateTime $scheduled_date = null ) { + protected function get_scheduled_date_string_local( ActionScheduler_Action $action, ?DateTime $scheduled_date = null ) { $next = is_null( $scheduled_date ) ? $action->get_schedule()->get_date() : $scheduled_date; if ( ! $next ) { diff --git a/classes/actions/ActionScheduler_Action.php b/classes/actions/ActionScheduler_Action.php index ef5a67628..1613efa19 100644 --- a/classes/actions/ActionScheduler_Action.php +++ b/classes/actions/ActionScheduler_Action.php @@ -53,7 +53,7 @@ class ActionScheduler_Action { * @param null|ActionScheduler_Schedule $schedule Action's schedule. * @param string $group Action's group. */ - public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) { + public function __construct( $hook, array $args = array(), ?ActionScheduler_Schedule $schedule = null, $group = '' ) { $schedule = empty( $schedule ) ? new ActionScheduler_NullSchedule() : $schedule; $this->set_hook( $hook ); $this->set_schedule( $schedule ); diff --git a/classes/actions/ActionScheduler_CanceledAction.php b/classes/actions/ActionScheduler_CanceledAction.php index d2df76ceb..c60075287 100644 --- a/classes/actions/ActionScheduler_CanceledAction.php +++ b/classes/actions/ActionScheduler_CanceledAction.php @@ -16,7 +16,7 @@ class ActionScheduler_CanceledAction extends ActionScheduler_FinishedAction { * @param null|ActionScheduler_Schedule $schedule Action's schedule. * @param string $group Action's group. */ - public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) { + public function __construct( $hook, array $args = array(), ?ActionScheduler_Schedule $schedule = null, $group = '' ) { parent::__construct( $hook, $args, $schedule, $group ); if ( is_null( $schedule ) ) { $this->set_schedule( new ActionScheduler_NullSchedule() ); diff --git a/classes/actions/ActionScheduler_NullAction.php b/classes/actions/ActionScheduler_NullAction.php index 05b676c9e..2cfaea61f 100644 --- a/classes/actions/ActionScheduler_NullAction.php +++ b/classes/actions/ActionScheduler_NullAction.php @@ -12,7 +12,7 @@ class ActionScheduler_NullAction extends ActionScheduler_Action { * @param mixed[] $args Action arguments. * @param null|ActionScheduler_Schedule $schedule Action schedule. */ - public function __construct( $hook = '', array $args = array(), ActionScheduler_Schedule $schedule = null ) { + public function __construct( $hook = '', array $args = array(), ?ActionScheduler_Schedule $schedule = null ) { $this->set_schedule( new ActionScheduler_NullSchedule() ); } diff --git a/classes/data-stores/ActionScheduler_DBLogger.php b/classes/data-stores/ActionScheduler_DBLogger.php index d285c8d27..0976b066c 100644 --- a/classes/data-stores/ActionScheduler_DBLogger.php +++ b/classes/data-stores/ActionScheduler_DBLogger.php @@ -12,13 +12,13 @@ class ActionScheduler_DBLogger extends ActionScheduler_Logger { /** * Add a record to an action log. * - * @param int $action_id Action ID. - * @param string $message Message to be saved in the log entry. - * @param DateTime $date Timestamp of the log entry. + * @param int $action_id Action ID. + * @param string $message Message to be saved in the log entry. + * @param DateTime|null $date Timestamp of the log entry. * * @return int The log entry ID. */ - public function log( $action_id, $message, DateTime $date = null ) { + public function log( $action_id, $message, ?DateTime $date = null ) { if ( empty( $date ) ) { $date = as_get_datetime_object(); } else { diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index 6e82e7708..25a883abd 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -59,12 +59,12 @@ public function init() { * Save an action, checks if this is a unique action before actually saving. * * @param ActionScheduler_Action $action Action object. - * @param \DateTime $scheduled_date Optional schedule date. Default null. + * @param DateTime|null $scheduled_date Optional schedule date. Default null. * * @return int Action ID. * @throws RuntimeException Throws exception when saving the action fails. */ - public function save_unique_action( ActionScheduler_Action $action, \DateTime $scheduled_date = null ) { + public function save_unique_action( ActionScheduler_Action $action, ?DateTime $scheduled_date = null ) { return $this->save_action_to_db( $action, $scheduled_date, true ); } @@ -72,12 +72,12 @@ public function save_unique_action( ActionScheduler_Action $action, \DateTime $s * Save an action. Can save duplicate action as well, prefer using `save_unique_action` instead. * * @param ActionScheduler_Action $action Action object. - * @param \DateTime $scheduled_date Optional schedule date. Default null. + * @param DateTime|null $scheduled_date Optional schedule date. Default null. * * @return int Action ID. * @throws RuntimeException Throws exception when saving the action fails. */ - public function save_action( ActionScheduler_Action $action, \DateTime $scheduled_date = null ) { + public function save_action( ActionScheduler_Action $action, ?DateTime $scheduled_date = null ) { return $this->save_action_to_db( $action, $scheduled_date, false ); } @@ -91,7 +91,7 @@ public function save_action( ActionScheduler_Action $action, \DateTime $schedule * @return int Action ID. * @throws \RuntimeException Throws exception when saving the action fails. */ - private function save_action_to_db( ActionScheduler_Action $action, DateTime $date = null, $unique = false ) { + private function save_action_to_db( ActionScheduler_Action $action, ?DateTime $date = null, $unique = false ) { global $wpdb; try { @@ -847,14 +847,14 @@ protected function get_date_gmt( $action_id ) { /** * Stake a claim on actions. * - * @param int $max_actions Maximum number of action to include in claim. - * @param \DateTime $before_date Jobs must be schedule before this date. Defaults to now. - * @param array $hooks Hooks to filter for. - * @param string $group Group to filter for. + * @param int $max_actions Maximum number of action to include in claim. + * @param DateTime|null $before_date Jobs must be schedule before this date. Defaults to now. + * @param array $hooks Hooks to filter for. + * @param string $group Group to filter for. * * @return ActionScheduler_ActionClaim */ - public function stake_claim( $max_actions = 10, \DateTime $before_date = null, $hooks = array(), $group = '' ) { + public function stake_claim( $max_actions = 10, ?DateTime $before_date = null, $hooks = array(), $group = '' ) { $claim_id = $this->generate_claim_id(); $this->claim_before_date = $before_date; @@ -914,17 +914,17 @@ public function get_claim_filter( $filter_name ) { /** * Mark actions claimed. * - * @param string $claim_id Claim Id. - * @param int $limit Number of action to include in claim. - * @param \DateTime $before_date Should use UTC timezone. - * @param array $hooks Hooks to filter for. - * @param string $group Group to filter for. + * @param string $claim_id Claim Id. + * @param int $limit Number of action to include in claim. + * @param DateTime|null $before_date Should use UTC timezone. + * @param array $hooks Hooks to filter for. + * @param string $group Group to filter for. * * @return int The number of actions that were claimed. * @throws \InvalidArgumentException Throws InvalidArgumentException if group doesn't exist. * @throws \RuntimeException Throws RuntimeException if unable to claim action. */ - protected function claim_actions( $claim_id, $limit, \DateTime $before_date = null, $hooks = array(), $group = '' ) { + protected function claim_actions( $claim_id, $limit, ?DateTime $before_date = null, $hooks = array(), $group = '' ) { /** * Global. * diff --git a/classes/data-stores/ActionScheduler_HybridStore.php b/classes/data-stores/ActionScheduler_HybridStore.php index 37eb82a02..c0845da4e 100644 --- a/classes/data-stores/ActionScheduler_HybridStore.php +++ b/classes/data-stores/ActionScheduler_HybridStore.php @@ -54,9 +54,9 @@ class ActionScheduler_HybridStore extends Store { /** * ActionScheduler_HybridStore constructor. * - * @param Config $config Migration config object. + * @param Config|null $config Migration config object. */ - public function __construct( Config $config = null ) { + public function __construct( ?Config $config = null ) { $this->demarkation_id = (int) get_option( self::DEMARKATION_OPTION, 0 ); if ( empty( $config ) ) { $config = Controller::instance()->get_migration_config_object(); @@ -240,7 +240,7 @@ public function action_counts() { * * @return ActionScheduler_ActionClaim */ - public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' ) { + public function stake_claim( $max_actions = 10, ?DateTime $before_date = null, $hooks = array(), $group = '' ) { $claim = $this->secondary_store->stake_claim( $max_actions, $before_date, $hooks, $group ); $claimed_actions = $claim->get_actions(); @@ -266,11 +266,11 @@ private function migrate( $action_ids ) { * Save an action to the primary store. * * @param ActionScheduler_Action $action Action object to be saved. - * @param DateTime $date Optional. Schedule date. Default null. + * @param DateTime|null $date Optional. Schedule date. Default null. * * @return int The action ID */ - public function save_action( ActionScheduler_Action $action, DateTime $date = null ) { + public function save_action( ActionScheduler_Action $action, ?DateTime $date = null ) { return $this->primary_store->save_action( $action, $date ); } diff --git a/classes/data-stores/ActionScheduler_wpCommentLogger.php b/classes/data-stores/ActionScheduler_wpCommentLogger.php index b6ceba1c6..a9d84d31e 100644 --- a/classes/data-stores/ActionScheduler_wpCommentLogger.php +++ b/classes/data-stores/ActionScheduler_wpCommentLogger.php @@ -10,13 +10,13 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger { /** * Create log entry. * - * @param string $action_id Action ID. - * @param string $message Action log's message. - * @param DateTime $date Action log's timestamp. + * @param string $action_id Action ID. + * @param string $message Action log's message. + * @param DateTime|null $date Action log's timestamp. * * @return string The log entry ID */ - public function log( $action_id, $message, DateTime $date = null ) { + public function log( $action_id, $message, ?DateTime $date = null ) { if ( empty( $date ) ) { $date = as_get_datetime_object(); } else { diff --git a/classes/data-stores/ActionScheduler_wpPostStore.php b/classes/data-stores/ActionScheduler_wpPostStore.php index 3971b3395..a503c1830 100644 --- a/classes/data-stores/ActionScheduler_wpPostStore.php +++ b/classes/data-stores/ActionScheduler_wpPostStore.php @@ -30,12 +30,12 @@ class ActionScheduler_wpPostStore extends ActionScheduler_Store { * Save action. * * @param ActionScheduler_Action $action Scheduled Action. - * @param DateTime $scheduled_date Scheduled Date. + * @param DateTime|null $scheduled_date Scheduled Date. * * @throws RuntimeException Throws an exception if the action could not be saved. * @return int */ - public function save_action( ActionScheduler_Action $action, DateTime $scheduled_date = null ) { + public function save_action( ActionScheduler_Action $action, ?DateTime $scheduled_date = null ) { try { $this->validate_action( $action ); $post_array = $this->create_post_array( $action, $scheduled_date ); @@ -54,11 +54,11 @@ public function save_action( ActionScheduler_Action $action, DateTime $scheduled * Create post array. * * @param ActionScheduler_Action $action Scheduled Action. - * @param DateTime $scheduled_date Scheduled Date. + * @param DateTime|null $scheduled_date Scheduled Date. * * @return array Returns an array of post data. */ - protected function create_post_array( ActionScheduler_Action $action, DateTime $scheduled_date = null ) { + protected function create_post_array( ActionScheduler_Action $action, ?DateTime $scheduled_date = null ) { $post = array( 'post_type' => self::POST_TYPE, 'post_title' => $action->get_hook(), @@ -573,16 +573,16 @@ public function get_date_gmt( $action_id ) { /** * Stake claim. * - * @param int $max_actions Maximum number of actions. - * @param DateTime $before_date Jobs must be schedule before this date. Defaults to now. - * @param array $hooks Claim only actions with a hook or hooks. - * @param string $group Claim only actions in the given group. + * @param int $max_actions Maximum number of actions. + * @param DateTime|null $before_date Jobs must be schedule before this date. Defaults to now. + * @param array $hooks Claim only actions with a hook or hooks. + * @param string $group Claim only actions in the given group. * * @return ActionScheduler_ActionClaim * @throws RuntimeException When there is an error staking a claim. * @throws InvalidArgumentException When the given group is not valid. */ - public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' ) { + public function stake_claim( $max_actions = 10, ?DateTime $before_date = null, $hooks = array(), $group = '' ) { $this->claim_before_date = $before_date; $claim_id = $this->generate_claim_id(); $this->claim_actions( $claim_id, $max_actions, $before_date, $hooks, $group ); @@ -622,16 +622,16 @@ protected function generate_claim_id() { /** * Claim actions. * - * @param string $claim_id Claim ID. - * @param int $limit Limit. - * @param DateTime $before_date Should use UTC timezone. - * @param array $hooks Claim only actions with a hook or hooks. - * @param string $group Claim only actions in the given group. + * @param string $claim_id Claim ID. + * @param int $limit Limit. + * @param DateTime|null $before_date Should use UTC timezone. + * @param array $hooks Claim only actions with a hook or hooks. + * @param string $group Claim only actions in the given group. * * @return int The number of actions that were claimed. * @throws RuntimeException When there is a database error. */ - protected function claim_actions( $claim_id, $limit, DateTime $before_date = null, $hooks = array(), $group = '' ) { + protected function claim_actions( $claim_id, $limit, ?DateTime $before_date = null, $hooks = array(), $group = '' ) { // Set up initial variables. $date = null === $before_date ? as_get_datetime_object() : clone $before_date; $limit_ids = ! empty( $group ); diff --git a/classes/migration/ActionScheduler_DBStoreMigrator.php b/classes/migration/ActionScheduler_DBStoreMigrator.php index bcdf480a5..66ab99707 100644 --- a/classes/migration/ActionScheduler_DBStoreMigrator.php +++ b/classes/migration/ActionScheduler_DBStoreMigrator.php @@ -3,7 +3,7 @@ /** * Class ActionScheduler_DBStoreMigrator * - * A class for direct saving of actions to the table data store during migration. + * A class for direct saving of actions to the table data store during migration. * * @since 3.0.0 */ @@ -17,13 +17,13 @@ class ActionScheduler_DBStoreMigrator extends ActionScheduler_DBStore { * that when first saving the action. * * @param ActionScheduler_Action $action Action to migrate. - * @param null|\DateTime $scheduled_date Optional date of the first instance to store. - * @param null|\DateTime $last_attempt_date Optional date the action was last attempted. + * @param null|DateTime $scheduled_date Optional date of the first instance to store. + * @param null|DateTime $last_attempt_date Optional date the action was last attempted. * * @return string The action ID * @throws \RuntimeException When the action is not saved. */ - public function save_action( ActionScheduler_Action $action, \DateTime $scheduled_date = null, \DateTime $last_attempt_date = null ) { + public function save_action( ActionScheduler_Action $action, ?DateTime $scheduled_date = null, ?DateTime $last_attempt_date = null ) { try { /** * Global. diff --git a/classes/schedules/ActionScheduler_CronSchedule.php b/classes/schedules/ActionScheduler_CronSchedule.php index d721a2efd..6ac43c943 100644 --- a/classes/schedules/ActionScheduler_CronSchedule.php +++ b/classes/schedules/ActionScheduler_CronSchedule.php @@ -27,7 +27,7 @@ class ActionScheduler_CronSchedule extends ActionScheduler_Abstract_RecurringSch * @param CronExpression|string $recurrence The CronExpression used to calculate the schedule's next instance. * @param DateTime|null $first (Optional) The date & time the first instance of this interval schedule ran. Default null, meaning this is the first instance. */ - public function __construct( DateTime $start, $recurrence, DateTime $first = null ) { + public function __construct( DateTime $start, $recurrence, ?DateTime $first = null ) { if ( ! is_a( $recurrence, 'CronExpression' ) ) { $recurrence = CronExpression::factory( $recurrence ); } diff --git a/classes/schedules/ActionScheduler_NullSchedule.php b/classes/schedules/ActionScheduler_NullSchedule.php index cc1ddb581..77c7c4ed4 100644 --- a/classes/schedules/ActionScheduler_NullSchedule.php +++ b/classes/schedules/ActionScheduler_NullSchedule.php @@ -17,7 +17,7 @@ class ActionScheduler_NullSchedule extends ActionScheduler_SimpleSchedule { * * @param null|DateTime $date The date & time to run the action. */ - public function __construct( DateTime $date = null ) { + public function __construct( ?DateTime $date = null ) { $this->scheduled_date = null; } diff --git a/classes/schedules/ActionScheduler_Schedule.php b/classes/schedules/ActionScheduler_Schedule.php index 6fa175ed2..e3803e184 100644 --- a/classes/schedules/ActionScheduler_Schedule.php +++ b/classes/schedules/ActionScheduler_Schedule.php @@ -11,7 +11,7 @@ interface ActionScheduler_Schedule { * @param null|DateTime $after Timestamp. * @return DateTime|null */ - public function next( DateTime $after = null ); + public function next( ?DateTime $after = null ); /** * Identify the schedule as (not) recurring.