From af5bce0f4d7f193f33476b4593528a5b99223319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Machulda?= Date: Mon, 13 May 2024 17:11:42 +0200 Subject: [PATCH] Feat: Remove the most risky fixers from the next version (will be readded in the next release) --- ecs.php | 29 ------------------- .../Fixtures/NewPhpFeatures.correct.php.inc | 5 +++- .../Fixtures/NewPhpFeatures.wrong.php.inc | 2 +- 3 files changed, 5 insertions(+), 31 deletions(-) diff --git a/ecs.php b/ecs.php index a9e3236..66f365a 100644 --- a/ecs.php +++ b/ecs.php @@ -69,9 +69,6 @@ use PhpCsFixer\Fixer\FunctionNotation\LambdaNotUsedImportFixer; use PhpCsFixer\Fixer\FunctionNotation\NoUnreachableDefaultArgumentValueFixer; use PhpCsFixer\Fixer\FunctionNotation\NoUselessSprintfFixer; -use PhpCsFixer\Fixer\FunctionNotation\PhpdocToParamTypeFixer; -use PhpCsFixer\Fixer\FunctionNotation\PhpdocToPropertyTypeFixer; -use PhpCsFixer\Fixer\FunctionNotation\PhpdocToReturnTypeFixer; use PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer; use PhpCsFixer\Fixer\FunctionNotation\VoidReturnFixer; use PhpCsFixer\Fixer\Import\NoLeadingImportSlashFixer; @@ -133,7 +130,6 @@ use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer; use PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer; use PhpCsFixer\Fixer\Whitespace\TypeDeclarationSpacesFixer; -use SlevomatCodingStandard\Sniffs\Classes\RequireConstructorPropertyPromotionSniff; use SlevomatCodingStandard\Sniffs\ControlStructures\RequireNullSafeObjectOperatorSniff; use SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff; use SlevomatCodingStandard\Sniffs\Functions\RequireTrailingCommaInCallSniff; @@ -377,15 +373,6 @@ ReferenceThrowableOnlySniff::class, // The @param, @return, @var and inline @var annotations should keep standard format ParamReturnAndVarTagMalformsFixer::class, - // Takes `@var` annotation of non-mixed types and adjusts accordingly the property signature. - PhpdocToPropertyTypeFixer::class, - // Takes `@param` annotations of non-mixed types and adjusts accordingly the function signature. - PhpdocToParamTypeFixer::class, - // Takes `@return` annotation of non-mixed types and adjusts accordingly the function signature. - PhpdocToReturnTypeFixer::class, - // Promote constructor properties - // @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/5956 - RequireConstructorPropertyPromotionSniff::class, // switch -> match // @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/5894 @@ -393,10 +380,6 @@ // Require \Stringable interface in classes implementing __toString() method // > it may probably be a phpstan rule, more than cs rule - since it needs a class hierarchy to solve this // @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/6235 - PropertyTypeHintSniff::class, - - ParameterTypeHintSniff::class, - ReturnTypeHintSniff::class, // Multi-line arguments list in function/method declaration must have a trailing comma RequireTrailingCommaInDeclarationSniff::class, @@ -531,18 +514,6 @@ // Allow single line closures ScopeClosingBraceSniff::class . '.ContentBefore' => null, - // Skip unwanted rules from PropertyTypeHintSniff - PropertyTypeHintSniff::class . '.' . PropertyTypeHintSniff::CODE_MISSING_TRAVERSABLE_TYPE_HINT_SPECIFICATION => null, - PropertyTypeHintSniff::class . '.' . PropertyTypeHintSniff::CODE_MISSING_ANY_TYPE_HINT => null, - - // Skip unwanted rules from ParameterTypeHintSniff - ParameterTypeHintSniff::class . '.' . ParameterTypeHintSniff::CODE_MISSING_TRAVERSABLE_TYPE_HINT_SPECIFICATION => null, - ParameterTypeHintSniff::class . '.' . ParameterTypeHintSniff::CODE_MISSING_ANY_TYPE_HINT => null, - - // Skip unwanted rules from ReturnTypeHintSniff - ReturnTypeHintSniff::class . '.' . ReturnTypeHintSniff::CODE_MISSING_TRAVERSABLE_TYPE_HINT_SPECIFICATION => null, - ReturnTypeHintSniff::class . '.' . ReturnTypeHintSniff::CODE_MISSING_ANY_TYPE_HINT => null, - // We use declare(strict_types=1); after opening tag BlankLineAfterOpeningTagFixer::class => null, ]); diff --git a/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc b/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc index c6e2726..f2962dd 100644 --- a/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc +++ b/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc @@ -4,8 +4,11 @@ namespace Lmc\CodingStandard\Integration\Fixtures; class NewPhpFeatures { - public function __construct(private string $someString) // RequireConstructorPropertyPromotionSniff + private string $someString; + + public function __construct(string $someString) { + $this->someString = $someString; } public function php80features( diff --git a/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc b/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc index 49d1d08..3435f7e 100644 --- a/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc +++ b/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc @@ -6,7 +6,7 @@ class NewPhpFeatures { private string $someString; - public function __construct(string $someString) // RequireConstructorPropertyPromotionSniff + public function __construct(string $someString) { $this->someString = $someString; }