diff --git a/config/set/symplify.php b/config/set/symplify.php index 3d7efbfc0a..5357130a73 100644 --- a/config/set/symplify.php +++ b/config/set/symplify.php @@ -2,42 +2,12 @@ declare(strict_types=1); -use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer; -use Symplify\CodingStandard\Fixer\Annotation\RemoveMethodNameDuplicateDescriptionFixer; -use Symplify\CodingStandard\Fixer\Annotation\RemovePHPStormAnnotationFixer; -use Symplify\CodingStandard\Fixer\Annotation\RemovePropertyVariableNameDescriptionFixer; -use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer; -use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer; -use Symplify\CodingStandard\Fixer\Commenting\ParamReturnAndVarTagMalformsFixer; -use Symplify\CodingStandard\Fixer\Commenting\RemoveUselessDefaultCommentFixer; -use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer; -use Symplify\CodingStandard\Fixer\Spacing\MethodChainingNewlineFixer; -use Symplify\CodingStandard\Fixer\Spacing\SpaceAfterCommaHereNowDocFixer; -use Symplify\CodingStandard\Fixer\Spacing\StandaloneLinePromotedPropertyFixer; -use Symplify\CodingStandard\Fixer\Strict\BlankLineAfterStrictTypesFixer; use Symplify\EasyCodingStandard\Config\ECSConfig; -return ECSConfig::configure() - ->withRules([ - // docblocks and comments - RemovePHPStormAnnotationFixer::class, - ParamReturnAndVarTagMalformsFixer::class, - RemoveUselessDefaultCommentFixer::class, - RemoveMethodNameDuplicateDescriptionFixer::class, - RemovePropertyVariableNameDescriptionFixer::class, - - // arrays - ArrayListItemNewlineFixer::class, - ArrayOpenerAndCloserNewlineFixer::class, - StandaloneLinePromotedPropertyFixer::class, +trigger_error( + 'The "symplify" set is deprecated. Its rules now live in the "common" sets - use ->withPreparedSets(common: true) or the matching ->withDocblockLevel()/->withSpacesLevel()/->withArrayLevel() methods instead.', + E_USER_DEPRECATED +); - // newlines - MethodChainingNewlineFixer::class, - SpaceAfterCommaHereNowDocFixer::class, - BlankLineAfterStrictTypesFixer::class, - - LineLengthFixer::class, - ]) - ->withConfiguredRule(GeneralPhpdocAnnotationRemoveFixer::class, [ - 'annotations' => ['throws', 'author', 'package', 'group', 'covers', 'category'], - ]); +return ECSConfig::configure() + ->withRules([]); diff --git a/ecs.php b/ecs.php index 19148d131e..eb36b8ac48 100644 --- a/ecs.php +++ b/ecs.php @@ -9,4 +9,4 @@ ->withEditorConfig() ->withRootFiles() ->withSkip(['*/Source/*', '*/Fixture/*']) - ->withPreparedSets(psr12: true, common: true, symplify: true); + ->withPreparedSets(psr12: true, common: true); diff --git a/packages/coding-standard/config/symplify.php b/packages/coding-standard/config/symplify.php deleted file mode 100644 index 13c10f9393..0000000000 --- a/packages/coding-standard/config/symplify.php +++ /dev/null @@ -1,48 +0,0 @@ -rules([ - // docblocks and comments - RemovePHPStormAnnotationFixer::class, - RemoveUselessDefaultCommentFixer::class, - RemoveMethodNameDuplicateDescriptionFixer::class, - RemovePropertyVariableNameDescriptionFixer::class, - - // arrays - ArrayListItemNewlineFixer::class, - ArrayOpenerAndCloserNewlineFixer::class, - StandaloneLineInMultilineArrayFixer::class, - StandaloneLinePromotedPropertyFixer::class, - StandaloneLineConstructorParamFixer::class, - - // newlines - MethodChainingNewlineFixer::class, - SpaceAfterCommaHereNowDocFixer::class, - BlankLineAfterStrictTypesFixer::class, - - // line length - LineLengthFixer::class, - ]); - - $ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, [ - 'annotations' => ['throws', 'author', 'package', 'group', 'covers', 'category'], - ]); -}; diff --git a/src/Config/Level/DocblockLevel.php b/src/Config/Level/DocblockLevel.php index 22cd53894e..b97860cbd9 100644 --- a/src/Config/Level/DocblockLevel.php +++ b/src/Config/Level/DocblockLevel.php @@ -8,6 +8,7 @@ use PhpCsFixer\Fixer\Comment\NoTrailingWhitespaceInCommentFixer; use PhpCsFixer\Fixer\FixerInterface; use PhpCsFixer\Fixer\Phpdoc\AlignMultilineCommentFixer; +use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer; use PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer; use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer; use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer; @@ -27,6 +28,9 @@ use PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer; use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer; use PhpCsFixer\Fixer\Phpdoc\PhpdocVarWithoutNameFixer; +use Symplify\CodingStandard\Fixer\Annotation\RemoveMethodNameDuplicateDescriptionFixer; +use Symplify\CodingStandard\Fixer\Annotation\RemovePHPStormAnnotationFixer; +use Symplify\CodingStandard\Fixer\Annotation\RemovePropertyVariableNameDescriptionFixer; use Symplify\CodingStandard\Fixer\Commenting\AddMissingParamNameFixer; use Symplify\CodingStandard\Fixer\Commenting\AddMissingVarNameFixer; use Symplify\CodingStandard\Fixer\Commenting\DoubleAsteriskInlineVarFixer; @@ -100,6 +104,11 @@ final class DocblockLevel PhpdocNoEmptyReturnFixer::class, RemoveUselessDefaultCommentFixer::class, NoSuperfluousPhpdocTagsFixer::class, + + // annotation cleanup (from deprecated "symplify" set) + RemovePHPStormAnnotationFixer::class, + RemoveMethodNameDuplicateDescriptionFixer::class, + RemovePropertyVariableNameDescriptionFixer::class, ]; /** @@ -110,5 +119,8 @@ final class DocblockLevel 'remove_inheritdoc' => true, 'allow_mixed' => true, ], + GeneralPhpdocAnnotationRemoveFixer::class => [ + 'annotations' => ['author', 'package', 'group', 'covers', 'category'], + ], ]; } diff --git a/src/Config/Level/SpacesLevel.php b/src/Config/Level/SpacesLevel.php index 04742a82d4..5b014f7bdf 100644 --- a/src/Config/Level/SpacesLevel.php +++ b/src/Config/Level/SpacesLevel.php @@ -29,7 +29,10 @@ use PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer; use PhpCsFixer\Fixer\Whitespace\TypeDeclarationSpacesFixer; use PhpCsFixer\Fixer\Whitespace\TypesSpacesFixer; +use Symplify\CodingStandard\Fixer\Spacing\MethodChainingNewlineFixer; +use Symplify\CodingStandard\Fixer\Spacing\SpaceAfterCommaHereNowDocFixer; use Symplify\CodingStandard\Fixer\Spacing\StandaloneLinePromotedPropertyFixer; +use Symplify\CodingStandard\Fixer\Strict\BlankLineAfterStrictTypesFixer; /** * Key 0 = level 0 @@ -79,6 +82,11 @@ final class SpacesLevel MethodArgumentSpaceFixer::class, ClassAttributesSeparationFixer::class, NoExtraBlankLinesFixer::class, + + // newline spacing (from deprecated "symplify" set) + BlankLineAfterStrictTypesFixer::class, + SpaceAfterCommaHereNowDocFixer::class, + MethodChainingNewlineFixer::class, ]; /** diff --git a/src/Configuration/ECSConfigBuilder.php b/src/Configuration/ECSConfigBuilder.php index 9fe12796c3..68a3cf1e17 100644 --- a/src/Configuration/ECSConfigBuilder.php +++ b/src/Configuration/ECSConfigBuilder.php @@ -28,7 +28,6 @@ use Symplify\EasyCodingStandard\Configuration\Levels\LevelRulesResolver; use Symplify\EasyCodingStandard\Exception\Configuration\InitializationException; use Symplify\EasyCodingStandard\Exception\Configuration\SuperfluousConfigurationException; -use Symplify\EasyCodingStandard\Exception\DeprecatedException; use Symplify\EasyCodingStandard\ValueObject\Option; use Symplify\EasyCodingStandard\ValueObject\Set\SetList; @@ -234,7 +233,10 @@ public function withPreparedSets( bool $psr12 = false, /** @see SetList::COMMON */ bool $common = false, - /** @see SetList::SYMPLIFY */ + /** + * @deprecated rules moved to the "common" sets. Use common: true or the with*Level() methods instead. + * @see SetList::SYMPLIFY + */ bool $symplify = false, /** @see SetList::LARAVEL */ bool $laravel = false, @@ -256,16 +258,6 @@ public function withPreparedSets( bool $casing = false, /** @see SetList::CLEANUP */ bool $cleanup = false, - /** - * @deprecated as never worked, used different rules. Use Rector instead. - * @see SetList::PHPUNIT - */ - bool $phpunit = false, - /** - * @deprecated as dangerous without context. Use Rector instead. - * @see SetList::STRICT - */ - bool $strict = false, /** @see SetList::CLEAN_CODE */ bool $cleanCode = false, ): self { @@ -321,12 +313,6 @@ public function withPreparedSets( $this->sets[] = SetList::CONTROL_STRUCTURES; } - if ($phpunit) { - throw new DeprecatedException( - 'The "phpunit" set is deprecated as it is dangerous to run without proper context. Please use Rector instead.' - ); - } - if ($comments) { $this->sets[] = SetList::COMMENTS; } @@ -340,19 +326,16 @@ public function withPreparedSets( } } - if ($strict) { - // throw exception, as deprecated - throw new DeprecatedException( - 'The "strict" set is deprecated as it is dangerous without context. Remove the "strict: true" from ->withPreparedSets(strict: true, ...) call in "ecs.php" and use Rector instead to make sure you are not breaking your code.' - ); - } - if ($cleanCode) { $this->sets[] = SetList::CLEAN_CODE; } if ($symplify) { - $this->sets[] = SetList::SYMPLIFY; + // soft-deprecated: rules moved to the "common" sets, still loaded for backward compatibility + trigger_error( + 'The "symplify" set is deprecated. Its rules now live in the "common" sets - use ->withPreparedSets(common: true) or the matching ->withDocblockLevel()/->withSpacesLevel()/->withArrayLevel() methods instead.', + E_USER_DEPRECATED + ); } if ($laravel) { @@ -672,21 +655,6 @@ public function withPhpCsFixerSets( */ public function withSets(array $sets): self { - // report deprecated STRICT set - foreach ($sets as $set) { - if ($set === SetList::STRICT) { - throw new DeprecatedException( - 'The "strict" set is deprecated as it is dangerous without context. Use Rector instead to make sure you are not breaking your code' - ); - } - - if ($set === SetList::PHPUNIT) { - throw new DeprecatedException( - 'The "phpunit" set is deprecated as it is dangerous to run without proper context. Please use Rector instead.' - ); - } - } - $this->sets = [...$this->sets, ...$sets]; return $this; diff --git a/src/Exception/DeprecatedException.php b/src/Exception/DeprecatedException.php index 330d05b543..89d3c413f1 100644 --- a/src/Exception/DeprecatedException.php +++ b/src/Exception/DeprecatedException.php @@ -6,6 +6,9 @@ use Exception; +/** + * @api to be used + */ final class DeprecatedException extends Exception { } diff --git a/src/ValueObject/Set/SetList.php b/src/ValueObject/Set/SetList.php index 5c236d985b..0b48b75329 100644 --- a/src/ValueObject/Set/SetList.php +++ b/src/ValueObject/Set/SetList.php @@ -21,6 +21,7 @@ final class SetList /** * @api + * @deprecated rules moved to the "common" sets (array, docblock, spaces). Use SetList::COMMON instead. */ public const string SYMPLIFY = __DIR__ . '/../../../config/set/symplify.php'; @@ -54,23 +55,11 @@ final class SetList */ public const string NAMESPACES = __DIR__ . '/../../../config/set/common/namespaces.php'; - /** - * @api - * @deprecated as dangerous without context. Use Rector instead. - */ - public const string PHPUNIT = __DIR__ . '/../../../config/set/common/phpunit.php'; - /** * @api */ public const string SPACES = __DIR__ . '/../../../config/set/common/spaces.php'; - /** - * @api - * @deprecated as dangerous without context. Use Rector instead. - */ - public const string STRICT = __DIR__ . '/../../../config/set/common/strict.php'; - /** * @api */ diff --git a/tests/Configuration/EditorConfig/EditorConfigFactoryTest.php b/tests/Configuration/EditorConfig/EditorConfigFactoryTest.php index 149a91fefe..f5830fddc8 100644 --- a/tests/Configuration/EditorConfig/EditorConfigFactoryTest.php +++ b/tests/Configuration/EditorConfig/EditorConfigFactoryTest.php @@ -47,7 +47,8 @@ public function testParsingInvalidIniFile(): void $this->expectException(Exception::class); $editorConfigFactory = new EditorConfigFactory(); - @$editorConfigFactory->parse(<<parse( + <<assertEquals( new EditorConfigFactory() - ->parse(<<parse( + <<assertEquals( new EditorConfigFactory() - ->parse(<<parse( + <<assertEquals( new EditorConfigFactory() - ->parse(<<parse( + <<assertEquals( new EditorConfigFactory() - ->parse(<<parse( + <<assertEquals( new EditorConfigFactory() - ->parse(<<parse( + <<assertEquals( new EditorConfigFactory() - ->parse(<<parse( + <<assertEquals( new EditorConfigFactory() - ->parse(<<parse( + <<assertEquals( new EditorConfigFactory() - ->parse(<<parse( + <<assertEquals( new EditorConfigFactory() - ->parse(<<parse( + <<assertEquals( new EditorConfigFactory() - ->parse(<<parse( + <<