5 Commits
Author SHA1 Message Date
dualfroz b3fc145df6 Add #[NoDiscard] to CarbonImmutable modify(), next(), previous() and __call()
On PHP 8.5, DateTimeImmutable::modify() warns when its result is
discarded, but CarbonImmutable overrides it and lost the attribute.
Override modify(), next(), previous() and __call() in CarbonImmutable
with #[NoDiscard] so a discarded result warns again. The attribute is
ignored on older PHP versions, and mutable Carbon is unchanged.

Existing immutable tests that discarded results now keep them; in
IsTest::testIsSameMonth this was a real slip, the loop never moved $dt.

Fixes #3377
2026-10-03 02:24:35 +02:00
upstream 8dc8cfa977 Upstream briannesbitt/Carbon state of the touched files before d8ff648865 2026-10-03 02:24:35 +02:00
dualfroz 95c416685a Carry a numeric rounding precision out of any unit, not just seconds 2026-09-23 07:05:08 +02:00
dualfroz 5192615f4e fix: carry numeric round/floor/ceil precision >= 60s into minute/hour/day
A numeric $precision passed to round()/floor()/ceil() is always resolved
to the "second" unit. Once the precision reaches or exceeds 60 (e.g.
round(3600) meaning "nearest hour"), the rounding stayed confined to the
second field (range 0-59) and never carried into minute/hour/day, unlike
the equivalent string form (round('hour')).

Re-target the unit to minute/hour/day once the numeric precision reaches
that unit's own span in seconds, rescaling the precision accordingly,
mirroring the existing week -> day re-targeting already in roundUnit().
Sub-minute numeric precisions are unaffected.
2026-09-06 01:25:01 +02:00
upstream 06596ca5df Upstream briannesbitt/Carbon state of the touched files before 56c9340e26 2026-09-04 04:29:29 +02:00