Skip to content

Commit 5fbe69c

Browse files
committed
fix: patch up PHP 8.4 warnings
1 parent 9f12bc1 commit 5fbe69c

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

src/Date.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function now(): string
3636
/**
3737
* Base method for all date/time operations
3838
*/
39-
public function tick($userDate = 'now', string $userTimeZone = null): Date
39+
public function tick($userDate = 'now', ?string $userTimeZone = null): Date
4040
{
4141
$this->date = ($userDate instanceof DateTime ? $userDate : new DateTime(str_replace('/', '-', $userDate)));
4242

@@ -60,7 +60,7 @@ public function setTimezone(String $timezone = "Africa/Accra")
6060
/**
6161
* Add a duration to the current date
6262
*/
63-
public function add($duration, string $interval = null): Date
63+
public function add($duration, ?string $interval = null): Date
6464
{
6565
$this->date->modify($interval ? "$duration $interval" : $duration);
6666

@@ -70,9 +70,9 @@ public function add($duration, string $interval = null): Date
7070
/**
7171
* Subtract a duration to the current date
7272
*/
73-
public function subtract($duration, string $interval = null): Date
73+
public function subtract($duration, ?string $interval = null): Date
7474
{
75-
return $this->add($interval ? "-$duration $interval" : '-' . $duration);
75+
return $this->add($interval ? "-$duration $interval" : "-$duration");
7676
}
7777

7878
/**
@@ -172,7 +172,7 @@ public function get(string $unit): string
172172
*
173173
* @return Date|int
174174
*/
175-
public function millisecond(int $value = null)
175+
public function millisecond(?int $value = null)
176176
{
177177
return $value ? $this->set('millisecond', $value) : (int) $this->get('millisecond');
178178
}
@@ -182,7 +182,7 @@ public function millisecond(int $value = null)
182182
*
183183
* @return Date|int
184184
*/
185-
public function second(int $value = null)
185+
public function second(?int $value = null)
186186
{
187187
return $value ? $this->set('second', $value) : (int) $this->get('second');
188188
}
@@ -192,7 +192,7 @@ public function second(int $value = null)
192192
*
193193
* @return Date|int
194194
*/
195-
public function minute(int $value = null)
195+
public function minute(?int $value = null)
196196
{
197197
return $value ? $this->set('minute', $value) : (int) $this->get('minute');
198198
}
@@ -202,7 +202,7 @@ public function minute(int $value = null)
202202
*
203203
* @return Date|int
204204
*/
205-
public function hour(int $value = null)
205+
public function hour(?int $value = null)
206206
{
207207
return $value ? $this->set('hour', $value) : (int) $this->get('hour');
208208
}
@@ -212,7 +212,7 @@ public function hour(int $value = null)
212212
*
213213
* @return Date|int
214214
*/
215-
public function day(int $value = null)
215+
public function day(?int $value = null)
216216
{
217217
return $value ? $this->set('day', $value) : (int) $this->get('day');
218218
}
@@ -222,7 +222,7 @@ public function day(int $value = null)
222222
*
223223
* @return Date|int
224224
*/
225-
public function month(int $value = null)
225+
public function month(?int $value = null)
226226
{
227227
return $value ? $this->set('month', $value) : (int) $this->get('month');
228228
}
@@ -232,7 +232,7 @@ public function month(int $value = null)
232232
*
233233
* @return Date|int
234234
*/
235-
public function year(int $value = null)
235+
public function year(?int $value = null)
236236
{
237237
return $value ? $this->set('year', $value) : (int) $this->get('year');
238238
}

src/functions.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
if (!function_exists('tick')) {
66
/**
77
* Return the leaf date instance
8-
*
98
* @return Leaf\Date
109
*/
11-
function tick(string $userDate = null, string $userTimeZone = null)
10+
function tick(?string $userDate = null, ?string $userTimeZone = null)
1211
{
1312
if (!class_exists('Leaf\App')) {
1413
return (new Leaf\Date())->tick($userDate, $userTimeZone);

0 commit comments

Comments
 (0)