From 4e5d2f3931126db6b33bccb1edb659a20bd0a3d7 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Mon, 1 Apr 2024 17:23:49 +0200 Subject: [PATCH] Add OrderedTypesFixer --- src/LocalDate.php | 4 ++-- src/LocalDateTime.php | 4 ++-- src/Month.php | 4 ++-- src/MonthDay.php | 4 ++-- src/ZonedDateTime.php | 2 +- tools/ecs/ecs.php | 2 ++ 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/LocalDate.php b/src/LocalDate.php index fcc10b6..6f22203 100644 --- a/src/LocalDate.php +++ b/src/LocalDate.php @@ -72,7 +72,7 @@ private function __construct( * * @throws DateTimeException If the date is not valid. */ - public static function of(int $year, Month|int $month, int $day): LocalDate + public static function of(int $year, int|Month $month, int $day): LocalDate { Field\Year::check($year); @@ -389,7 +389,7 @@ public function withYear(int $year): LocalDate * * @throws DateTimeException If the month is invalid. */ - public function withMonth(Month|int $month): LocalDate + public function withMonth(int|Month $month): LocalDate { if (is_int($month)) { Field\MonthOfYear::check($month); diff --git a/src/LocalDateTime.php b/src/LocalDateTime.php index 62c159d..a2d2a3a 100644 --- a/src/LocalDateTime.php +++ b/src/LocalDateTime.php @@ -41,7 +41,7 @@ public function __construct( * * @throws DateTimeException If the date or time is not valid. */ - public static function of(int $year, Month|int $month, int $day, int $hour = 0, int $minute = 0, int $second = 0, int $nano = 0): LocalDateTime + public static function of(int $year, int|Month $month, int $day, int $hour = 0, int $minute = 0, int $second = 0, int $nano = 0): LocalDateTime { $date = LocalDate::of($year, $month, $day); $time = LocalTime::of($hour, $minute, $second, $nano); @@ -306,7 +306,7 @@ public function withYear(int $year): LocalDateTime * * @throws DateTimeException If the month is invalid. */ - public function withMonth(Month|int $month): LocalDateTime + public function withMonth(int|Month $month): LocalDateTime { $date = $this->date->withMonth($month); diff --git a/src/Month.php b/src/Month.php index c9e3955..9dbea2e 100644 --- a/src/Month.php +++ b/src/Month.php @@ -38,7 +38,7 @@ enum Month: int implements JsonSerializable * * @throws DateTimeException */ - public static function of(Month|int $value): Month + public static function of(int|Month $value): Month { if ($value instanceof Month) { return $value; @@ -86,7 +86,7 @@ public function getValue(): int * * @return bool True if this month is equal to the given value, false otherwise. */ - public function is(Month|int $month): bool + public function is(int|Month $month): bool { if ($month instanceof Month) { return $this === $month; diff --git a/src/MonthDay.php b/src/MonthDay.php index 1731c10..850ea84 100644 --- a/src/MonthDay.php +++ b/src/MonthDay.php @@ -38,7 +38,7 @@ private function __construct( * * @throws DateTimeException If the month-day is not valid. */ - public static function of(Month|int $month, int $day): MonthDay + public static function of(int|Month $month, int $day): MonthDay { if (is_int($month)) { Field\MonthOfYear::check($month); @@ -194,7 +194,7 @@ public function isValidYear(int $year): bool * * @throws DateTimeException If the month is invalid. */ - public function withMonth(Month|int $month): MonthDay + public function withMonth(int|Month $month): MonthDay { if (is_int($month)) { Field\MonthOfYear::check($month); diff --git a/src/ZonedDateTime.php b/src/ZonedDateTime.php index d62c28c..e782c2a 100644 --- a/src/ZonedDateTime.php +++ b/src/ZonedDateTime.php @@ -347,7 +347,7 @@ public function withYear(int $year): ZonedDateTime /** * Returns a copy of this ZonedDateTime with the month-of-year altered. */ - public function withMonth(Month|int $month): ZonedDateTime + public function withMonth(int|Month $month): ZonedDateTime { return ZonedDateTime::of($this->localDateTime->withMonth($month), $this->timeZone); } diff --git a/tools/ecs/ecs.php b/tools/ecs/ecs.php index 3fe7429..e82efd2 100644 --- a/tools/ecs/ecs.php +++ b/tools/ecs/ecs.php @@ -17,6 +17,7 @@ use PhpCsFixer\Fixer\CastNotation\ShortScalarCastFixer; use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer; use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer; +use PhpCsFixer\Fixer\ClassNotation\OrderedTypesFixer; use PhpCsFixer\Fixer\Comment\CommentToPhpdocFixer; use PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer; use PhpCsFixer\Fixer\ConstantNotation\NativeConstantInvocationFixer; @@ -194,6 +195,7 @@ WhitespaceAfterCommaInArrayFixer::class, NoTrailingCommaInSinglelineArrayFixer::class, StandaloneLinePromotedPropertyFixer::class, + OrderedTypesFixer::class, ], );