Skip to content

Commit 2720a77

Browse files
committed
Make nullable parameters explicitly nullable (for improved compatibility with PHP 8.4 upwards).
1 parent 4f2a46c commit 2720a77

19 files changed

+86
-86
lines changed

classes/ActionScheduler_QueueCleaner.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class ActionScheduler_QueueCleaner {
3939
/**
4040
* ActionScheduler_QueueCleaner constructor.
4141
*
42-
* @param ActionScheduler_Store $store The store instance.
43-
* @param int $batch_size The batch size.
42+
* @param ActionScheduler_Store|null $store The store instance.
43+
* @param int $batch_size The batch size.
4444
*/
45-
public function __construct( ActionScheduler_Store $store = null, $batch_size = 20 ) {
45+
public function __construct( ?ActionScheduler_Store $store = null, $batch_size = 20 ) {
4646
$this->store = $store ? $store : ActionScheduler_Store::instance();
4747
$this->batch_size = $batch_size;
4848
}

classes/ActionScheduler_QueueRunner.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public static function instance() {
4747
/**
4848
* ActionScheduler_QueueRunner constructor.
4949
*
50-
* @param ActionScheduler_Store $store Store object.
51-
* @param ActionScheduler_FatalErrorMonitor $monitor Monitor object.
52-
* @param ActionScheduler_QueueCleaner $cleaner Cleaner object.
53-
* @param ActionScheduler_AsyncRequest_QueueRunner $async_request Async request runner object.
50+
* @param ActionScheduler_Store|null $store Store object.
51+
* @param ActionScheduler_FatalErrorMonitor|null $monitor Monitor object.
52+
* @param ActionScheduler_QueueCleaner|null $cleaner Cleaner object.
53+
* @param ActionScheduler_AsyncRequest_QueueRunner|null $async_request Async request runner object.
5454
*/
55-
public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null, ActionScheduler_AsyncRequest_QueueRunner $async_request = null ) {
55+
public function __construct( ?ActionScheduler_Store $store = null, ?ActionScheduler_FatalErrorMonitor $monitor = null, ?ActionScheduler_QueueCleaner $cleaner = null, ?ActionScheduler_AsyncRequest_QueueRunner $async_request = null ) {
5656
parent::__construct( $store, $monitor, $cleaner );
5757

5858
if ( is_null( $async_request ) ) {

classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ class ActionScheduler_WPCLI_QueueRunner extends ActionScheduler_Abstract_QueueRu
3333
/**
3434
* ActionScheduler_WPCLI_QueueRunner constructor.
3535
*
36-
* @param ActionScheduler_Store $store Store object.
37-
* @param ActionScheduler_FatalErrorMonitor $monitor Monitor object.
38-
* @param ActionScheduler_QueueCleaner $cleaner Cleaner object.
36+
* @param ActionScheduler_Store|null $store Store object.
37+
* @param ActionScheduler_FatalErrorMonitor|null $monitor Monitor object.
38+
* @param ActionScheduler_QueueCleaner|null $cleaner Cleaner object.
3939
*
4040
* @throws Exception When this is not run within WP CLI.
4141
*/
42-
public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null ) {
42+
public function __construct( ?ActionScheduler_Store $store = null, ?ActionScheduler_FatalErrorMonitor $monitor = null, ?ActionScheduler_QueueCleaner $cleaner = null ) {
4343
if ( ! ( defined( 'WP_CLI' ) && WP_CLI ) ) {
4444
/* translators: %s php class name */
4545
throw new Exception( sprintf( __( 'The %s class can only be run within WP CLI.', 'action-scheduler' ), __CLASS__ ) );

classes/abstracts/ActionScheduler_Abstract_QueueRunner.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ abstract class ActionScheduler_Abstract_QueueRunner extends ActionScheduler_Abst
3939
/**
4040
* ActionScheduler_Abstract_QueueRunner constructor.
4141
*
42-
* @param ActionScheduler_Store $store Store object.
43-
* @param ActionScheduler_FatalErrorMonitor $monitor Monitor object.
44-
* @param ActionScheduler_QueueCleaner $cleaner Cleaner object.
42+
* @param ActionScheduler_Store|null $store Store object.
43+
* @param ActionScheduler_FatalErrorMonitor|null $monitor Monitor object.
44+
* @param ActionScheduler_QueueCleaner|null $cleaner Cleaner object.
4545
*/
46-
public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null ) {
46+
public function __construct( ?ActionScheduler_Store $store = null, ?ActionScheduler_FatalErrorMonitor $monitor = null, ?ActionScheduler_QueueCleaner $cleaner = null ) {
4747

4848
$this->created_time = microtime( true );
4949

classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class ActionScheduler_Abstract_RecurringSchedule extends ActionSchedule
4141
* @param mixed $recurrence The data used to determine the schedule's recurrence.
4242
* @param DateTime|null $first (Optional) The date & time the first instance of this interval schedule ran. Default null, meaning this is the first instance.
4343
*/
44-
public function __construct( DateTime $date, $recurrence, DateTime $first = null ) {
44+
public function __construct( DateTime $date, $recurrence, ?DateTime $first = null ) {
4545
parent::__construct( $date );
4646
$this->first_date = empty( $first ) ? $date : $first;
4747
$this->recurrence = $recurrence;

classes/abstracts/ActionScheduler_Logger.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public static function instance() {
3030
/**
3131
* Create log entry.
3232
*
33-
* @param string $action_id Action ID.
34-
* @param string $message Log message.
35-
* @param DateTime $date Log date.
33+
* @param string $action_id Action ID.
34+
* @param string $message Log message.
35+
* @param DateTime|null $date Log date.
3636
*
3737
* @return string The log entry ID
3838
*/
39-
abstract public function log( $action_id, $message, DateTime $date = null );
39+
abstract public function log( $action_id, $message, ?DateTime $date = null );
4040

4141
/**
4242
* Get action's log entry.
@@ -215,7 +215,7 @@ public function log_ignored_action( $action_id, $context = '' ) {
215215
* @param string $action_id Action ID.
216216
* @param null|Exception $exception The exception which occurred when fetching the action. NULL by default for backward compatibility.
217217
*/
218-
public function log_failed_fetch_action( $action_id, Exception $exception = null ) {
218+
public function log_failed_fetch_action( $action_id, ?Exception $exception = null ) {
219219

220220
if ( ! is_null( $exception ) ) {
221221
/* translators: %s: exception message */

classes/abstracts/ActionScheduler_Store.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract class ActionScheduler_Store extends ActionScheduler_Store_Deprecated {
3737
*
3838
* @return int The action ID
3939
*/
40-
abstract public function save_action( ActionScheduler_Action $action, DateTime $scheduled_date = null );
40+
abstract public function save_action( ActionScheduler_Action $action, ?DateTime $scheduled_date = null );
4141

4242
/**
4343
* Get action.
@@ -202,14 +202,14 @@ abstract public function get_date( $action_id );
202202
/**
203203
* Make a claim.
204204
*
205-
* @param int $max_actions Maximum number of actions to claim.
206-
* @param DateTime $before_date Claim only actions schedule before the given date. Defaults to now.
207-
* @param array $hooks Claim only actions with a hook or hooks.
208-
* @param string $group Claim only actions in the given group.
205+
* @param int $max_actions Maximum number of actions to claim.
206+
* @param DateTime|null $before_date Claim only actions schedule before the given date. Defaults to now.
207+
* @param array $hooks Claim only actions with a hook or hooks.
208+
* @param string $group Claim only actions in the given group.
209209
*
210210
* @return ActionScheduler_ActionClaim
211211
*/
212-
abstract public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' );
212+
abstract public function stake_claim( $max_actions = 10, ?DateTime $before_date = null, $hooks = array(), $group = '' );
213213

214214
/**
215215
* Get claim count.
@@ -298,7 +298,7 @@ protected function validate_sql_comparator( $comparison_operator ) {
298298
* @param null|DateTime $scheduled_date Action's schedule date (optional).
299299
* @return string
300300
*/
301-
protected function get_scheduled_date_string( ActionScheduler_Action $action, DateTime $scheduled_date = null ) {
301+
protected function get_scheduled_date_string( ActionScheduler_Action $action, ?DateTime $scheduled_date = null ) {
302302
$next = is_null( $scheduled_date ) ? $action->get_schedule()->get_date() : $scheduled_date;
303303

304304
if ( ! $next ) {
@@ -313,11 +313,11 @@ protected function get_scheduled_date_string( ActionScheduler_Action $action, Da
313313
/**
314314
* Get the time MySQL formatted date/time string for an action's (next) scheduled date.
315315
*
316-
* @param ActionScheduler_Action $action Action.
317-
* @param null|DateTime $scheduled_date Action's scheduled date (optional).
316+
* @param ActionScheduler_Action|null $action Action.
317+
* @param null|DateTime $scheduled_date Action's scheduled date (optional).
318318
* @return string
319319
*/
320-
protected function get_scheduled_date_string_local( ActionScheduler_Action $action, DateTime $scheduled_date = null ) {
320+
protected function get_scheduled_date_string_local( ActionScheduler_Action $action, ?DateTime $scheduled_date = null ) {
321321
$next = is_null( $scheduled_date ) ? $action->get_schedule()->get_date() : $scheduled_date;
322322

323323
if ( ! $next ) {

classes/actions/ActionScheduler_Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ActionScheduler_Action {
5353
* @param null|ActionScheduler_Schedule $schedule Action's schedule.
5454
* @param string $group Action's group.
5555
*/
56-
public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) {
56+
public function __construct( $hook, array $args = array(), ?ActionScheduler_Schedule $schedule = null, $group = '' ) {
5757
$schedule = empty( $schedule ) ? new ActionScheduler_NullSchedule() : $schedule;
5858
$this->set_hook( $hook );
5959
$this->set_schedule( $schedule );

classes/actions/ActionScheduler_CanceledAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ActionScheduler_CanceledAction extends ActionScheduler_FinishedAction {
1616
* @param null|ActionScheduler_Schedule $schedule Action's schedule.
1717
* @param string $group Action's group.
1818
*/
19-
public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) {
19+
public function __construct( $hook, array $args = array(), ?ActionScheduler_Schedule $schedule = null, $group = '' ) {
2020
parent::__construct( $hook, $args, $schedule, $group );
2121
if ( is_null( $schedule ) ) {
2222
$this->set_schedule( new ActionScheduler_NullSchedule() );

classes/actions/ActionScheduler_NullAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ActionScheduler_NullAction extends ActionScheduler_Action {
1212
* @param mixed[] $args Action arguments.
1313
* @param null|ActionScheduler_Schedule $schedule Action schedule.
1414
*/
15-
public function __construct( $hook = '', array $args = array(), ActionScheduler_Schedule $schedule = null ) {
15+
public function __construct( $hook = '', array $args = array(), ?ActionScheduler_Schedule $schedule = null ) {
1616
$this->set_schedule( new ActionScheduler_NullSchedule() );
1717
}
1818

0 commit comments

Comments
 (0)