Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.6] fix: Time::createFromTimestamp() change for PHP 8.4 #9105

Merged
merged 15 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -7483,18 +7483,6 @@
'count' => 1,
'path' => __DIR__ . '/system/I18n/Time.php',
];
$ignoreErrors[] = [
// identifier: method.childReturnType
'message' => '#^Return type \\(CodeIgniter\\\\I18n\\\\Time\\) of method CodeIgniter\\\\I18n\\\\Time\\:\\:setTimestamp\\(\\) should be covariant with return type \\(static\\(DateTimeImmutable\\)\\) of method DateTimeImmutable\\:\\:setTimestamp\\(\\)$#',
'count' => 1,
'path' => __DIR__ . '/system/I18n/Time.php',
];
$ignoreErrors[] = [
// identifier: method.childReturnType
'message' => '#^Return type \\(CodeIgniter\\\\I18n\\\\Time\\) of method CodeIgniter\\\\I18n\\\\Time\\:\\:setTimezone\\(\\) should be covariant with return type \\(static\\(DateTimeImmutable\\)\\) of method DateTimeImmutable\\:\\:setTimezone\\(\\)$#',
'count' => 1,
'path' => __DIR__ . '/system/I18n/Time.php',
];
$ignoreErrors[] = [
// identifier: ternary.shortNotAllowed
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
Expand All @@ -7507,18 +7495,6 @@
'count' => 1,
'path' => __DIR__ . '/system/I18n/TimeLegacy.php',
];
$ignoreErrors[] = [
// identifier: method.childReturnType
'message' => '#^Return type \\(CodeIgniter\\\\I18n\\\\TimeLegacy\\) of method CodeIgniter\\\\I18n\\\\TimeLegacy\\:\\:setTimestamp\\(\\) should be covariant with return type \\(static\\(DateTime\\)\\) of method DateTime\\:\\:setTimestamp\\(\\)$#',
'count' => 1,
'path' => __DIR__ . '/system/I18n/TimeLegacy.php',
];
$ignoreErrors[] = [
// identifier: method.childReturnType
'message' => '#^Return type \\(CodeIgniter\\\\I18n\\\\TimeLegacy\\) of method CodeIgniter\\\\I18n\\\\TimeLegacy\\:\\:setTimezone\\(\\) should be covariant with return type \\(static\\(DateTime\\)\\) of method DateTime\\:\\:setTimezone\\(\\)$#',
'count' => 1,
'path' => __DIR__ . '/system/I18n/TimeLegacy.php',
];
$ignoreErrors[] = [
// identifier: ternary.shortNotAllowed
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
Expand Down
2 changes: 1 addition & 1 deletion system/DataCaster/Cast/TimestampCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function get(
self::invalidTypeValueError($value);
}

return Time::createFromTimestamp((int) $value);
return Time::createFromTimestamp((int) $value, date_default_timezone_get());
}

public static function set(
Expand Down
2 changes: 1 addition & 1 deletion system/Entity/Cast/DatetimeCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function get($value, array $params = [])
}

if (is_numeric($value)) {
return Time::createFromTimestamp((int) $value);
return Time::createFromTimestamp((int) $value, date_default_timezone_get());
}

if (is_string($value)) {
Expand Down
2 changes: 2 additions & 0 deletions system/I18n/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
* @property-read string $weekOfYear
* @property-read string $year
*
* @phpstan-consistent-constructor
*
* @see \CodeIgniter\I18n\TimeTest
*/
class Time extends DateTimeImmutable implements Stringable
Expand Down
2 changes: 2 additions & 0 deletions system/I18n/TimeLegacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
* @property string $weekOfYear read-only
* @property string $year read-only
*
* @phpstan-consistent-constructor
*
* @deprecated Use Time instead.
* @see \CodeIgniter\I18n\TimeLegacyTest
*/
Expand Down
Loading
Loading