Skip to content

Commit 4d0110f

Browse files
authored
Make Time compatible with DateTime (#5022)
1 parent d8b43eb commit 4d0110f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

system/I18n/Time.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
use IntlCalendar;
2222
use IntlDateFormatter;
2323
use Locale;
24+
use ReturnTypeWillChange;
2425

2526
/**
26-
* Class Time
27-
*
2827
* A localized date/time package inspired
2928
* by Nesbot/Carbon and CakePHP/Chronos.
3029
*
@@ -232,19 +231,20 @@ public static function create(?int $year = null, ?int $month = null, ?int $day =
232231
*
233232
* @param string $format
234233
* @param string $datetime
235-
* @param DateTimeZone|string|null $timeZone
234+
* @param DateTimeZone|string|null $timezone
236235
*
237236
* @throws Exception
238237
*
239238
* @return Time
240239
*/
241-
public static function createFromFormat($format, $datetime, $timeZone = null)
240+
#[ReturnTypeWillChange]
241+
public static function createFromFormat($format, $datetime, $timezone = null)
242242
{
243243
if (! $date = parent::createFromFormat($format, $datetime)) {
244244
throw I18nException::forInvalidFormat($format);
245245
}
246246

247-
return new self($date->format('Y-m-d H:i:s'), $timeZone);
247+
return new self($date->format('Y-m-d H:i:s'), $timezone);
248248
}
249249

250250
/**
@@ -679,6 +679,7 @@ protected function setValue(string $name, $value)
679679
*
680680
* @return Time
681681
*/
682+
#[ReturnTypeWillChange]
682683
public function setTimezone($timezone)
683684
{
684685
$timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
@@ -695,6 +696,7 @@ public function setTimezone($timezone)
695696
*
696697
* @return Time
697698
*/
699+
#[ReturnTypeWillChange]
698700
public function setTimestamp($timestamp)
699701
{
700702
$time = date('Y-m-d H:i:s', $timestamp);
@@ -1181,7 +1183,7 @@ public function __isset($name): bool
11811183
/**
11821184
* This is called when we unserialize the Time object.
11831185
*/
1184-
public function __wakeup()
1186+
public function __wakeup(): void
11851187
{
11861188
/**
11871189
* Prior to unserialization, this is a string.

0 commit comments

Comments
 (0)