Skip to content

Commit a5fc034

Browse files
authored
refactor: use __unserialize instead of __wakeup in TimeTrait (#9957)
1 parent 2582088 commit a5fc034

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

system/I18n/TimeTrait.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,19 +1238,11 @@ public function __isset($name): bool
12381238

12391239
/**
12401240
* This is called when we unserialize the Time object.
1241+
*
1242+
* @param array{date: string, timezone: string, timezone_type: int} $data
12411243
*/
1242-
public function __wakeup(): void
1244+
public function __unserialize(array $data): void
12431245
{
1244-
/**
1245-
* Prior to unserialization, this is a string.
1246-
*
1247-
* @var string $timezone
1248-
*/
1249-
$timezone = $this->timezone;
1250-
1251-
$this->timezone = new DateTimeZone($timezone);
1252-
1253-
// @phpstan-ignore-next-line `$this->date` is a special property for PHP internal use.
1254-
parent::__construct($this->date, $this->timezone);
1246+
parent::__construct($data['date'], new DateTimeZone($data['timezone']));
12551247
}
12561248
}

utils/phpstan-baseline/loader.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 2122 errors
1+
# total 2126 errors
22

33
includes:
44
- argument.type.neon

utils/phpstan-baseline/method.childParameterType.neon

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 8 errors
1+
# total 12 errors
22

33
parameters:
44
ignoreErrors:
@@ -41,3 +41,23 @@ parameters:
4141
message: '#^Parameter \#1 \$value \(int\) of method CodeIgniter\\Entity\\Cast\\IntBoolCast\:\:get\(\) should be contravariant with parameter \$value \(array\|bool\|float\|int\|object\|string\|null\) of method CodeIgniter\\Entity\\Cast\\CastInterface\:\:get\(\)$#'
4242
count: 1
4343
path: ../../system/Entity/Cast/IntBoolCast.php
44+
45+
-
46+
message: '#^Parameter \#1 \$data \(array\{date\: string, timezone\: string, timezone_type\: int\}\) of method CodeIgniter\\I18n\\Time\:\:__unserialize\(\) should be contravariant with parameter \$data \(array\) of method DateTimeImmutable\:\:__unserialize\(\)$#'
47+
count: 1
48+
path: ../../system/I18n/Time.php
49+
50+
-
51+
message: '#^Parameter \#1 \$data \(array\{date\: string, timezone\: string, timezone_type\: int\}\) of method CodeIgniter\\I18n\\Time\:\:__unserialize\(\) should be contravariant with parameter \$data \(array\) of method DateTimeInterface\:\:__unserialize\(\)$#'
52+
count: 1
53+
path: ../../system/I18n/Time.php
54+
55+
-
56+
message: '#^Parameter \#1 \$data \(array\{date\: string, timezone\: string, timezone_type\: int\}\) of method CodeIgniter\\I18n\\TimeLegacy\:\:__unserialize\(\) should be contravariant with parameter \$data \(array\) of method DateTimeInterface\:\:__unserialize\(\)$#'
57+
count: 1
58+
path: ../../system/I18n/TimeLegacy.php
59+
60+
-
61+
message: '#^Parameter \#1 \$data \(array\{date\: string, timezone\: string, timezone_type\: int\}\) of method CodeIgniter\\I18n\\TimeLegacy\:\:__unserialize\(\) should be contravariant with parameter \$data \(array\) of method DateTime\:\:__unserialize\(\)$#'
62+
count: 1
63+
path: ../../system/I18n/TimeLegacy.php

0 commit comments

Comments
 (0)