Skip to content

Commit

Permalink
Merge pull request #2463 from kylekatarnls/fix/php-8.1
Browse files Browse the repository at this point in the history
Document bug 81458
  • Loading branch information
kylekatarnls committed Sep 18, 2021
2 parents e013414 + a4e22a2 commit 2d363e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Carbon/Traits/Difference.php
Expand Up @@ -124,10 +124,10 @@ public function diff($date = null, $absolute = false)
{
$other = $this->resolveCarbon($date);

// Can be removed if https://github.com/derickr/timelib/pull/110
// is merged
// https://bugs.php.net/bug.php?id=80998 was announced fixed in PHP 8.1.0beta3
// but created a reverse-regression when using UTC, so we still need this hack
// Work-around for https://bugs.php.net/bug.php?id=81458
// It was initially introduced for https://bugs.php.net/bug.php?id=80998
// The very specific case of 80998 was fixed in PHP 8.1beta3, but it introduced 81458
// So we still need to keep this for now
// @codeCoverageIgnoreStart
if (version_compare(PHP_VERSION, '8.1.0-dev', '>=') && $other->tz !== $this->tz) {
$other = $other->avoidMutation()->tz($this->tz);
Expand Down
5 changes: 5 additions & 0 deletions tests/Carbon/IsTest.php
Expand Up @@ -976,6 +976,11 @@ public function getFormatLetters(): Generator
public function testHasFormatWithSingleLetter($letter)
{
$output = Carbon::now()->format($letter);

if ($output === '1000' && $letter === 'v' && version_compare(PHP_VERSION, '7.2.12', '<')) {
$output = '000';
}

$this->assertTrue(Carbon::hasFormat($output, $letter), "'$letter' format should match '$output'");
}

Expand Down
5 changes: 5 additions & 0 deletions tests/CarbonImmutable/IsTest.php
Expand Up @@ -963,6 +963,11 @@ public function getFormatLetters(): Generator
public function testHasFormatWithSingleLetter($letter)
{
$output = Carbon::now()->format($letter);

if ($output === '1000' && $letter === 'v' && version_compare(PHP_VERSION, '7.2.12', '<')) {
$output = '000';
}

$this->assertTrue(Carbon::hasFormat($output, $letter), "'$letter' format should match '$output'");
}

Expand Down

0 comments on commit 2d363e8

Please sign in to comment.