-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Expand Time for interface #4633
Conversation
I suggest changes within this PR. CodeIgniter4/system/I18n/Time.php Lines 1233 to 1248 in 9896c24
On cleaned of duplication. if ($time instanceof Time)
{
$time = $time->toDateTime();
}
elseif (is_string($time))
{
$timezone = $timezone ?: $this->timezone;
$timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
$time = new DateTime($time, $timezone);
}
if ($time instanceof DateTimeInterface)
{
$time = $time->setTimezone(new DateTimeZone('UTC'));
} |
I did it like this because
I'm not sure if PHPStan would complain though. |
This is just a suggestion and I'm not really against using your condition. $time instanceof DateTime || $time instanceof DateTimeImmutable The main thing is to get rid of duplication. |
Got it! If you can add it as an inline suggestion I can accept it on mobile, otherwise it will need to wait until I'm back on desktop. |
@iRedds I think I got that taken care of. |
Description
Many libraries use
DateTimeInterface
to allowDateTime
orDateTimeImmutable
. In a few cases inTime
our functions are already compatible with either yet the docblocks limit it toDateTime
. This PR expands the use for the interface, with one deprecation for an explicit method type.Checklist: