From aa124ac7499d6dd7abca9772ed2397c663587cfc Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Tue, 1 Jun 2021 13:13:21 +0200 Subject: [PATCH 01/16] Allow to add and sub decimal numbers of any unit --- phpdoc.php | 18 +- src/Carbon/Carbon.php | 250 ++++++++++++++-------------- src/Carbon/CarbonImmutable.php | 250 ++++++++++++++-------------- src/Carbon/CarbonInterface.php | 264 +++++++++++++++--------------- src/Carbon/Traits/Date.php | 250 ++++++++++++++-------------- src/Carbon/Traits/Units.php | 27 +-- tests/Carbon/AddTest.php | 20 +++ tests/CarbonImmutable/AddTest.php | 20 +++ 8 files changed, 572 insertions(+), 527 deletions(-) diff --git a/phpdoc.php b/phpdoc.php index f0a76a5725..8b6d00e86b 100644 --- a/phpdoc.php +++ b/phpdoc.php @@ -312,7 +312,7 @@ function dumpParameter($method, ReflectionParameter $parameter) $autoDocLines[] = [ '@method', 'self', - 'add'.ucFirst($plUnit).'(int $value = 1)', + 'add'.ucFirst($plUnit).'(int|float $value = 1)', "Add $plUnitName (the \$value count passed in) to the instance (using date interval).", ]; $autoDocLines[] = [ @@ -324,7 +324,7 @@ function dumpParameter($method, ReflectionParameter $parameter) $autoDocLines[] = [ '@method', 'self', - 'sub'.ucFirst($plUnit).'(int $value = 1)', + 'sub'.ucFirst($plUnit).'(int|float $value = 1)', "Sub $plUnitName (the \$value count passed in) to the instance (using date interval).", ]; $autoDocLines[] = [ @@ -345,7 +345,7 @@ function dumpParameter($method, ReflectionParameter $parameter) $autoDocLines[] = [ '@method', 'self', - 'add'.ucFirst($plUnit).'WithOverflow(int $value = 1)', + 'add'.ucFirst($plUnit).'WithOverflow(int|float $value = 1)', "Add $plUnitName (the \$value count passed in) to the instance (using date interval) with overflow explicitly allowed.", ]; $autoDocLines[] = [ @@ -357,7 +357,7 @@ function dumpParameter($method, ReflectionParameter $parameter) $autoDocLines[] = [ '@method', 'self', - 'sub'.ucFirst($plUnit).'WithOverflow(int $value = 1)', + 'sub'.ucFirst($plUnit).'WithOverflow(int|float $value = 1)', "Sub $plUnitName (the \$value count passed in) to the instance (using date interval) with overflow explicitly allowed.", ]; $autoDocLines[] = [ @@ -371,7 +371,7 @@ function dumpParameter($method, ReflectionParameter $parameter) $autoDocLines[] = [ '@method', 'self', - 'add'.ucFirst($plUnit)."$alias(int \$value = 1)", + 'add'.ucFirst($plUnit)."$alias(int|float \$value = 1)", "Add $plUnitName (the \$value count passed in) to the instance (using date interval) with overflow explicitly forbidden.", ]; $autoDocLines[] = [ @@ -383,7 +383,7 @@ function dumpParameter($method, ReflectionParameter $parameter) $autoDocLines[] = [ '@method', 'self', - 'sub'.ucFirst($plUnit)."$alias(int \$value = 1)", + 'sub'.ucFirst($plUnit)."$alias(int|float \$value = 1)", "Sub $plUnitName (the \$value count passed in) to the instance (using date interval) with overflow explicitly forbidden.", ]; $autoDocLines[] = [ @@ -407,7 +407,7 @@ function dumpParameter($method, ReflectionParameter $parameter) $autoDocLines[] = [ '@method', 'self', - 'addReal'.ucFirst($plUnit).'(int $value = 1)', + 'addReal'.ucFirst($plUnit).'(int|float $value = 1)', "Add $plUnitName (the \$value count passed in) to the instance (using timestamp).", ]; $autoDocLines[] = [ @@ -419,7 +419,7 @@ function dumpParameter($method, ReflectionParameter $parameter) $autoDocLines[] = [ '@method', 'self', - 'subReal'.ucFirst($plUnit).'(int $value = 1)', + 'subReal'.ucFirst($plUnit).'(int|float $value = 1)', "Sub $plUnitName (the \$value count passed in) to the instance (using timestamp).", ]; $autoDocLines[] = [ @@ -431,7 +431,7 @@ function dumpParameter($method, ReflectionParameter $parameter) $autoDocLines[] = [ '@method', 'CarbonPeriod', - $plUnit.'Until($endDate = null, int $factor = 1)', + $plUnit.'Until($endDate = null, int|float $factor = 1)', "Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each $unitName or every X $plUnitName if a factor is given.", ]; diff --git a/src/Carbon/Carbon.php b/src/Carbon/Carbon.php index f4128544c4..d1a1eb8120 100644 --- a/src/Carbon/Carbon.php +++ b/src/Carbon/Carbon.php @@ -187,241 +187,241 @@ * @method $this microsecond(int $value) Set current instance microsecond to the given value. * @method $this setMicroseconds(int $value) Set current instance microsecond to the given value. * @method $this setMicrosecond(int $value) Set current instance microsecond to the given value. - * @method $this addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval). + * @method $this addYears(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval). * @method $this addYear() Add one year to the instance (using date interval). - * @method $this subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval). + * @method $this subYears(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval). * @method $this subYear() Sub one year to the instance (using date interval). - * @method $this addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this addYearsWithOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed. - * @method $this subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this subYearsWithOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed. - * @method $this addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addYearsWithoutOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subYearsWithoutOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addYearsWithNoOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subYearsWithNoOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addYearsNoOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subYearsNoOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval). + * @method $this addMonths(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval). * @method $this addMonth() Add one month to the instance (using date interval). - * @method $this subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval). + * @method $this subMonths(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval). * @method $this subMonth() Sub one month to the instance (using date interval). - * @method $this addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this addMonthsWithOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed. - * @method $this subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this subMonthsWithOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed. - * @method $this addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addMonthsWithoutOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subMonthsWithoutOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addMonthsWithNoOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subMonthsWithNoOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addMonthsNoOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subMonthsNoOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval). + * @method $this addDays(int|float $value = 1) Add days (the $value count passed in) to the instance (using date interval). * @method $this addDay() Add one day to the instance (using date interval). - * @method $this subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval). + * @method $this subDays(int|float $value = 1) Sub days (the $value count passed in) to the instance (using date interval). * @method $this subDay() Sub one day to the instance (using date interval). - * @method $this addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval). + * @method $this addHours(int|float $value = 1) Add hours (the $value count passed in) to the instance (using date interval). * @method $this addHour() Add one hour to the instance (using date interval). - * @method $this subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). + * @method $this subHours(int|float $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). * @method $this subHour() Sub one hour to the instance (using date interval). - * @method $this addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). + * @method $this addMinutes(int|float $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). * @method $this addMinute() Add one minute to the instance (using date interval). - * @method $this subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). + * @method $this subMinutes(int|float $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). * @method $this subMinute() Sub one minute to the instance (using date interval). - * @method $this addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). + * @method $this addSeconds(int|float $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). * @method $this addSecond() Add one second to the instance (using date interval). - * @method $this subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). + * @method $this subSeconds(int|float $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). * @method $this subSecond() Sub one second to the instance (using date interval). - * @method $this addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). + * @method $this addMillis(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). * @method $this addMilli() Add one millisecond to the instance (using date interval). - * @method $this subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). + * @method $this subMillis(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). * @method $this subMilli() Sub one millisecond to the instance (using date interval). - * @method $this addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). + * @method $this addMilliseconds(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). * @method $this addMillisecond() Add one millisecond to the instance (using date interval). - * @method $this subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). + * @method $this subMilliseconds(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). * @method $this subMillisecond() Sub one millisecond to the instance (using date interval). - * @method $this addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). + * @method $this addMicros(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). * @method $this addMicro() Add one microsecond to the instance (using date interval). - * @method $this subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). + * @method $this subMicros(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). * @method $this subMicro() Sub one microsecond to the instance (using date interval). - * @method $this addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). + * @method $this addMicroseconds(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). * @method $this addMicrosecond() Add one microsecond to the instance (using date interval). - * @method $this subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). + * @method $this subMicroseconds(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). * @method $this subMicrosecond() Sub one microsecond to the instance (using date interval). - * @method $this addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). + * @method $this addMillennia(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). * @method $this addMillennium() Add one millennium to the instance (using date interval). - * @method $this subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). + * @method $this subMillennia(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). * @method $this subMillennium() Sub one millennium to the instance (using date interval). - * @method $this addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this addMillenniaWithOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed. - * @method $this subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this subMillenniaWithOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed. - * @method $this addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addMillenniaWithoutOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subMillenniaWithoutOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addMillenniaWithNoOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subMillenniaWithNoOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addMillenniaNoOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subMillenniaNoOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). + * @method $this addCenturies(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). * @method $this addCentury() Add one century to the instance (using date interval). - * @method $this subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). + * @method $this subCenturies(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). * @method $this subCentury() Sub one century to the instance (using date interval). - * @method $this addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this addCenturiesWithOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed. - * @method $this subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this subCenturiesWithOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed. - * @method $this addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addCenturiesWithoutOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subCenturiesWithoutOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addCenturiesWithNoOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subCenturiesWithNoOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addCenturiesNoOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subCenturiesNoOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval). + * @method $this addDecades(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval). * @method $this addDecade() Add one decade to the instance (using date interval). - * @method $this subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). + * @method $this subDecades(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). * @method $this subDecade() Sub one decade to the instance (using date interval). - * @method $this addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this addDecadesWithOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed. - * @method $this subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this subDecadesWithOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed. - * @method $this addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addDecadesWithoutOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subDecadesWithoutOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addDecadesWithNoOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subDecadesWithNoOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addDecadesNoOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subDecadesNoOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). + * @method $this addQuarters(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). * @method $this addQuarter() Add one quarter to the instance (using date interval). - * @method $this subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). + * @method $this subQuarters(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). * @method $this subQuarter() Sub one quarter to the instance (using date interval). - * @method $this addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this addQuartersWithOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed. - * @method $this subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method $this subQuartersWithOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed. - * @method $this addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addQuartersWithoutOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subQuartersWithoutOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addQuartersWithNoOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subQuartersWithNoOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this addQuartersNoOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method $this subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method $this subQuartersNoOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method $this addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). + * @method $this addWeeks(int|float $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). * @method $this addWeek() Add one week to the instance (using date interval). - * @method $this subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). + * @method $this subWeeks(int|float $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). * @method $this subWeek() Sub one week to the instance (using date interval). - * @method $this addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). + * @method $this addWeekdays(int|float $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). * @method $this addWeekday() Add one weekday to the instance (using date interval). - * @method $this subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). + * @method $this subWeekdays(int|float $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). * @method $this subWeekday() Sub one weekday to the instance (using date interval). - * @method $this addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). + * @method $this addRealMicros(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). * @method $this addRealMicro() Add one microsecond to the instance (using timestamp). - * @method $this subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). + * @method $this subRealMicros(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). * @method $this subRealMicro() Sub one microsecond to the instance (using timestamp). - * @method CarbonPeriod microsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. - * @method $this addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod microsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. + * @method $this addRealMicroseconds(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). * @method $this addRealMicrosecond() Add one microsecond to the instance (using timestamp). - * @method $this subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). + * @method $this subRealMicroseconds(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). * @method $this subRealMicrosecond() Sub one microsecond to the instance (using timestamp). - * @method CarbonPeriod microsecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. - * @method $this addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod microsecondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. + * @method $this addRealMillis(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). * @method $this addRealMilli() Add one millisecond to the instance (using timestamp). - * @method $this subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). + * @method $this subRealMillis(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). * @method $this subRealMilli() Sub one millisecond to the instance (using timestamp). - * @method CarbonPeriod millisUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. - * @method $this addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod millisUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. + * @method $this addRealMilliseconds(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). * @method $this addRealMillisecond() Add one millisecond to the instance (using timestamp). - * @method $this subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). + * @method $this subRealMilliseconds(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). * @method $this subRealMillisecond() Sub one millisecond to the instance (using timestamp). - * @method CarbonPeriod millisecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. - * @method $this addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod millisecondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. + * @method $this addRealSeconds(int|float $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). * @method $this addRealSecond() Add one second to the instance (using timestamp). - * @method $this subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). + * @method $this subRealSeconds(int|float $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). * @method $this subRealSecond() Sub one second to the instance (using timestamp). - * @method CarbonPeriod secondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given. - * @method $this addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod secondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given. + * @method $this addRealMinutes(int|float $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). * @method $this addRealMinute() Add one minute to the instance (using timestamp). - * @method $this subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). + * @method $this subRealMinutes(int|float $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). * @method $this subRealMinute() Sub one minute to the instance (using timestamp). - * @method CarbonPeriod minutesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given. - * @method $this addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod minutesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given. + * @method $this addRealHours(int|float $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). * @method $this addRealHour() Add one hour to the instance (using timestamp). - * @method $this subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). + * @method $this subRealHours(int|float $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). * @method $this subRealHour() Sub one hour to the instance (using timestamp). - * @method CarbonPeriod hoursUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given. - * @method $this addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod hoursUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given. + * @method $this addRealDays(int|float $value = 1) Add days (the $value count passed in) to the instance (using timestamp). * @method $this addRealDay() Add one day to the instance (using timestamp). - * @method $this subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). + * @method $this subRealDays(int|float $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). * @method $this subRealDay() Sub one day to the instance (using timestamp). - * @method CarbonPeriod daysUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given. - * @method $this addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod daysUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given. + * @method $this addRealWeeks(int|float $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). * @method $this addRealWeek() Add one week to the instance (using timestamp). - * @method $this subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). + * @method $this subRealWeeks(int|float $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). * @method $this subRealWeek() Sub one week to the instance (using timestamp). - * @method CarbonPeriod weeksUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given. - * @method $this addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod weeksUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given. + * @method $this addRealMonths(int|float $value = 1) Add months (the $value count passed in) to the instance (using timestamp). * @method $this addRealMonth() Add one month to the instance (using timestamp). - * @method $this subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). + * @method $this subRealMonths(int|float $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). * @method $this subRealMonth() Sub one month to the instance (using timestamp). - * @method CarbonPeriod monthsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given. - * @method $this addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod monthsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given. + * @method $this addRealQuarters(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). * @method $this addRealQuarter() Add one quarter to the instance (using timestamp). - * @method $this subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). + * @method $this subRealQuarters(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). * @method $this subRealQuarter() Sub one quarter to the instance (using timestamp). - * @method CarbonPeriod quartersUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given. - * @method $this addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod quartersUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given. + * @method $this addRealYears(int|float $value = 1) Add years (the $value count passed in) to the instance (using timestamp). * @method $this addRealYear() Add one year to the instance (using timestamp). - * @method $this subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). + * @method $this subRealYears(int|float $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). * @method $this subRealYear() Sub one year to the instance (using timestamp). - * @method CarbonPeriod yearsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given. - * @method $this addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod yearsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given. + * @method $this addRealDecades(int|float $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). * @method $this addRealDecade() Add one decade to the instance (using timestamp). - * @method $this subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). + * @method $this subRealDecades(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). * @method $this subRealDecade() Sub one decade to the instance (using timestamp). - * @method CarbonPeriod decadesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given. - * @method $this addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod decadesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given. + * @method $this addRealCenturies(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). * @method $this addRealCentury() Add one century to the instance (using timestamp). - * @method $this subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). + * @method $this subRealCenturies(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). * @method $this subRealCentury() Sub one century to the instance (using timestamp). - * @method CarbonPeriod centuriesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given. - * @method $this addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod centuriesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given. + * @method $this addRealMillennia(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). * @method $this addRealMillennium() Add one millennium to the instance (using timestamp). - * @method $this subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). + * @method $this subRealMillennia(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). * @method $this subRealMillennium() Sub one millennium to the instance (using timestamp). - * @method CarbonPeriod millenniaUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given. + * @method CarbonPeriod millenniaUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given. * @method $this roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. * @method $this roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. * @method $this floorYear(float $precision = 1) Truncate the current instance year with given precision. diff --git a/src/Carbon/CarbonImmutable.php b/src/Carbon/CarbonImmutable.php index 688081fd10..2480480b79 100644 --- a/src/Carbon/CarbonImmutable.php +++ b/src/Carbon/CarbonImmutable.php @@ -187,241 +187,241 @@ * @method CarbonImmutable microsecond(int $value) Set current instance microsecond to the given value. * @method CarbonImmutable setMicroseconds(int $value) Set current instance microsecond to the given value. * @method CarbonImmutable setMicrosecond(int $value) Set current instance microsecond to the given value. - * @method CarbonImmutable addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addYears(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addYear() Add one year to the instance (using date interval). - * @method CarbonImmutable subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subYears(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subYear() Sub one year to the instance (using date interval). - * @method CarbonImmutable addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addYearsWithOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subYearsWithOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addYearsWithoutOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subYearsWithoutOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addYearsWithNoOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subYearsWithNoOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addYearsNoOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subYearsNoOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMonths(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addMonth() Add one month to the instance (using date interval). - * @method CarbonImmutable subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMonths(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subMonth() Sub one month to the instance (using date interval). - * @method CarbonImmutable addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addMonthsWithOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subMonthsWithOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMonthsWithoutOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMonthsWithoutOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMonthsWithNoOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMonthsWithNoOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMonthsNoOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMonthsNoOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addDays(int|float $value = 1) Add days (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addDay() Add one day to the instance (using date interval). - * @method CarbonImmutable subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subDays(int|float $value = 1) Sub days (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subDay() Sub one day to the instance (using date interval). - * @method CarbonImmutable addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addHours(int|float $value = 1) Add hours (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addHour() Add one hour to the instance (using date interval). - * @method CarbonImmutable subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subHours(int|float $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subHour() Sub one hour to the instance (using date interval). - * @method CarbonImmutable addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMinutes(int|float $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addMinute() Add one minute to the instance (using date interval). - * @method CarbonImmutable subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMinutes(int|float $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subMinute() Sub one minute to the instance (using date interval). - * @method CarbonImmutable addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addSeconds(int|float $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addSecond() Add one second to the instance (using date interval). - * @method CarbonImmutable subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subSeconds(int|float $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subSecond() Sub one second to the instance (using date interval). - * @method CarbonImmutable addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMillis(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addMilli() Add one millisecond to the instance (using date interval). - * @method CarbonImmutable subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMillis(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subMilli() Sub one millisecond to the instance (using date interval). - * @method CarbonImmutable addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMilliseconds(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addMillisecond() Add one millisecond to the instance (using date interval). - * @method CarbonImmutable subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMilliseconds(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subMillisecond() Sub one millisecond to the instance (using date interval). - * @method CarbonImmutable addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMicros(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addMicro() Add one microsecond to the instance (using date interval). - * @method CarbonImmutable subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMicros(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subMicro() Sub one microsecond to the instance (using date interval). - * @method CarbonImmutable addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMicroseconds(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addMicrosecond() Add one microsecond to the instance (using date interval). - * @method CarbonImmutable subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMicroseconds(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subMicrosecond() Sub one microsecond to the instance (using date interval). - * @method CarbonImmutable addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addMillennia(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addMillennium() Add one millennium to the instance (using date interval). - * @method CarbonImmutable subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subMillennia(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subMillennium() Sub one millennium to the instance (using date interval). - * @method CarbonImmutable addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addMillenniaWithOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subMillenniaWithOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMillenniaWithoutOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMillenniaWithoutOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMillenniaWithNoOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMillenniaWithNoOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addMillenniaNoOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subMillenniaNoOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addCenturies(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addCentury() Add one century to the instance (using date interval). - * @method CarbonImmutable subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subCenturies(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subCentury() Sub one century to the instance (using date interval). - * @method CarbonImmutable addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addCenturiesWithOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subCenturiesWithOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addCenturiesWithoutOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subCenturiesWithoutOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addCenturiesWithNoOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subCenturiesWithNoOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addCenturiesNoOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subCenturiesNoOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addDecades(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addDecade() Add one decade to the instance (using date interval). - * @method CarbonImmutable subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subDecades(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subDecade() Sub one decade to the instance (using date interval). - * @method CarbonImmutable addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addDecadesWithOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subDecadesWithOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addDecadesWithoutOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subDecadesWithoutOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addDecadesWithNoOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subDecadesWithNoOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addDecadesNoOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subDecadesNoOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addQuarters(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addQuarter() Add one quarter to the instance (using date interval). - * @method CarbonImmutable subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subQuarters(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subQuarter() Sub one quarter to the instance (using date interval). - * @method CarbonImmutable addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable addQuartersWithOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonImmutable subQuartersWithOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonImmutable subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonImmutable addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addQuartersWithoutOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subQuartersWithoutOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addQuartersWithNoOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subQuartersWithNoOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable addQuartersNoOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonImmutable subQuartersNoOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonImmutable subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonImmutable addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addWeeks(int|float $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addWeek() Add one week to the instance (using date interval). - * @method CarbonImmutable subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subWeeks(int|float $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subWeek() Sub one week to the instance (using date interval). - * @method CarbonImmutable addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable addWeekdays(int|float $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable addWeekday() Add one weekday to the instance (using date interval). - * @method CarbonImmutable subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). + * @method CarbonImmutable subWeekdays(int|float $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). * @method CarbonImmutable subWeekday() Sub one weekday to the instance (using date interval). - * @method CarbonImmutable addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable addRealMicros(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealMicro() Add one microsecond to the instance (using timestamp). - * @method CarbonImmutable subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMicros(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealMicro() Sub one microsecond to the instance (using timestamp). - * @method CarbonPeriod microsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. - * @method CarbonImmutable addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod microsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. + * @method CarbonImmutable addRealMicroseconds(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealMicrosecond() Add one microsecond to the instance (using timestamp). - * @method CarbonImmutable subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMicroseconds(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealMicrosecond() Sub one microsecond to the instance (using timestamp). - * @method CarbonPeriod microsecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. - * @method CarbonImmutable addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod microsecondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. + * @method CarbonImmutable addRealMillis(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealMilli() Add one millisecond to the instance (using timestamp). - * @method CarbonImmutable subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMillis(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealMilli() Sub one millisecond to the instance (using timestamp). - * @method CarbonPeriod millisUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. - * @method CarbonImmutable addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod millisUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. + * @method CarbonImmutable addRealMilliseconds(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealMillisecond() Add one millisecond to the instance (using timestamp). - * @method CarbonImmutable subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMilliseconds(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealMillisecond() Sub one millisecond to the instance (using timestamp). - * @method CarbonPeriod millisecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. - * @method CarbonImmutable addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod millisecondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. + * @method CarbonImmutable addRealSeconds(int|float $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealSecond() Add one second to the instance (using timestamp). - * @method CarbonImmutable subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealSeconds(int|float $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealSecond() Sub one second to the instance (using timestamp). - * @method CarbonPeriod secondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given. - * @method CarbonImmutable addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod secondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given. + * @method CarbonImmutable addRealMinutes(int|float $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealMinute() Add one minute to the instance (using timestamp). - * @method CarbonImmutable subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMinutes(int|float $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealMinute() Sub one minute to the instance (using timestamp). - * @method CarbonPeriod minutesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given. - * @method CarbonImmutable addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod minutesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given. + * @method CarbonImmutable addRealHours(int|float $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealHour() Add one hour to the instance (using timestamp). - * @method CarbonImmutable subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealHours(int|float $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealHour() Sub one hour to the instance (using timestamp). - * @method CarbonPeriod hoursUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given. - * @method CarbonImmutable addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod hoursUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given. + * @method CarbonImmutable addRealDays(int|float $value = 1) Add days (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealDay() Add one day to the instance (using timestamp). - * @method CarbonImmutable subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealDays(int|float $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealDay() Sub one day to the instance (using timestamp). - * @method CarbonPeriod daysUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given. - * @method CarbonImmutable addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod daysUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given. + * @method CarbonImmutable addRealWeeks(int|float $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealWeek() Add one week to the instance (using timestamp). - * @method CarbonImmutable subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealWeeks(int|float $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealWeek() Sub one week to the instance (using timestamp). - * @method CarbonPeriod weeksUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given. - * @method CarbonImmutable addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod weeksUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given. + * @method CarbonImmutable addRealMonths(int|float $value = 1) Add months (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealMonth() Add one month to the instance (using timestamp). - * @method CarbonImmutable subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMonths(int|float $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealMonth() Sub one month to the instance (using timestamp). - * @method CarbonPeriod monthsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given. - * @method CarbonImmutable addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod monthsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given. + * @method CarbonImmutable addRealQuarters(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealQuarter() Add one quarter to the instance (using timestamp). - * @method CarbonImmutable subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealQuarters(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealQuarter() Sub one quarter to the instance (using timestamp). - * @method CarbonPeriod quartersUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given. - * @method CarbonImmutable addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod quartersUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given. + * @method CarbonImmutable addRealYears(int|float $value = 1) Add years (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealYear() Add one year to the instance (using timestamp). - * @method CarbonImmutable subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealYears(int|float $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealYear() Sub one year to the instance (using timestamp). - * @method CarbonPeriod yearsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given. - * @method CarbonImmutable addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod yearsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given. + * @method CarbonImmutable addRealDecades(int|float $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealDecade() Add one decade to the instance (using timestamp). - * @method CarbonImmutable subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealDecades(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealDecade() Sub one decade to the instance (using timestamp). - * @method CarbonPeriod decadesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given. - * @method CarbonImmutable addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod decadesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given. + * @method CarbonImmutable addRealCenturies(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealCentury() Add one century to the instance (using timestamp). - * @method CarbonImmutable subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealCenturies(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealCentury() Sub one century to the instance (using timestamp). - * @method CarbonPeriod centuriesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given. - * @method CarbonImmutable addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod centuriesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given. + * @method CarbonImmutable addRealMillennia(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable addRealMillennium() Add one millennium to the instance (using timestamp). - * @method CarbonImmutable subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). + * @method CarbonImmutable subRealMillennia(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). * @method CarbonImmutable subRealMillennium() Sub one millennium to the instance (using timestamp). - * @method CarbonPeriod millenniaUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given. + * @method CarbonPeriod millenniaUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given. * @method CarbonImmutable roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. * @method CarbonImmutable roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. * @method CarbonImmutable floorYear(float $precision = 1) Truncate the current instance year with given precision. diff --git a/src/Carbon/CarbonInterface.php b/src/Carbon/CarbonInterface.php index 3da4314fc8..4ab3f4526a 100644 --- a/src/Carbon/CarbonInterface.php +++ b/src/Carbon/CarbonInterface.php @@ -199,241 +199,241 @@ * @method CarbonInterface microsecond(int $value) Set current instance microsecond to the given value. * @method CarbonInterface setMicroseconds(int $value) Set current instance microsecond to the given value. * @method CarbonInterface setMicrosecond(int $value) Set current instance microsecond to the given value. - * @method CarbonInterface addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addYears(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addYear() Add one year to the instance (using date interval). - * @method CarbonInterface subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subYears(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subYear() Sub one year to the instance (using date interval). - * @method CarbonInterface addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addYearsWithOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subYearsWithOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addYearsWithoutOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subYearsWithoutOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addYearsWithNoOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subYearsWithNoOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addYearsNoOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subYearsNoOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMonths(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMonth() Add one month to the instance (using date interval). - * @method CarbonInterface subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMonths(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMonth() Sub one month to the instance (using date interval). - * @method CarbonInterface addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addMonthsWithOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subMonthsWithOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMonthsWithoutOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMonthsWithoutOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMonthsWithNoOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMonthsWithNoOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMonthsNoOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMonthsNoOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addDays(int|float $value = 1) Add days (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addDay() Add one day to the instance (using date interval). - * @method CarbonInterface subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subDays(int|float $value = 1) Sub days (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subDay() Sub one day to the instance (using date interval). - * @method CarbonInterface addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addHours(int|float $value = 1) Add hours (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addHour() Add one hour to the instance (using date interval). - * @method CarbonInterface subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subHours(int|float $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subHour() Sub one hour to the instance (using date interval). - * @method CarbonInterface addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMinutes(int|float $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMinute() Add one minute to the instance (using date interval). - * @method CarbonInterface subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMinutes(int|float $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMinute() Sub one minute to the instance (using date interval). - * @method CarbonInterface addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addSeconds(int|float $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addSecond() Add one second to the instance (using date interval). - * @method CarbonInterface subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subSeconds(int|float $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subSecond() Sub one second to the instance (using date interval). - * @method CarbonInterface addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMillis(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMilli() Add one millisecond to the instance (using date interval). - * @method CarbonInterface subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMillis(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMilli() Sub one millisecond to the instance (using date interval). - * @method CarbonInterface addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMilliseconds(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMillisecond() Add one millisecond to the instance (using date interval). - * @method CarbonInterface subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMilliseconds(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMillisecond() Sub one millisecond to the instance (using date interval). - * @method CarbonInterface addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMicros(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMicro() Add one microsecond to the instance (using date interval). - * @method CarbonInterface subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMicros(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMicro() Sub one microsecond to the instance (using date interval). - * @method CarbonInterface addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMicroseconds(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMicrosecond() Add one microsecond to the instance (using date interval). - * @method CarbonInterface subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMicroseconds(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMicrosecond() Sub one microsecond to the instance (using date interval). - * @method CarbonInterface addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMillennia(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMillennium() Add one millennium to the instance (using date interval). - * @method CarbonInterface subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMillennia(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMillennium() Sub one millennium to the instance (using date interval). - * @method CarbonInterface addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addMillenniaWithOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subMillenniaWithOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMillenniaWithoutOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMillenniaWithoutOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMillenniaWithNoOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMillenniaWithNoOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMillenniaNoOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMillenniaNoOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addCenturies(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addCentury() Add one century to the instance (using date interval). - * @method CarbonInterface subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subCenturies(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subCentury() Sub one century to the instance (using date interval). - * @method CarbonInterface addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addCenturiesWithOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subCenturiesWithOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addCenturiesWithoutOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subCenturiesWithoutOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addCenturiesWithNoOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subCenturiesWithNoOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addCenturiesNoOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subCenturiesNoOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addDecades(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addDecade() Add one decade to the instance (using date interval). - * @method CarbonInterface subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subDecades(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subDecade() Sub one decade to the instance (using date interval). - * @method CarbonInterface addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addDecadesWithOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subDecadesWithOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addDecadesWithoutOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subDecadesWithoutOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addDecadesWithNoOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subDecadesWithNoOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addDecadesNoOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subDecadesNoOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addQuarters(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addQuarter() Add one quarter to the instance (using date interval). - * @method CarbonInterface subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subQuarters(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subQuarter() Sub one quarter to the instance (using date interval). - * @method CarbonInterface addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addQuartersWithOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subQuartersWithOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addQuartersWithoutOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subQuartersWithoutOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addQuartersWithNoOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subQuartersWithNoOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addQuartersNoOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subQuartersNoOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addWeeks(int|float $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addWeek() Add one week to the instance (using date interval). - * @method CarbonInterface subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subWeeks(int|float $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subWeek() Sub one week to the instance (using date interval). - * @method CarbonInterface addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addWeekdays(int|float $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addWeekday() Add one weekday to the instance (using date interval). - * @method CarbonInterface subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subWeekdays(int|float $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subWeekday() Sub one weekday to the instance (using date interval). - * @method CarbonInterface addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface addRealMicros(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMicro() Add one microsecond to the instance (using timestamp). - * @method CarbonInterface subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMicros(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMicro() Sub one microsecond to the instance (using timestamp). - * @method CarbonPeriod microsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. - * @method CarbonInterface addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod microsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. + * @method CarbonInterface addRealMicroseconds(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMicrosecond() Add one microsecond to the instance (using timestamp). - * @method CarbonInterface subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMicroseconds(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMicrosecond() Sub one microsecond to the instance (using timestamp). - * @method CarbonPeriod microsecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. - * @method CarbonInterface addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod microsecondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. + * @method CarbonInterface addRealMillis(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMilli() Add one millisecond to the instance (using timestamp). - * @method CarbonInterface subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMillis(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMilli() Sub one millisecond to the instance (using timestamp). - * @method CarbonPeriod millisUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. - * @method CarbonInterface addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod millisUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. + * @method CarbonInterface addRealMilliseconds(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMillisecond() Add one millisecond to the instance (using timestamp). - * @method CarbonInterface subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMilliseconds(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMillisecond() Sub one millisecond to the instance (using timestamp). - * @method CarbonPeriod millisecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. - * @method CarbonInterface addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod millisecondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. + * @method CarbonInterface addRealSeconds(int|float $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealSecond() Add one second to the instance (using timestamp). - * @method CarbonInterface subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealSeconds(int|float $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealSecond() Sub one second to the instance (using timestamp). - * @method CarbonPeriod secondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given. - * @method CarbonInterface addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod secondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given. + * @method CarbonInterface addRealMinutes(int|float $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMinute() Add one minute to the instance (using timestamp). - * @method CarbonInterface subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMinutes(int|float $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMinute() Sub one minute to the instance (using timestamp). - * @method CarbonPeriod minutesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given. - * @method CarbonInterface addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod minutesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given. + * @method CarbonInterface addRealHours(int|float $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealHour() Add one hour to the instance (using timestamp). - * @method CarbonInterface subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealHours(int|float $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealHour() Sub one hour to the instance (using timestamp). - * @method CarbonPeriod hoursUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given. - * @method CarbonInterface addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod hoursUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given. + * @method CarbonInterface addRealDays(int|float $value = 1) Add days (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealDay() Add one day to the instance (using timestamp). - * @method CarbonInterface subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealDays(int|float $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealDay() Sub one day to the instance (using timestamp). - * @method CarbonPeriod daysUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given. - * @method CarbonInterface addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod daysUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given. + * @method CarbonInterface addRealWeeks(int|float $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealWeek() Add one week to the instance (using timestamp). - * @method CarbonInterface subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealWeeks(int|float $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealWeek() Sub one week to the instance (using timestamp). - * @method CarbonPeriod weeksUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given. - * @method CarbonInterface addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod weeksUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given. + * @method CarbonInterface addRealMonths(int|float $value = 1) Add months (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMonth() Add one month to the instance (using timestamp). - * @method CarbonInterface subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMonths(int|float $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMonth() Sub one month to the instance (using timestamp). - * @method CarbonPeriod monthsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given. - * @method CarbonInterface addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod monthsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given. + * @method CarbonInterface addRealQuarters(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealQuarter() Add one quarter to the instance (using timestamp). - * @method CarbonInterface subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealQuarters(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealQuarter() Sub one quarter to the instance (using timestamp). - * @method CarbonPeriod quartersUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given. - * @method CarbonInterface addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod quartersUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given. + * @method CarbonInterface addRealYears(int|float $value = 1) Add years (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealYear() Add one year to the instance (using timestamp). - * @method CarbonInterface subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealYears(int|float $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealYear() Sub one year to the instance (using timestamp). - * @method CarbonPeriod yearsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given. - * @method CarbonInterface addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod yearsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given. + * @method CarbonInterface addRealDecades(int|float $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealDecade() Add one decade to the instance (using timestamp). - * @method CarbonInterface subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealDecades(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealDecade() Sub one decade to the instance (using timestamp). - * @method CarbonPeriod decadesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given. - * @method CarbonInterface addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod decadesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given. + * @method CarbonInterface addRealCenturies(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealCentury() Add one century to the instance (using timestamp). - * @method CarbonInterface subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealCenturies(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealCentury() Sub one century to the instance (using timestamp). - * @method CarbonPeriod centuriesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given. - * @method CarbonInterface addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod centuriesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given. + * @method CarbonInterface addRealMillennia(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMillennium() Add one millennium to the instance (using timestamp). - * @method CarbonInterface subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMillennia(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMillennium() Sub one millennium to the instance (using timestamp). - * @method CarbonPeriod millenniaUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given. + * @method CarbonPeriod millenniaUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given. * @method CarbonInterface roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. * @method CarbonInterface roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. * @method CarbonInterface floorYear(float $precision = 1) Truncate the current instance year with given precision. @@ -757,7 +757,7 @@ public function __toString(); * @example $date->add(CarbonInterval::days(4)) * * @param string|DateInterval|Closure|CarbonConverterInterface $unit - * @param int $value + * @param int|float $value * @param bool|null $overflow * * @return static @@ -780,12 +780,12 @@ public function addRealUnit(string $unit, $value = 1); * Add given units to the current instance. * * @param string $unit - * @param int $value + * @param int|float $value * @param bool|null $overflow * * @return static */ - public function addUnit(string $unit, int $value = 1, ?bool $overflow = null); + public function addUnit(string $unit, $value = 1, ?bool $overflow = null); /** * Add any unit to a new value without overflowing current other unit given. @@ -4073,7 +4073,7 @@ public function startOfYear(); * @example $date->sub(CarbonInterval::days(4)) * * @param string|DateInterval|Closure|CarbonConverterInterface $unit - * @param int $value + * @param int|float $value * @param bool|null $overflow * * @return static @@ -4096,12 +4096,12 @@ public function subRealUnit($unit, $value = 1); * Subtract given units to the current instance. * * @param string $unit - * @param int $value + * @param int|float $value * @param bool|null $overflow * * @return static */ - public function subUnit(string $unit, int $value = 1, ?bool $overflow = null); + public function subUnit(string $unit, $value = 1, ?bool $overflow = null); /** * Subtract any unit to a new value without overflowing current other unit given. @@ -4120,7 +4120,7 @@ public function subUnitNoOverflow($valueUnit, $value, $overflowUnit); * @see sub() * * @param string|DateInterval $unit - * @param int $value + * @param int|float $value * @param bool|null $overflow * * @return static diff --git a/src/Carbon/Traits/Date.php b/src/Carbon/Traits/Date.php index b99b1c94ce..883aa2b6f1 100644 --- a/src/Carbon/Traits/Date.php +++ b/src/Carbon/Traits/Date.php @@ -207,241 +207,241 @@ * @method CarbonInterface microsecond(int $value) Set current instance microsecond to the given value. * @method CarbonInterface setMicroseconds(int $value) Set current instance microsecond to the given value. * @method CarbonInterface setMicrosecond(int $value) Set current instance microsecond to the given value. - * @method CarbonInterface addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addYears(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addYear() Add one year to the instance (using date interval). - * @method CarbonInterface subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subYears(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subYear() Sub one year to the instance (using date interval). - * @method CarbonInterface addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addYearsWithOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subYearsWithOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addYearsWithoutOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subYearsWithoutOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addYearsWithNoOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subYearsWithNoOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addYearsNoOverflow(int|float $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subYearsNoOverflow(int|float $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMonths(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMonth() Add one month to the instance (using date interval). - * @method CarbonInterface subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMonths(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMonth() Sub one month to the instance (using date interval). - * @method CarbonInterface addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addMonthsWithOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subMonthsWithOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMonthsWithoutOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMonthsWithoutOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMonthsWithNoOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMonthsWithNoOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMonthsNoOverflow(int|float $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMonthsNoOverflow(int|float $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addDays(int|float $value = 1) Add days (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addDay() Add one day to the instance (using date interval). - * @method CarbonInterface subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subDays(int|float $value = 1) Sub days (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subDay() Sub one day to the instance (using date interval). - * @method CarbonInterface addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addHours(int|float $value = 1) Add hours (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addHour() Add one hour to the instance (using date interval). - * @method CarbonInterface subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subHours(int|float $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subHour() Sub one hour to the instance (using date interval). - * @method CarbonInterface addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMinutes(int|float $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMinute() Add one minute to the instance (using date interval). - * @method CarbonInterface subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMinutes(int|float $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMinute() Sub one minute to the instance (using date interval). - * @method CarbonInterface addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addSeconds(int|float $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addSecond() Add one second to the instance (using date interval). - * @method CarbonInterface subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subSeconds(int|float $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subSecond() Sub one second to the instance (using date interval). - * @method CarbonInterface addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMillis(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMilli() Add one millisecond to the instance (using date interval). - * @method CarbonInterface subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMillis(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMilli() Sub one millisecond to the instance (using date interval). - * @method CarbonInterface addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMilliseconds(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMillisecond() Add one millisecond to the instance (using date interval). - * @method CarbonInterface subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMilliseconds(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMillisecond() Sub one millisecond to the instance (using date interval). - * @method CarbonInterface addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMicros(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMicro() Add one microsecond to the instance (using date interval). - * @method CarbonInterface subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMicros(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMicro() Sub one microsecond to the instance (using date interval). - * @method CarbonInterface addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMicroseconds(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMicrosecond() Add one microsecond to the instance (using date interval). - * @method CarbonInterface subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMicroseconds(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMicrosecond() Sub one microsecond to the instance (using date interval). - * @method CarbonInterface addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addMillennia(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addMillennium() Add one millennium to the instance (using date interval). - * @method CarbonInterface subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subMillennia(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subMillennium() Sub one millennium to the instance (using date interval). - * @method CarbonInterface addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addMillenniaWithOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subMillenniaWithOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMillenniaWithoutOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMillenniaWithoutOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMillenniaWithNoOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMillenniaWithNoOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addMillenniaNoOverflow(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subMillenniaNoOverflow(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addCenturies(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addCentury() Add one century to the instance (using date interval). - * @method CarbonInterface subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subCenturies(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subCentury() Sub one century to the instance (using date interval). - * @method CarbonInterface addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addCenturiesWithOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subCenturiesWithOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addCenturiesWithoutOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subCenturiesWithoutOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addCenturiesWithNoOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subCenturiesWithNoOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addCenturiesNoOverflow(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subCenturiesNoOverflow(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addDecades(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addDecade() Add one decade to the instance (using date interval). - * @method CarbonInterface subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subDecades(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subDecade() Sub one decade to the instance (using date interval). - * @method CarbonInterface addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addDecadesWithOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subDecadesWithOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addDecadesWithoutOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subDecadesWithoutOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addDecadesWithNoOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subDecadesWithNoOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addDecadesNoOverflow(int|float $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subDecadesNoOverflow(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addQuarters(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addQuarter() Add one quarter to the instance (using date interval). - * @method CarbonInterface subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subQuarters(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subQuarter() Sub one quarter to the instance (using date interval). - * @method CarbonInterface addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface addQuartersWithOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. + * @method CarbonInterface subQuartersWithOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method CarbonInterface subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed. - * @method CarbonInterface addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addQuartersWithoutOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subQuartersWithoutOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addQuartersWithNoOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subQuartersWithNoOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface addQuartersNoOverflow(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. + * @method CarbonInterface subQuartersNoOverflow(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method CarbonInterface subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. - * @method CarbonInterface addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addWeeks(int|float $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addWeek() Add one week to the instance (using date interval). - * @method CarbonInterface subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subWeeks(int|float $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subWeek() Sub one week to the instance (using date interval). - * @method CarbonInterface addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface addWeekdays(int|float $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). * @method CarbonInterface addWeekday() Add one weekday to the instance (using date interval). - * @method CarbonInterface subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). + * @method CarbonInterface subWeekdays(int|float $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). * @method CarbonInterface subWeekday() Sub one weekday to the instance (using date interval). - * @method CarbonInterface addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface addRealMicros(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMicro() Add one microsecond to the instance (using timestamp). - * @method CarbonInterface subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMicros(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMicro() Sub one microsecond to the instance (using timestamp). - * @method CarbonPeriod microsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. - * @method CarbonInterface addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod microsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. + * @method CarbonInterface addRealMicroseconds(int|float $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMicrosecond() Add one microsecond to the instance (using timestamp). - * @method CarbonInterface subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMicroseconds(int|float $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMicrosecond() Sub one microsecond to the instance (using timestamp). - * @method CarbonPeriod microsecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. - * @method CarbonInterface addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod microsecondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. + * @method CarbonInterface addRealMillis(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMilli() Add one millisecond to the instance (using timestamp). - * @method CarbonInterface subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMillis(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMilli() Sub one millisecond to the instance (using timestamp). - * @method CarbonPeriod millisUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. - * @method CarbonInterface addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod millisUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. + * @method CarbonInterface addRealMilliseconds(int|float $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMillisecond() Add one millisecond to the instance (using timestamp). - * @method CarbonInterface subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMilliseconds(int|float $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMillisecond() Sub one millisecond to the instance (using timestamp). - * @method CarbonPeriod millisecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. - * @method CarbonInterface addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod millisecondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. + * @method CarbonInterface addRealSeconds(int|float $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealSecond() Add one second to the instance (using timestamp). - * @method CarbonInterface subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealSeconds(int|float $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealSecond() Sub one second to the instance (using timestamp). - * @method CarbonPeriod secondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given. - * @method CarbonInterface addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod secondsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given. + * @method CarbonInterface addRealMinutes(int|float $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMinute() Add one minute to the instance (using timestamp). - * @method CarbonInterface subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMinutes(int|float $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMinute() Sub one minute to the instance (using timestamp). - * @method CarbonPeriod minutesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given. - * @method CarbonInterface addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod minutesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given. + * @method CarbonInterface addRealHours(int|float $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealHour() Add one hour to the instance (using timestamp). - * @method CarbonInterface subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealHours(int|float $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealHour() Sub one hour to the instance (using timestamp). - * @method CarbonPeriod hoursUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given. - * @method CarbonInterface addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod hoursUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given. + * @method CarbonInterface addRealDays(int|float $value = 1) Add days (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealDay() Add one day to the instance (using timestamp). - * @method CarbonInterface subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealDays(int|float $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealDay() Sub one day to the instance (using timestamp). - * @method CarbonPeriod daysUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given. - * @method CarbonInterface addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod daysUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given. + * @method CarbonInterface addRealWeeks(int|float $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealWeek() Add one week to the instance (using timestamp). - * @method CarbonInterface subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealWeeks(int|float $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealWeek() Sub one week to the instance (using timestamp). - * @method CarbonPeriod weeksUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given. - * @method CarbonInterface addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod weeksUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given. + * @method CarbonInterface addRealMonths(int|float $value = 1) Add months (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMonth() Add one month to the instance (using timestamp). - * @method CarbonInterface subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMonths(int|float $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMonth() Sub one month to the instance (using timestamp). - * @method CarbonPeriod monthsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given. - * @method CarbonInterface addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod monthsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given. + * @method CarbonInterface addRealQuarters(int|float $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealQuarter() Add one quarter to the instance (using timestamp). - * @method CarbonInterface subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealQuarters(int|float $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealQuarter() Sub one quarter to the instance (using timestamp). - * @method CarbonPeriod quartersUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given. - * @method CarbonInterface addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod quartersUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given. + * @method CarbonInterface addRealYears(int|float $value = 1) Add years (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealYear() Add one year to the instance (using timestamp). - * @method CarbonInterface subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealYears(int|float $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealYear() Sub one year to the instance (using timestamp). - * @method CarbonPeriod yearsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given. - * @method CarbonInterface addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod yearsUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given. + * @method CarbonInterface addRealDecades(int|float $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealDecade() Add one decade to the instance (using timestamp). - * @method CarbonInterface subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealDecades(int|float $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealDecade() Sub one decade to the instance (using timestamp). - * @method CarbonPeriod decadesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given. - * @method CarbonInterface addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod decadesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given. + * @method CarbonInterface addRealCenturies(int|float $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealCentury() Add one century to the instance (using timestamp). - * @method CarbonInterface subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealCenturies(int|float $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealCentury() Sub one century to the instance (using timestamp). - * @method CarbonPeriod centuriesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given. - * @method CarbonInterface addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). + * @method CarbonPeriod centuriesUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given. + * @method CarbonInterface addRealMillennia(int|float $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface addRealMillennium() Add one millennium to the instance (using timestamp). - * @method CarbonInterface subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). + * @method CarbonInterface subRealMillennia(int|float $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). * @method CarbonInterface subRealMillennium() Sub one millennium to the instance (using timestamp). - * @method CarbonPeriod millenniaUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given. + * @method CarbonPeriod millenniaUntil($endDate = null, int|float $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given. * @method CarbonInterface roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. * @method CarbonInterface roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. * @method CarbonInterface floorYear(float $precision = 1) Truncate the current instance year with given precision. diff --git a/src/Carbon/Traits/Units.php b/src/Carbon/Traits/Units.php index dde424bc0f..e04c0acacf 100644 --- a/src/Carbon/Traits/Units.php +++ b/src/Carbon/Traits/Units.php @@ -202,7 +202,7 @@ public function rawAdd(DateInterval $interval): self * @example $date->add(CarbonInterval::days(4)) * * @param string|DateInterval|Closure|CarbonConverterInterface $unit - * @param int $value + * @param int|float $value * @param bool|null $overflow * * @return static @@ -230,23 +230,23 @@ public function add($unit, $value = 1, ?bool $overflow = null): self [$value, $unit] = [$unit, $value]; } - return $this->addUnit((string) $unit, (int) $value, $overflow); + return $this->addUnit((string) $unit, $value, $overflow); } /** * Add given units to the current instance. * * @param string $unit - * @param int $value + * @param int|float $value * @param bool|null $overflow * * @return static */ - public function addUnit(string $unit, int $value = 1, ?bool $overflow = null): self + public function addUnit(string $unit, $value = 1, ?bool $overflow = null): self { $date = $this; - if ($value === 0) { + if (!is_numeric($value) || !\floatval($value)) { return $date->isMutable() ? $date : $date->copy(); } @@ -302,7 +302,12 @@ public function addUnit(string $unit, int $value = 1, ?bool $overflow = null): s $value *= static::MICROSECONDS_PER_MILLISECOND; } - $date = $date->modify("$value $unit"); + $inverted = $value < 0; + $value = abs($value); + + $date = $date->rawAdd( + CarbonInterval::fromString("$value $unit")->invert($inverted), + ); if (isset($timeString)) { $date = $date->setTimeFromTimeString($timeString); @@ -321,12 +326,12 @@ public function addUnit(string $unit, int $value = 1, ?bool $overflow = null): s * Subtract given units to the current instance. * * @param string $unit - * @param int $value + * @param int|float $value * @param bool|null $overflow * * @return static */ - public function subUnit(string $unit, int $value = 1, ?bool $overflow = null): self + public function subUnit(string $unit, $value = 1, ?bool $overflow = null): self { return $this->addUnit($unit, -$value, $overflow); } @@ -351,7 +356,7 @@ public function rawSub(DateInterval $interval): self * @example $date->sub(CarbonInterval::days(4)) * * @param string|DateInterval|Closure|CarbonConverterInterface $unit - * @param int $value + * @param int|float $value * @param bool|null $overflow * * @return static @@ -379,7 +384,7 @@ public function sub($unit, $value = 1, ?bool $overflow = null): self [$value, $unit] = [$unit, $value]; } - return $this->addUnit((string) $unit, -((int) $value), $overflow); + return $this->addUnit((string) $unit, -\floatval($value), $overflow); } /** @@ -388,7 +393,7 @@ public function sub($unit, $value = 1, ?bool $overflow = null): self * @see sub() * * @param string|DateInterval $unit - * @param int $value + * @param int|float $value * @param bool|null $overflow * * @return static diff --git a/tests/Carbon/AddTest.php b/tests/Carbon/AddTest.php index ca3d7d2246..8de1b5ec69 100644 --- a/tests/Carbon/AddTest.php +++ b/tests/Carbon/AddTest.php @@ -240,6 +240,26 @@ public function testAddSecondsNegative() $this->assertSame(59, Carbon::createFromTime(0, 0, 0)->addSeconds(-1)->second); } + public function testAddDecimalSeconds() + { + $this->assertSame( + '1999-12-31 23:59:58.500000', + Carbon::parse('2000-01-01 00:00:00')->addSeconds(-1.5)->format('Y-m-d H:i:s.u'), + ); + $this->assertSame( + '2000-01-01 00:00:01.500000', + Carbon::parse('2000-01-01 00:00:00')->addSeconds(1.5)->format('Y-m-d H:i:s.u'), + ); + $this->assertSame( + '1999-12-31 23:59:58.500000', + Carbon::parse('2000-01-01 00:00:00')->addRealSeconds(-1.5)->format('Y-m-d H:i:s.u'), + ); + $this->assertSame( + '2000-01-01 00:00:01.500000', + Carbon::parse('2000-01-01 00:00:00')->addRealSeconds(1.5)->format('Y-m-d H:i:s.u'), + ); + } + public function testAddSecond() { $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->addSecond()->second); diff --git a/tests/CarbonImmutable/AddTest.php b/tests/CarbonImmutable/AddTest.php index 6ec191d286..fbdc9bc65b 100644 --- a/tests/CarbonImmutable/AddTest.php +++ b/tests/CarbonImmutable/AddTest.php @@ -214,6 +214,26 @@ public function testAddSecondsNegative() $this->assertSame(59, Carbon::createFromTime(0, 0, 0)->addSeconds(-1)->second); } + public function testAddDecimalSeconds() + { + $this->assertSame( + '1999-12-31 23:59:58.500000', + Carbon::parse('2000-01-01 00:00:00')->addSeconds(-1.5)->format('Y-m-d H:i:s.u'), + ); + $this->assertSame( + '2000-01-01 00:00:01.500000', + Carbon::parse('2000-01-01 00:00:00')->addSeconds(1.5)->format('Y-m-d H:i:s.u'), + ); + $this->assertSame( + '1999-12-31 23:59:58.500000', + Carbon::parse('2000-01-01 00:00:00')->addRealSeconds(-1.5)->format('Y-m-d H:i:s.u'), + ); + $this->assertSame( + '2000-01-01 00:00:01.500000', + Carbon::parse('2000-01-01 00:00:00')->addRealSeconds(1.5)->format('Y-m-d H:i:s.u'), + ); + } + public function testAddSecond() { $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->addSecond()->second); From 58cf8600ff5a18cbd0901b77630ca7acba8ed274 Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Tue, 1 Jun 2021 13:40:34 +0200 Subject: [PATCH 02/16] Allow negative numbers in CarbonInterval constructor --- src/Carbon/CarbonInterval.php | 12 +++++++++--- tests/CarbonInterval/AddTest.php | 8 ++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Carbon/CarbonInterval.php b/src/Carbon/CarbonInterval.php index 5121d2addf..4f5ce5e4b0 100644 --- a/src/Carbon/CarbonInterval.php +++ b/src/Carbon/CarbonInterval.php @@ -447,6 +447,12 @@ public function __construct($years = null, $months = null, $weeks = null, $days if ($microseconds !== null) { $this->f = $microseconds / Carbon::MICROSECONDS_PER_SECOND; } + + foreach (['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds'] as $unit) { + if ($$unit < 0) { + $this->set($unit, $$unit); + } + } } /** @@ -814,7 +820,7 @@ public static function fromString(string $intervalDefinition): self $milliseconds = 0; $microseconds = 0; - $pattern = '/(\d+(?:\.\d+)?)\h*([^\d\h]*)/i'; + $pattern = '/(-?\d+(?:\.\d+)?)\h*([^\d\h]*)/i'; preg_match_all($pattern, $intervalDefinition, $parts, PREG_SET_ORDER); while ([$part, $value, $unit] = array_shift($parts)) { @@ -1092,7 +1098,7 @@ protected static function makeFromString(string $interval): ?self return new static($interval); } - if (preg_match('/^(?:\h*\d+(?:\.\d+)?\h*[a-z]+)+$/i', $interval)) { + if (preg_match('/^(?:\h*-?\d+(?:\.\d+)?\h*[a-z]+)+$/i', $interval)) { return static::fromString($interval); } @@ -1988,7 +1994,7 @@ public function add($unit, $value = 1): self [$value, $unit] = [$unit, $value]; } - if (\is_string($unit) && !preg_match('/^\s*\d/', $unit)) { + if (\is_string($unit) && !preg_match('/^\s*-?\d/', $unit)) { $unit = "$value $unit"; $value = 1; } diff --git a/tests/CarbonInterval/AddTest.php b/tests/CarbonInterval/AddTest.php index 079f03884d..87357317a3 100644 --- a/tests/CarbonInterval/AddTest.php +++ b/tests/CarbonInterval/AddTest.php @@ -186,6 +186,14 @@ public function testPlusWithPHP8Syntax() $interval = eval('use Carbon\CarbonInterval;return CarbonInterval::days(3)->plus(weeks: 2, hours: 26);'); $this->assertCarbonInterval($interval, 0, 0, 17, 26, 0, 0); + + $interval = eval('return \Carbon\CarbonInterval::days(3)->plus(hours: 1, minutes: 1.5);'); + + $this->assertCarbonInterval($interval, 0, 0, 3, 1, 1, 30); + + $interval = eval('return \Carbon\CarbonInterval::days(3)->plus(hours: 1, minutes: -1.5);'); + + $this->assertCarbonInterval($interval, 0, 0, 3, 1, -1, -30); } public function testMinus() From 85ceebaaa929d7f678deebefa5775e756a4751c3 Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Tue, 1 Jun 2021 14:10:30 +0200 Subject: [PATCH 03/16] Fallback interval unknown units --- src/Carbon/Traits/Units.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Carbon/Traits/Units.php b/src/Carbon/Traits/Units.php index e04c0acacf..e5efec2b64 100644 --- a/src/Carbon/Traits/Units.php +++ b/src/Carbon/Traits/Units.php @@ -14,6 +14,7 @@ use Carbon\CarbonConverterInterface; use Carbon\CarbonInterface; use Carbon\CarbonInterval; +use Carbon\Exceptions\InvalidIntervalException; use Carbon\Exceptions\UnitException; use Closure; use DateInterval; @@ -302,12 +303,13 @@ public function addUnit(string $unit, $value = 1, ?bool $overflow = null): self $value *= static::MICROSECONDS_PER_MILLISECOND; } - $inverted = $value < 0; - $value = abs($value); - - $date = $date->rawAdd( - CarbonInterval::fromString("$value $unit")->invert($inverted), - ); + try { + $date = $date->rawAdd( + CarbonInterval::fromString(abs($value)." $unit")->invert($value < 0), + ); + } catch (InvalidIntervalException $exception) { + $date = $date->modify("$value $unit"); + } if (isset($timeString)) { $date = $date->setTimeFromTimeString($timeString); From 811e8ee6e0acfeadebab42ca1be17548cade2f33 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sun, 27 Jun 2021 19:01:04 +0200 Subject: [PATCH 04/16] Fix type casts --- src/Carbon/Traits/Units.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Carbon/Traits/Units.php b/src/Carbon/Traits/Units.php index e5efec2b64..b49807779f 100644 --- a/src/Carbon/Traits/Units.php +++ b/src/Carbon/Traits/Units.php @@ -247,7 +247,7 @@ public function addUnit(string $unit, $value = 1, ?bool $overflow = null): self { $date = $this; - if (!is_numeric($value) || !\floatval($value)) { + if (!is_numeric($value) || !(float) $value) { return $date->isMutable() ? $date : $date->copy(); } @@ -386,7 +386,7 @@ public function sub($unit, $value = 1, ?bool $overflow = null): self [$value, $unit] = [$unit, $value]; } - return $this->addUnit((string) $unit, -\floatval($value), $overflow); + return $this->addUnit((string) $unit, -(float) $value, $overflow); } /** From 5d5d4c3392ba7b9883a40f0adeeebf8d760e02af Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sun, 15 Aug 2021 19:38:43 +0200 Subject: [PATCH 05/16] Expect DST interval to be fixed in PHP 8.1 --- tests/Carbon/ModifyNearDSTChangeTest.php | 14 ++++++++++++-- tests/CarbonImmutable/ModifyNearDSTChangeTest.php | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/Carbon/ModifyNearDSTChangeTest.php b/tests/Carbon/ModifyNearDSTChangeTest.php index 14bb821a5a..b94b071cee 100644 --- a/tests/Carbon/ModifyNearDSTChangeTest.php +++ b/tests/Carbon/ModifyNearDSTChangeTest.php @@ -22,6 +22,8 @@ class ModifyNearDSTChangeTest extends AbstractTestCase /** * Tests transition through DST change hour in non default timezone * + * @group dst + * * @param string $dateString * @param int $addHours * @param string $expected @@ -38,6 +40,8 @@ public function testTransitionInNonDefaultTimezone($dateString, $addHours, $expe /** * Tests transition through DST change hour in default timezone * + * @group dst + * * @param string $dateString * @param int $addHours * @param string $expected @@ -61,11 +65,17 @@ public static function dataForTransitionTests(): Generator // testForwardTransition // When standard time was about to reach 2010-03-14T02:00:00-05:00 clocks were turned forward 1 hour to // 2010-03-14T03:00:00-04:00 local daylight time instead - yield ['2010-03-14T00:00:00', 24, '2010-03-15T00:00:00-04:00']; + yield [ + '2010-03-14T00:00:00', + 24, + version_compare(PHP_VERSION, '8.1.0-dev', '>=') + ? '2010-03-15T01:00:00-04:00' + : '2010-03-15T00:00:00-04:00', + ]; // testBackwardTransition // When local daylight time was about to reach 2010-11-07T02:00:00-04:00 clocks were turned backward 1 hour // to 2010-11-07T01:00:00-05:00 local standard time instead - yield ['2010-11-07T00:00:00', 24, '2010-11-08T00:00:00-05:00']; + yield ['2010-11-07T00:00:00', 24, '2010-11-07T23:00:00-05:00']; } } diff --git a/tests/CarbonImmutable/ModifyNearDSTChangeTest.php b/tests/CarbonImmutable/ModifyNearDSTChangeTest.php index 3619c0eca6..b7a010c486 100644 --- a/tests/CarbonImmutable/ModifyNearDSTChangeTest.php +++ b/tests/CarbonImmutable/ModifyNearDSTChangeTest.php @@ -22,6 +22,8 @@ class ModifyNearDSTChangeTest extends AbstractTestCase /** * Tests transition through DST change hour in non default timezone * + * @group dst + * * @param string $dateString * @param int $addHours * @param string $expected @@ -38,6 +40,8 @@ public function testTransitionInNonDefaultTimezone($dateString, $addHours, $expe /** * Tests transition through DST change hour in default timezone * + * @group dst + * * @param string $dateString * @param int $addHours * @param string $expected @@ -61,11 +65,17 @@ public static function dataForTransitionTests(): Generator // testForwardTransition // When standard time was about to reach 2010-03-14T02:00:00-05:00 clocks were turned forward 1 hour to // 2010-03-14T03:00:00-04:00 local daylight time instead - yield ['2010-03-14T00:00:00', 24, '2010-03-15T00:00:00-04:00']; + yield [ + '2010-03-14T00:00:00', + 24, + version_compare(PHP_VERSION, '8.1.0-dev', '>=') + ? '2010-03-15T01:00:00-04:00' + : '2010-03-15T00:00:00-04:00', + ]; // testBackwardTransition // When local daylight time was about to reach 2010-11-07T02:00:00-04:00 clocks were turned backward 1 hour // to 2010-11-07T01:00:00-05:00 local standard time instead - yield ['2010-11-07T00:00:00', 24, '2010-11-08T00:00:00-05:00']; + yield ['2010-11-07T00:00:00', 24, '2010-11-07T23:00:00-05:00']; } } From d137858c560e75c98cdbc5ec4e0d813b0531080a Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 4 Dec 2021 19:11:17 +0100 Subject: [PATCH 06/16] Add strong types to CarbonPeriod Use static return instead of self --- src/Carbon/CarbonImmutable.php | 4 +- src/Carbon/CarbonInterval.php | 68 ++--- src/Carbon/CarbonPeriod.php | 241 +++++++++--------- src/Carbon/CarbonTimeZone.php | 2 +- src/Carbon/Language.php | 4 +- src/Carbon/Traits/Creator.php | 6 +- src/Carbon/Traits/Date.php | 6 +- src/Carbon/Traits/Options.php | 2 +- src/Carbon/Traits/Serialization.php | 2 +- src/Carbon/Traits/Timestamp.php | 10 +- src/Carbon/Traits/Units.php | 18 +- tests/Carbon/IsTest.php | 1 + .../CarbonPeriod/Fixtures/AbstractCarbon.php | 2 +- tests/CarbonPeriod/SettersTest.php | 18 -- 14 files changed, 180 insertions(+), 204 deletions(-) diff --git a/src/Carbon/CarbonImmutable.php b/src/Carbon/CarbonImmutable.php index 2480480b79..17e8df4a3f 100644 --- a/src/Carbon/CarbonImmutable.php +++ b/src/Carbon/CarbonImmutable.php @@ -525,7 +525,7 @@ public function __clone() * * @return static */ - public static function startOfTime(): self + public static function startOfTime(): static { $date = static::parse('0001-01-01')->years(self::getStartOfTimeYear()); $date->startOfTime = true; @@ -538,7 +538,7 @@ public static function startOfTime(): self * * @return static */ - public static function endOfTime(): self + public static function endOfTime(): static { $date = static::parse('9999-12-31 23:59:59.999999')->years(self::getEndOfTimeYear()); $date->endOfTime = true; diff --git a/src/Carbon/CarbonInterval.php b/src/Carbon/CarbonInterval.php index 4f5ce5e4b0..7cd7f2835f 100644 --- a/src/Carbon/CarbonInterval.php +++ b/src/Carbon/CarbonInterval.php @@ -612,7 +612,7 @@ public static function create($years = null, $months = null, $weeks = null, $day * * @return static */ - public static function createFromFormat(string $format, ?string $interval): self + public static function createFromFormat(string $format, ?string $interval): static { $instance = new static(0); $length = mb_strlen($format); @@ -699,7 +699,7 @@ public function end(): ?CarbonInterface * * @return $this */ - public function optimize(): self + public function optimize(): static { $this->originalInput = null; $this->startDate = null; @@ -713,7 +713,7 @@ public function optimize(): self * * @return static */ - public function copy(): self + public function copy(): static { $date = new static(0); $date->copyProperties($this); @@ -727,7 +727,7 @@ public function copy(): self * * @return static */ - public function clone(): self + public function clone(): static { return $this->copy(); } @@ -773,7 +773,7 @@ public static function __callStatic(string $method, array $parameters) * * @return static */ - protected static function this(): self + protected static function this(): static { return end(static::$macroContextStack) ?: new static(0); } @@ -804,7 +804,7 @@ protected static function this(): self * * @return static */ - public static function fromString(string $intervalDefinition): self + public static function fromString(string $intervalDefinition): static { if (empty($intervalDefinition)) { return self::withOriginal(new static(0), $intervalDefinition); @@ -975,7 +975,7 @@ public static function fromString(string $intervalDefinition): self * * @return static */ - public static function parseFromLocale(string $interval, ?string $locale = null): self + public static function parseFromLocale(string $interval, ?string $locale = null): static { return static::fromString(Carbon::translateTimeString($interval, $locale ?: static::getLocale(), CarbonInterface::DEFAULT_LOCALE)); } @@ -988,7 +988,7 @@ public static function parseFromLocale(string $interval, ?string $locale = null) * * @return static */ - public static function diff($start, $end = null, bool $absolute = false): self + public static function diff($start, $end = null, bool $absolute = false): static { $start = $start instanceof CarbonInterface ? $start : Carbon::make($start); $end = $end instanceof CarbonInterface ? $end : Carbon::make($end); @@ -1007,7 +1007,7 @@ public static function diff($start, $end = null, bool $absolute = false): self * * @return $this */ - public function abs(bool $absolute = false): self + public function abs(bool $absolute = false): static { if ($absolute && $this->invert) { $this->invert(); @@ -1025,7 +1025,7 @@ public function abs(bool $absolute = false): self * * @return $this */ - public function absolute(bool $absolute = true): self + public function absolute(bool $absolute = true): static { return $this->abs($absolute); } @@ -1053,7 +1053,7 @@ public function cast(string $className) * * @return static */ - public static function instance(DateInterval $interval): self + public static function instance(DateInterval $interval): static { return self::castIntervalToClass($interval, static::class); } @@ -1203,7 +1203,7 @@ public function __get(string $name) * * @return $this */ - public function set($name, $value = null): self + public function set($name, $value = null): static { $properties = \is_array($name) ? $name : [$name => $value]; @@ -1295,7 +1295,7 @@ public function __set(string $name, $value) * * @return static */ - public function weeksAndDays(int $weeks, int $days): self + public function weeksAndDays(int $weeks, int $days): static { $this->dayz = ($weeks * static::getDaysPerWeek()) + $days; @@ -1957,14 +1957,14 @@ public function stepBy($interval, ?string $unit = null): CarbonPeriod * * @return $this */ - public function invert($inverted = null): self + public function invert($inverted = null): static { $this->invert = (\func_num_args() === 0 ? !$this->invert : $inverted) ? 1 : 0; return $this; } - protected function solveNegativeInterval(): self + protected function solveNegativeInterval(): static { if (!$this->isEmpty() && $this->years <= 0 && $this->months <= 0 && $this->dayz <= 0 && $this->hours <= 0 && $this->minutes <= 0 && $this->seconds <= 0 && $this->microseconds <= 0) { $this->years *= self::NEGATIVE; @@ -1988,7 +1988,7 @@ protected function solveNegativeInterval(): self * * @return $this */ - public function add($unit, $value = 1): self + public function add($unit, $value = 1): static { if (is_numeric($unit)) { [$value, $unit] = [$unit, $value]; @@ -2031,7 +2031,7 @@ public function add($unit, $value = 1): self * * @return $this */ - public function sub($unit, $value = 1): self + public function sub($unit, $value = 1): static { if (is_numeric($unit)) { [$value, $unit] = [$unit, $value]; @@ -2048,7 +2048,7 @@ public function sub($unit, $value = 1): self * * @return $this */ - public function subtract($unit, $value = 1): self + public function subtract($unit, $value = 1): static { return $this->sub($unit, $value); } @@ -2076,7 +2076,7 @@ public function plus( $minutes = 0, $seconds = 0, $microseconds = 0 - ): self { + ): static { return $this->add(" $years years $months months $weeks weeks $days days $hours hours $minutes minutes $seconds seconds $microseconds microseconds @@ -2106,7 +2106,7 @@ public function minus( $minutes = 0, $seconds = 0, $microseconds = 0 - ): self { + ): static { return $this->sub(" $years years $months months $weeks weeks $days days $hours hours $minutes minutes $seconds seconds $microseconds microseconds @@ -2128,7 +2128,7 @@ public function minus( * * @return $this */ - public function times($factor): self + public function times($factor): static { if ($factor < 0) { $this->invert = $this->invert ? 0 : 1; @@ -2161,12 +2161,12 @@ public function times($factor): self * * @return $this */ - public function shares($divider): self + public function shares($divider): static { return $this->times(1 / $divider); } - protected function copyProperties(self $interval, $ignoreSign = false): self + protected function copyProperties(self $interval, $ignoreSign = false): static { $this->years = $interval->years; $this->months = $interval->months; @@ -2190,7 +2190,7 @@ protected function copyProperties(self $interval, $ignoreSign = false): self * * @return $this */ - public function multiply($factor): self + public function multiply($factor): static { if ($factor < 0) { $this->invert = $this->invert ? 0 : 1; @@ -2218,7 +2218,7 @@ public function multiply($factor): self * * @return $this */ - public function divide($divider): self + public function divide($divider): static { return $this->multiply(1 / $divider); } @@ -2304,7 +2304,7 @@ public function compare(DateInterval $interval): int * * @return $this */ - public function cascade(): self + public function cascade(): static { return $this->doCascade(false); } @@ -2712,7 +2712,7 @@ public function isBetween($interval1, $interval2, bool $equal = true): bool * * @return $this */ - public function roundUnit(string $unit, $precision = 1, string $function = 'round'): self + public function roundUnit(string $unit, $precision = 1, string $function = 'round'): static { $base = CarbonImmutable::parse('2000-01-01 00:00:00', 'UTC') ->roundUnit($unit, $precision, $function); @@ -2742,7 +2742,7 @@ public function roundUnit(string $unit, $precision = 1, string $function = 'roun * * @return $this */ - public function floorUnit(string $unit, $precision = 1): self + public function floorUnit(string $unit, $precision = 1): static { return $this->roundUnit($unit, $precision, 'floor'); } @@ -2757,7 +2757,7 @@ public function floorUnit(string $unit, $precision = 1): self * * @return $this */ - public function ceilUnit(string $unit, $precision = 1): self + public function ceilUnit(string $unit, $precision = 1): static { return $this->roundUnit($unit, $precision, 'ceil'); } @@ -2772,7 +2772,7 @@ public function ceilUnit(string $unit, $precision = 1): self * * @return $this */ - public function round($precision = 1, string $function = 'round'): self + public function round($precision = 1, string $function = 'round'): static { return $this->roundWith($precision, $function); } @@ -2786,7 +2786,7 @@ public function round($precision = 1, string $function = 'round'): self * * @return $this */ - public function floor($precision = 1): self + public function floor($precision = 1): static { return $this->round($precision, 'floor'); } @@ -2800,7 +2800,7 @@ public function floor($precision = 1): self * * @return $this */ - public function ceil($precision = 1): self + public function ceil($precision = 1): static { return $this->round($precision, 'ceil'); } @@ -2894,14 +2894,14 @@ private static function copyNegativeUnits(DateInterval $from, DateInterval $to): } } - private function invertCascade(array $values): self + private function invertCascade(array $values): static { return $this->set(array_map(function ($value) { return -$value; }, $values))->doCascade(true)->invert(); } - private function doCascade(bool $deep): self + private function doCascade(bool $deep): static { $originalData = $this->toArray(); $originalData['milliseconds'] = (int) ($originalData['microseconds'] / static::getMicrosecondsPerMillisecond()); diff --git a/src/Carbon/CarbonPeriod.php b/src/Carbon/CarbonPeriod.php index 3f38ed4a70..dde76f9dbb 100644 --- a/src/Carbon/CarbonPeriod.php +++ b/src/Carbon/CarbonPeriod.php @@ -362,7 +362,7 @@ public function getIterator(): Generator * * @return static|null */ - public static function make($var) + public static function make(mixed $var): ?static { try { return static::instance($var); @@ -378,7 +378,7 @@ public static function make($var) * * @return static */ - public static function instance($period) + public static function instance(mixed $period): static { if ($period instanceof static) { return $period->copy(); @@ -389,7 +389,7 @@ public static function instance($period) $period->getStartDate(), $period->getEndDate() ?: $period->getRecurrences(), $period->getDateInterval(), - $period->getOptions() + $period->getOptions(), ); } @@ -398,7 +398,7 @@ public static function instance($period) $period->start, $period->end ?: ($period->recurrences - 1), $period->interval, - $period->include_start_date ? 0 : static::EXCLUDE_START_DATE + $period->include_start_date ? 0 : static::EXCLUDE_START_DATE, ); } @@ -417,7 +417,7 @@ public static function instance($period) * * @return static */ - public static function create(...$params) + public static function create(...$params): static { return static::createFromArray($params); } @@ -429,7 +429,7 @@ public static function create(...$params) * * @return static */ - public static function createFromArray(array $params) + public static function createFromArray(array $params): static { return new static(...$params); } @@ -442,7 +442,7 @@ public static function createFromArray(array $params) * * @return static */ - public static function createFromIso($iso, $options = null) + public static function createFromIso(string $iso, ?int $options = null): static { $params = static::parseIso8601($iso); @@ -462,7 +462,7 @@ public static function createFromIso($iso, $options = null) * * @return bool */ - protected static function intervalHasTime(DateInterval $interval) + protected static function intervalHasTime(DateInterval $interval): bool { return $interval->h || $interval->i || $interval->s || $interval->f; } @@ -477,7 +477,7 @@ protected static function intervalHasTime(DateInterval $interval) * * @return bool */ - protected static function isIso8601($var) + protected static function isIso8601(mixed $var): bool { if (!\is_string($var)) { return false; @@ -500,7 +500,7 @@ protected static function isIso8601($var) * * @return array */ - protected static function parseIso8601($iso) + protected static function parseIso8601(string $iso): array { $result = []; @@ -535,7 +535,7 @@ protected static function parseIso8601($iso) * * @return string */ - protected static function addMissingParts($source, $target) + protected static function addMissingParts(string $source, string $target): string { $pattern = '/'.preg_replace('/[0-9]+/', '[0-9]+', preg_quote($target, '/')).'$/'; @@ -560,7 +560,7 @@ protected static function addMissingParts($source, $target) * * @return void */ - public static function macro($name, $macro) + public static function macro(string $name, $macro): void { static::$macros[$name] = $macro; } @@ -599,7 +599,7 @@ public static function macro($name, $macro) * * @return void */ - public static function mixin($mixin) + public static function mixin(object|string $mixin) { static::baseMixin($mixin); } @@ -611,7 +611,7 @@ public static function mixin($mixin) * * @return bool */ - public static function hasMacro($name) + public static function hasMacro(string $name): bool { return isset(static::$macros[$name]); } @@ -624,7 +624,7 @@ public static function hasMacro($name) * * @return mixed */ - public static function __callStatic($method, $parameters) + public static function __callStatic(string $method, array $parameters): mixed { $date = new static(); @@ -658,7 +658,6 @@ public function __construct(...$arguments) if ($argumentsCount === 1) { if ($arguments[0] instanceof self) { - //var_dump($arguments[0]->getStartDate()); $arguments = [ $arguments[0]->getStartDate(), $arguments[0]->getEndDate() ?: $arguments[0]->getRecurrences(), @@ -666,7 +665,6 @@ public function __construct(...$arguments) $arguments[0]->getOptions(), ]; } elseif ($arguments[0] instanceof DatePeriod) { - //var_dump($arguments[0]->start); $arguments = [ $arguments[0]->start, $arguments[0]->end ?: ($arguments[0]->recurrences - 1), @@ -697,7 +695,11 @@ public function __construct(...$arguments) $this->setStartDate($parsedDate); } elseif ($this->endDate === null && ($parsedDate = $parsedDate ?? $this->makeDateTime($argument))) { $this->setEndDate($parsedDate); - } elseif ($this->carbonRecurrences === null && $this->endDate === null && is_numeric($argument) && $argument >= 0) { + } elseif ($this->carbonRecurrences === null && + $this->endDate === null && + (\is_int($argument) || \is_float($argument)) + && $argument >= 0 + ) { $this->setRecurrences($argument); } elseif ($this->options === null && ((\is_int($argument) && $argument >= 0) || $argument === null)) { $this->setOptions($argument); @@ -850,7 +852,7 @@ public function getDateClass(): string * * @return $this */ - public function setDateInterval($interval, $unit = null) + public function setDateInterval(mixed $interval, ?string $unit = null) { if (!$interval = CarbonInterval::make($interval, $unit)) { throw new InvalidIntervalException('Invalid interval.'); @@ -889,7 +891,7 @@ public function invertDateInterval() * * @return $this */ - public function setDates($start, $end) + public function setDates(mixed $start, mixed $end): static { $this->setStartDate($start); $this->setEndDate($end); @@ -902,17 +904,11 @@ public function setDates($start, $end) * * @param int|null $options * - * @throws InvalidArgumentException - * * @return $this */ - public function setOptions($options) + public function setOptions(?int $options): static { - if (!\is_int($options) && $options !== null) { - throw new InvalidPeriodParameterException('Invalid options.'); - } - - $this->options = $options ?: 0; + $this->options = $options ?? 0; $this->handleChangedParameters(); @@ -924,9 +920,9 @@ public function setOptions($options) * * @return int */ - public function getOptions() + public function getOptions(): ?int { - return $this->options; + return $this->options ?? 0; } /** @@ -939,7 +935,7 @@ public function getOptions() * * @return $this */ - public function toggleOptions($options, $state = null) + public function toggleOptions(int $options, bool $state = null): static { if ($state === null) { $state = ($this->options & $options) !== $options; @@ -959,7 +955,7 @@ public function toggleOptions($options, $state = null) * * @return $this */ - public function excludeStartDate($state = true) + public function excludeStartDate(bool $state = true): static { return $this->toggleOptions(static::EXCLUDE_START_DATE, $state); } @@ -971,7 +967,7 @@ public function excludeStartDate($state = true) * * @return $this */ - public function excludeEndDate($state = true) + public function excludeEndDate(bool $state = true): static { return $this->toggleOptions(static::EXCLUDE_END_DATE, $state); } @@ -981,7 +977,7 @@ public function excludeEndDate($state = true) * * @return CarbonInterval */ - public function getDateInterval() + public function getDateInterval(): CarbonInterval { return $this->dateInterval->copy(); } @@ -993,7 +989,7 @@ public function getDateInterval() * * @return CarbonInterface */ - public function getStartDate(string $rounding = null) + public function getStartDate(string $rounding = null): CarbonInterface { $date = $this->startDate->avoidMutation(); @@ -1007,7 +1003,7 @@ public function getStartDate(string $rounding = null) * * @return CarbonInterface|null */ - public function getEndDate(string $rounding = null) + public function getEndDate(string $rounding = null): ?CarbonInterface { if (!$this->endDate) { return null; @@ -1023,7 +1019,8 @@ public function getEndDate(string $rounding = null) * * @return int|float|null */ - public function getRecurrences() + #[ReturnTypeWillChange] + public function getRecurrences(): int|float|null { return $this->carbonRecurrences; } @@ -1033,7 +1030,7 @@ public function getRecurrences() * * @return bool */ - public function isStartExcluded() + public function isStartExcluded(): bool { return ($this->options & static::EXCLUDE_START_DATE) !== 0; } @@ -1043,7 +1040,7 @@ public function isStartExcluded() * * @return bool */ - public function isEndExcluded() + public function isEndExcluded(): bool { return ($this->options & static::EXCLUDE_END_DATE) !== 0; } @@ -1053,7 +1050,7 @@ public function isEndExcluded() * * @return bool */ - public function isStartIncluded() + public function isStartIncluded(): bool { return !$this->isStartExcluded(); } @@ -1063,7 +1060,7 @@ public function isStartIncluded() * * @return bool */ - public function isEndIncluded() + public function isEndIncluded(): bool { return !$this->isEndExcluded(); } @@ -1073,7 +1070,7 @@ public function isEndIncluded() * * @return CarbonInterface */ - public function getIncludedStartDate() + public function getIncludedStartDate(): CarbonInterface { $start = $this->getStartDate(); @@ -1090,7 +1087,7 @@ public function getIncludedStartDate() * * @return CarbonInterface */ - public function getIncludedEndDate() + public function getIncludedEndDate(): CarbonInterface { $end = $this->getEndDate(); @@ -1115,7 +1112,7 @@ public function getIncludedEndDate() * * @return $this */ - public function addFilter($callback, $name = null) + public function addFilter($callback, ?string $name = null): static { $tuple = $this->createFilterTuple(\func_get_args()); @@ -1136,7 +1133,7 @@ public function addFilter($callback, $name = null) * * @return $this */ - public function prependFilter($callback, $name = null) + public function prependFilter($callback, ?string $name = null): static { $tuple = $this->createFilterTuple(\func_get_args()); @@ -1154,7 +1151,7 @@ public function prependFilter($callback, $name = null) * * @return $this */ - public function removeFilter($filter) + public function removeFilter($filter): static { $key = \is_callable($filter) ? 0 : 1; @@ -1177,7 +1174,7 @@ public function removeFilter($filter) * * @return bool */ - public function hasFilter($filter) + public function hasFilter($filter): bool { $key = \is_callable($filter) ? 0 : 1; @@ -1195,7 +1192,7 @@ public function hasFilter($filter) * * @return array */ - public function getFilters() + public function getFilters(): array { return $this->filters; } @@ -1207,7 +1204,7 @@ public function getFilters() * * @return $this */ - public function setFilters(array $filters) + public function setFilters(array $filters): static { $this->filters = $filters; @@ -1223,7 +1220,7 @@ public function setFilters(array $filters) * * @return $this */ - public function resetFilters() + public function resetFilters(): static { $this->filters = []; @@ -1249,16 +1246,16 @@ public function resetFilters() * * @return $this */ - public function setRecurrences($recurrences) + public function setRecurrences(int|float|null $recurrences): static { - if (!is_numeric($recurrences) && $recurrences !== null || $recurrences < 0) { - throw new InvalidPeriodParameterException('Invalid number of recurrences.'); - } - if ($recurrences === null) { return $this->removeFilter(static::RECURRENCES_FILTER); } + if ($recurrences < 0) { + throw new InvalidPeriodParameterException('Invalid number of recurrences.'); + } + $this->carbonRecurrences = $recurrences === INF ? INF : (int) $recurrences; if (!$this->hasFilter(static::RECURRENCES_FILTER)) { @@ -1280,7 +1277,7 @@ public function setRecurrences($recurrences) * * @return $this */ - public function setStartDate($date, $inclusive = null) + public function setStartDate(mixed $date, bool $inclusive = null): static { if (!$date = ([$this->dateClass, 'make'])($date)) { throw new InvalidPeriodDateException('Invalid start date.'); @@ -1305,7 +1302,7 @@ public function setStartDate($date, $inclusive = null) * * @return $this */ - public function setEndDate($date, $inclusive = null) + public function setEndDate(mixed $date, ?bool $inclusive = null): static { if ($date !== null && !$date = ([$this->dateClass, 'make'])($date)) { throw new InvalidPeriodDateException('Invalid end date.'); @@ -1335,8 +1332,7 @@ public function setEndDate($date, $inclusive = null) * * @return bool */ - #[ReturnTypeWillChange] - public function valid() + public function valid(): bool { return $this->validateCurrentDate() === true; } @@ -1346,8 +1342,7 @@ public function valid() * * @return int|null */ - #[ReturnTypeWillChange] - public function key() + public function key(): ?int { return $this->valid() ? $this->key @@ -1359,8 +1354,7 @@ public function key() * * @return CarbonInterface|null */ - #[ReturnTypeWillChange] - public function current() + public function current(): ?CarbonInterface { return $this->valid() ? $this->prepareForReturn($this->carbonCurrent) @@ -1374,8 +1368,7 @@ public function current() * * @return void */ - #[ReturnTypeWillChange] - public function next() + public function next(): void { if ($this->carbonCurrent === null) { $this->rewind(); @@ -1401,8 +1394,7 @@ public function next() * * @return void */ - #[ReturnTypeWillChange] - public function rewind() + public function rewind(): void { $this->key = 0; $this->carbonCurrent = ([$this->dateClass, 'make'])($this->startDate); @@ -1433,7 +1425,7 @@ public function rewind() * * @return bool */ - public function skip($count = 1) + public function skip(int $count = 1): bool { for ($i = $count; $this->valid() && $i > 0; $i--) { $this->next(); @@ -1447,7 +1439,7 @@ public function skip($count = 1) * * @return string */ - public function toIso8601String() + public function toIso8601String(): string { $parts = []; @@ -1471,7 +1463,7 @@ public function toIso8601String() * * @return string */ - public function toString() + public function toString(): string { $translator = ([$this->dateClass, 'getTranslator'])(); @@ -1505,7 +1497,7 @@ public function toString() * * @return string */ - public function spec() + public function spec(): string { return $this->toIso8601String(); } @@ -1515,9 +1507,9 @@ public function spec() * * @param string $className The $className::instance() method will be called to cast the current object. * - * @return DatePeriod + * @return DatePeriod|object */ - public function cast(string $className) + public function cast(string $className): object { if (!method_exists($className, 'instance')) { if (is_a($className, DatePeriod::class, true)) { @@ -1545,7 +1537,7 @@ public function cast(string $className) * * @return DatePeriod */ - public function toDatePeriod() + public function toDatePeriod(): DatePeriod { return $this->cast(DatePeriod::class); } @@ -1555,7 +1547,7 @@ public function toDatePeriod() * * @return CarbonInterface[] */ - public function toArray() + public function toArray(): array { $state = [ $this->key, @@ -1575,8 +1567,7 @@ public function toArray() * * @return int */ - #[ReturnTypeWillChange] - public function count() + public function count(): int { return \count($this->toArray()); } @@ -1586,7 +1577,7 @@ public function count() * * @return CarbonInterface|null */ - public function first() + public function first(): ?CarbonInterface { return ($this->toArray() ?: [])[0] ?? null; } @@ -1596,7 +1587,7 @@ public function first() * * @return CarbonInterface|null */ - public function last() + public function last(): ?CarbonInterface { $array = $this->toArray(); @@ -1608,7 +1599,7 @@ public function last() * * @return string */ - public function __toString() + public function __toString(): string { return $this->toString(); } @@ -1628,7 +1619,7 @@ public function __toString() * * @return mixed */ - public function __call($method, $parameters) + public function __call(string $method, array $parameters): mixed { if (static::hasMacro($method)) { return static::bindMacroContext($this, fn () => $this->callMacro($method, $parameters)); @@ -1729,7 +1720,7 @@ public function __call($method, $parameters) * * @return static */ - public function setTimezone($timezone) + public function setTimezone(mixed $timezone): static { $this->tzName = $timezone; $this->timezone = $timezone; @@ -1752,7 +1743,7 @@ public function setTimezone($timezone) * * @return static */ - public function shiftTimezone($timezone) + public function shiftTimezone(mixed $timezone): static { $this->tzName = $timezone; $this->timezone = $timezone; @@ -1775,7 +1766,7 @@ public function shiftTimezone($timezone) * * @return CarbonInterface */ - public function calculateEnd(string $rounding = null) + public function calculateEnd(?string $rounding = null): CarbonInterface { if ($end = $this->getEndDate($rounding)) { return $end; @@ -1797,7 +1788,7 @@ public function calculateEnd(string $rounding = null) /** * @return CarbonInterface|null */ - private function getEndFromRecurrences() + private function getEndFromRecurrences(): ?CarbonInterface { if ($this->carbonRecurrences === null) { throw new UnreachableException( @@ -1828,7 +1819,7 @@ private function getEndFromRecurrences() /** * @return CarbonInterface|null */ - private function iterateUntilEnd() + private function iterateUntilEnd(): ?CarbonInterface { $attempts = 0; $date = null; @@ -1853,7 +1844,7 @@ private function iterateUntilEnd() * * @return bool */ - public function overlaps($rangeOrRangeStart, $rangeEnd = null) + public function overlaps(mixed $rangeOrRangeStart, mixed $rangeEnd = null): bool { $range = $rangeEnd ? static::create($rangeOrRangeStart, $rangeEnd) : $rangeOrRangeStart; @@ -1879,7 +1870,7 @@ public function overlaps($rangeOrRangeStart, $rangeEnd = null) * * @param callable $callback */ - public function forEach(callable $callback) + public function forEach(callable $callback): void { foreach ($this as $date) { $callback($date); @@ -1899,9 +1890,9 @@ public function forEach(callable $callback) * * @param callable $callback * - * @return \Generator + * @return Generator */ - public function map(callable $callback) + public function map(callable $callback): Generator { foreach ($this as $date) { yield $callback($date); @@ -1918,7 +1909,7 @@ public function map(callable $callback) * * @return bool */ - public function eq($period): bool + public function eq(mixed $period): bool { return $this->equalTo($period); } @@ -1931,7 +1922,7 @@ public function eq($period): bool * * @return bool */ - public function equalTo($period): bool + public function equalTo(mixed $period): bool { if (!($period instanceof self)) { $period = self::make($period); @@ -1956,7 +1947,7 @@ public function equalTo($period): bool * * @return bool */ - public function ne($period): bool + public function ne(mixed $period): bool { return $this->notEqualTo($period); } @@ -1969,7 +1960,7 @@ public function ne($period): bool * * @return bool */ - public function notEqualTo($period): bool + public function notEqualTo(mixed $period): bool { return !$this->eq($period); } @@ -1982,7 +1973,7 @@ public function notEqualTo($period): bool * * @return bool */ - public function startsBefore($date = null): bool + public function startsBefore(mixed $date = null): bool { return $this->getStartDate()->lessThan($this->resolveCarbon($date)); } @@ -1995,7 +1986,7 @@ public function startsBefore($date = null): bool * * @return bool */ - public function startsBeforeOrAt($date = null): bool + public function startsBeforeOrAt(mixed $date = null): bool { return $this->getStartDate()->lessThanOrEqualTo($this->resolveCarbon($date)); } @@ -2008,7 +1999,7 @@ public function startsBeforeOrAt($date = null): bool * * @return bool */ - public function startsAfter($date = null): bool + public function startsAfter(mixed $date = null): bool { return $this->getStartDate()->greaterThan($this->resolveCarbon($date)); } @@ -2021,7 +2012,7 @@ public function startsAfter($date = null): bool * * @return bool */ - public function startsAfterOrAt($date = null): bool + public function startsAfterOrAt(mixed $date = null): bool { return $this->getStartDate()->greaterThanOrEqualTo($this->resolveCarbon($date)); } @@ -2034,7 +2025,7 @@ public function startsAfterOrAt($date = null): bool * * @return bool */ - public function startsAt($date = null): bool + public function startsAt(mixed $date = null): bool { return $this->getStartDate()->equalTo($this->resolveCarbon($date)); } @@ -2047,7 +2038,7 @@ public function startsAt($date = null): bool * * @return bool */ - public function endsBefore($date = null): bool + public function endsBefore(mixed $date = null): bool { return $this->calculateEnd()->lessThan($this->resolveCarbon($date)); } @@ -2060,7 +2051,7 @@ public function endsBefore($date = null): bool * * @return bool */ - public function endsBeforeOrAt($date = null): bool + public function endsBeforeOrAt(mixed $date = null): bool { return $this->calculateEnd()->lessThanOrEqualTo($this->resolveCarbon($date)); } @@ -2073,7 +2064,7 @@ public function endsBeforeOrAt($date = null): bool * * @return bool */ - public function endsAfter($date = null): bool + public function endsAfter(mixed $date = null): bool { return $this->calculateEnd()->greaterThan($this->resolveCarbon($date)); } @@ -2086,7 +2077,7 @@ public function endsAfter($date = null): bool * * @return bool */ - public function endsAfterOrAt($date = null): bool + public function endsAfterOrAt(mixed $date = null): bool { return $this->calculateEnd()->greaterThanOrEqualTo($this->resolveCarbon($date)); } @@ -2099,7 +2090,7 @@ public function endsAfterOrAt($date = null): bool * * @return bool */ - public function endsAt($date = null): bool + public function endsAt(mixed $date = null): bool { return $this->calculateEnd()->equalTo($this->resolveCarbon($date)); } @@ -2140,14 +2131,17 @@ public function isInProgress(): bool /** * Round the current instance at the given unit with given precision if specified and the given function. * - * @param string $unit - * @param float|int|string|\DateInterval|null $precision - * @param string $function + * @param string $unit + * @param float|int|string|DateInterval|null $precision + * @param string $function * * @return $this */ - public function roundUnit($unit, $precision = 1, $function = 'round') - { + public function roundUnit( + string $unit, + DateInterval|float|int|string|null $precision = 1, + string $function = 'round', + ): static { $this->setStartDate($this->getStartDate()->roundUnit($unit, $precision, $function)); if ($this->endDate) { @@ -2162,12 +2156,12 @@ public function roundUnit($unit, $precision = 1, $function = 'round') /** * Truncate the current instance at the given unit with given precision if specified. * - * @param string $unit - * @param float|int|string|\DateInterval|null $precision + * @param string $unit + * @param float|int|string|DateInterval|null $precision * * @return $this */ - public function floorUnit($unit, $precision = 1) + public function floorUnit(string $unit, DateInterval|float|int|string|null $precision = 1): static { return $this->roundUnit($unit, $precision, 'floor'); } @@ -2175,12 +2169,12 @@ public function floorUnit($unit, $precision = 1) /** * Ceil the current instance at the given unit with given precision if specified. * - * @param string $unit - * @param float|int|string|\DateInterval|null $precision + * @param string $unit + * @param float|int|string|DateInterval|null $precision * * @return $this */ - public function ceilUnit($unit, $precision = 1) + public function ceilUnit(string $unit, DateInterval|float|int|string|null $precision = 1): static { return $this->roundUnit($unit, $precision, 'ceil'); } @@ -2188,12 +2182,12 @@ public function ceilUnit($unit, $precision = 1) /** * Round the current instance second with given precision if specified (else period interval is used). * - * @param float|int|string|\DateInterval|null $precision - * @param string $function + * @param float|int|string|DateInterval|null $precision + * @param string $function * * @return $this */ - public function round($precision = null, $function = 'round') + public function round(DateInterval|float|int|string|null $precision = null, string $function = 'round'): static { return $this->roundWith($precision ?? (string) $this->getDateInterval(), $function); } @@ -2201,11 +2195,11 @@ public function round($precision = null, $function = 'round') /** * Round the current instance second with given precision if specified (else period interval is used). * - * @param float|int|string|\DateInterval|null $precision + * @param float|int|string|DateInterval|null $precision * * @return $this */ - public function floor($precision = null) + public function floor(DateInterval|float|int|string|null $precision = null) { return $this->round($precision, 'floor'); } @@ -2213,11 +2207,11 @@ public function floor($precision = null) /** * Ceil the current instance second with given precision if specified (else period interval is used). * - * @param float|int|string|\DateInterval|null $precision + * @param float|int|string|DateInterval|null $precision * * @return $this */ - public function ceil($precision = null) + public function ceil(DateInterval|float|int|string|null $precision = null) { return $this->round($precision, 'ceil'); } @@ -2229,8 +2223,7 @@ public function ceil($precision = null) * * @return CarbonInterface[] */ - #[ReturnTypeWillChange] - public function jsonSerialize() + public function jsonSerialize(): array { return $this->toArray(); } diff --git a/src/Carbon/CarbonTimeZone.php b/src/Carbon/CarbonTimeZone.php index 4fbeda5b2e..35b4b7a95d 100644 --- a/src/Carbon/CarbonTimeZone.php +++ b/src/Carbon/CarbonTimeZone.php @@ -174,7 +174,7 @@ public function toOffsetName(DateTimeInterface $date = null): string * * @return CarbonTimeZone */ - public function toOffsetTimeZone(DateTimeInterface $date = null): self + public function toOffsetTimeZone(DateTimeInterface $date = null): static { return new static($this->toOffsetName($date)); } diff --git a/src/Carbon/Language.php b/src/Carbon/Language.php index 1fb5bafdc8..ff292af050 100644 --- a/src/Carbon/Language.php +++ b/src/Carbon/Language.php @@ -210,7 +210,7 @@ public function getFullIsoName(): string * * @param string $isoName */ - public function setIsoName(string $isoName): self + public function setIsoName(string $isoName): static { $this->isoName = $isoName; @@ -236,7 +236,7 @@ public function getFullNativeName(): string * * @param string $nativeName */ - public function setNativeName(string $nativeName): self + public function setNativeName(string $nativeName): static { $this->nativeName = $nativeName; diff --git a/src/Carbon/Traits/Creator.php b/src/Carbon/Traits/Creator.php index 06c91f4dd5..2baf0f5523 100644 --- a/src/Carbon/Traits/Creator.php +++ b/src/Carbon/Traits/Creator.php @@ -62,7 +62,7 @@ public function __construct($time = null, $tz = null) $time = $this->constructTimezoneFromDateTime($time, $tz)->format('Y-m-d H:i:s.u'); } - if (substr($time, 0, 1) === '@') { + if (is_string($time) && substr($time, 0, 1) === '@') { $time = static::createFromTimestampUTC(substr($time, 1))->format('Y-m-d\TH:i:s.uP'); } @@ -129,7 +129,7 @@ public function __clone() * * @return static */ - public static function instance($date): self + public static function instance($date): static { if ($date instanceof static) { return clone $date; @@ -455,7 +455,7 @@ public static function createSafe($year = null, $month = null, $day = null, $hou * * @return static */ - public static function createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null): self + public static function createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null): static { $initialStrictMode = static::isStrictModeEnabled(); static::useStrictMode(true); diff --git a/src/Carbon/Traits/Date.php b/src/Carbon/Traits/Date.php index 883aa2b6f1..5a65e4cc32 100644 --- a/src/Carbon/Traits/Date.php +++ b/src/Carbon/Traits/Date.php @@ -692,7 +692,7 @@ public function clone() * * @return static */ - public function avoidMutation(): self + public function avoidMutation(): static { if ($this instanceof DateTimeImmutable) { return $this; @@ -706,7 +706,7 @@ public function avoidMutation(): self * * @return static */ - public function nowWithSameTz() + public function nowWithSameTz(): static { return static::now($this->getTimezone()); } @@ -2577,7 +2577,7 @@ protected function resolveCarbon($date = null) * * @return static */ - protected function resolveUTC($date = null): self + protected function resolveUTC($date = null): static { if (!$date) { return static::now('UTC'); diff --git a/src/Carbon/Traits/Options.php b/src/Carbon/Traits/Options.php index 02b0676deb..49971acd80 100644 --- a/src/Carbon/Traits/Options.php +++ b/src/Carbon/Traits/Options.php @@ -343,7 +343,7 @@ public static function shouldOverflowYears(): bool * * @return $this|static */ - public function settings(array $settings): self + public function settings(array $settings): static { $this->localStrictModeEnabled = $settings['strictMode'] ?? null; $this->localMonthsOverflow = $settings['monthOverflow'] ?? null; diff --git a/src/Carbon/Traits/Serialization.php b/src/Carbon/Traits/Serialization.php index eebc69bd0c..d9dba4c62f 100644 --- a/src/Carbon/Traits/Serialization.php +++ b/src/Carbon/Traits/Serialization.php @@ -103,7 +103,7 @@ public static function fromSerialized($value) * @return static */ #[ReturnTypeWillChange] - public static function __set_state($dump) + public static function __set_state($dump): static { if (\is_string($dump)) { return static::parse($dump); diff --git a/src/Carbon/Traits/Timestamp.php b/src/Carbon/Traits/Timestamp.php index 4d65417064..cb8b7bd7a7 100644 --- a/src/Carbon/Traits/Timestamp.php +++ b/src/Carbon/Traits/Timestamp.php @@ -26,7 +26,7 @@ trait Timestamp * * @return static */ - public static function createFromTimestamp($timestamp, $tz = null): self + public static function createFromTimestamp($timestamp, $tz = null): static { return static::createFromTimestampUTC($timestamp)->setTimezone($tz); } @@ -40,7 +40,7 @@ public static function createFromTimestamp($timestamp, $tz = null): self * * @return static */ - public static function createFromTimestampUTC($timestamp): self + public static function createFromTimestampUTC($timestamp): static { [$integer, $decimal] = self::getIntegerAndDecimalParts($timestamp); $delta = floor($decimal / static::MICROSECONDS_PER_SECOND); @@ -60,7 +60,7 @@ public static function createFromTimestampUTC($timestamp): self * * @return static */ - public static function createFromTimestampMsUTC($timestamp): self + public static function createFromTimestampMsUTC($timestamp): static { [$milliseconds, $microseconds] = self::getIntegerAndDecimalParts($timestamp, 3); $sign = $milliseconds < 0 || $milliseconds === 0.0 && $microseconds < 0 ? -1 : 1; @@ -85,7 +85,7 @@ public static function createFromTimestampMsUTC($timestamp): self * * @return static */ - public static function createFromTimestampMs($timestamp, $tz = null): self + public static function createFromTimestampMs($timestamp, $tz = null): static { return static::createFromTimestampMsUTC($timestamp) ->setTimezone($tz); @@ -100,7 +100,7 @@ public static function createFromTimestampMs($timestamp, $tz = null): self * * @return static */ - public function timestamp($unixTimestamp): self + public function timestamp($unixTimestamp): static { return $this->setTimestamp($unixTimestamp); } diff --git a/src/Carbon/Traits/Units.php b/src/Carbon/Traits/Units.php index b49807779f..d8c6d1f530 100644 --- a/src/Carbon/Traits/Units.php +++ b/src/Carbon/Traits/Units.php @@ -36,7 +36,7 @@ trait Units * * @return static */ - public function addRealUnit(string $unit, $value = 1): self + public function addRealUnit(string $unit, $value = 1): static { switch ($unit) { // @call addRealUnit @@ -151,7 +151,7 @@ public function addRealUnit(string $unit, $value = 1): self * * @return static */ - public function subRealUnit($unit, $value = 1): self + public function subRealUnit($unit, $value = 1): static { return $this->addRealUnit($unit, -$value); } @@ -190,7 +190,7 @@ public static function isModifiableUnit($unit): bool * * @return static */ - public function rawAdd(DateInterval $interval): self + public function rawAdd(DateInterval $interval): static { return parent::add($interval); } @@ -209,7 +209,7 @@ public function rawAdd(DateInterval $interval): self * @return static */ #[ReturnTypeWillChange] - public function add($unit, $value = 1, ?bool $overflow = null): self + public function add($unit, $value = 1, ?bool $overflow = null): static { if (\is_string($unit) && \func_num_args() === 1) { $unit = CarbonInterval::make($unit); @@ -243,7 +243,7 @@ public function add($unit, $value = 1, ?bool $overflow = null): self * * @return static */ - public function addUnit(string $unit, $value = 1, ?bool $overflow = null): self + public function addUnit(string $unit, $value = 1, ?bool $overflow = null): static { $date = $this; @@ -333,7 +333,7 @@ public function addUnit(string $unit, $value = 1, ?bool $overflow = null): self * * @return static */ - public function subUnit(string $unit, $value = 1, ?bool $overflow = null): self + public function subUnit(string $unit, $value = 1, ?bool $overflow = null): static { return $this->addUnit($unit, -$value, $overflow); } @@ -345,7 +345,7 @@ public function subUnit(string $unit, $value = 1, ?bool $overflow = null): self * * @return static */ - public function rawSub(DateInterval $interval): self + public function rawSub(DateInterval $interval): static { return parent::sub($interval); } @@ -364,7 +364,7 @@ public function rawSub(DateInterval $interval): self * @return static */ #[ReturnTypeWillChange] - public function sub($unit, $value = 1, ?bool $overflow = null): self + public function sub($unit, $value = 1, ?bool $overflow = null): static { if (\is_string($unit) && \func_num_args() === 1) { $unit = CarbonInterval::make($unit); @@ -400,7 +400,7 @@ public function sub($unit, $value = 1, ?bool $overflow = null): self * * @return static */ - public function subtract($unit, $value = 1, ?bool $overflow = null): self + public function subtract($unit, $value = 1, ?bool $overflow = null): static { if (\is_string($unit) && \func_num_args() === 1) { $unit = CarbonInterval::make($unit); diff --git a/tests/Carbon/IsTest.php b/tests/Carbon/IsTest.php index c369ee1721..8a2abc6536 100644 --- a/tests/Carbon/IsTest.php +++ b/tests/Carbon/IsTest.php @@ -605,6 +605,7 @@ public function testIsCurrentSecondFalse() $this->assertFalse(Carbon::now()->subDay()->isCurrentSecond()); } + /** @group i */ public function testIsSameMicrosecond() { $current = new Carbon('2018-05-06T13:30:54.123456'); diff --git a/tests/CarbonPeriod/Fixtures/AbstractCarbon.php b/tests/CarbonPeriod/Fixtures/AbstractCarbon.php index ad3dcc9eba..0913f2bba6 100644 --- a/tests/CarbonPeriod/Fixtures/AbstractCarbon.php +++ b/tests/CarbonPeriod/Fixtures/AbstractCarbon.php @@ -25,7 +25,7 @@ public function __construct($time = null, $tz = null) parent::__construct($time, $tz); } - public static function __set_state($dump): self + public static function __set_state($dump): static { return new static($dump); } diff --git a/tests/CarbonPeriod/SettersTest.php b/tests/CarbonPeriod/SettersTest.php index 123e50e7c8..5111339d5e 100644 --- a/tests/CarbonPeriod/SettersTest.php +++ b/tests/CarbonPeriod/SettersTest.php @@ -144,15 +144,6 @@ public function testEmptyInterval() CarbonPeriod::create()->setDateInterval(new DateInterval('P0D')); } - public function testInvalidNumberOfRecurrencesString() - { - $this->expectExceptionObject(new InvalidArgumentException( - 'Invalid number of recurrences.', - )); - - CarbonPeriod::create()->setRecurrences('foo'); - } - public function testInvalidNegativeNumberOfRecurrences() { $this->expectExceptionObject(new InvalidArgumentException( @@ -162,15 +153,6 @@ public function testInvalidNegativeNumberOfRecurrences() CarbonPeriod::create()->setRecurrences(-4); } - public function testInvalidOptions() - { - $this->expectExceptionObject(new InvalidArgumentException( - 'Invalid options.', - )); - - CarbonPeriod::create()->setOptions('1'); - } - public function testInvalidConstructorParameters() { $this->expectExceptionObject(new InvalidArgumentException( From cdd1c2d116051fcb67be69d6ae0f974cd8bbf4d1 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 4 Dec 2021 21:53:39 +0100 Subject: [PATCH 07/16] Fix __set_state test --- tests/CarbonImmutable/SetStateTest.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/CarbonImmutable/SetStateTest.php b/tests/CarbonImmutable/SetStateTest.php index 7343e4f7ec..99ee771373 100644 --- a/tests/CarbonImmutable/SetStateTest.php +++ b/tests/CarbonImmutable/SetStateTest.php @@ -19,14 +19,18 @@ class SetStateTest extends AbstractTestCase { - public function testSteState() + public function testSteState(): void { - $obj = new class() { + $obj = new class(null) { use Serialization; - public static function instance($value) + public function __construct(public mixed $data) { - return $value; + } + + public static function instance($value): static + { + return new static($value); } public function callSetState($value) @@ -37,7 +41,9 @@ public function callSetState($value) $data = $obj->callSetState(['foo' => 'bar']); - $this->assertInstanceOf(stdClass::class, $data); - $this->assertSame(['foo' => 'bar'], (array) $data); + $this->assertInstanceOf(get_class($obj), $data); + $this->assertInstanceOf(stdClass::class, $data->data); + $this->assertSame('bar', $data->data->foo); + $this->assertSame(['foo' => 'bar'], (array) $data->data); } } From 2f1ef6602f731517707051006379ff1c4e0ef26c Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 4 Dec 2021 22:00:19 +0100 Subject: [PATCH 08/16] Handle new fix for diff in PHP 8.1 --- phpmd.xml | 2 +- tests/Carbon/IsTest.php | 2 +- tests/Carbon/ModifyTest.php | 16 +++++++++------- tests/CarbonImmutable/ModifyTest.php | 16 +++++++++------- tests/CarbonInterval/AddTest.php | 1 + 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/phpmd.xml b/phpmd.xml index 32d62dcde1..8cd9c2264d 100644 --- a/phpmd.xml +++ b/phpmd.xml @@ -35,7 +35,7 @@ - + diff --git a/tests/Carbon/IsTest.php b/tests/Carbon/IsTest.php index 8a2abc6536..ddbd7613d8 100644 --- a/tests/Carbon/IsTest.php +++ b/tests/Carbon/IsTest.php @@ -605,7 +605,7 @@ public function testIsCurrentSecondFalse() $this->assertFalse(Carbon::now()->subDay()->isCurrentSecond()); } - /** @group i */ + /** @group php-8.1 */ public function testIsSameMicrosecond() { $current = new Carbon('2018-05-06T13:30:54.123456'); diff --git a/tests/Carbon/ModifyTest.php b/tests/Carbon/ModifyTest.php index ee46f1b234..8f0352712a 100644 --- a/tests/Carbon/ModifyTest.php +++ b/tests/Carbon/ModifyTest.php @@ -27,20 +27,22 @@ public function testSimpleModify() $this->assertSame(24.0, $a->diffInHours($b)); } + /** @group php-8.1 */ public function testTimezoneModify() { + $php81Fix = version_compare(PHP_VERSION, '8.1.0-dev', '>=') ? 1.0 : 0.0; // For daylight saving time reason 2014-03-30 0h59 is immediately followed by 2h00 $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->copy(); $b->addHours(24); - $this->assertSame(23.0, $a->diffInRealHours($b)); - $this->assertSame(23.0, $b->diffInRealHours($a, true)); - $this->assertSame(-23.0, $b->diffInRealHours($a)); - $this->assertSame(-23.0 * 60, $b->diffInRealMinutes($a)); - $this->assertSame(-23.0 * 60 * 60, $b->diffInRealSeconds($a)); - $this->assertSame(-23.0 * 60 * 60 * 1000, $b->diffInRealMilliseconds($a)); - $this->assertSame(-23.0 * 60 * 60 * 1000000, $b->diffInRealMicroseconds($a)); + $this->assertSame(23.0 + $php81Fix, $a->diffInRealHours($b)); + $this->assertSame(23.0 + $php81Fix, $b->diffInRealHours($a, true)); + $this->assertSame(-(23.0 + $php81Fix), $b->diffInRealHours($a)); + $this->assertSame(-(23.0 + $php81Fix) * 60, $b->diffInRealMinutes($a)); + $this->assertSame(-(23.0 + $php81Fix) * 60 * 60, $b->diffInRealSeconds($a)); + $this->assertSame(-(23.0 + $php81Fix) * 60 * 60 * 1000, $b->diffInRealMilliseconds($a)); + $this->assertSame(-(23.0 + $php81Fix) * 60 * 60 * 1000000, $b->diffInRealMicroseconds($a)); $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->copy(); diff --git a/tests/CarbonImmutable/ModifyTest.php b/tests/CarbonImmutable/ModifyTest.php index 5701989884..cfc1b6e6e7 100644 --- a/tests/CarbonImmutable/ModifyTest.php +++ b/tests/CarbonImmutable/ModifyTest.php @@ -25,19 +25,21 @@ public function testSimpleModify() $this->assertSame(24.0, $a->diffInHours($b)); } + /** @group php-8.1 */ public function testTimezoneModify() { + $php81Fix = version_compare(PHP_VERSION, '8.1.0-dev', '>=') ? 1.0 : 0.0; // For daylight saving time reason 2014-03-30 0h59 is immediately followed by 2h00 $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addHours(24); - $this->assertSame(23.0, $a->diffInHours($b)); - $this->assertSame(23.0, $b->diffInHours($a, true)); - $this->assertSame(-23.0, $b->diffInHours($a)); - $this->assertSame(-23.0 * 60, $b->diffInMinutes($a)); - $this->assertSame(-23.0 * 60 * 60, $b->diffInSeconds($a)); - $this->assertSame(-23.0 * 60 * 60 * 1000, $b->diffInMilliseconds($a)); - $this->assertSame(-23.0 * 60 * 60 * 1000000, $b->diffInMicroseconds($a)); + $this->assertSame(23.0 + $php81Fix, $a->diffInHours($b)); + $this->assertSame(23.0 + $php81Fix, $b->diffInHours($a, true)); + $this->assertSame(-23.0 - $php81Fix, $b->diffInHours($a)); + $this->assertSame(-(23.0 + $php81Fix) * 60, $b->diffInMinutes($a)); + $this->assertSame(-(23.0 + $php81Fix) * 60 * 60, $b->diffInSeconds($a)); + $this->assertSame(-(23.0 + $php81Fix) * 60 * 60 * 1000, $b->diffInMilliseconds($a)); + $this->assertSame(-(23.0 + $php81Fix) * 60 * 60 * 1000000, $b->diffInMicroseconds($a)); $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addRealHours(24); diff --git a/tests/CarbonInterval/AddTest.php b/tests/CarbonInterval/AddTest.php index 87357317a3..c7f83480e0 100644 --- a/tests/CarbonInterval/AddTest.php +++ b/tests/CarbonInterval/AddTest.php @@ -44,6 +44,7 @@ public function testAddWithNegativeDiffDateInterval() $this->assertCarbonInterval($ci, 4, 3, 28, 8, 10, 11); } + /** @group php-8.1 */ public function testAddMicroseconds() { $diff = Carbon::now()->diff(Carbon::now()->addDays(3)->addMicroseconds(111222)); From 523bac63ae603f11176205bfb34ea9f6cd9dbf5d Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 4 Dec 2021 22:41:13 +0100 Subject: [PATCH 09/16] Update CarbonInterface --- phpstan.neon | 3 +- src/Carbon/CarbonInterface.php | 40 +++++++++---------- src/Carbon/Traits/Creator.php | 2 +- src/Carbon/Traits/Date.php | 2 +- tests/Carbon/IsTest.php | 8 +++- tests/CarbonImmutable/SetStateTest.php | 2 +- .../CarbonPeriod/Fixtures/AbstractCarbon.php | 4 +- 7 files changed, 34 insertions(+), 27 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 5f58ff2a74..12c3b35ba6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -15,17 +15,18 @@ parameters: - '#^Call to an undefined method Carbon\\Carbon(Interface|Immutable)?::(super|noThis)\(\)\.$#' - '#Call to an undefined method DateTimeInterface::setTimezone\(\)\.#' - '#should return (\S*)static\(Carbon\\CarbonInterval\)\|null but returns Carbon\\CarbonInterval(\|null)?\.$#' - - '#should return (\S*)\$this\(Carbon\\CarbonInterval\) but returns Carbon\\CarbonInterval\.$#' # - '#should return (\S*)static\(Carbon\\CarbonPeriod\) but returns Carbon\\CarbonPeriod\.$#' - '#should return (\S*)static\(Carbon\\Carbon\) but returns Carbon\\Carbon(Interface)?\.$#' - '#should return (\S*)static\(Carbon\\CarbonImmutable\) but returns Carbon\\Carbon(Immutable|Interface)\.$#' - '#should return (\S*)static\(Carbon\\CarbonImmutable\)\|null but returns Carbon\\Carbon(Immutable|Interface)\|null\.$#' + - '#^PHPDoc tag @return with type Carbon\\CarbonTimeZone is not subtype of native type static\(Carbon\\CarbonTimeZone\)\.$#' - '#^PHPDoc tag @mixin contains invalid type Carbon\\Traits\\DeprecatedProperties\.$#' - '#^Implementing PHPStan\\Reflection\\Php\\BuiltinMethodReflection is not covered by backward compatibility promise\.#' - '#^Calling PHPStan\\Reflection\\Php\\PhpMethodReflectionFactory::create\(\) is not covered by backward compatibility promise\.#' # - '#^Protected property Carbon\\CarbonPeriod::\$.+ overriding public property DatePeriod::\$.+ should also be public\.$#' - '#^Method Carbon\\CarbonInterval::withOriginal\(\) should return T but returns \(Carbon\\CarbonInterval&T\)\|T\.$#' - '#^Method Carbon\\CarbonInterval::castIntervalToClass\(\) should return T of DateInterval but returns \(Carbon\CarbonInterval&T of DateInterval\)|T of DateInterval\.$#' + - '#^Method Carbon\\CarbonInterval::[a-zA-Z]+\(\) should return \$this\(Carbon\\CarbonInterval\) but returns static\(Carbon\\CarbonInterval\)\.#' excludePaths: - '*/src/Carbon/CarbonPeriod.php' - '*/src/Carbon/Laravel/ServiceProvider.php' diff --git a/src/Carbon/CarbonInterface.php b/src/Carbon/CarbonInterface.php index 4ab3f4526a..03da9c3fd7 100644 --- a/src/Carbon/CarbonInterface.php +++ b/src/Carbon/CarbonInterface.php @@ -728,7 +728,7 @@ public function __set($name, $value); * @return static */ #[ReturnTypeWillChange] - public static function __set_state($dump); + public static function __set_state($dump): static; /** * Returns the list of properties to dump on serialize() called on. @@ -763,7 +763,7 @@ public function __toString(); * @return static */ #[ReturnTypeWillChange] - public function add($unit, $value = 1, ?bool $overflow = null); + public function add($unit, $value = 1, ?bool $overflow = null): static; /** * Add seconds to the instance using timestamp. Positive $value travels @@ -774,7 +774,7 @@ public function add($unit, $value = 1, ?bool $overflow = null); * * @return static */ - public function addRealUnit(string $unit, $value = 1); + public function addRealUnit(string $unit, $value = 1): static; /** * Add given units to the current instance. @@ -785,7 +785,7 @@ public function addRealUnit(string $unit, $value = 1); * * @return static */ - public function addUnit(string $unit, $value = 1, ?bool $overflow = null); + public function addUnit(string $unit, $value = 1, ?bool $overflow = null): static; /** * Add any unit to a new value without overflowing current other unit given. @@ -846,7 +846,7 @@ public function average($date = null); * * @return static */ - public function avoidMutation(); + public function avoidMutation(): static; /** * Determines if the instance is between two others. @@ -1166,7 +1166,7 @@ public static function createFromTimeString($time, $tz = null); * * @return static */ - public static function createFromTimestamp($timestamp, $tz = null); + public static function createFromTimestamp($timestamp, $tz = null): static; /** * Create a Carbon instance from a timestamp in milliseconds. @@ -1178,7 +1178,7 @@ public static function createFromTimestamp($timestamp, $tz = null); * * @return static */ - public static function createFromTimestampMs($timestamp, $tz = null); + public static function createFromTimestampMs($timestamp, $tz = null): static; /** * Create a Carbon instance from a timestamp in milliseconds. @@ -1189,7 +1189,7 @@ public static function createFromTimestampMs($timestamp, $tz = null); * * @return static */ - public static function createFromTimestampMsUTC($timestamp); + public static function createFromTimestampMsUTC($timestamp): static; /** * Create a Carbon instance from an timestamp keeping the timezone to UTC. @@ -1200,7 +1200,7 @@ public static function createFromTimestampMsUTC($timestamp); * * @return static */ - public static function createFromTimestampUTC($timestamp); + public static function createFromTimestampUTC($timestamp): static; /** * Create a Carbon instance from just a date. The time portion is set to midnight. @@ -1262,7 +1262,7 @@ public static function createSafe($year = null, $month = null, $day = null, $hou * * @return static */ - public static function createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null); + public static function createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null): static; /** * Get/set the day of year. @@ -2369,7 +2369,7 @@ public static function hasTestNow(); * * @return static */ - public static function instance($date); + public static function instance($date): static; /** * Returns true if the current date matches the given string. @@ -3258,7 +3258,7 @@ public static function now($tz = null); * * @return static */ - public function nowWithSameTz(); + public function nowWithSameTz(): static; /** * Modify to the given occurrence of a given day of the week @@ -3392,7 +3392,7 @@ public function range($end = null, $interval = null, $unit = null); * * @return static */ - public function rawAdd(DateInterval $interval); + public function rawAdd(DateInterval $interval): static; /** * Create a Carbon instance from a specific format. @@ -3439,7 +3439,7 @@ public static function rawParse($time = null, $tz = null); * * @return static */ - public function rawSub(DateInterval $interval); + public function rawSub(DateInterval $interval): static; /** * Remove all macros and generic macros. @@ -3868,7 +3868,7 @@ public static function setWeekendDays($days); * * @return $this|static */ - public function settings(array $settings); + public function settings(array $settings): static; /** * Set the instance's timezone from a string or object and add/subtract the offset difference. @@ -4079,7 +4079,7 @@ public function startOfYear(); * @return static */ #[ReturnTypeWillChange] - public function sub($unit, $value = 1, ?bool $overflow = null); + public function sub($unit, $value = 1, ?bool $overflow = null): static; /** * Subtract seconds to the instance using timestamp. Positive $value travels @@ -4090,7 +4090,7 @@ public function sub($unit, $value = 1, ?bool $overflow = null); * * @return static */ - public function subRealUnit($unit, $value = 1); + public function subRealUnit($unit, $value = 1): static; /** * Subtract given units to the current instance. @@ -4101,7 +4101,7 @@ public function subRealUnit($unit, $value = 1); * * @return static */ - public function subUnit(string $unit, $value = 1, ?bool $overflow = null); + public function subUnit(string $unit, $value = 1, ?bool $overflow = null): static; /** * Subtract any unit to a new value without overflowing current other unit given. @@ -4125,7 +4125,7 @@ public function subUnitNoOverflow($valueUnit, $value, $overflowUnit); * * @return static */ - public function subtract($unit, $value = 1, ?bool $overflow = null); + public function subtract($unit, $value = 1, ?bool $overflow = null): static; /** * Get the difference in a human readable format in the current locale from current instance to an other @@ -4144,7 +4144,7 @@ public function timespan($other = null, $timezone = null); * * @return static */ - public function timestamp($unixTimestamp); + public function timestamp($unixTimestamp): static; /** * @alias setTimezone diff --git a/src/Carbon/Traits/Creator.php b/src/Carbon/Traits/Creator.php index 2baf0f5523..4008eaabbb 100644 --- a/src/Carbon/Traits/Creator.php +++ b/src/Carbon/Traits/Creator.php @@ -62,7 +62,7 @@ public function __construct($time = null, $tz = null) $time = $this->constructTimezoneFromDateTime($time, $tz)->format('Y-m-d H:i:s.u'); } - if (is_string($time) && substr($time, 0, 1) === '@') { + if (\is_string($time) && substr($time, 0, 1) === '@') { $time = static::createFromTimestampUTC(substr($time, 1))->format('Y-m-d\TH:i:s.uP'); } diff --git a/src/Carbon/Traits/Date.php b/src/Carbon/Traits/Date.php index 5a65e4cc32..452e9c1019 100644 --- a/src/Carbon/Traits/Date.php +++ b/src/Carbon/Traits/Date.php @@ -2467,7 +2467,7 @@ public function __call($method, $parameters) $lowerUnit = strtolower(substr($unit, 6)); if (static::isModifiableUnit($lowerUnit)) { - return $this->copy()->addUnit($lowerUnit, $factor, false)->isSameUnit($lowerUnit, ...$parameters); + return $this->avoidMutation()->addUnit($lowerUnit, $factor, false)->isSameUnit($lowerUnit, ...$parameters); } } diff --git a/tests/Carbon/IsTest.php b/tests/Carbon/IsTest.php index ddbd7613d8..f392813b8a 100644 --- a/tests/Carbon/IsTest.php +++ b/tests/Carbon/IsTest.php @@ -605,7 +605,7 @@ public function testIsCurrentSecondFalse() $this->assertFalse(Carbon::now()->subDay()->isCurrentSecond()); } - /** @group php-8.1 */ + /** @group php-8.1b */ public function testIsSameMicrosecond() { $current = new Carbon('2018-05-06T13:30:54.123456'); @@ -617,6 +617,12 @@ public function testIsSameMicrosecond() $this->assertTrue(Carbon::now()->isCurrentMicrosecond()); $this->assertFalse(Carbon::now()->subMicrosecond()->isCurrentMicrosecond()); $this->assertFalse(Carbon::now()->isLastMicrosecond()); + $this->assertSame( + Carbon::now()->subMicrosecond()->avoidMutation()->addUnit('microsecond', 1, false) + ->format('Y-m-d H:i:s.u'), + Carbon::now() + ->format('Y-m-d H:i:s.u'), + ); $this->assertTrue(Carbon::now()->subMicrosecond()->isLastMicrosecond()); $this->assertFalse(Carbon::now()->isNextMicrosecond()); $this->assertTrue(Carbon::now()->addMicrosecond()->isNextMicrosecond()); diff --git a/tests/CarbonImmutable/SetStateTest.php b/tests/CarbonImmutable/SetStateTest.php index 99ee771373..b1f5233ea5 100644 --- a/tests/CarbonImmutable/SetStateTest.php +++ b/tests/CarbonImmutable/SetStateTest.php @@ -41,7 +41,7 @@ public function callSetState($value) $data = $obj->callSetState(['foo' => 'bar']); - $this->assertInstanceOf(get_class($obj), $data); + $this->assertInstanceOf(\get_class($obj), $data); $this->assertInstanceOf(stdClass::class, $data->data); $this->assertSame('bar', $data->data->foo); $this->assertSame(['foo' => 'bar'], (array) $data->data); diff --git a/tests/CarbonPeriod/Fixtures/AbstractCarbon.php b/tests/CarbonPeriod/Fixtures/AbstractCarbon.php index 0913f2bba6..6eb73d2b98 100644 --- a/tests/CarbonPeriod/Fixtures/AbstractCarbon.php +++ b/tests/CarbonPeriod/Fixtures/AbstractCarbon.php @@ -31,13 +31,13 @@ public static function __set_state($dump): static } #[ReturnTypeWillChange] - public function add($unit, $value = 1, $overflow = null) + public function add($unit, $value = 1, ?bool $overflow = null): static { return parent::add($unit); } #[ReturnTypeWillChange] - public function sub($unit, $value = 1, $overflow = null) + public function sub($unit, $value = 1, ?bool $overflow = null): static { return parent::sub($unit); } From d99c48bb20c3fbadfc7cd1779e96826988e1871c Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 4 Dec 2021 22:55:31 +0100 Subject: [PATCH 10/16] Fix time mocking with dataProvider --- src/Carbon/Traits/Test.php | 4 ++-- tests/Carbon/IsTest.php | 2 +- tests/CarbonPeriod/ToStringTest.php | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Carbon/Traits/Test.php b/src/Carbon/Traits/Test.php index d01392aabf..19a666e362 100644 --- a/src/Carbon/Traits/Test.php +++ b/src/Carbon/Traits/Test.php @@ -94,7 +94,7 @@ public static function setTestNowAndTimezone($testNow = null, $tz = null) if (!$useDateInstanceTimezone) { $now = static::getMockedTestNow(\func_num_args() === 1 ? null : $tz); - self::setDefaultTimezone($now->tzName, $now); + self::setDefaultTimezone($now?->tzName ?? null, $now); } } @@ -186,7 +186,7 @@ private static function setDefaultTimezone($timezone, DateTimeInterface $date = $success = false; try { - $success = date_default_timezone_set($timezone); + $success = date_default_timezone_set($timezone ?? 'UTC'); } catch (Throwable $exception) { $previous = $exception; } diff --git a/tests/Carbon/IsTest.php b/tests/Carbon/IsTest.php index f392813b8a..78e552b620 100644 --- a/tests/Carbon/IsTest.php +++ b/tests/Carbon/IsTest.php @@ -605,7 +605,7 @@ public function testIsCurrentSecondFalse() $this->assertFalse(Carbon::now()->subDay()->isCurrentSecond()); } - /** @group php-8.1b */ + /** @group php-8.1 */ public function testIsSameMicrosecond() { $current = new Carbon('2018-05-06T13:30:54.123456'); diff --git a/tests/CarbonPeriod/ToStringTest.php b/tests/CarbonPeriod/ToStringTest.php index 63831b4114..ac6475d43c 100644 --- a/tests/CarbonPeriod/ToStringTest.php +++ b/tests/CarbonPeriod/ToStringTest.php @@ -27,6 +27,8 @@ class ToStringTest extends AbstractTestCase */ public function testToString($period, $expected) { + Carbon::setTestNowAndTimezone(new Carbon('2015-09-01', 'America/Toronto')); + $this->assertSame( $expected, $period->toString(), @@ -72,6 +74,8 @@ public static function dataForToString(): Generator CarbonPeriod::create('2015-10-01', '2015-10-05', 'PT30M'), 'Every 30 minutes from 2015-10-01 to 2015-10-05', ]; + + Carbon::setTestNowAndTimezone(); } public function testMagicToString() @@ -93,6 +97,8 @@ public function testMagicToString() */ public function testToIso8601String($period, $expected) { + Carbon::setTestNowAndTimezone(new Carbon('2015-09-01', 'America/Toronto')); + $this->assertSame( $expected, $period->toIso8601String(), @@ -133,6 +139,8 @@ public static function dataForToIso8601String(): Generator CarbonPeriod::create(), '2015-09-01T00:00:00-04:00/P1D', ]; + + Carbon::setTestNowAndTimezone(); } public function testSpec() From 32eb7673e3de12835672a8aeab9f091b98e4d59d Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 4 Dec 2021 22:59:40 +0100 Subject: [PATCH 11/16] Mock time for testIsSameMicrosecond --- tests/Carbon/IsTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Carbon/IsTest.php b/tests/Carbon/IsTest.php index 78e552b620..4eec6cd498 100644 --- a/tests/Carbon/IsTest.php +++ b/tests/Carbon/IsTest.php @@ -608,6 +608,8 @@ public function testIsCurrentSecondFalse() /** @group php-8.1 */ public function testIsSameMicrosecond() { + Carbon::setTestNow('now'); + $current = new Carbon('2018-05-06T13:30:54.123456'); $this->assertTrue($current->isSameMicrosecond(new DateTime('2018-05-06T13:30:54.123456'))); $this->assertFalse($current->isSameMicrosecond(new DateTime('2018-05-06T13:30:54.123457'))); From 3c77a1233e1e9886a233a3f4d939f27e95b7e1d3 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sun, 5 Dec 2021 18:36:48 +0100 Subject: [PATCH 12/16] Rollback add using intervals --- src/Carbon/Traits/Units.php | 33 ++++++++++++++++++++++++-------- tests/Carbon/IsTest.php | 8 -------- tests/CarbonImmutable/IsTest.php | 19 ++++++++++++++++++ 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/Carbon/Traits/Units.php b/src/Carbon/Traits/Units.php index d8c6d1f530..1a3af9b6ea 100644 --- a/src/Carbon/Traits/Units.php +++ b/src/Carbon/Traits/Units.php @@ -192,6 +192,21 @@ public static function isModifiableUnit($unit): bool */ public function rawAdd(DateInterval $interval): static { + if (isset($GLOBALS['debug']) && !isset($GLOBALS['nested'])) { + $GLOBALS['nested'] = true; + echo "DEBUG " . __LINE__ . "\n"; + $d = new static($this->format('Y-m-d H:i:s.u'), $this->getTimezone()); + var_dump($this->format('Y-m-d H:i:s.u')); + var_dump($d->format('Y-m-d H:i:s.u')); + echo "\n\n"; + var_dump($d); + echo "\n\n"; + var_dump($this); + echo "\n\n"; + var_dump($d->add($interval)->format('Y-m-d H:i:s.u')); + var_dump(parent::add($interval)->format('Y-m-d H:i:s.u')); + exit; + } return parent::add($interval); } @@ -294,7 +309,8 @@ public function addUnit(string $unit, $value = 1, ?bool $overflow = null): stati $overflow === null && ($ucUnit = ucfirst($unit).'s') && !($this->{'local'.$ucUnit.'Overflow'} ?? static::{'shouldOverflow'.$ucUnit}()) - ))) { + )) + ) { $day = $date->day; } @@ -303,13 +319,14 @@ public function addUnit(string $unit, $value = 1, ?bool $overflow = null): stati $value *= static::MICROSECONDS_PER_MILLISECOND; } - try { - $date = $date->rawAdd( - CarbonInterval::fromString(abs($value)." $unit")->invert($value < 0), - ); - } catch (InvalidIntervalException $exception) { - $date = $date->modify("$value $unit"); - } + $date = $date->modify("$value $unit"); +// try { +// $date = $date->rawAdd( +// CarbonInterval::fromString(abs($value)." $unit")->invert($value < 0), +// ); +// } catch (InvalidIntervalException $exception) { +// $date = $date->modify("$value $unit"); +// } if (isset($timeString)) { $date = $date->setTimeFromTimeString($timeString); diff --git a/tests/Carbon/IsTest.php b/tests/Carbon/IsTest.php index 4eec6cd498..ddbd7613d8 100644 --- a/tests/Carbon/IsTest.php +++ b/tests/Carbon/IsTest.php @@ -608,8 +608,6 @@ public function testIsCurrentSecondFalse() /** @group php-8.1 */ public function testIsSameMicrosecond() { - Carbon::setTestNow('now'); - $current = new Carbon('2018-05-06T13:30:54.123456'); $this->assertTrue($current->isSameMicrosecond(new DateTime('2018-05-06T13:30:54.123456'))); $this->assertFalse($current->isSameMicrosecond(new DateTime('2018-05-06T13:30:54.123457'))); @@ -619,12 +617,6 @@ public function testIsSameMicrosecond() $this->assertTrue(Carbon::now()->isCurrentMicrosecond()); $this->assertFalse(Carbon::now()->subMicrosecond()->isCurrentMicrosecond()); $this->assertFalse(Carbon::now()->isLastMicrosecond()); - $this->assertSame( - Carbon::now()->subMicrosecond()->avoidMutation()->addUnit('microsecond', 1, false) - ->format('Y-m-d H:i:s.u'), - Carbon::now() - ->format('Y-m-d H:i:s.u'), - ); $this->assertTrue(Carbon::now()->subMicrosecond()->isLastMicrosecond()); $this->assertFalse(Carbon::now()->isNextMicrosecond()); $this->assertTrue(Carbon::now()->addMicrosecond()->isNextMicrosecond()); diff --git a/tests/CarbonImmutable/IsTest.php b/tests/CarbonImmutable/IsTest.php index b0783c35ab..800e10de72 100644 --- a/tests/CarbonImmutable/IsTest.php +++ b/tests/CarbonImmutable/IsTest.php @@ -634,6 +634,25 @@ public function testIsCurrentSecondFalse() $this->assertFalse(Carbon::now()->subDay()->isCurrentSecond()); } + /** @group php-8.1 */ + public function testIsSameMicrosecond() + { + $current = new Carbon('2018-05-06T13:30:54.123456'); + $this->assertTrue($current->isSameMicrosecond(new DateTime('2018-05-06T13:30:54.123456'))); + $this->assertFalse($current->isSameMicrosecond(new DateTime('2018-05-06T13:30:54.123457'))); + $this->assertFalse($current->isSameMicrosecond(new DateTime('2019-05-06T13:30:54.123456'))); + $this->assertFalse($current->isSameMicrosecond(new DateTime('2018-05-06T13:30:55.123456'))); + $this->assertTrue($current->isSameSecond($current->copy())); + $this->assertTrue(Carbon::now()->isCurrentMicrosecond()); + $this->assertFalse(Carbon::now()->subMicrosecond()->isCurrentMicrosecond()); + $this->assertFalse(Carbon::now()->isLastMicrosecond()); + $this->assertTrue(Carbon::now()->subMicrosecond()->isLastMicrosecond()); + $this->assertFalse(Carbon::now()->isNextMicrosecond()); + $this->assertTrue(Carbon::now()->addMicrosecond()->isNextMicrosecond()); + $this->assertTrue(Carbon::now()->subMicroseconds(Carbon::MICROSECONDS_PER_SECOND)->isLastSecond()); + $this->assertSame(4.0, Carbon::now()->subMicroseconds(4 * Carbon::MICROSECONDS_PER_SECOND)->diffInSeconds(Carbon::now())); + } + public function testIsDayOfWeek() { // True in the past past From 12ce3f4488e6f352b0d31ed2ed734fbf076b621a Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sun, 5 Dec 2021 19:12:34 +0100 Subject: [PATCH 13/16] Exclude microsecond in PHP 8.1 from interval calculation --- .../Exceptions/UnsupportedUnitException.php | 22 ++++++++++++ src/Carbon/Traits/Units.php | 35 +++++++------------ 2 files changed, 34 insertions(+), 23 deletions(-) create mode 100644 src/Carbon/Exceptions/UnsupportedUnitException.php diff --git a/src/Carbon/Exceptions/UnsupportedUnitException.php b/src/Carbon/Exceptions/UnsupportedUnitException.php new file mode 100644 index 0000000000..9fc09d2a19 --- /dev/null +++ b/src/Carbon/Exceptions/UnsupportedUnitException.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon\Exceptions; + +use Exception; + +class UnsupportedUnitException extends UnitException +{ + public function __construct(string $unit, string $phpVersion, int $code = 0, Exception $previous = null) + { + parent::__construct("Unsupported unit '$unit' on PHP >= $phpVersion.", $code, $previous); + } +} diff --git a/src/Carbon/Traits/Units.php b/src/Carbon/Traits/Units.php index 1a3af9b6ea..dec887d139 100644 --- a/src/Carbon/Traits/Units.php +++ b/src/Carbon/Traits/Units.php @@ -16,6 +16,7 @@ use Carbon\CarbonInterval; use Carbon\Exceptions\InvalidIntervalException; use Carbon\Exceptions\UnitException; +use Carbon\Exceptions\UnsupportedUnitException; use Closure; use DateInterval; use ReturnTypeWillChange; @@ -192,21 +193,6 @@ public static function isModifiableUnit($unit): bool */ public function rawAdd(DateInterval $interval): static { - if (isset($GLOBALS['debug']) && !isset($GLOBALS['nested'])) { - $GLOBALS['nested'] = true; - echo "DEBUG " . __LINE__ . "\n"; - $d = new static($this->format('Y-m-d H:i:s.u'), $this->getTimezone()); - var_dump($this->format('Y-m-d H:i:s.u')); - var_dump($d->format('Y-m-d H:i:s.u')); - echo "\n\n"; - var_dump($d); - echo "\n\n"; - var_dump($this); - echo "\n\n"; - var_dump($d->add($interval)->format('Y-m-d H:i:s.u')); - var_dump(parent::add($interval)->format('Y-m-d H:i:s.u')); - exit; - } return parent::add($interval); } @@ -319,14 +305,17 @@ public function addUnit(string $unit, $value = 1, ?bool $overflow = null): stati $value *= static::MICROSECONDS_PER_MILLISECOND; } - $date = $date->modify("$value $unit"); -// try { -// $date = $date->rawAdd( -// CarbonInterval::fromString(abs($value)." $unit")->invert($value < 0), -// ); -// } catch (InvalidIntervalException $exception) { -// $date = $date->modify("$value $unit"); -// } + try { + if ($unit === 'microsecond' && version_compare(PHP_VERSION, '8.1.0-dev', '>=')) { + throw new UnsupportedUnitException($unit, '8.1'); + } + + $date = $date->rawAdd( + CarbonInterval::fromString(abs($value)." $unit")->invert($value < 0), + ); + } catch (InvalidIntervalException|UnsupportedUnitException $exception) { + $date = $date->modify("$value $unit"); + } if (isset($timeString)) { $date = $date->setTimeFromTimeString($timeString); From 973534830d2cb45e52bb69b2201f5e4decf7b95c Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sun, 5 Dec 2021 19:42:09 +0100 Subject: [PATCH 14/16] Extract add/sub logic --- .../Exceptions/UnsupportedUnitException.php | 3 ++ src/Carbon/Traits/Units.php | 28 +++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Carbon/Exceptions/UnsupportedUnitException.php b/src/Carbon/Exceptions/UnsupportedUnitException.php index 9fc09d2a19..8818015989 100644 --- a/src/Carbon/Exceptions/UnsupportedUnitException.php +++ b/src/Carbon/Exceptions/UnsupportedUnitException.php @@ -13,6 +13,9 @@ use Exception; +/** + * @codeCoverageIgnore + */ class UnsupportedUnitException extends UnitException { public function __construct(string $unit, string $phpVersion, int $code = 0, Exception $previous = null) diff --git a/src/Carbon/Traits/Units.php b/src/Carbon/Traits/Units.php index dec887d139..03ff15e663 100644 --- a/src/Carbon/Traits/Units.php +++ b/src/Carbon/Traits/Units.php @@ -305,17 +305,7 @@ public function addUnit(string $unit, $value = 1, ?bool $overflow = null): stati $value *= static::MICROSECONDS_PER_MILLISECOND; } - try { - if ($unit === 'microsecond' && version_compare(PHP_VERSION, '8.1.0-dev', '>=')) { - throw new UnsupportedUnitException($unit, '8.1'); - } - - $date = $date->rawAdd( - CarbonInterval::fromString(abs($value)." $unit")->invert($value < 0), - ); - } catch (InvalidIntervalException|UnsupportedUnitException $exception) { - $date = $date->modify("$value $unit"); - } + $date = self::rawAddUnit($date, $unit, $value); if (isset($timeString)) { $date = $date->setTimeFromTimeString($timeString); @@ -414,4 +404,20 @@ public function subtract($unit, $value = 1, ?bool $overflow = null): static return $this->sub($unit, $value, $overflow); } + + private static function rawAddUnit(self $date, string $unit, int|float $value): static + { + try { + + if ($unit === 'microsecond' && version_compare(PHP_VERSION, '8.1.0-dev', '>=')) { + throw new UnsupportedUnitException($unit, '8.1'); // @codeCoverageIgnore + } + + return $date->rawAdd( + CarbonInterval::fromString(abs($value)." $unit")->invert($value < 0), + ); + } catch (InvalidIntervalException|UnsupportedUnitException) { + return $date->modify("$value $unit"); + } + } } From b6e0b24272c4cfe466a842b0dd2c89f2ba59bebc Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sun, 5 Dec 2021 21:39:41 +0100 Subject: [PATCH 15/16] Handle modify() return as null --- src/Carbon/Traits/Units.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Carbon/Traits/Units.php b/src/Carbon/Traits/Units.php index 03ff15e663..a3ffbb7bc8 100644 --- a/src/Carbon/Traits/Units.php +++ b/src/Carbon/Traits/Units.php @@ -308,9 +308,9 @@ public function addUnit(string $unit, $value = 1, ?bool $overflow = null): stati $date = self::rawAddUnit($date, $unit, $value); if (isset($timeString)) { - $date = $date->setTimeFromTimeString($timeString); - } elseif (isset($canOverflow, $day) && $canOverflow && $day !== $date->day) { - $date = $date->modify('last day of previous month'); + $date = $date?->setTimeFromTimeString($timeString); + } elseif (isset($canOverflow, $day) && $canOverflow && $day !== $date?->day) { + $date = $date?->modify('last day of previous month'); } if (!$date) { @@ -405,7 +405,7 @@ public function subtract($unit, $value = 1, ?bool $overflow = null): static return $this->sub($unit, $value, $overflow); } - private static function rawAddUnit(self $date, string $unit, int|float $value): static + private static function rawAddUnit(self $date, string $unit, int|float $value): ?static { try { @@ -417,7 +417,7 @@ private static function rawAddUnit(self $date, string $unit, int|float $value): CarbonInterval::fromString(abs($value)." $unit")->invert($value < 0), ); } catch (InvalidIntervalException|UnsupportedUnitException) { - return $date->modify("$value $unit"); + return $date->modify("$value $unit") ?: null; } } } From cb20bc3cc51e900ad2ffc9d7306a33591b40a524 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sun, 5 Dec 2021 22:00:15 +0100 Subject: [PATCH 16/16] Fix PHPStan exceptions --- phpstan.neon | 5 ++--- src/Carbon/CarbonInterval.php | 2 ++ src/Carbon/Traits/Units.php | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 12c3b35ba6..5eac32e9ac 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -16,9 +16,8 @@ parameters: - '#Call to an undefined method DateTimeInterface::setTimezone\(\)\.#' - '#should return (\S*)static\(Carbon\\CarbonInterval\)\|null but returns Carbon\\CarbonInterval(\|null)?\.$#' # - '#should return (\S*)static\(Carbon\\CarbonPeriod\) but returns Carbon\\CarbonPeriod\.$#' - - '#should return (\S*)static\(Carbon\\Carbon\) but returns Carbon\\Carbon(Interface)?\.$#' - - '#should return (\S*)static\(Carbon\\CarbonImmutable\) but returns Carbon\\Carbon(Immutable|Interface)\.$#' - - '#should return (\S*)static\(Carbon\\CarbonImmutable\)\|null but returns Carbon\\Carbon(Immutable|Interface)\|null\.$#' + - '#should return (\S*)static\(Carbon\\Carbon\)(\|null)? but returns Carbon\\Carbon(Interface)?(\|null)?\.$#' + - '#should return (\S*)static\(Carbon\\CarbonImmutable\)(\|null)? but returns Carbon\\Carbon(Immutable|Interface)(\|null)?\.$#' - '#^PHPDoc tag @return with type Carbon\\CarbonTimeZone is not subtype of native type static\(Carbon\\CarbonTimeZone\)\.$#' - '#^PHPDoc tag @mixin contains invalid type Carbon\\Traits\\DeprecatedProperties\.$#' - '#^Implementing PHPStan\\Reflection\\Php\\BuiltinMethodReflection is not covered by backward compatibility promise\.#' diff --git a/src/Carbon/CarbonInterval.php b/src/Carbon/CarbonInterval.php index 7cd7f2835f..cf5c6c2239 100644 --- a/src/Carbon/CarbonInterval.php +++ b/src/Carbon/CarbonInterval.php @@ -802,6 +802,8 @@ protected static function this(): static * * @param string $intervalDefinition * + * @throws InvalidIntervalException + * * @return static */ public static function fromString(string $intervalDefinition): static diff --git a/src/Carbon/Traits/Units.php b/src/Carbon/Traits/Units.php index a3ffbb7bc8..4494419c4c 100644 --- a/src/Carbon/Traits/Units.php +++ b/src/Carbon/Traits/Units.php @@ -408,7 +408,6 @@ public function subtract($unit, $value = 1, ?bool $overflow = null): static private static function rawAddUnit(self $date, string $unit, int|float $value): ?static { try { - if ($unit === 'microsecond' && version_compare(PHP_VERSION, '8.1.0-dev', '>=')) { throw new UnsupportedUnitException($unit, '8.1'); // @codeCoverageIgnore }