From d6f5afbe807670ae002f32c73c64b5c14ac00229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20=C3=87al=C4=B1=C5=9Fkan?= Date: Wed, 8 Jan 2025 13:08:10 +0300 Subject: [PATCH 1/9] Added PHP 8.4 support --- src/Carbon/CarbonTimeZone.php | 8 ++++---- src/Carbon/Traits/Date.php | 6 +++--- src/Carbon/Traits/Localization.php | 2 +- src/Carbon/Traits/Test.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Carbon/CarbonTimeZone.php b/src/Carbon/CarbonTimeZone.php index c81899f1ea..c423da7049 100644 --- a/src/Carbon/CarbonTimeZone.php +++ b/src/Carbon/CarbonTimeZone.php @@ -155,7 +155,7 @@ public function getAbbr($dst = false) * * @return string */ - public function toOffsetName(DateTimeInterface $date = null) + public function toOffsetName(?DateTimeInterface $date = null) { return static::getOffsetNameFromMinuteOffset( $this->getOffset($date ?: Carbon::now($this)) / 60 @@ -169,7 +169,7 @@ public function toOffsetName(DateTimeInterface $date = null) * * @return CarbonTimeZone */ - public function toOffsetTimeZone(DateTimeInterface $date = null) + public function toOffsetTimeZone(?DateTimeInterface $date = null) { return new static($this->toOffsetName($date)); } @@ -185,7 +185,7 @@ public function toOffsetTimeZone(DateTimeInterface $date = null) * * @return string|false */ - public function toRegionName(DateTimeInterface $date = null, $isDst = 1) + public function toRegionName(?DateTimeInterface $date = null, $isDst = 1) { $name = $this->getName(); $firstChar = substr($name, 0, 1); @@ -227,7 +227,7 @@ public function toRegionName(DateTimeInterface $date = null, $isDst = 1) * * @return CarbonTimeZone|false */ - public function toRegionTimeZone(DateTimeInterface $date = null) + public function toRegionTimeZone(?DateTimeInterface $date = null) { $tz = $this->toRegionName($date); diff --git a/src/Carbon/Traits/Date.php b/src/Carbon/Traits/Date.php index 8ae5c17819..75ee1f837e 100644 --- a/src/Carbon/Traits/Date.php +++ b/src/Carbon/Traits/Date.php @@ -1391,7 +1391,7 @@ public function isoWeekday($value = null) * * @return int */ - public function getDaysFromStartOfWeek(int $weekStartsAt = null): int + public function getDaysFromStartOfWeek(?int $weekStartsAt = null): int { $firstDay = (int) ($weekStartsAt ?? $this->getTranslationMessage('first_day_of_week') ?? 0); @@ -1409,7 +1409,7 @@ public function getDaysFromStartOfWeek(int $weekStartsAt = null): int * * @return static */ - public function setDaysFromStartOfWeek(int $numberOfDays, int $weekStartsAt = null) + public function setDaysFromStartOfWeek(int $numberOfDays, ?int $weekStartsAt = null) { return $this->addDays($numberOfDays - $this->getDaysFromStartOfWeek($weekStartsAt)); } @@ -1478,7 +1478,7 @@ public function subUnitNoOverflow($valueUnit, $value, $overflowUnit) * * @return int|static */ - public function utcOffset(int $minuteOffset = null) + public function utcOffset(?int $minuteOffset = null) { if (\func_num_args() < 1) { return $this->offsetMinutes; diff --git a/src/Carbon/Traits/Localization.php b/src/Carbon/Traits/Localization.php index 46aff113e5..0e9078106a 100644 --- a/src/Carbon/Traits/Localization.php +++ b/src/Carbon/Traits/Localization.php @@ -444,7 +444,7 @@ public function translateTimeStringTo($timeString, $to = null) * * @return $this|string */ - public function locale(string $locale = null, ...$fallbackLocales) + public function locale(?string $locale = null, ...$fallbackLocales) { if ($locale === null) { return $this->getTranslatorLocale(); diff --git a/src/Carbon/Traits/Test.php b/src/Carbon/Traits/Test.php index f23c72e8fd..7c68b57a03 100644 --- a/src/Carbon/Traits/Test.php +++ b/src/Carbon/Traits/Test.php @@ -200,7 +200,7 @@ protected static function mockConstructorParameters(&$time, $tz) : $testInstance->format(static::MOCK_DATETIME_FORMAT); } - private static function setDefaultTimezone($timezone, DateTimeInterface $date = null) + private static function setDefaultTimezone($timezone, ?DateTimeInterface $date = null) { $previous = null; $success = false; From a4932f3bb087a8dafaedaace90a2b6e9012ba828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20=C3=87al=C4=B1=C5=9Fkan?= Date: Wed, 8 Jan 2025 13:18:33 +0300 Subject: [PATCH 2/9] Fixed CS --- .github/workflows/tests.yml | 8 ++ src/Carbon/AbstractTranslator.php | 2 +- src/Carbon/CarbonInterval.php | 4 +- .../BadFluentConstructorException.php | 2 +- .../Exceptions/BadFluentSetterException.php | 2 +- .../Exceptions/NotACarbonClassException.php | 2 +- src/Carbon/Lang/fr.php | 2 +- src/Carbon/Traits/Creator.php | 2 +- src/Carbon/Traits/Date.php | 94 +++++++++---------- src/Carbon/Traits/Units.php | 28 +++--- tests/CarbonPeriod/IteratorTest.php | 8 +- 11 files changed, 81 insertions(+), 73 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f01c512bb2..df54a119de 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -74,6 +74,10 @@ jobs: - php: 8.3 setup: lowest + - php: 8.4 + - php: 8.4 + setup: lowest + - php: 8.1 laravel: true reference: 10.x @@ -230,6 +234,10 @@ jobs: - php: 8.3 setup: lowest + - php: 8.4 + - php: 8.4 + setup: lowest + name: PHP ${{ matrix.php }} - ${{ matrix.setup || 'stable' }} - windows steps: diff --git a/src/Carbon/AbstractTranslator.php b/src/Carbon/AbstractTranslator.php index ffe82e43ca..06383426da 100644 --- a/src/Carbon/AbstractTranslator.php +++ b/src/Carbon/AbstractTranslator.php @@ -162,7 +162,7 @@ public function resetMessages($locale = null) $this->assertValidLocale($locale); foreach ($this->getDirectories() as $directory) { - $data = @include sprintf('%s/%s.php', rtrim($directory, '\\/'), $locale); + $data = @include \sprintf('%s/%s.php', rtrim($directory, '\\/'), $locale); if ($data !== false) { $this->messages[$locale] = $data; diff --git a/src/Carbon/CarbonInterval.php b/src/Carbon/CarbonInterval.php index 8437c545e1..c1f3289478 100644 --- a/src/Carbon/CarbonInterval.php +++ b/src/Carbon/CarbonInterval.php @@ -980,7 +980,7 @@ public static function fromString($intervalDefinition) default: throw new InvalidIntervalException( - sprintf('Invalid part %s in definition %s', $part, $intervalDefinition) + \sprintf('Invalid part %s in definition %s', $part, $intervalDefinition) ); } } @@ -2329,7 +2329,7 @@ public static function getDateIntervalSpec(DateInterval $interval, bool $microse $seconds = abs($interval->s); if ($microseconds && $interval->f > 0) { - $seconds = sprintf('%d.%06d', $seconds, abs($interval->f) * 1000000); + $seconds = \sprintf('%d.%06d', $seconds, abs($interval->f) * 1000000); } $time = array_filter([ diff --git a/src/Carbon/Exceptions/BadFluentConstructorException.php b/src/Carbon/Exceptions/BadFluentConstructorException.php index 2e222e54e9..36ea0e7098 100644 --- a/src/Carbon/Exceptions/BadFluentConstructorException.php +++ b/src/Carbon/Exceptions/BadFluentConstructorException.php @@ -34,7 +34,7 @@ public function __construct($method, $code = 0, Throwable $previous = null) { $this->method = $method; - parent::__construct(sprintf("Unknown fluent constructor '%s'.", $method), $code, $previous); + parent::__construct(\sprintf("Unknown fluent constructor '%s'.", $method), $code, $previous); } /** diff --git a/src/Carbon/Exceptions/BadFluentSetterException.php b/src/Carbon/Exceptions/BadFluentSetterException.php index 4ceaa2ef06..932e7f740e 100644 --- a/src/Carbon/Exceptions/BadFluentSetterException.php +++ b/src/Carbon/Exceptions/BadFluentSetterException.php @@ -34,7 +34,7 @@ public function __construct($setter, $code = 0, Throwable $previous = null) { $this->setter = $setter; - parent::__construct(sprintf("Unknown fluent setter '%s'", $setter), $code, $previous); + parent::__construct(\sprintf("Unknown fluent setter '%s'", $setter), $code, $previous); } /** diff --git a/src/Carbon/Exceptions/NotACarbonClassException.php b/src/Carbon/Exceptions/NotACarbonClassException.php index 7a87632c41..2d96557c78 100644 --- a/src/Carbon/Exceptions/NotACarbonClassException.php +++ b/src/Carbon/Exceptions/NotACarbonClassException.php @@ -35,7 +35,7 @@ public function __construct($className, $code = 0, Throwable $previous = null) { $this->className = $className; - parent::__construct(sprintf('Given class does not implement %s: %s', CarbonInterface::class, $className), $code, $previous); + parent::__construct(\sprintf('Given class does not implement %s: %s', CarbonInterface::class, $className), $code, $previous); } /** diff --git a/src/Carbon/Lang/fr.php b/src/Carbon/Lang/fr.php index f4c7247b43..9784598560 100644 --- a/src/Carbon/Lang/fr.php +++ b/src/Carbon/Lang/fr.php @@ -102,7 +102,7 @@ case 'd': return $number.($number === 1 ? 'er' : 'e'); - // Words with feminine grammatical gender: semaine + // Words with feminine grammatical gender: semaine case 'w': case 'W': return $number.($number === 1 ? 're' : 'e'); diff --git a/src/Carbon/Traits/Creator.php b/src/Carbon/Traits/Creator.php index 0d611ea22e..4ffb3e432d 100644 --- a/src/Carbon/Traits/Creator.php +++ b/src/Carbon/Traits/Creator.php @@ -422,7 +422,7 @@ public static function create($year = 0, $month = 1, $day = 1, $hour = 0, $minut } $second = ($second < 10 ? '0' : '').number_format($second, 6); - $instance = static::rawCreateFromFormat('!Y-n-j G:i:s.u', sprintf('%s-%s-%s %s:%02s:%02s', $year, $month, $day, $hour, $minute, $second), $tz); + $instance = static::rawCreateFromFormat('!Y-n-j G:i:s.u', \sprintf('%s-%s-%s %s:%02s:%02s', $year, $month, $day, $hour, $minute, $second), $tz); if ($fixYear !== null) { $instance = $instance->addYears($fixYear); diff --git a/src/Carbon/Traits/Date.php b/src/Carbon/Traits/Date.php index 75ee1f837e..6757b7f034 100644 --- a/src/Carbon/Traits/Date.php +++ b/src/Carbon/Traits/Date.php @@ -913,102 +913,102 @@ public function get($name) return is_numeric($value) ? (int) $value : $value; - // @property-read string long name of weekday translated according to Carbon locale, in english if no translation available for current language + // @property-read string long name of weekday translated according to Carbon locale, in english if no translation available for current language case $name === 'dayName': return $this->getTranslatedDayName(); - // @property-read string short name of weekday translated according to Carbon locale, in english if no translation available for current language + // @property-read string short name of weekday translated according to Carbon locale, in english if no translation available for current language case $name === 'shortDayName': return $this->getTranslatedShortDayName(); - // @property-read string very short name of weekday translated according to Carbon locale, in english if no translation available for current language + // @property-read string very short name of weekday translated according to Carbon locale, in english if no translation available for current language case $name === 'minDayName': return $this->getTranslatedMinDayName(); - // @property-read string long name of month translated according to Carbon locale, in english if no translation available for current language + // @property-read string long name of month translated according to Carbon locale, in english if no translation available for current language case $name === 'monthName': return $this->getTranslatedMonthName(); - // @property-read string short name of month translated according to Carbon locale, in english if no translation available for current language + // @property-read string short name of month translated according to Carbon locale, in english if no translation available for current language case $name === 'shortMonthName': return $this->getTranslatedShortMonthName(); - // @property-read string lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language + // @property-read string lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language case $name === 'meridiem': return $this->meridiem(true); - // @property-read string uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language + // @property-read string uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language case $name === 'upperMeridiem': return $this->meridiem(); - // @property-read int current hour from 1 to 24 + // @property-read int current hour from 1 to 24 case $name === 'noZeroHour': return $this->hour ?: 24; - // @property int + // @property int case $name === 'milliseconds': // @property int case $name === 'millisecond': - // @property int + // @property int case $name === 'milli': return (int) floor(((int) $this->rawFormat('u')) / 1000); - // @property int 1 through 53 + // @property int 1 through 53 case $name === 'week': return (int) $this->week(); - // @property int 1 through 53 + // @property int 1 through 53 case $name === 'isoWeek': return (int) $this->isoWeek(); - // @property int year according to week format + // @property int year according to week format case $name === 'weekYear': return (int) $this->weekYear(); - // @property int year according to ISO week format + // @property int year according to ISO week format case $name === 'isoWeekYear': return (int) $this->isoWeekYear(); - // @property-read int 51 through 53 + // @property-read int 51 through 53 case $name === 'weeksInYear': return $this->weeksInYear(); - // @property-read int 51 through 53 + // @property-read int 51 through 53 case $name === 'isoWeeksInYear': return $this->isoWeeksInYear(); - // @property-read int 1 through 5 + // @property-read int 1 through 5 case $name === 'weekOfMonth': return (int) ceil($this->day / static::DAYS_PER_WEEK); - // @property-read int 1 through 5 + // @property-read int 1 through 5 case $name === 'weekNumberInMonth': return (int) ceil(($this->day + $this->avoidMutation()->startOfMonth()->dayOfWeekIso - 1) / static::DAYS_PER_WEEK); - // @property-read int 0 through 6 + // @property-read int 0 through 6 case $name === 'firstWeekDay': return $this->localTranslator ? ($this->getTranslationMessage('first_day_of_week') ?? 0) : static::getWeekStartsAt(); - // @property-read int 0 through 6 + // @property-read int 0 through 6 case $name === 'lastWeekDay': return $this->localTranslator ? (($this->getTranslationMessage('first_day_of_week') ?? 0) + static::DAYS_PER_WEEK - 1) % static::DAYS_PER_WEEK : static::getWeekEndsAt(); - // @property int 1 through 366 + // @property int 1 through 366 case $name === 'dayOfYear': return 1 + (int) ($this->rawFormat('z')); - // @property-read int 365 or 366 + // @property-read int 365 or 366 case $name === 'daysInYear': return $this->isLeapYear() ? 366 : 365; - // @property int does a diffInYears() with default parameters + // @property int does a diffInYears() with default parameters case $name === 'age': return $this->diffInYears(); - // @property-read int the quarter of this instance, 1 - 4 - // @call isSameUnit + // @property-read int the quarter of this instance, 1 - 4 + // @call isSameUnit case $name === 'quarter': return (int) ceil($this->month / static::MONTHS_PER_QUARTER); - // @property-read int the decade of this instance - // @call isSameUnit + // @property-read int the decade of this instance + // @call isSameUnit case $name === 'decade': return (int) ceil($this->year / static::YEARS_PER_DECADE); - // @property-read int the century of this instance - // @call isSameUnit + // @property-read int the century of this instance + // @call isSameUnit case $name === 'century': $factor = 1; $year = $this->year; @@ -1019,8 +1019,8 @@ public function get($name) return (int) ($factor * ceil($year / static::YEARS_PER_CENTURY)); - // @property-read int the millennium of this instance - // @call isSameUnit + // @property-read int the millennium of this instance + // @call isSameUnit case $name === 'millennium': $factor = 1; $year = $this->year; @@ -1031,41 +1031,41 @@ public function get($name) return (int) ($factor * ceil($year / static::YEARS_PER_MILLENNIUM)); - // @property int the timezone offset in seconds from UTC + // @property int the timezone offset in seconds from UTC case $name === 'offset': return $this->getOffset(); - // @property int the timezone offset in minutes from UTC + // @property int the timezone offset in minutes from UTC case $name === 'offsetMinutes': return $this->getOffset() / static::SECONDS_PER_MINUTE; - // @property int the timezone offset in hours from UTC + // @property int the timezone offset in hours from UTC case $name === 'offsetHours': return $this->getOffset() / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR; - // @property-read bool daylight savings time indicator, true if DST, false otherwise + // @property-read bool daylight savings time indicator, true if DST, false otherwise case $name === 'dst': return $this->rawFormat('I') === '1'; - // @property-read bool checks if the timezone is local, true if local, false otherwise + // @property-read bool checks if the timezone is local, true if local, false otherwise case $name === 'local': return $this->getOffset() === $this->avoidMutation()->setTimezone(date_default_timezone_get())->getOffset(); - // @property-read bool checks if the timezone is UTC, true if UTC, false otherwise + // @property-read bool checks if the timezone is UTC, true if UTC, false otherwise case $name === 'utc': return $this->getOffset() === 0; - // @property CarbonTimeZone $timezone the current timezone - // @property CarbonTimeZone $tz alias of $timezone + // @property CarbonTimeZone $timezone the current timezone + // @property CarbonTimeZone $tz alias of $timezone case $name === 'timezone' || $name === 'tz': return CarbonTimeZone::instance($this->getTimezone()); - // @property-read string $timezoneName the current timezone name - // @property-read string $tzName alias of $timezoneName + // @property-read string $timezoneName the current timezone name + // @property-read string $tzName alias of $timezoneName case $name === 'timezoneName' || $name === 'tzName': return $this->getTimezone()->getName(); - // @property-read string locale of the current instance + // @property-read string locale of the current instance case $name === 'locale': return $this->getTranslatorLocale(); @@ -1132,7 +1132,7 @@ public function __set($name, $value) public function set($name, $value = null) { if ($this->isImmutable()) { - throw new ImmutableException(sprintf('%s class', static::class)); + throw new ImmutableException(\sprintf('%s class', static::class)); } if (\is_array($name)) { @@ -2453,7 +2453,7 @@ public static function __callStatic($method, $parameters) } } if (static::isStrictModeEnabled()) { - throw new UnknownMethodException(sprintf('%s::%s', static::class, $method)); + throw new UnknownMethodException(\sprintf('%s::%s', static::class, $method)); } return null; @@ -2630,13 +2630,13 @@ public function __call($method, $parameters) case 'Utc': case 'UTC': return $this->utc; - // @call is Check if the current instance has non-UTC timezone. + // @call is Check if the current instance has non-UTC timezone. case 'Local': return $this->local; - // @call is Check if the current instance is a valid date. + // @call is Check if the current instance is a valid date. case 'Valid': return $this->year !== 0; - // @call is Check if the current instance is in a daylight saving time. + // @call is Check if the current instance is in a daylight saving time. case 'DST': return $this->dst; } diff --git a/src/Carbon/Traits/Units.php b/src/Carbon/Traits/Units.php index 5be14ec7ef..2601c25c04 100644 --- a/src/Carbon/Traits/Units.php +++ b/src/Carbon/Traits/Units.php @@ -42,7 +42,7 @@ public function addRealUnit($unit, $value = 1) // @call addRealUnit case 'micro': - // @call addRealUnit + // @call addRealUnit case 'microsecond': /* @var CarbonInterface $this */ $diff = $this->microsecond + $value; @@ -55,71 +55,71 @@ public function addRealUnit($unit, $value = 1) return $this->tz('UTC')->modify("@$time.$microtime")->tz($tz); - // @call addRealUnit + // @call addRealUnit case 'milli': - // @call addRealUnit + // @call addRealUnit case 'millisecond': return $this->addRealUnit('microsecond', $value * static::MICROSECONDS_PER_MILLISECOND); - // @call addRealUnit + // @call addRealUnit case 'second': break; - // @call addRealUnit + // @call addRealUnit case 'minute': $value *= static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'hour': $value *= static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'day': $value *= static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'week': $value *= static::DAYS_PER_WEEK * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'month': $value *= 30 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'quarter': $value *= static::MONTHS_PER_QUARTER * 30 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'year': $value *= 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'decade': $value *= static::YEARS_PER_DECADE * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'century': $value *= static::YEARS_PER_CENTURY * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'millennium': $value *= static::YEARS_PER_MILLENNIUM * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; diff --git a/tests/CarbonPeriod/IteratorTest.php b/tests/CarbonPeriod/IteratorTest.php index 59f889842e..88ca1fff08 100644 --- a/tests/CarbonPeriod/IteratorTest.php +++ b/tests/CarbonPeriod/IteratorTest.php @@ -197,7 +197,7 @@ public function testChangeEndDateDuringIteration() $results = []; foreach ($period as $key => $current) { - $results[] = sprintf('%s => %s', $key, $current->toDateString()); + $results[] = \sprintf('%s => %s', $key, $current->toDateString()); if ($current->toDateString() === '2012-07-16') { $period = $period->setEndDate($current); @@ -226,7 +226,7 @@ public function testKeepIncreasingRecurrencesDuringIteration() $results = []; foreach ($period as $key => $current) { - $results[] = sprintf('%s => %s', $key, $current->toDateString()); + $results[] = \sprintf('%s => %s', $key, $current->toDateString()); if ($recurrences < 4) { $period->setRecurrences(++$recurrences); @@ -257,7 +257,7 @@ public function testChangeStartDateDuringIteration() $newStart = new Carbon('2012-07-03'); foreach ($period as $key => $current) { - $results[] = sprintf('%s => %s', $key, $current->toDateString()); + $results[] = \sprintf('%s => %s', $key, $current->toDateString()); if ($current < $newStart) { $period->setStartDate($newStart); @@ -287,7 +287,7 @@ public function testChangeDateIntervalDuringIteration() $results = []; foreach ($period as $key => $current) { - $results[] = sprintf('%s => %s', $key, $current->toDateString()); + $results[] = \sprintf('%s => %s', $key, $current->toDateString()); $period->setDateInterval('P3D'); From 5f4c750da3f2f18e39dbdbf9ba788f12ca361904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20=C3=87al=C4=B1=C5=9Fkan?= Date: Wed, 8 Jan 2025 13:27:17 +0300 Subject: [PATCH 3/9] upgraded phpunit version on tests --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index df54a119de..b7df928c30 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -152,7 +152,7 @@ jobs: if [[ "${{ matrix.laravel }}" != 'true' ]]; then composer remove --no-update kylekatarnls/multi-tester --no-interaction --dev; fi; - ${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.5.20 --no-interaction --dev;' || '' }} + ${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.6.21 --no-interaction --dev;' || '' }} composer update --prefer-dist --no-progress --prefer-${{ matrix.setup || 'stable' }} ${{ matrix.classmap-authoritative && '--classmap-authoritative' || '' }}${{ matrix.php >= 8.2 && ' --ignore-platform-reqs' || '' }}; - name: Run test suite @@ -271,7 +271,7 @@ jobs: max_attempts: 3 command: | composer remove --no-update kylekatarnls/multi-tester phpmd/phpmd friendsofphp/php-cs-fixer --no-interaction --dev; - ${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.5.20 --no-interaction --dev;' || '' }} + ${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.6.21 --no-interaction --dev;' || '' }} composer update --prefer-dist --no-progress --prefer-${{ matrix.setup || 'stable' }}${{ matrix.php >= 8.2 && ' --ignore-platform-reqs' || '' }}; - name: Run test suite From 8c3e607078c363b4805a46511e73aa75c2bbebe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20=C3=87al=C4=B1=C5=9Fkan?= Date: Wed, 8 Jan 2025 14:04:48 +0300 Subject: [PATCH 4/9] Fixes for implicit nullability deprecation --- src/Carbon/AbstractTranslator.php | 2 +- src/Carbon/CarbonPeriod.php | 6 +++--- src/Carbon/Exceptions/BadComparisonUnitException.php | 2 +- src/Carbon/Exceptions/BadFluentConstructorException.php | 2 +- src/Carbon/Exceptions/BadFluentSetterException.php | 2 +- src/Carbon/Exceptions/ImmutableException.php | 2 +- src/Carbon/Exceptions/InvalidDateException.php | 2 +- src/Carbon/Exceptions/NotACarbonClassException.php | 2 +- src/Carbon/Exceptions/NotLocaleAwareException.php | 2 +- src/Carbon/Exceptions/OutOfRangeException.php | 2 +- src/Carbon/Exceptions/ParseErrorException.php | 2 +- src/Carbon/Exceptions/UnitNotConfiguredException.php | 2 +- src/Carbon/Exceptions/UnknownGetterException.php | 2 +- src/Carbon/Exceptions/UnknownMethodException.php | 2 +- src/Carbon/Exceptions/UnknownSetterException.php | 2 +- src/Carbon/Exceptions/UnknownUnitException.php | 2 +- src/Carbon/Factory.php | 4 ++-- src/Carbon/TranslatorImmutable.php | 2 +- tests/AbstractTestCase.php | 2 +- tests/Carbon/DiffTest.php | 2 +- tests/CarbonImmutable/DiffTest.php | 2 +- tests/CarbonImmutable/TestingAidsTest.php | 2 +- 22 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Carbon/AbstractTranslator.php b/src/Carbon/AbstractTranslator.php index 06383426da..30110b7d0e 100644 --- a/src/Carbon/AbstractTranslator.php +++ b/src/Carbon/AbstractTranslator.php @@ -78,7 +78,7 @@ public static function get($locale = null) return static::$singletons[$key]; } - public function __construct($locale, MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false) + public function __construct($locale, ?MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false) { parent::setLocale($locale); $this->initializing = true; diff --git a/src/Carbon/CarbonPeriod.php b/src/Carbon/CarbonPeriod.php index d12a986971..bedef0b205 100644 --- a/src/Carbon/CarbonPeriod.php +++ b/src/Carbon/CarbonPeriod.php @@ -1017,7 +1017,7 @@ public function getDateInterval() * * @return CarbonInterface */ - public function getStartDate(string $rounding = null) + public function getStartDate(?string $rounding = null) { $date = $this->startDate->avoidMutation(); @@ -1031,7 +1031,7 @@ public function getStartDate(string $rounding = null) * * @return CarbonInterface|null */ - public function getEndDate(string $rounding = null) + public function getEndDate(?string $rounding = null) { if (!$this->endDate) { return null; @@ -1899,7 +1899,7 @@ public function shiftTimezone($timezone) * * @return CarbonInterface */ - public function calculateEnd(string $rounding = null) + public function calculateEnd(?string $rounding = null) { if ($end = $this->getEndDate($rounding)) { return $end; diff --git a/src/Carbon/Exceptions/BadComparisonUnitException.php b/src/Carbon/Exceptions/BadComparisonUnitException.php index 3ca8837d18..526f6d6396 100644 --- a/src/Carbon/Exceptions/BadComparisonUnitException.php +++ b/src/Carbon/Exceptions/BadComparisonUnitException.php @@ -29,7 +29,7 @@ class BadComparisonUnitException extends UnitException * @param int $code * @param Throwable|null $previous */ - public function __construct($unit, $code = 0, Throwable $previous = null) + public function __construct($unit, $code = 0, ?Throwable $previous = null) { $this->unit = $unit; diff --git a/src/Carbon/Exceptions/BadFluentConstructorException.php b/src/Carbon/Exceptions/BadFluentConstructorException.php index 36ea0e7098..c904f6f855 100644 --- a/src/Carbon/Exceptions/BadFluentConstructorException.php +++ b/src/Carbon/Exceptions/BadFluentConstructorException.php @@ -30,7 +30,7 @@ class BadFluentConstructorException extends BaseBadMethodCallException implement * @param int $code * @param Throwable|null $previous */ - public function __construct($method, $code = 0, Throwable $previous = null) + public function __construct($method, $code = 0, ?Throwable $previous = null) { $this->method = $method; diff --git a/src/Carbon/Exceptions/BadFluentSetterException.php b/src/Carbon/Exceptions/BadFluentSetterException.php index 932e7f740e..7f6b4b434c 100644 --- a/src/Carbon/Exceptions/BadFluentSetterException.php +++ b/src/Carbon/Exceptions/BadFluentSetterException.php @@ -30,7 +30,7 @@ class BadFluentSetterException extends BaseBadMethodCallException implements Bad * @param int $code * @param Throwable|null $previous */ - public function __construct($setter, $code = 0, Throwable $previous = null) + public function __construct($setter, $code = 0, ?Throwable $previous = null) { $this->setter = $setter; diff --git a/src/Carbon/Exceptions/ImmutableException.php b/src/Carbon/Exceptions/ImmutableException.php index db334c6c9c..71e95a78e1 100644 --- a/src/Carbon/Exceptions/ImmutableException.php +++ b/src/Carbon/Exceptions/ImmutableException.php @@ -30,7 +30,7 @@ class ImmutableException extends BaseRuntimeException implements RuntimeExceptio * @param int $code * @param Throwable|null $previous */ - public function __construct($value, $code = 0, Throwable $previous = null) + public function __construct($value, $code = 0, ?Throwable $previous = null) { $this->value = $value; parent::__construct("$value is immutable.", $code, $previous); diff --git a/src/Carbon/Exceptions/InvalidDateException.php b/src/Carbon/Exceptions/InvalidDateException.php index c9ecb6b060..981added04 100644 --- a/src/Carbon/Exceptions/InvalidDateException.php +++ b/src/Carbon/Exceptions/InvalidDateException.php @@ -38,7 +38,7 @@ class InvalidDateException extends BaseInvalidArgumentException implements Inval * @param int $code * @param Throwable|null $previous */ - public function __construct($field, $value, $code = 0, Throwable $previous = null) + public function __construct($field, $value, $code = 0, ?Throwable $previous = null) { $this->field = $field; $this->value = $value; diff --git a/src/Carbon/Exceptions/NotACarbonClassException.php b/src/Carbon/Exceptions/NotACarbonClassException.php index 2d96557c78..528ebf669f 100644 --- a/src/Carbon/Exceptions/NotACarbonClassException.php +++ b/src/Carbon/Exceptions/NotACarbonClassException.php @@ -31,7 +31,7 @@ class NotACarbonClassException extends BaseInvalidArgumentException implements I * @param int $code * @param Throwable|null $previous */ - public function __construct($className, $code = 0, Throwable $previous = null) + public function __construct($className, $code = 0, ?Throwable $previous = null) { $this->className = $className; diff --git a/src/Carbon/Exceptions/NotLocaleAwareException.php b/src/Carbon/Exceptions/NotLocaleAwareException.php index f2c546843b..4f753dc96d 100644 --- a/src/Carbon/Exceptions/NotLocaleAwareException.php +++ b/src/Carbon/Exceptions/NotLocaleAwareException.php @@ -23,7 +23,7 @@ class NotLocaleAwareException extends BaseInvalidArgumentException implements In * @param int $code * @param Throwable|null $previous */ - public function __construct($object, $code = 0, Throwable $previous = null) + public function __construct($object, $code = 0, ?Throwable $previous = null) { $dump = \is_object($object) ? \get_class($object) : \gettype($object); diff --git a/src/Carbon/Exceptions/OutOfRangeException.php b/src/Carbon/Exceptions/OutOfRangeException.php index 2c586d0b76..f0f67c7f09 100644 --- a/src/Carbon/Exceptions/OutOfRangeException.php +++ b/src/Carbon/Exceptions/OutOfRangeException.php @@ -57,7 +57,7 @@ class OutOfRangeException extends BaseInvalidArgumentException implements Invali * @param int $code * @param Throwable|null $previous */ - public function __construct($unit, $min, $max, $value, $code = 0, Throwable $previous = null) + public function __construct($unit, $min, $max, $value, $code = 0, ?Throwable $previous = null) { $this->unit = $unit; $this->min = $min; diff --git a/src/Carbon/Exceptions/ParseErrorException.php b/src/Carbon/Exceptions/ParseErrorException.php index 5416fd1491..3592c03c5e 100644 --- a/src/Carbon/Exceptions/ParseErrorException.php +++ b/src/Carbon/Exceptions/ParseErrorException.php @@ -45,7 +45,7 @@ class ParseErrorException extends BaseInvalidArgumentException implements Invali * @param int $code * @param Throwable|null $previous */ - public function __construct($expected, $actual, $help = '', $code = 0, Throwable $previous = null) + public function __construct($expected, $actual, $help = '', $code = 0, ?Throwable $previous = null) { $this->expected = $expected; $this->actual = $actual; diff --git a/src/Carbon/Exceptions/UnitNotConfiguredException.php b/src/Carbon/Exceptions/UnitNotConfiguredException.php index 0e7230563b..24915e1bcd 100644 --- a/src/Carbon/Exceptions/UnitNotConfiguredException.php +++ b/src/Carbon/Exceptions/UnitNotConfiguredException.php @@ -29,7 +29,7 @@ class UnitNotConfiguredException extends UnitException * @param int $code * @param Throwable|null $previous */ - public function __construct($unit, $code = 0, Throwable $previous = null) + public function __construct($unit, $code = 0, ?Throwable $previous = null) { $this->unit = $unit; diff --git a/src/Carbon/Exceptions/UnknownGetterException.php b/src/Carbon/Exceptions/UnknownGetterException.php index 5c504975aa..7ebfe8db39 100644 --- a/src/Carbon/Exceptions/UnknownGetterException.php +++ b/src/Carbon/Exceptions/UnknownGetterException.php @@ -30,7 +30,7 @@ class UnknownGetterException extends BaseInvalidArgumentException implements Inv * @param int $code * @param Throwable|null $previous */ - public function __construct($getter, $code = 0, Throwable $previous = null) + public function __construct($getter, $code = 0, ?Throwable $previous = null) { $this->getter = $getter; diff --git a/src/Carbon/Exceptions/UnknownMethodException.php b/src/Carbon/Exceptions/UnknownMethodException.php index 75273a706e..3a2aca8070 100644 --- a/src/Carbon/Exceptions/UnknownMethodException.php +++ b/src/Carbon/Exceptions/UnknownMethodException.php @@ -30,7 +30,7 @@ class UnknownMethodException extends BaseBadMethodCallException implements BadMe * @param int $code * @param Throwable|null $previous */ - public function __construct($method, $code = 0, Throwable $previous = null) + public function __construct($method, $code = 0, ?Throwable $previous = null) { $this->method = $method; diff --git a/src/Carbon/Exceptions/UnknownSetterException.php b/src/Carbon/Exceptions/UnknownSetterException.php index a795f5d725..b9cb7117d1 100644 --- a/src/Carbon/Exceptions/UnknownSetterException.php +++ b/src/Carbon/Exceptions/UnknownSetterException.php @@ -30,7 +30,7 @@ class UnknownSetterException extends BaseInvalidArgumentException implements Bad * @param int $code * @param Throwable|null $previous */ - public function __construct($setter, $code = 0, Throwable $previous = null) + public function __construct($setter, $code = 0, ?Throwable $previous = null) { $this->setter = $setter; diff --git a/src/Carbon/Exceptions/UnknownUnitException.php b/src/Carbon/Exceptions/UnknownUnitException.php index ecd7f7a592..bcfc42e238 100644 --- a/src/Carbon/Exceptions/UnknownUnitException.php +++ b/src/Carbon/Exceptions/UnknownUnitException.php @@ -29,7 +29,7 @@ class UnknownUnitException extends UnitException * @param int $code * @param Throwable|null $previous */ - public function __construct($unit, $code = 0, Throwable $previous = null) + public function __construct($unit, $code = 0, ?Throwable $previous = null) { $this->unit = $unit; diff --git a/src/Carbon/Factory.php b/src/Carbon/Factory.php index d497535f77..e214e5b214 100644 --- a/src/Carbon/Factory.php +++ b/src/Carbon/Factory.php @@ -266,7 +266,7 @@ public function setClassName(string $className) return $this; } - public function className(string $className = null) + public function className(?string $className = null) { return $className === null ? $this->getClassName() : $this->setClassName($className); } @@ -283,7 +283,7 @@ public function setSettings(array $settings) return $this; } - public function settings(array $settings = null) + public function settings(?array $settings = null) { return $settings === null ? $this->getSettings() : $this->setSettings($settings); } diff --git a/src/Carbon/TranslatorImmutable.php b/src/Carbon/TranslatorImmutable.php index ce6b2f90ac..807666e12e 100644 --- a/src/Carbon/TranslatorImmutable.php +++ b/src/Carbon/TranslatorImmutable.php @@ -20,7 +20,7 @@ class TranslatorImmutable extends Translator /** @var bool */ private $constructed = false; - public function __construct($locale, MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false) + public function __construct($locale, ?MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false) { parent::__construct($locale, $formatter, $cacheDir, $debug); $this->constructed = true; diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index 5bdc253d32..321ac4f76e 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -241,7 +241,7 @@ public function assertInstanceOfCarbonInterval($d) $this->assertInstanceOf(CarbonInterval::class, $d); } - public function wrapWithTestNow(Closure $func, CarbonInterface $dt = null) + public function wrapWithTestNow(Closure $func, ?CarbonInterface $dt = null) { $test = Carbon::getTestNow(); $immutableTest = CarbonImmutable::getTestNow(); diff --git a/tests/Carbon/DiffTest.php b/tests/Carbon/DiffTest.php index 566b6a0a17..fc4d43797b 100644 --- a/tests/Carbon/DiffTest.php +++ b/tests/Carbon/DiffTest.php @@ -24,7 +24,7 @@ class DiffTest extends AbstractTestCase { - public function wrapWithTestNow(Closure $func, CarbonInterface $dt = null) + public function wrapWithTestNow(Closure $func, ?CarbonInterface $dt = null) { parent::wrapWithTestNow($func, $dt ?: Carbon::createFromDate(2012, 1, 1)); } diff --git a/tests/CarbonImmutable/DiffTest.php b/tests/CarbonImmutable/DiffTest.php index d3639fe933..f0b2a9af61 100644 --- a/tests/CarbonImmutable/DiffTest.php +++ b/tests/CarbonImmutable/DiffTest.php @@ -24,7 +24,7 @@ class DiffTest extends AbstractTestCase { - public function wrapWithTestNow(Closure $func, CarbonInterface $dt = null) + public function wrapWithTestNow(Closure $func, ?CarbonInterface $dt = null) { parent::wrapWithTestNow($func, $dt ?: Carbon::createMidnightDate(2012, 1, 1)); } diff --git a/tests/CarbonImmutable/TestingAidsTest.php b/tests/CarbonImmutable/TestingAidsTest.php index aeb782bdd9..bdd1a5b32a 100644 --- a/tests/CarbonImmutable/TestingAidsTest.php +++ b/tests/CarbonImmutable/TestingAidsTest.php @@ -23,7 +23,7 @@ class TestingAidsTest extends AbstractTestCase { - public function wrapWithTestNow(Closure $func, CarbonInterface $dt = null) + public function wrapWithTestNow(Closure $func, ?CarbonInterface $dt = null) { Carbon::setTestNow($dt ?: Carbon::now()); $func(); From 5dca8dc5fcd18b1e88206c16b2adeef055cea408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20=C3=87al=C4=B1=C5=9Fkan?= Date: Wed, 8 Jan 2025 14:25:35 +0300 Subject: [PATCH 5/9] Fixes for PHP 8.4 --- src/Carbon/CarbonInterface.php | 1 + src/Carbon/Traits/Timestamp.php | 1 + tests/Carbon/SettersTest.php | 2 +- tests/CarbonPeriod/Fixtures/AbstractCarbon.php | 6 ++++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Carbon/CarbonInterface.php b/src/Carbon/CarbonInterface.php index b90e298172..4589a0b49f 100644 --- a/src/Carbon/CarbonInterface.php +++ b/src/Carbon/CarbonInterface.php @@ -1162,6 +1162,7 @@ public static function createFromTimeString($time, $tz = null); * * @return static */ + #[ReturnTypeWillChange] public static function createFromTimestamp($timestamp, $tz = null); /** diff --git a/src/Carbon/Traits/Timestamp.php b/src/Carbon/Traits/Timestamp.php index 88a465c938..a354eed312 100644 --- a/src/Carbon/Traits/Timestamp.php +++ b/src/Carbon/Traits/Timestamp.php @@ -26,6 +26,7 @@ trait Timestamp * * @return static */ + #[\ReturnTypeWillChange] public static function createFromTimestamp($timestamp, $tz = null) { return static::createFromTimestampUTC($timestamp)->setTimezone($tz); diff --git a/tests/Carbon/SettersTest.php b/tests/Carbon/SettersTest.php index 95d1d5f8ed..128af945ce 100644 --- a/tests/Carbon/SettersTest.php +++ b/tests/Carbon/SettersTest.php @@ -241,7 +241,7 @@ public function testTimestampSetter() $d->timestamp = 1600887164.88952298; $this->assertSame('2020-09-23 14:52:44.889523', $d->format('Y-m-d H:i:s.u')); - $d->setTimestamp(1599828571.23561248); + $d->setTimestamp(1599828571.235612); $this->assertSame('2020-09-11 08:49:31.235612', $d->format('Y-m-d H:i:s.u')); $d->timestamp = '0.88951247 1600887164'; diff --git a/tests/CarbonPeriod/Fixtures/AbstractCarbon.php b/tests/CarbonPeriod/Fixtures/AbstractCarbon.php index 705c4856ab..352a777834 100644 --- a/tests/CarbonPeriod/Fixtures/AbstractCarbon.php +++ b/tests/CarbonPeriod/Fixtures/AbstractCarbon.php @@ -82,4 +82,10 @@ public static function createFromFormat($format, $time, $tz = null) { return parent::createFromFormat($format, $time, $tz); } + + #[ReturnTypeWillChange] + public static function createFromTimestamp($timestamp, $tz = null) + { + return parent::createFromTimestamp($timestamp, $tz); + } } From d1e695f7b2daae2def15568f41b89391b86ef5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20=C3=87al=C4=B1=C5=9Fkan?= Date: Wed, 8 Jan 2025 14:39:09 +0300 Subject: [PATCH 6/9] Added PHP 8.3 and PHP 8.4 test for laravel and removed PHP 8.4 lowest test matrix --- .github/workflows/tests.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b7df928c30..89696117e8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -75,8 +75,6 @@ jobs: setup: lowest - php: 8.4 - - php: 8.4 - setup: lowest - php: 8.1 laravel: true @@ -91,6 +89,14 @@ jobs: laravel: true reference: master + - php: 8.3 + laravel: true + reference: master + + - php: 8.4 + laravel: true + reference: master + - php: 8.2 laravel: true reference: master @@ -235,8 +241,6 @@ jobs: setup: lowest - php: 8.4 - - php: 8.4 - setup: lowest name: PHP ${{ matrix.php }} - ${{ matrix.setup || 'stable' }} - windows From 8910c5114f60f2a918aa2d9ae2c14056dcb71e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20=C3=87al=C4=B1=C5=9Fkan?= Date: Wed, 8 Jan 2025 16:57:21 +0300 Subject: [PATCH 7/9] changed expected result for PHP 8.4 --- tests/Carbon/SettersTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Carbon/SettersTest.php b/tests/Carbon/SettersTest.php index 128af945ce..e1a5e46743 100644 --- a/tests/Carbon/SettersTest.php +++ b/tests/Carbon/SettersTest.php @@ -241,8 +241,8 @@ public function testTimestampSetter() $d->timestamp = 1600887164.88952298; $this->assertSame('2020-09-23 14:52:44.889523', $d->format('Y-m-d H:i:s.u')); - $d->setTimestamp(1599828571.235612); - $this->assertSame('2020-09-11 08:49:31.235612', $d->format('Y-m-d H:i:s.u')); + $d->setTimestamp(1599828571.23561248); + $this->assertSame(PHP_VERSION_ID < 80400 ? '2020-09-11 08:49:31.235612' : '2020-09-11 08:49:31.235613', $d->format('Y-m-d H:i:s.u')); $d->timestamp = '0.88951247 1600887164'; $this->assertSame('2020-09-23 14:52:44.889512', $d->format('Y-m-d H:i:s.u')); From dc27804306d1197bc5f8f46f298acf13fa35ed7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20=C3=87al=C4=B1=C5=9Fkan?= Date: Wed, 8 Jan 2025 18:30:05 +0300 Subject: [PATCH 8/9] changed CS rule --- .php-cs-fixer.dist.php | 1 + src/Carbon/Traits/Date.php | 92 ++++++++++++++++++------------------- src/Carbon/Traits/Units.php | 28 +++++------ 3 files changed, 61 insertions(+), 60 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 615bde993f..258cc558bf 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -87,6 +87,7 @@ 'single_quote' => true, 'space_after_semicolon' => true, 'standardize_not_equals' => true, + 'statement_indentation' => false, 'ternary_operator_spaces' => true, 'trailing_comma_in_multiline' => true, 'trim_array_spaces' => true, diff --git a/src/Carbon/Traits/Date.php b/src/Carbon/Traits/Date.php index 6757b7f034..55a68f4398 100644 --- a/src/Carbon/Traits/Date.php +++ b/src/Carbon/Traits/Date.php @@ -913,102 +913,102 @@ public function get($name) return is_numeric($value) ? (int) $value : $value; - // @property-read string long name of weekday translated according to Carbon locale, in english if no translation available for current language + // @property-read string long name of weekday translated according to Carbon locale, in english if no translation available for current language case $name === 'dayName': return $this->getTranslatedDayName(); - // @property-read string short name of weekday translated according to Carbon locale, in english if no translation available for current language + // @property-read string short name of weekday translated according to Carbon locale, in english if no translation available for current language case $name === 'shortDayName': return $this->getTranslatedShortDayName(); - // @property-read string very short name of weekday translated according to Carbon locale, in english if no translation available for current language + // @property-read string very short name of weekday translated according to Carbon locale, in english if no translation available for current language case $name === 'minDayName': return $this->getTranslatedMinDayName(); - // @property-read string long name of month translated according to Carbon locale, in english if no translation available for current language + // @property-read string long name of month translated according to Carbon locale, in english if no translation available for current language case $name === 'monthName': return $this->getTranslatedMonthName(); - // @property-read string short name of month translated according to Carbon locale, in english if no translation available for current language + // @property-read string short name of month translated according to Carbon locale, in english if no translation available for current language case $name === 'shortMonthName': return $this->getTranslatedShortMonthName(); - // @property-read string lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language + // @property-read string lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language case $name === 'meridiem': return $this->meridiem(true); - // @property-read string uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language + // @property-read string uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language case $name === 'upperMeridiem': return $this->meridiem(); - // @property-read int current hour from 1 to 24 + // @property-read int current hour from 1 to 24 case $name === 'noZeroHour': return $this->hour ?: 24; - // @property int + // @property int case $name === 'milliseconds': - // @property int + // @property int case $name === 'millisecond': - // @property int + // @property int case $name === 'milli': return (int) floor(((int) $this->rawFormat('u')) / 1000); - // @property int 1 through 53 + // @property int 1 through 53 case $name === 'week': return (int) $this->week(); - // @property int 1 through 53 + // @property int 1 through 53 case $name === 'isoWeek': return (int) $this->isoWeek(); - // @property int year according to week format + // @property int year according to week format case $name === 'weekYear': return (int) $this->weekYear(); - // @property int year according to ISO week format + // @property int year according to ISO week format case $name === 'isoWeekYear': return (int) $this->isoWeekYear(); - // @property-read int 51 through 53 + // @property-read int 51 through 53 case $name === 'weeksInYear': return $this->weeksInYear(); - // @property-read int 51 through 53 + // @property-read int 51 through 53 case $name === 'isoWeeksInYear': return $this->isoWeeksInYear(); - // @property-read int 1 through 5 + // @property-read int 1 through 5 case $name === 'weekOfMonth': return (int) ceil($this->day / static::DAYS_PER_WEEK); - // @property-read int 1 through 5 + // @property-read int 1 through 5 case $name === 'weekNumberInMonth': return (int) ceil(($this->day + $this->avoidMutation()->startOfMonth()->dayOfWeekIso - 1) / static::DAYS_PER_WEEK); - // @property-read int 0 through 6 + // @property-read int 0 through 6 case $name === 'firstWeekDay': return $this->localTranslator ? ($this->getTranslationMessage('first_day_of_week') ?? 0) : static::getWeekStartsAt(); - // @property-read int 0 through 6 + // @property-read int 0 through 6 case $name === 'lastWeekDay': return $this->localTranslator ? (($this->getTranslationMessage('first_day_of_week') ?? 0) + static::DAYS_PER_WEEK - 1) % static::DAYS_PER_WEEK : static::getWeekEndsAt(); - // @property int 1 through 366 + // @property int 1 through 366 case $name === 'dayOfYear': return 1 + (int) ($this->rawFormat('z')); - // @property-read int 365 or 366 + // @property-read int 365 or 366 case $name === 'daysInYear': return $this->isLeapYear() ? 366 : 365; - // @property int does a diffInYears() with default parameters + // @property int does a diffInYears() with default parameters case $name === 'age': return $this->diffInYears(); - // @property-read int the quarter of this instance, 1 - 4 - // @call isSameUnit + // @property-read int the quarter of this instance, 1 - 4 + // @call isSameUnit case $name === 'quarter': return (int) ceil($this->month / static::MONTHS_PER_QUARTER); - // @property-read int the decade of this instance - // @call isSameUnit + // @property-read int the decade of this instance + // @call isSameUnit case $name === 'decade': return (int) ceil($this->year / static::YEARS_PER_DECADE); - // @property-read int the century of this instance - // @call isSameUnit + // @property-read int the century of this instance + // @call isSameUnit case $name === 'century': $factor = 1; $year = $this->year; @@ -1019,8 +1019,8 @@ public function get($name) return (int) ($factor * ceil($year / static::YEARS_PER_CENTURY)); - // @property-read int the millennium of this instance - // @call isSameUnit + // @property-read int the millennium of this instance + // @call isSameUnit case $name === 'millennium': $factor = 1; $year = $this->year; @@ -1031,41 +1031,41 @@ public function get($name) return (int) ($factor * ceil($year / static::YEARS_PER_MILLENNIUM)); - // @property int the timezone offset in seconds from UTC + // @property int the timezone offset in seconds from UTC case $name === 'offset': return $this->getOffset(); - // @property int the timezone offset in minutes from UTC + // @property int the timezone offset in minutes from UTC case $name === 'offsetMinutes': return $this->getOffset() / static::SECONDS_PER_MINUTE; - // @property int the timezone offset in hours from UTC + // @property int the timezone offset in hours from UTC case $name === 'offsetHours': return $this->getOffset() / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR; - // @property-read bool daylight savings time indicator, true if DST, false otherwise + // @property-read bool daylight savings time indicator, true if DST, false otherwise case $name === 'dst': return $this->rawFormat('I') === '1'; - // @property-read bool checks if the timezone is local, true if local, false otherwise + // @property-read bool checks if the timezone is local, true if local, false otherwise case $name === 'local': return $this->getOffset() === $this->avoidMutation()->setTimezone(date_default_timezone_get())->getOffset(); - // @property-read bool checks if the timezone is UTC, true if UTC, false otherwise + // @property-read bool checks if the timezone is UTC, true if UTC, false otherwise case $name === 'utc': return $this->getOffset() === 0; - // @property CarbonTimeZone $timezone the current timezone - // @property CarbonTimeZone $tz alias of $timezone + // @property CarbonTimeZone $timezone the current timezone + // @property CarbonTimeZone $tz alias of $timezone case $name === 'timezone' || $name === 'tz': return CarbonTimeZone::instance($this->getTimezone()); - // @property-read string $timezoneName the current timezone name - // @property-read string $tzName alias of $timezoneName + // @property-read string $timezoneName the current timezone name + // @property-read string $tzName alias of $timezoneName case $name === 'timezoneName' || $name === 'tzName': return $this->getTimezone()->getName(); - // @property-read string locale of the current instance + // @property-read string locale of the current instance case $name === 'locale': return $this->getTranslatorLocale(); @@ -2630,13 +2630,13 @@ public function __call($method, $parameters) case 'Utc': case 'UTC': return $this->utc; - // @call is Check if the current instance has non-UTC timezone. + // @call is Check if the current instance has non-UTC timezone. case 'Local': return $this->local; - // @call is Check if the current instance is a valid date. + // @call is Check if the current instance is a valid date. case 'Valid': return $this->year !== 0; - // @call is Check if the current instance is in a daylight saving time. + // @call is Check if the current instance is in a daylight saving time. case 'DST': return $this->dst; } diff --git a/src/Carbon/Traits/Units.php b/src/Carbon/Traits/Units.php index 2601c25c04..5be14ec7ef 100644 --- a/src/Carbon/Traits/Units.php +++ b/src/Carbon/Traits/Units.php @@ -42,7 +42,7 @@ public function addRealUnit($unit, $value = 1) // @call addRealUnit case 'micro': - // @call addRealUnit + // @call addRealUnit case 'microsecond': /* @var CarbonInterface $this */ $diff = $this->microsecond + $value; @@ -55,71 +55,71 @@ public function addRealUnit($unit, $value = 1) return $this->tz('UTC')->modify("@$time.$microtime")->tz($tz); - // @call addRealUnit + // @call addRealUnit case 'milli': - // @call addRealUnit + // @call addRealUnit case 'millisecond': return $this->addRealUnit('microsecond', $value * static::MICROSECONDS_PER_MILLISECOND); - // @call addRealUnit + // @call addRealUnit case 'second': break; - // @call addRealUnit + // @call addRealUnit case 'minute': $value *= static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'hour': $value *= static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'day': $value *= static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'week': $value *= static::DAYS_PER_WEEK * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'month': $value *= 30 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'quarter': $value *= static::MONTHS_PER_QUARTER * 30 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'year': $value *= 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'decade': $value *= static::YEARS_PER_DECADE * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'century': $value *= static::YEARS_PER_CENTURY * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; break; - // @call addRealUnit + // @call addRealUnit case 'millennium': $value *= static::YEARS_PER_MILLENNIUM * 365 * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE; From 142f0f5ca773f383e2868dfa0f7ea59c2ef1865f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20=C3=87al=C4=B1=C5=9Fkan?= Date: Wed, 8 Jan 2025 18:32:45 +0300 Subject: [PATCH 9/9] changed CS rule --- src/Carbon/Lang/fr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Carbon/Lang/fr.php b/src/Carbon/Lang/fr.php index 9784598560..f4c7247b43 100644 --- a/src/Carbon/Lang/fr.php +++ b/src/Carbon/Lang/fr.php @@ -102,7 +102,7 @@ case 'd': return $number.($number === 1 ? 'er' : 'e'); - // Words with feminine grammatical gender: semaine + // Words with feminine grammatical gender: semaine case 'w': case 'W': return $number.($number === 1 ? 're' : 'e');