diff --git a/README.md b/README.md
index 6b1baeee6..75ae80e29 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,9 @@
[](https://packagist.org/packages/symplify/coding-standard/stats)
-Set of rules for PHP_CodeSniffer and PHP-CS-Fixer used by Symplify projects.
+Coding standard rules for clean, consistent, and readable PHP code. No configuration needed—just install and let it handle the rest.
-**They run best with [EasyCodingStandard](https://github.com/symplify/easy-coding-standard)**.
+They run best with [ECS](https://github.com/symplify/easy-coding-standard).
@@ -12,24 +12,35 @@ Set of rules for PHP_CodeSniffer and PHP-CS-Fixer used by Symplify projects.
```bash
composer require symplify/coding-standard --dev
-composer require symplify/easy-coding-standard --dev
+composer require phpecs/phpecs --dev
```
-1. Run with [ECS](https://github.com/symplify/easy-coding-standard):
+1. Register in ECS config:
-```diff
-# ecs.php
+```php
+ # ecs.php
use Symplify\EasyCodingStandard\Config\ECSConfig;
-+use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
+ use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
- return static function (ECSConfig $ecsConfig): void {
-+ $ecsConfig->sets([SetList::SYMPLIFY]);
+ return ECSConfig::configure()
+ ->withSets([SetList::SYMPLIFY]);
+```
+
+
+2. And run:
+
+```bash
+# dry-run without changes
+vendor/bin/ecs
+
+
+# apply changes
+vendor/bin/ecs --fix
```
-
-# 12 Rules Overview
+# 12 Rules to Keep Your Code Clean
## ArrayListItemNewlineFixer
@@ -255,5 +266,3 @@ Promoted property should be on standalone line
```
-
-
diff --git a/composer.json b/composer.json
index 291ce7936..ddda48f0c 100644
--- a/composer.json
+++ b/composer.json
@@ -5,19 +5,18 @@
"require": {
"php": ">=8.2",
"nette/utils": "^4.0",
- "friendsofphp/php-cs-fixer": "^3.59",
+ "friendsofphp/php-cs-fixer": "^3.73.1",
"symplify/rule-doc-generator-contracts": "^11.2"
},
"require-dev": {
- "symplify/easy-coding-standard": "^12.3",
- "squizlabs/php_codesniffer": "^3.10.1",
- "phpunit/phpunit": "^10.5",
- "symplify/rule-doc-generator": "^12.2.2",
+ "symplify/easy-coding-standard": "^12.5",
+ "squizlabs/php_codesniffer": "^3.12",
+ "phpunit/phpunit": "^11.5",
"phpstan/extension-installer": "^1.4",
- "phpstan/phpstan": "^1.11",
- "rector/rector": "^1.1",
- "symplify/phpstan-extensions": "^11.4",
- "tomasvotruba/class-leak": "^0.2",
+ "phpstan/phpstan": "^2.1",
+ "rector/rector": "^2.0",
+ "symplify/phpstan-extensions": "^12.0",
+ "tomasvotruba/class-leak": "^2.0",
"tracy/tracy": "^2.10"
},
"autoload": {
@@ -38,8 +37,7 @@
"scripts": {
"check-cs": "vendor/bin/ecs check --ansi",
"fix-cs": "vendor/bin/ecs check --fix --ansi",
- "phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify",
- "rector": "vendor/bin/rector process --dry-run --ansi",
- "docs": "vendor/bin/rule-doc-generator generate src --readme --ansi"
+ "phpstan": "vendor/bin/phpstan analyse --ansi",
+ "rector": "vendor/bin/rector process --dry-run --ansi"
}
}
diff --git a/docs/rules_overview.md b/docs/rules_overview.md
deleted file mode 100644
index bc765542d..000000000
--- a/docs/rules_overview.md
+++ /dev/null
@@ -1,226 +0,0 @@
-# 12 Rules Overview
-
-## ArrayListItemNewlineFixer
-
-Indexed PHP array item has to have one line per item
-
-- class: [`Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer`](../src/Fixer/ArrayNotation/ArrayListItemNewlineFixer.php)
-
-```diff
--$value = ['simple' => 1, 'easy' => 2];
-+$value = ['simple' => 1,
-+'easy' => 2];
-```
-
-
-
-## ArrayOpenerAndCloserNewlineFixer
-
-Indexed PHP array opener [ and closer ] must be on own line
-
-- class: [`Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer`](../src/Fixer/ArrayNotation/ArrayOpenerAndCloserNewlineFixer.php)
-
-```diff
--$items = [1 => 'Hey'];
-+$items = [
-+1 => 'Hey'
-+];
-```
-
-
-
-## BlankLineAfterStrictTypesFixer
-
-Strict type declaration has to be followed by empty line
-
-- class: [`Symplify\CodingStandard\Fixer\Strict\BlankLineAfterStrictTypesFixer`](../src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php)
-
-```diff
- declare(strict_types=1);
-+
- namespace App;
-```
-
-
-
-## LineLengthFixer
-
-Array items, method parameters, method call arguments, new arguments should be on same/standalone line to fit line length.
-
-:wrench: **configure it!**
-
-- class: [`Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer`](../src/Fixer/LineLength/LineLengthFixer.php)
-
-```diff
--function some($veryLong, $superLong, $oneMoreTime)
--{
-+function some(
-+ $veryLong,
-+ $superLong,
-+ $oneMoreTime
-+) {
- }
-
--function another(
-- $short,
-- $now
--) {
-+function another($short, $now) {
- }
-```
-
-
-
-## MethodChainingNewlineFixer
-
-Each chain method call must be on own line
-
-- class: [`Symplify\CodingStandard\Fixer\Spacing\MethodChainingNewlineFixer`](../src/Fixer/Spacing/MethodChainingNewlineFixer.php)
-
-```diff
--$someClass->firstCall()->secondCall();
-+$someClass->firstCall()
-+->secondCall();
-```
-
-
-
-## ParamReturnAndVarTagMalformsFixer
-
-Fixes @param, @return, `@var` and inline `@var` annotations broken formats
-
-- class: [`Symplify\CodingStandard\Fixer\Commenting\ParamReturnAndVarTagMalformsFixer`](../src/Fixer/Commenting/ParamReturnAndVarTagMalformsFixer.php)
-
-```diff
- /**
-- * @param string
-+ * @param string $name
- */
- function getPerson($name)
- {
- }
-```
-
-
-
-## RemovePHPStormAnnotationFixer
-
-Remove "Created by PhpStorm" annotations
-
-- class: [`Symplify\CodingStandard\Fixer\Annotation\RemovePHPStormAnnotationFixer`](../src/Fixer/Annotation/RemovePHPStormAnnotationFixer.php)
-
-```diff
--/**
-- * Created by PhpStorm.
-- * User: ...
-- * Date: 17/10/17
-- * Time: 8:50 AM
-- */
- class SomeClass
- {
- }
-```
-
-
-
-## RemoveUselessDefaultCommentFixer
-
-Remove useless PHPStorm-generated `@todo` comments, redundant "Class XY" or "gets service" comments etc.
-
-- class: [`Symplify\CodingStandard\Fixer\Commenting\RemoveUselessDefaultCommentFixer`](../src/Fixer/Commenting/RemoveUselessDefaultCommentFixer.php)
-
-```diff
--/**
-- * class SomeClass
-- */
- class SomeClass
- {
-- /**
-- * SomeClass Constructor.
-- */
- public function __construct()
- {
-- // TODO: Change the autogenerated stub
-- // TODO: Implement whatever() method.
- }
- }
-```
-
-
-
-## SpaceAfterCommaHereNowDocFixer
-
-Add space after nowdoc and heredoc keyword, to prevent bugs on PHP 7.2 and lower, see https://laravel-news.com/flexible-heredoc-and-nowdoc-coming-to-php-7-3
-
-- class: [`Symplify\CodingStandard\Fixer\Spacing\SpaceAfterCommaHereNowDocFixer`](../src/Fixer/Spacing/SpaceAfterCommaHereNowDocFixer.php)
-
-```diff
- $values = [
- <<
-
-## StandaloneLineConstructorParamFixer
-
-Constructor param should be on a standalone line to ease git diffs on new dependency
-
-- class: [`Symplify\CodingStandard\Fixer\Spacing\StandaloneLineConstructorParamFixer`](../src/Fixer/Spacing/StandaloneLineConstructorParamFixer.php)
-
-```diff
- final class PromotedProperties
- {
-- public function __construct(int $age, string $name)
-- {
-+ public function __construct(
-+ int $age,
-+ string $name
-+ ) {
- }
- }
-```
-
-
-
-## StandaloneLineInMultilineArrayFixer
-
-Indexed arrays must have 1 item per line
-
-- class: [`Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer`](../src/Fixer/ArrayNotation/StandaloneLineInMultilineArrayFixer.php)
-
-```diff
--$friends = [1 => 'Peter', 2 => 'Paul'];
-+$friends = [
-+ 1 => 'Peter',
-+ 2 => 'Paul'
-+];
-```
-
-
-
-## StandaloneLinePromotedPropertyFixer
-
-Promoted property should be on standalone line
-
-- class: [`Symplify\CodingStandard\Fixer\Spacing\StandaloneLinePromotedPropertyFixer`](../src/Fixer/Spacing/StandaloneLinePromotedPropertyFixer.php)
-
-```diff
- final class PromotedProperties
- {
-- public function __construct(public int $age, private string $name)
-- {
-+ public function __construct(
-+ public int $age,
-+ private string $name
-+ ) {
- }
- }
-```
-
-
diff --git a/phpstan.neon b/phpstan.neon
index fab7d8d63..c3af9c45a 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,6 +1,8 @@
parameters:
level: 8
+ errorFormat: symplify
+
paths:
- src
- config
@@ -24,7 +26,7 @@ parameters:
# unused generics
- '#Class (.*?) implements generic interface PhpCsFixer\\Fixer\\ConfigurableFixerInterface but does not specify its types\: TFixerInputConfig, TFixerComputedConfig#'
- # false positive
+ # conditional check to allow various php versions
-
- message: '#Parameter \#1 \$sequence of method PhpCsFixer\\Tokenizer\\Tokens\:\:findSequence\(\) expects non\-empty\-array, array given#'
- path: src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php
+ message: '#Comparison operation ">\=" between int<80200, 80499> and (.*?) is always true#'
+ path: src/TokenAnalyzer/DocblockRelatedParamNamesResolver.php
diff --git a/rector.php b/rector.php
index e13eff1d9..7c36316c8 100644
--- a/rector.php
+++ b/rector.php
@@ -7,6 +7,7 @@
return RectorConfig::configure()
->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests'])
->withPhpSets()
+ ->withRootFiles()
->withPreparedSets(codeQuality: true, codingStyle: true, naming: true, earlyReturn: true, privatization: true)
->withImportNames(removeUnusedImports: true)
->withSkip([
diff --git a/src/Fixer/Annotation/RemovePHPStormAnnotationFixer.php b/src/Fixer/Annotation/RemovePHPStormAnnotationFixer.php
index 40f204304..52d90c887 100644
--- a/src/Fixer/Annotation/RemovePHPStormAnnotationFixer.php
+++ b/src/Fixer/Annotation/RemovePHPStormAnnotationFixer.php
@@ -12,14 +12,11 @@
use SplFileInfo;
use Symplify\CodingStandard\Fixer\AbstractSymplifyFixer;
use Symplify\CodingStandard\TokenRunner\Traverser\TokenReverser;
-use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Symplify\CodingStandard\Tests\Fixer\Annotation\RemovePHPStormAnnotationFixer\RemovePHPStormAnnotationFixerTest
*/
-final class RemovePHPStormAnnotationFixer extends AbstractSymplifyFixer implements DocumentedRuleInterface
+final class RemovePHPStormAnnotationFixer extends AbstractSymplifyFixer
{
/**
* @see https://regex101.com/r/nGZBzj/2
@@ -72,29 +69,4 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void
$tokens->clearAt($index);
}
}
-
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new CodeSample(
- <<<'CODE_SAMPLE'
-/**
- * Created by PhpStorm.
- * User: ...
- * Date: 17/10/17
- * Time: 8:50 AM
- */
-class SomeClass
-{
-}
-CODE_SAMPLE
- ,
- <<<'CODE_SAMPLE'
-class SomeClass
-{
-}
-CODE_SAMPLE
- ),
- ]);
- }
}
diff --git a/src/Fixer/ArrayNotation/ArrayListItemNewlineFixer.php b/src/Fixer/ArrayNotation/ArrayListItemNewlineFixer.php
index 705aaa115..99be3382c 100644
--- a/src/Fixer/ArrayNotation/ArrayListItemNewlineFixer.php
+++ b/src/Fixer/ArrayNotation/ArrayListItemNewlineFixer.php
@@ -14,14 +14,11 @@
use Symplify\CodingStandard\TokenRunner\Arrays\ArrayItemNewliner;
use Symplify\CodingStandard\TokenRunner\Traverser\ArrayBlockInfoFinder;
use Symplify\CodingStandard\TokenRunner\ValueObject\TokenKinds;
-use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Symplify\CodingStandard\Tests\Fixer\ArrayNotation\ArrayListItemNewlineFixer\ArrayListItemNewlineFixerTest
*/
-final class ArrayListItemNewlineFixer extends AbstractSymplifyFixer implements DocumentedRuleInterface
+final class ArrayListItemNewlineFixer extends AbstractSymplifyFixer
{
/**
* @var string
@@ -71,20 +68,4 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void
$this->arrayItemNewliner->fixArrayOpener($tokens, $arrayBlockInfo);
}
}
-
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new CodeSample(
- <<<'CODE_SAMPLE'
-$value = ['simple' => 1, 'easy' => 2];
-CODE_SAMPLE
- ,
- <<<'CODE_SAMPLE'
-$value = ['simple' => 1,
-'easy' => 2];
-CODE_SAMPLE
- ),
- ]);
- }
}
diff --git a/src/Fixer/ArrayNotation/ArrayOpenerAndCloserNewlineFixer.php b/src/Fixer/ArrayNotation/ArrayOpenerAndCloserNewlineFixer.php
index b84908d38..76eec60ac 100644
--- a/src/Fixer/ArrayNotation/ArrayOpenerAndCloserNewlineFixer.php
+++ b/src/Fixer/ArrayNotation/ArrayOpenerAndCloserNewlineFixer.php
@@ -16,14 +16,11 @@
use Symplify\CodingStandard\TokenRunner\Traverser\ArrayBlockInfoFinder;
use Symplify\CodingStandard\TokenRunner\ValueObject\TokenKinds;
use Symplify\CodingStandard\ValueObject\BlockInfoMetadata;
-use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Symplify\CodingStandard\Tests\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer\ArrayOpenerAndCloserNewlineFixerTest
*/
-final class ArrayOpenerAndCloserNewlineFixer extends AbstractSymplifyFixer implements DocumentedRuleInterface
+final class ArrayOpenerAndCloserNewlineFixer extends AbstractSymplifyFixer
{
/**
* @var string
@@ -52,23 +49,6 @@ public function getPriority(): int
return 34;
}
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new CodeSample(
- <<<'CODE_SAMPLE'
-$items = [1 => 'Hey'];
-CODE_SAMPLE
- ,
- <<<'CODE_SAMPLE'
-$items = [
-1 => 'Hey'
-];
-CODE_SAMPLE
- ),
- ]);
- }
-
/**
* @param Tokens $tokens
*/
diff --git a/src/Fixer/ArrayNotation/StandaloneLineInMultilineArrayFixer.php b/src/Fixer/ArrayNotation/StandaloneLineInMultilineArrayFixer.php
index 0a0276f5b..8ffdc7ff0 100644
--- a/src/Fixer/ArrayNotation/StandaloneLineInMultilineArrayFixer.php
+++ b/src/Fixer/ArrayNotation/StandaloneLineInMultilineArrayFixer.php
@@ -16,14 +16,11 @@
use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo;
use Symplify\CodingStandard\TokenRunner\ValueObject\TokenKinds;
use Symplify\CodingStandard\TokenRunner\Wrapper\FixerWrapper\ArrayWrapperFactory;
-use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Symplify\CodingStandard\Tests\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer\StandaloneLineInMultilineArrayFixerTest
*/
-final class StandaloneLineInMultilineArrayFixer extends AbstractSymplifyFixer implements DocumentedRuleInterface
+final class StandaloneLineInMultilineArrayFixer extends AbstractSymplifyFixer
{
/**
* @var string
@@ -52,24 +49,6 @@ public function getPriority(): int
return 5;
}
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new CodeSample(
- <<<'CODE_SAMPLE'
-$friends = [1 => 'Peter', 2 => 'Paul'];
-CODE_SAMPLE
- ,
- <<<'CODE_SAMPLE'
-$friends = [
- 1 => 'Peter',
- 2 => 'Paul'
-];
-CODE_SAMPLE
- ),
- ]);
- }
-
/**
* @param Tokens $tokens
*/
diff --git a/src/Fixer/Commenting/ParamReturnAndVarTagMalformsFixer.php b/src/Fixer/Commenting/ParamReturnAndVarTagMalformsFixer.php
index d7ba6dcf6..bc6aa556e 100644
--- a/src/Fixer/Commenting/ParamReturnAndVarTagMalformsFixer.php
+++ b/src/Fixer/Commenting/ParamReturnAndVarTagMalformsFixer.php
@@ -22,14 +22,11 @@
use Symplify\CodingStandard\TokenRunner\DocBlock\MalformWorker\SuperfluousVarNameMalformWorker;
use Symplify\CodingStandard\TokenRunner\DocBlock\MalformWorker\SwitchedTypeAndNameMalformWorker;
use Symplify\CodingStandard\TokenRunner\Traverser\TokenReverser;
-use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Symplify\CodingStandard\Tests\Fixer\Commenting\ParamReturnAndVarTagMalformsFixer\ParamReturnAndVarTagMalformsFixerTest
*/
-final class ParamReturnAndVarTagMalformsFixer extends AbstractSymplifyFixer implements DocumentedRuleInterface
+final class ParamReturnAndVarTagMalformsFixer extends AbstractSymplifyFixer
{
/**
* @var string
@@ -142,29 +139,4 @@ public function getPriority(): int
{
return -37;
}
-
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new CodeSample(
- <<<'CODE_SAMPLE'
-/**
- * @param string
- */
-function getPerson($name)
-{
-}
-CODE_SAMPLE
- ,
- <<<'CODE_SAMPLE'
-/**
- * @param string $name
- */
-function getPerson($name)
-{
-}
-CODE_SAMPLE
- ),
- ]);
- }
}
diff --git a/src/Fixer/Commenting/RemoveUselessDefaultCommentFixer.php b/src/Fixer/Commenting/RemoveUselessDefaultCommentFixer.php
index 79713c45b..64ebe62b7 100644
--- a/src/Fixer/Commenting/RemoveUselessDefaultCommentFixer.php
+++ b/src/Fixer/Commenting/RemoveUselessDefaultCommentFixer.php
@@ -13,14 +13,11 @@
use Symplify\CodingStandard\Fixer\AbstractSymplifyFixer;
use Symplify\CodingStandard\Fixer\Naming\ClassNameResolver;
use Symplify\CodingStandard\TokenRunner\Traverser\TokenReverser;
-use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Symplify\CodingStandard\Tests\Fixer\Commenting\RemoveUselessDefaultCommentFixer\RemoveUselessDefaultCommentFixerTest
*/
-final class RemoveUselessDefaultCommentFixer extends AbstractSymplifyFixer implements DocumentedRuleInterface
+final class RemoveUselessDefaultCommentFixer extends AbstractSymplifyFixer
{
/**
* @var string
@@ -79,37 +76,4 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void
}
}
}
-
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new CodeSample(
- <<<'CODE_SAMPLE'
-/**
- * class SomeClass
- */
-class SomeClass
-{
- /**
- * SomeClass Constructor.
- */
- public function __construct()
- {
- // TODO: Change the autogenerated stub
- // TODO: Implement whatever() method.
- }
-}
-CODE_SAMPLE
- ,
- <<<'CODE_SAMPLE'
-class SomeClass
-{
- public function __construct()
- {
- }
-}
-CODE_SAMPLE
- ),
- ]);
- }
}
diff --git a/src/Fixer/LineLength/LineLengthFixer.php b/src/Fixer/LineLength/LineLengthFixer.php
index e792d2893..a0ef5aad4 100644
--- a/src/Fixer/LineLength/LineLengthFixer.php
+++ b/src/Fixer/LineLength/LineLengthFixer.php
@@ -22,15 +22,12 @@
use Symplify\CodingStandard\TokenRunner\Transformer\FixerTransformer\LineLengthTransformer;
use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo;
use Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface;
-use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Symplify\CodingStandard\Tests\Fixer\LineLength\LineLengthFixer\LineLengthFixerTest
* @see \Symplify\CodingStandard\Tests\Fixer\LineLength\LineLengthFixer\ConfiguredLineLengthFixerTest
*/
-final class LineLengthFixer extends AbstractSymplifyFixer implements ConfigurableRuleInterface, ConfigurableFixerInterface, DocumentedRuleInterface
+final class LineLengthFixer extends AbstractSymplifyFixer implements ConfigurableRuleInterface, ConfigurableFixerInterface
{
/**
* @api
@@ -138,41 +135,6 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void
}
}
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new ConfiguredCodeSample(
- <<<'CODE_SAMPLE'
-function some($veryLong, $superLong, $oneMoreTime)
-{
-}
-
-function another(
- $short,
- $now
-) {
-}
-CODE_SAMPLE
- ,
- <<<'CODE_SAMPLE'
-function some(
- $veryLong,
- $superLong,
- $oneMoreTime
-) {
-}
-
-function another($short, $now) {
-}
-CODE_SAMPLE
- ,
- [
- self::LINE_LENGTH => 40,
- ]
- ),
- ]);
- }
-
/**
* Must run before
*
diff --git a/src/Fixer/Spacing/MethodChainingNewlineFixer.php b/src/Fixer/Spacing/MethodChainingNewlineFixer.php
index 1edc17739..09e22a3b3 100644
--- a/src/Fixer/Spacing/MethodChainingNewlineFixer.php
+++ b/src/Fixer/Spacing/MethodChainingNewlineFixer.php
@@ -14,14 +14,11 @@
use Symplify\CodingStandard\TokenAnalyzer\ChainMethodCallAnalyzer;
use Symplify\CodingStandard\TokenRunner\Analyzer\FixerAnalyzer\BlockFinder;
use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo;
-use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Symplify\CodingStandard\Tests\Fixer\Spacing\MethodChainingNewlineFixer\MethodChainingNewlineFixerTest
*/
-final class MethodChainingNewlineFixer extends AbstractSymplifyFixer implements DocumentedRuleInterface
+final class MethodChainingNewlineFixer extends AbstractSymplifyFixer
{
/**
* @var string
@@ -79,22 +76,6 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void
}
}
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new CodeSample(
- <<<'CODE_SAMPLE'
-$someClass->firstCall()->secondCall();
-CODE_SAMPLE
- ,
- <<<'CODE_SAMPLE'
-$someClass->firstCall()
-->secondCall();
-CODE_SAMPLE
- ),
- ]);
- }
-
/**
* @param Tokens $tokens
*/
diff --git a/src/Fixer/Spacing/SpaceAfterCommaHereNowDocFixer.php b/src/Fixer/Spacing/SpaceAfterCommaHereNowDocFixer.php
index 4b6019447..e93d6c499 100644
--- a/src/Fixer/Spacing/SpaceAfterCommaHereNowDocFixer.php
+++ b/src/Fixer/Spacing/SpaceAfterCommaHereNowDocFixer.php
@@ -10,15 +10,12 @@
use PhpCsFixer\Tokenizer\Tokens;
use SplFileInfo;
use Symplify\CodingStandard\Fixer\AbstractSymplifyFixer;
-use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Symplify\CodingStandard\Tests\Fixer\Spacing\SpaceAfterCommaHereNowDocFixer\SpaceAfterCommaHereNowDocFixerTest
* @see https://3v4l.org/KPZXU
*/
-final class SpaceAfterCommaHereNowDocFixer extends AbstractSymplifyFixer implements DocumentedRuleInterface
+final class SpaceAfterCommaHereNowDocFixer extends AbstractSymplifyFixer
{
/**
* @var string
@@ -66,30 +63,4 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void
$tokens->ensureWhitespaceAtIndex($position + 1, 0, PHP_EOL);
}
}
-
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new CodeSample(
- <<<'CODE_SAMPLE'
-$values = [
- <<paramNewliner->processFunction($tokens, $position);
}
}
-
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new CodeSample(
- <<<'CODE_SAMPLE'
-final class PromotedProperties
-{
- public function __construct(int $age, string $name)
- {
- }
-}
-CODE_SAMPLE
- ,
- <<<'CODE_SAMPLE'
-final class PromotedProperties
-{
- public function __construct(
- int $age,
- string $name
- ) {
- }
-}
-CODE_SAMPLE
- ),
- ]);
- }
}
diff --git a/src/Fixer/Spacing/StandaloneLinePromotedPropertyFixer.php b/src/Fixer/Spacing/StandaloneLinePromotedPropertyFixer.php
index bfd036508..7f12c3485 100644
--- a/src/Fixer/Spacing/StandaloneLinePromotedPropertyFixer.php
+++ b/src/Fixer/Spacing/StandaloneLinePromotedPropertyFixer.php
@@ -13,14 +13,11 @@
use Symplify\CodingStandard\Fixer\AbstractSymplifyFixer;
use Symplify\CodingStandard\TokenAnalyzer\Naming\MethodNameResolver;
use Symplify\CodingStandard\TokenAnalyzer\ParamNewliner;
-use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Symplify\CodingStandard\Tests\Fixer\Spacing\StandaloneLinePromotedPropertyFixer\StandaloneLinePromotedPropertyFixerTest
*/
-final class StandaloneLinePromotedPropertyFixer extends AbstractSymplifyFixer implements DocumentedRuleInterface
+final class StandaloneLinePromotedPropertyFixer extends AbstractSymplifyFixer
{
/**
* @var string
@@ -81,31 +78,4 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void
$this->paramNewliner->processFunction($tokens, $position);
}
}
-
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new CodeSample(
- <<<'CODE_SAMPLE'
-final class PromotedProperties
-{
- public function __construct(public int $age, private string $name)
- {
- }
-}
-CODE_SAMPLE
- ,
- <<<'CODE_SAMPLE'
-final class PromotedProperties
-{
- public function __construct(
- public int $age,
- private string $name
- ) {
- }
-}
-CODE_SAMPLE
- ),
- ]);
- }
}
diff --git a/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php b/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php
index b671f84b4..e46eefc0a 100644
--- a/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php
+++ b/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php
@@ -11,17 +11,15 @@
use PhpCsFixer\WhitespacesFixerConfig;
use SplFileInfo;
use Symplify\CodingStandard\Fixer\AbstractSymplifyFixer;
-use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* Inspired at https://github.com/aidantwoods/PHP-CS-Fixer/tree/feature/DeclareStrictTypesFixer-split
*
* @thanks Aidan Woods
+ *
* @see \Symplify\CodingStandard\Tests\Fixer\Strict\BlankLineAfterStrictTypesFixer\BlankLineAfterStrictTypesFixerTest
*/
-final class BlankLineAfterStrictTypesFixer extends AbstractSymplifyFixer implements DocumentedRuleInterface
+final class BlankLineAfterStrictTypesFixer extends AbstractSymplifyFixer
{
/**
* @var string
@@ -31,9 +29,9 @@ final class BlankLineAfterStrictTypesFixer extends AbstractSymplifyFixer impleme
/**
* Generates: "declare(strict_types=1);"
*
- * @var Token[]
+ * @var non-empty-list
*/
- private array $declareStrictTypeTokens = [];
+ private readonly array $declareStrictTypeTokens;
public function __construct(
private readonly WhitespacesFixerConfig $whitespacesFixerConfig
@@ -83,22 +81,4 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void
$tokens->ensureWhitespaceAtIndex($semicolonPosition + 1, 0, $lineEnding . $lineEnding);
}
-
- public function getRuleDefinition(): RuleDefinition
- {
- return new RuleDefinition(self::ERROR_MESSAGE, [
- new CodeSample(
- <<<'CODE_SAMPLE'
-declare(strict_types=1);
-namespace App;
-CODE_SAMPLE
- ,
- <<<'CODE_SAMPLE'
-declare(strict_types=1);
-
-namespace App;
-CODE_SAMPLE
- ),
- ]);
- }
}
diff --git a/src/TokenAnalyzer/DocblockRelatedParamNamesResolver.php b/src/TokenAnalyzer/DocblockRelatedParamNamesResolver.php
index 8ffb5ddf8..978f7e7c7 100644
--- a/src/TokenAnalyzer/DocblockRelatedParamNamesResolver.php
+++ b/src/TokenAnalyzer/DocblockRelatedParamNamesResolver.php
@@ -11,9 +11,9 @@
final class DocblockRelatedParamNamesResolver
{
/**
- * @var Token[]
+ * @var list
*/
- private array $functionTokens = [];
+ private array $functionTokens;
private readonly FunctionsAnalyzer $functionsAnalyzer;
@@ -21,7 +21,9 @@ public function __construct(
) {
$this->functionsAnalyzer = new FunctionsAnalyzer();
- $this->functionTokens[] = new Token([T_FUNCTION, 'function']);
+ $this->functionTokens = [
+ new Token([T_FUNCTION, 'function']),
+ ];
// only in PHP 7.4+
if ($this->doesFnTokenExist()) {