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

Fix createFromMutable error #298

Merged
merged 4 commits into from
Oct 16, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix type mismatch
  • Loading branch information
dbrekelmans committed Oct 16, 2021
commit 417a797a64ad8c46d907b0a06a3f2cbdd8fa148d
9 changes: 2 additions & 7 deletions lib/DateTimeImmutable.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function setTimezone($timezone): self

/**
* @param \DateInterval $interval
* @return \DateTimeImmutable
* @return DateTimeImmutable
* @throws DatetimeException
*/
public function sub($interval): self
Expand Down Expand Up @@ -234,12 +234,7 @@ public function add($interval): self
*/
public static function createFromMutable($dateTime): self
{
$date = parent::createFromMutable($dateTime);

if ($date instanceof DateTimeImmutable) {
// parent::createFromMutable() apparantly returns a \Safe\DateTimeImmutable instead of \DateTimeImmutable
$date->innerDateTime = $dateTime;
}
$date = \DateTimeImmutable::createFromMutable($dateTime);

return self::createFromRegular($date);
}
Expand Down