← All changes
|
vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php
+21
-11
1.0.2
→
trunk
View file →
| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | * first instance of this chain of schedules ran. |
| 15 | 15 | * |
| 16 | 16 | * @var DateTime |
| 17 | 17 | */ |
| 18 | - private $first_date = NULL; | |
| 18 | + private $first_date = null; | |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Timestamp equivalent of @see $this->first_date |
| 22 | 22 | * |
| @@ -21,12 +21,12 @@ | ||
| 21 | 21 | * Timestamp equivalent of @see $this->first_date |
| 22 | 22 | * |
| 23 | 23 | * @var int |
| 24 | 24 | */ |
| 25 | - protected $first_timestamp = NULL; | |
| 25 | + protected $first_timestamp = null; | |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * The recurrance between each time an action is run using this schedule. | |
| 28 | + * The recurrence between each time an action is run using this schedule. | |
| 29 | 29 | * Used to calculate the start date & time. Can be a number of seconds, in the |
| 30 | 30 | * case of ActionScheduler_IntervalSchedule, or a cron expression, as in the |
| 31 | 31 | * case of ActionScheduler_CronSchedule. Or something else. |
| 32 | 32 | * |
| @@ -34,13 +34,15 @@ | ||
| 34 | 34 | */ |
| 35 | 35 | protected $recurrence; |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * @param DateTime $date The date & time to run the action. | |
| 39 | - * @param mixed $recurrence The data used to determine the schedule's recurrance. | |
| 38 | + * Construct. | |
| 39 | + * | |
| 40 | + * @param DateTime $date The date & time to run the action. | |
| 41 | + * @param mixed $recurrence The data used to determine the schedule's recurrence. | |
| 40 | 42 | * @param DateTime|null $first (Optional) The date & time the first instance of this interval schedule ran. Default null, meaning this is the first instance. |
| 41 | 43 | */ |
| 42 | - public function __construct( DateTime $date, $recurrence, DateTime $first = null ) { | |
| 44 | + public function __construct( DateTime $date, $recurrence, ?DateTime $first = null ) { | |
| 43 | 45 | parent::__construct( $date ); |
| 44 | 46 | $this->first_date = empty( $first ) ? $date : $first; |
| 45 | 47 | $this->recurrence = $recurrence; |
| 46 | 48 | } |
| @@ -45,8 +47,10 @@ | ||
| 45 | 47 | $this->recurrence = $recurrence; |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | 50 | /** |
| 51 | + * Schedule is recurring. | |
| 52 | + * | |
| 49 | 53 | * @return bool |
| 50 | 54 | */ |
| 51 | 55 | public function is_recurring() { |
| 52 | 56 | return true; |
| @@ -61,8 +65,10 @@ | ||
| 61 | 65 | return clone $this->first_date; |
| 62 | 66 | } |
| 63 | 67 | |
| 64 | 68 | /** |
| 69 | + * Get the schedule's recurrence. | |
| 70 | + * | |
| 65 | 71 | * @return string |
| 66 | 72 | */ |
| 67 | 73 | public function get_recurrence() { |
| 68 | 74 | return $this->recurrence; |
| @@ -69,17 +75,21 @@ | ||
| 69 | 75 | } |
| 70 | 76 | |
| 71 | 77 | /** |
| 72 | 78 | * For PHP 5.2 compat, since DateTime objects can't be serialized |
| 79 | + * | |
| 73 | 80 | * @return array |
| 74 | 81 | */ |
| 75 | 82 | public function __sleep() { |
| 76 | - $sleep_params = parent::__sleep(); | |
| 83 | + $sleep_params = parent::__sleep(); | |
| 77 | 84 | $this->first_timestamp = $this->first_date->getTimestamp(); |
| 78 | - return array_merge( $sleep_params, array( | |
| 79 | - 'first_timestamp', | |
| 80 | - 'recurrence' | |
| 81 | - ) ); | |
| 85 | + return array_merge( | |
| 86 | + $sleep_params, | |
| 87 | + array( | |
| 88 | + 'first_timestamp', | |
| 89 | + 'recurrence', | |
| 90 | + ) | |
| 91 | + ); | |
| 82 | 92 | } |
| 83 | 93 | |
| 84 | 94 | /** |
| 85 | 95 | * Unserialize recurring schedules serialized/stored prior to AS 3.0.0 |