diff --git a/ecs.php b/ecs.php index 2071a35..7f8b221 100644 --- a/ecs.php +++ b/ecs.php @@ -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; @@ -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; @@ -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. @@ -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, diff --git a/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc b/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc index c6e2726..a2cbc45 100644 --- a/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc +++ b/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc @@ -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( diff --git a/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc b/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc index 49d1d08..f4c786b 100644 --- a/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc +++ b/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc @@ -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(