Skip to content

Commit

Permalink
Add OrderedTypesFixer
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Apr 1, 2024
1 parent f01ca66 commit 4e5d2f3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/LocalDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/LocalDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/Month.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/MonthDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/ZonedDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions tools/ecs/ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -194,6 +195,7 @@
WhitespaceAfterCommaInArrayFixer::class,
NoTrailingCommaInSinglelineArrayFixer::class,
StandaloneLinePromotedPropertyFixer::class,
OrderedTypesFixer::class,
],
);

Expand Down

0 comments on commit 4e5d2f3

Please sign in to comment.