diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml index 2faa71380..de302e360 100644 --- a/.github/workflows/code_analysis.yaml +++ b/.github/workflows/code_analysis.yaml @@ -36,10 +36,6 @@ jobs: name: 'Tests' run: vendor/bin/phpunit - - - name: 'Check Commented Code' - run: vendor/bin/easy-ci check-commented-code src tests --ansi - - name: 'Check Active Classes' run: vendor/bin/class-leak check src --ansi diff --git a/composer.json b/composer.json index 55e427f4e..f574321c0 100644 --- a/composer.json +++ b/composer.json @@ -3,23 +3,20 @@ "description": "Set of Symplify rules for PHP_CodeSniffer and PHP CS Fixer.", "license": "MIT", "require": { - "php": ">=8.1", + "php": ">=8.2", "nette/utils": "^3.2", - "friendsofphp/php-cs-fixer": "^3.40", + "friendsofphp/php-cs-fixer": "^3.45", "symplify/rule-doc-generator-contracts": "^11.1" }, "require-dev": { "symplify/easy-coding-standard": "^12.0.11", - "squizlabs/php_codesniffer": "^3.7.2", - "phpunit/phpunit": "^10.2", + "squizlabs/php_codesniffer": "^3.8.0", + "phpunit/phpunit": "^10.5", "symplify/rule-doc-generator": "^12.0", "phpstan/extension-installer": "^1.3", - "phpstan/phpstan": "^1.10.26", - "rector/rector": "^0.17.7", - "symplify/easy-ci": "^11.3", + "phpstan/phpstan": "^1.10.50", + "rector/rector": "^0.18", "symplify/phpstan-extensions": "^11.2", - "tomasvotruba/unused-public": "^0.3", - "tomasvotruba/type-coverage": "^0.2", "tomasvotruba/class-leak": "^0.2", "tracy/tracy": "^2.10" }, diff --git a/phpstan.neon b/phpstan.neon index 3854ffb06..fba06832b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -21,3 +21,8 @@ parameters: - '#Constant T_OPEN_CURLY_BRACKET|T_START_NOWDOC not found#' - '#Parameter \#1 \$index of method PhpCsFixer\\Tokenizer\\Tokens\:\:getNextTokenOfKind\(\) expects int, int\|null given#' - '#Method Symplify\\CodingStandard\\TokenRunner\\Traverser\\ArrayBlockInfoFinder\:\:reverseTokens\(\) should return array but returns array#' + + # false positive + - + message: '#Parameter \#1 \$sequence of method PhpCsFixer\\Tokenizer\\Tokens\:\:findSequence\(\) expects non\-empty\-array, array given#' + path: src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php diff --git a/rector.php b/rector.php index 8b8493338..7bf8b84b7 100644 --- a/rector.php +++ b/rector.php @@ -9,7 +9,7 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_81, + LevelSetList::UP_TO_PHP_82, SetList::CODE_QUALITY, SetList::DEAD_CODE, SetList::CODING_STYLE, diff --git a/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php b/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php index 5308e655c..b671f84b4 100644 --- a/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php +++ b/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php @@ -72,7 +72,7 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void return; } - $semicolonPosition = (int) array_key_last($sequenceLocation); + $semicolonPosition = array_key_last($sequenceLocation); // empty file if (! isset($tokens[$semicolonPosition + 2])) { diff --git a/src/TokenAnalyzer/ParamNewliner.php b/src/TokenAnalyzer/ParamNewliner.php index ca1f3ef8a..f0aa6b3a0 100644 --- a/src/TokenAnalyzer/ParamNewliner.php +++ b/src/TokenAnalyzer/ParamNewliner.php @@ -11,11 +11,11 @@ use Symplify\CodingStandard\TokenRunner\Transformer\FixerTransformer\TokensNewliner; use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; -final class ParamNewliner +final readonly class ParamNewliner { public function __construct( - private readonly BlockFinder $blockFinder, - private readonly TokensNewliner $tokensNewliner, + private BlockFinder $blockFinder, + private TokensNewliner $tokensNewliner, ) { } diff --git a/src/TokenRunner/Analyzer/FixerAnalyzer/ArrayAnalyzer.php b/src/TokenRunner/Analyzer/FixerAnalyzer/ArrayAnalyzer.php index 9e096b2ef..818c7d453 100644 --- a/src/TokenRunner/Analyzer/FixerAnalyzer/ArrayAnalyzer.php +++ b/src/TokenRunner/Analyzer/FixerAnalyzer/ArrayAnalyzer.php @@ -9,10 +9,10 @@ use PhpCsFixer\Tokenizer\Tokens; use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; -final class ArrayAnalyzer +final readonly class ArrayAnalyzer { public function __construct( - private readonly TokenSkipper $tokenSkipper + private TokenSkipper $tokenSkipper ) { } diff --git a/src/TokenRunner/Analyzer/FixerAnalyzer/IndentDetector.php b/src/TokenRunner/Analyzer/FixerAnalyzer/IndentDetector.php index ebf0f34d3..5d4fd436d 100644 --- a/src/TokenRunner/Analyzer/FixerAnalyzer/IndentDetector.php +++ b/src/TokenRunner/Analyzer/FixerAnalyzer/IndentDetector.php @@ -8,10 +8,10 @@ use PhpCsFixer\Tokenizer\Tokens; use PhpCsFixer\WhitespacesFixerConfig; -final class IndentDetector +final readonly class IndentDetector { public function __construct( - private readonly WhitespacesFixerConfig $whitespacesFixerConfig + private WhitespacesFixerConfig $whitespacesFixerConfig ) { } diff --git a/src/TokenRunner/Analyzer/FixerAnalyzer/TokenSkipper.php b/src/TokenRunner/Analyzer/FixerAnalyzer/TokenSkipper.php index c40b0376d..aa577dc2f 100644 --- a/src/TokenRunner/Analyzer/FixerAnalyzer/TokenSkipper.php +++ b/src/TokenRunner/Analyzer/FixerAnalyzer/TokenSkipper.php @@ -11,10 +11,10 @@ use Symplify\CodingStandard\TokenRunner\Exception\TokenNotFoundException; use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; -final class TokenSkipper +final readonly class TokenSkipper { public function __construct( - private readonly BlockFinder $blockFinder + private BlockFinder $blockFinder ) { } diff --git a/src/TokenRunner/Arrays/ArrayItemNewliner.php b/src/TokenRunner/Arrays/ArrayItemNewliner.php index b152cb3a6..10fb49eb1 100644 --- a/src/TokenRunner/Arrays/ArrayItemNewliner.php +++ b/src/TokenRunner/Arrays/ArrayItemNewliner.php @@ -10,11 +10,11 @@ use Symplify\CodingStandard\TokenRunner\Analyzer\FixerAnalyzer\ArrayAnalyzer; use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; -final class ArrayItemNewliner +final readonly class ArrayItemNewliner { public function __construct( - private readonly ArrayAnalyzer $arrayAnalyzer, - private readonly WhitespacesFixerConfig $whitespacesFixerConfig + private ArrayAnalyzer $arrayAnalyzer, + private WhitespacesFixerConfig $whitespacesFixerConfig ) { } diff --git a/src/TokenRunner/DocBlock/MalformWorker/MissingParamNameMalformWorker.php b/src/TokenRunner/DocBlock/MalformWorker/MissingParamNameMalformWorker.php index d7a00f340..7a059527f 100644 --- a/src/TokenRunner/DocBlock/MalformWorker/MissingParamNameMalformWorker.php +++ b/src/TokenRunner/DocBlock/MalformWorker/MissingParamNameMalformWorker.php @@ -12,7 +12,7 @@ use Symplify\CodingStandard\TokenAnalyzer\DocblockRelatedParamNamesResolver; use Symplify\CodingStandard\TokenRunner\Contract\DocBlock\MalformWorkerInterface; -final class MissingParamNameMalformWorker implements MalformWorkerInterface +final readonly class MissingParamNameMalformWorker implements MalformWorkerInterface { /** * @var string @@ -33,7 +33,7 @@ final class MissingParamNameMalformWorker implements MalformWorkerInterface private const PARAM_WITH_NAME_REGEX = '#@param(.*?)\$[\w]+(.*?)\n#'; public function __construct( - private readonly DocblockRelatedParamNamesResolver $docblockRelatedParamNamesResolver + private DocblockRelatedParamNamesResolver $docblockRelatedParamNamesResolver ) { } diff --git a/src/TokenRunner/DocBlock/MalformWorker/ParamNameTypoMalformWorker.php b/src/TokenRunner/DocBlock/MalformWorker/ParamNameTypoMalformWorker.php index 0bbee54dd..1358f6478 100644 --- a/src/TokenRunner/DocBlock/MalformWorker/ParamNameTypoMalformWorker.php +++ b/src/TokenRunner/DocBlock/MalformWorker/ParamNameTypoMalformWorker.php @@ -12,7 +12,7 @@ use Symplify\CodingStandard\TokenAnalyzer\DocblockRelatedParamNamesResolver; use Symplify\CodingStandard\TokenRunner\Contract\DocBlock\MalformWorkerInterface; -final class ParamNameTypoMalformWorker implements MalformWorkerInterface +final readonly class ParamNameTypoMalformWorker implements MalformWorkerInterface { /** * @var string @@ -21,7 +21,7 @@ final class ParamNameTypoMalformWorker implements MalformWorkerInterface private const PARAM_NAME_REGEX = '#@param(\s+)(?callable)?(.*?)(?\$\w+)#'; public function __construct( - private readonly DocblockRelatedParamNamesResolver $docblockRelatedParamNamesResolver + private DocblockRelatedParamNamesResolver $docblockRelatedParamNamesResolver ) { } diff --git a/src/TokenRunner/Transformer/FixerTransformer/FirstLineLengthResolver.php b/src/TokenRunner/Transformer/FixerTransformer/FirstLineLengthResolver.php index 99ae1ddcf..e0bc51a8e 100644 --- a/src/TokenRunner/Transformer/FixerTransformer/FirstLineLengthResolver.php +++ b/src/TokenRunner/Transformer/FixerTransformer/FirstLineLengthResolver.php @@ -11,10 +11,10 @@ use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; use Symplify\CodingStandard\TokenRunner\ValueObjectFactory\LineLengthAndPositionFactory; -final class FirstLineLengthResolver +final readonly class FirstLineLengthResolver { public function __construct( - private readonly LineLengthAndPositionFactory $lineLengthAndPositionFactory + private LineLengthAndPositionFactory $lineLengthAndPositionFactory ) { } diff --git a/src/TokenRunner/Transformer/FixerTransformer/LineLengthCloserTransformer.php b/src/TokenRunner/Transformer/FixerTransformer/LineLengthCloserTransformer.php index 71630ac30..4a6ff995b 100644 --- a/src/TokenRunner/Transformer/FixerTransformer/LineLengthCloserTransformer.php +++ b/src/TokenRunner/Transformer/FixerTransformer/LineLengthCloserTransformer.php @@ -12,11 +12,11 @@ use Symplify\CodingStandard\TokenRunner\TokenFinder; use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; -final class LineLengthCloserTransformer +final readonly class LineLengthCloserTransformer { public function __construct( - private readonly CallAnalyzer $callAnalyzer, - private readonly TokenFinder $tokenFinder + private CallAnalyzer $callAnalyzer, + private TokenFinder $tokenFinder ) { } diff --git a/src/TokenRunner/Transformer/FixerTransformer/LineLengthOpenerTransformer.php b/src/TokenRunner/Transformer/FixerTransformer/LineLengthOpenerTransformer.php index ef45ad480..8295a4bec 100644 --- a/src/TokenRunner/Transformer/FixerTransformer/LineLengthOpenerTransformer.php +++ b/src/TokenRunner/Transformer/FixerTransformer/LineLengthOpenerTransformer.php @@ -10,10 +10,10 @@ use Symplify\CodingStandard\TokenRunner\Analyzer\FixerAnalyzer\CallAnalyzer; use Symplify\CodingStandard\TokenRunner\Exception\TokenNotFoundException; -final class LineLengthOpenerTransformer +final readonly class LineLengthOpenerTransformer { public function __construct( - private readonly CallAnalyzer $callAnalyzer + private CallAnalyzer $callAnalyzer ) { } diff --git a/src/TokenRunner/Transformer/FixerTransformer/LineLengthTransformer.php b/src/TokenRunner/Transformer/FixerTransformer/LineLengthTransformer.php index 20ed359e1..8cfb81649 100644 --- a/src/TokenRunner/Transformer/FixerTransformer/LineLengthTransformer.php +++ b/src/TokenRunner/Transformer/FixerTransformer/LineLengthTransformer.php @@ -10,13 +10,13 @@ use Symplify\CodingStandard\TokenRunner\Enum\LineKind; use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; -final class LineLengthTransformer +final readonly class LineLengthTransformer { public function __construct( - private readonly LineLengthResolver $lineLengthResolver, - private readonly TokensInliner $tokensInliner, - private readonly FirstLineLengthResolver $firstLineLengthResolver, - private readonly TokensNewliner $tokensNewliner + private LineLengthResolver $lineLengthResolver, + private TokensInliner $tokensInliner, + private FirstLineLengthResolver $firstLineLengthResolver, + private TokensNewliner $tokensNewliner ) { } diff --git a/src/TokenRunner/Transformer/FixerTransformer/TokensInliner.php b/src/TokenRunner/Transformer/FixerTransformer/TokensInliner.php index a6862dc58..9e2fc191a 100644 --- a/src/TokenRunner/Transformer/FixerTransformer/TokensInliner.php +++ b/src/TokenRunner/Transformer/FixerTransformer/TokensInliner.php @@ -9,10 +9,10 @@ use Symplify\CodingStandard\TokenRunner\Analyzer\FixerAnalyzer\TokenSkipper; use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; -final class TokensInliner +final readonly class TokensInliner { public function __construct( - private readonly TokenSkipper $tokenSkipper + private TokenSkipper $tokenSkipper ) { } diff --git a/src/TokenRunner/Transformer/FixerTransformer/TokensNewliner.php b/src/TokenRunner/Transformer/FixerTransformer/TokensNewliner.php index 949ba5862..140dfedcb 100644 --- a/src/TokenRunner/Transformer/FixerTransformer/TokensNewliner.php +++ b/src/TokenRunner/Transformer/FixerTransformer/TokensNewliner.php @@ -12,14 +12,14 @@ use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; use Symplify\CodingStandard\TokenRunner\Whitespace\IndentResolver; -final class TokensNewliner +final readonly class TokensNewliner { public function __construct( - private readonly LineLengthCloserTransformer $lineLengthCloserTransformer, - private readonly TokenSkipper $tokenSkipper, - private readonly LineLengthOpenerTransformer $lineLengthOpenerTransformer, - private readonly WhitespacesFixerConfig $whitespacesFixerConfig, - private readonly IndentResolver $indentResolver + private LineLengthCloserTransformer $lineLengthCloserTransformer, + private TokenSkipper $tokenSkipper, + private LineLengthOpenerTransformer $lineLengthOpenerTransformer, + private WhitespacesFixerConfig $whitespacesFixerConfig, + private IndentResolver $indentResolver ) { } diff --git a/src/TokenRunner/Traverser/ArrayBlockInfoFinder.php b/src/TokenRunner/Traverser/ArrayBlockInfoFinder.php index 4dc5cc530..18069edf7 100644 --- a/src/TokenRunner/Traverser/ArrayBlockInfoFinder.php +++ b/src/TokenRunner/Traverser/ArrayBlockInfoFinder.php @@ -10,10 +10,10 @@ use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; use Symplify\CodingStandard\TokenRunner\ValueObject\TokenKinds; -final class ArrayBlockInfoFinder +final readonly class ArrayBlockInfoFinder { public function __construct( - private readonly BlockFinder $blockFinder + private BlockFinder $blockFinder ) { } diff --git a/src/TokenRunner/ValueObject/BlockInfo.php b/src/TokenRunner/ValueObject/BlockInfo.php index c8531b29f..c9a2ac9ea 100644 --- a/src/TokenRunner/ValueObject/BlockInfo.php +++ b/src/TokenRunner/ValueObject/BlockInfo.php @@ -4,11 +4,11 @@ namespace Symplify\CodingStandard\TokenRunner\ValueObject; -final class BlockInfo +final readonly class BlockInfo { public function __construct( - private readonly int $start, - private readonly int $end + private int $start, + private int $end ) { } diff --git a/src/TokenRunner/ValueObject/LineLengthAndPosition.php b/src/TokenRunner/ValueObject/LineLengthAndPosition.php index ae2dedc6c..04a1b84ee 100644 --- a/src/TokenRunner/ValueObject/LineLengthAndPosition.php +++ b/src/TokenRunner/ValueObject/LineLengthAndPosition.php @@ -4,11 +4,11 @@ namespace Symplify\CodingStandard\TokenRunner\ValueObject; -final class LineLengthAndPosition +final readonly class LineLengthAndPosition { public function __construct( - private readonly int $lineLength, - private readonly int $currentPosition + private int $lineLength, + private int $currentPosition ) { } diff --git a/src/TokenRunner/ValueObject/Wrapper/FixerWrapper/ArrayWrapper.php b/src/TokenRunner/ValueObject/Wrapper/FixerWrapper/ArrayWrapper.php index 6021ee7f4..978e2ac53 100644 --- a/src/TokenRunner/ValueObject/Wrapper/FixerWrapper/ArrayWrapper.php +++ b/src/TokenRunner/ValueObject/Wrapper/FixerWrapper/ArrayWrapper.php @@ -10,7 +10,7 @@ use Symplify\CodingStandard\TokenRunner\Analyzer\FixerAnalyzer\TokenSkipper; use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; -final class ArrayWrapper +final readonly class ArrayWrapper { /** * @var int[] @@ -21,9 +21,9 @@ final class ArrayWrapper * @param Tokens $tokens */ public function __construct( - private readonly Tokens $tokens, - private readonly BlockInfo $blockInfo, - private readonly TokenSkipper $tokenSkipper + private Tokens $tokens, + private BlockInfo $blockInfo, + private TokenSkipper $tokenSkipper ) { } diff --git a/src/TokenRunner/Whitespace/IndentResolver.php b/src/TokenRunner/Whitespace/IndentResolver.php index 026fd8ad8..ad0bdf407 100644 --- a/src/TokenRunner/Whitespace/IndentResolver.php +++ b/src/TokenRunner/Whitespace/IndentResolver.php @@ -9,11 +9,11 @@ use PhpCsFixer\WhitespacesFixerConfig; use Symplify\CodingStandard\TokenRunner\Analyzer\FixerAnalyzer\IndentDetector; -final class IndentResolver +final readonly class IndentResolver { public function __construct( - private readonly IndentDetector $indentDetector, - private readonly WhitespacesFixerConfig $whitespacesFixerConfig + private IndentDetector $indentDetector, + private WhitespacesFixerConfig $whitespacesFixerConfig ) { } diff --git a/src/TokenRunner/Wrapper/FixerWrapper/ArrayWrapperFactory.php b/src/TokenRunner/Wrapper/FixerWrapper/ArrayWrapperFactory.php index 152bbd0d6..3c050cab7 100644 --- a/src/TokenRunner/Wrapper/FixerWrapper/ArrayWrapperFactory.php +++ b/src/TokenRunner/Wrapper/FixerWrapper/ArrayWrapperFactory.php @@ -10,10 +10,10 @@ use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; use Symplify\CodingStandard\TokenRunner\ValueObject\Wrapper\FixerWrapper\ArrayWrapper; -final class ArrayWrapperFactory +final readonly class ArrayWrapperFactory { public function __construct( - private readonly TokenSkipper $tokenSkipper + private TokenSkipper $tokenSkipper ) { } diff --git a/src/ValueObject/BlockInfoMetadata.php b/src/ValueObject/BlockInfoMetadata.php index 4855e0c29..2450e86a7 100644 --- a/src/ValueObject/BlockInfoMetadata.php +++ b/src/ValueObject/BlockInfoMetadata.php @@ -6,11 +6,11 @@ use Symplify\CodingStandard\TokenRunner\ValueObject\BlockInfo; -final class BlockInfoMetadata +final readonly class BlockInfoMetadata { public function __construct( - private readonly string $blockType, - private readonly BlockInfo $blockInfo + private string $blockType, + private BlockInfo $blockInfo ) { }