Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 6 additions & 36 deletions config/set/symplify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
2 changes: 1 addition & 1 deletion ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
->withEditorConfig()
->withRootFiles()
->withSkip(['*/Source/*', '*/Fixture/*'])
->withPreparedSets(psr12: true, common: true, symplify: true);
->withPreparedSets(psr12: true, common: true);
48 changes: 0 additions & 48 deletions packages/coding-standard/config/symplify.php

This file was deleted.

12 changes: 12 additions & 0 deletions src/Config/Level/DocblockLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
];

/**
Expand All @@ -110,5 +119,8 @@ final class DocblockLevel
'remove_inheritdoc' => true,
'allow_mixed' => true,
],
GeneralPhpdocAnnotationRemoveFixer::class => [
'annotations' => ['author', 'package', 'group', 'covers', 'category'],
],
];
}
8 changes: 8 additions & 0 deletions src/Config/Level/SpacesLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
];

/**
Expand Down
50 changes: 9 additions & 41 deletions src/Configuration/ECSConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/Exception/DeprecatedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Exception;

/**
* @api to be used
*/
final class DeprecatedException extends Exception
{
}
13 changes: 1 addition & 12 deletions src/ValueObject/Set/SetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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
*/
Expand Down
Loading
Loading