diff --git a/src/Carbon/CarbonInterval.php b/src/Carbon/CarbonInterval.php index 34820098d2..5ba85db757 100644 --- a/src/Carbon/CarbonInterval.php +++ b/src/Carbon/CarbonInterval.php @@ -296,12 +296,6 @@ class CarbonInterval extends DateInterval implements CarbonConverterInterface protected ?array $initialValues = null; - /** - * Total number of days the interval spans. If this is unknown, days will be FALSE. - * @var int|false - */ - private $days = false; - /** * Set the instance's timezone from a string or object. */ @@ -315,7 +309,6 @@ public function setTimezone(DateTimeZone|string|int $timezone): static ->avoidMutation() ->setTimezone($timezone); $this->rawInterval = null; - $this->days = false; } if ($this->endDate) { @@ -323,7 +316,6 @@ public function setTimezone(DateTimeZone|string|int $timezone): static ->avoidMutation() ->setTimezone($timezone); $this->rawInterval = null; - $this->days = false; } return $this; @@ -342,7 +334,6 @@ public function shiftTimezone(DateTimeZone|string|int $timezone): static ->avoidMutation() ->shiftTimezone($timezone); $this->rawInterval = null; - $this->days = false; } if ($this->endDate) { @@ -350,7 +341,6 @@ public function shiftTimezone(DateTimeZone|string|int $timezone): static ->avoidMutation() ->shiftTimezone($timezone); $this->rawInterval = null; - $this->days = false; } return $this; @@ -801,7 +791,6 @@ public function optimize(): static $this->startDate = null; $this->endDate = null; $this->rawInterval = null; - $this->days = false; return $this; } @@ -1116,7 +1105,6 @@ public static function diff($start, $end = null, bool $absolute = false, array $ $interval = static::instance($rawInterval, $skip); $interval->rawInterval = $rawInterval; - $interval->days = $rawInterval->days; $interval->startDate = $start; $interval->endDate = $end; $interval->initialValues = $interval->getInnerValues(); @@ -1356,7 +1344,6 @@ public function __get(string $name): int|float|string|null */ public function set($name, $value = null): static { - $this->days = false; $properties = \is_array($name) ? $name : [$name => $value]; foreach ($properties as $key => $value) { @@ -3353,7 +3340,6 @@ private function checkStartAndEnd(): void $this->startDate = null; $this->endDate = null; $this->rawInterval = null; - $this->days = false; } } diff --git a/tests/CarbonInterval/ConstructTest.php b/tests/CarbonInterval/ConstructTest.php index f6bf9b9868..d430c5ea8c 100644 --- a/tests/CarbonInterval/ConstructTest.php +++ b/tests/CarbonInterval/ConstructTest.php @@ -449,12 +449,18 @@ public function testFromSerialization() // Ignore translator for the English comparison $copy->setLocalTranslator($interval->getLocalTranslator()); + (function () { + $this->days ??= false; + })->call($copy); $this->assertEquals($interval, $copy); $interval = $today->locale('ja')->diffAsCarbonInterval($past); /** @var CarbonInterval $copy */ $copy = unserialize(serialize($interval)); + (function () { + $this->days ??= false; + })->call($copy); $this->assertInstanceOf(CarbonInterval::class, $copy);