Skip to content

Commit fb3ce4a

Browse files
committed
feature #47730 Ban DateTime from the codebase (WebMamba)
This PR was squashed before being merged into the 6.2 branch. Discussion ---------- Ban DateTime from the codebase | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | yes | Deprecations? | yes | Tickets | #47580 | License | MIT | Doc PR | symfony As discuss in this issue, the purpose of this PR is to remove DateTime from the code base in favor to DateTimeImmutable. I will process it component by component. Feel free to discuss! Commits ------- 689385a83f Ban DateTime from the codebase
2 parents cf25dc4 + 8a9b746 commit fb3ce4a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Tests/TimezonesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ public function provideCountries(): iterable
666666

667667
public function testGetRawOffsetChangeTimeCountry()
668668
{
669-
$this->assertSame(7200, Timezones::getRawOffset('Europe/Paris', (new \DateTime('2022-07-16 00:00:00+00:00'))->getTimestamp()));
670-
$this->assertSame(3600, Timezones::getRawOffset('Europe/Paris', (new \DateTime('2022-02-16 00:00:00+00:00'))->getTimestamp()));
669+
$this->assertSame(7200, Timezones::getRawOffset('Europe/Paris', (new \DateTimeImmutable('2022-07-16 00:00:00+00:00'))->getTimestamp()));
670+
$this->assertSame(3600, Timezones::getRawOffset('Europe/Paris', (new \DateTimeImmutable('2022-02-16 00:00:00+00:00'))->getTimestamp()));
671671
}
672672
}

Tests/Util/GitRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testItClonesTheRepository()
5656
$this->assertSame(self::REPO_URL, $git->getUrl());
5757
$this->assertMatchesRegularExpression('#^[0-9a-z]{40}$#', $git->getLastCommitHash());
5858
$this->assertNotEmpty($git->getLastAuthor());
59-
$this->assertInstanceOf(\DateTime::class, $git->getLastAuthoredDate());
59+
$this->assertInstanceOf(\DateTimeImmutable::class, $git->getLastAuthoredDate());
6060
$this->assertStringMatchesFormat('v%s', $git->getLastTag());
6161
$this->assertStringMatchesFormat('v3%s', $git->getLastTag(function ($tag) { return str_starts_with($tag, 'v3'); }));
6262
}

Util/GitRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public function getLastAuthor(): string
6464
return $this->getLastLine($this->execInPath('git log -1 --format="%an"'));
6565
}
6666

67-
public function getLastAuthoredDate(): \DateTime
67+
public function getLastAuthoredDate(): \DateTimeImmutable
6868
{
69-
return new \DateTime($this->getLastLine($this->execInPath('git log -1 --format="%ai"')));
69+
return new \DateTimeImmutable($this->getLastLine($this->execInPath('git log -1 --format="%ai"')));
7070
}
7171

7272
public function getLastTag(callable $filter = null): string

0 commit comments

Comments
 (0)