Skip to content

Commit

Permalink
Feat: Replace UnionTypeHintFormatSniff with TypesSpacesFixer
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed May 23, 2024
1 parent 139faea commit 09400f5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer;
use PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer;
use PhpCsFixer\Fixer\Whitespace\TypeDeclarationSpacesFixer;
use PhpCsFixer\Fixer\Whitespace\TypesSpacesFixer;
use SlevomatCodingStandard\Sniffs\Classes\RequireConstructorPropertyPromotionSniff;
use SlevomatCodingStandard\Sniffs\ControlStructures\RequireNullSafeObjectOperatorSniff;
use SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff;
Expand All @@ -143,7 +144,6 @@
use SlevomatCodingStandard\Sniffs\TypeHints\ParameterTypeHintSniff;
use SlevomatCodingStandard\Sniffs\TypeHints\PropertyTypeHintSniff;
use SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff;
use SlevomatCodingStandard\Sniffs\TypeHints\UnionTypeHintFormatSniff;
use Symplify\CodingStandard\Fixer\Commenting\ParamReturnAndVarTagMalformsFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

Expand Down Expand Up @@ -263,6 +263,8 @@
FopenFlagsFixer::class,
// Add missing space between function's argument and its typehint.
TypeDeclarationSpacesFixer::class,
// None space should be around union type and intersection type operators.
TypesSpacesFixer::class,
// Function `implode` must be called with 2 arguments in the documented order.
ImplodeCallFixer::class,
// Lambda must not import variables it doesn't use.
Expand Down Expand Up @@ -505,8 +507,6 @@
'use_trait',
],
])
// Format union types
->withConfiguredRule(UnionTypeHintFormatSniff::class, ['withSpaces' => 'no'])
->withSkip([
// We allow empty catch statements (but they must have comment - see EmptyCatchCommentSniff)
EmptyStatementSniff::class . '.DetectedCatch' => null,
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class NewPhpFeatures
}

public function php80features(
string|bool $foo, // UnionTypeHintFormatSniff
string|bool $foo, // TypesSpacesFixer
int $bar, // RequireTrailingCommaInDeclarationSniff
): string|bool {
$value = mt_rand(
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NewPhpFeatures
}

public function php80features(
string | bool $foo, // UnionTypeHintFormatSniff
string | bool $foo, // TypesSpacesFixer
int $bar // RequireTrailingCommaInDeclarationSniff
): string | bool {
$value = mt_rand(
Expand Down

0 comments on commit 09400f5

Please sign in to comment.