From 4318c3ca4d8c375ff5872ee4f963dba13402b159 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 8 Jun 2026 12:01:40 +0100 Subject: [PATCH] bump to PHP 84 --- .github/workflows/code_analysis.yaml | 2 +- composer.json | 20 ++++++------- phpstan.neon | 2 +- src/DocBlock/UselessDocBlockCleaner.php | 30 ++++++------------- src/Enum/BlockBorderType.php | 10 ++----- ...oveMethodNameDuplicateDescriptionFixer.php | 5 +--- .../RemovePHPStormAnnotationFixer.php | 8 ++--- ...vePropertyVariableNameDescriptionFixer.php | 8 ++--- .../ArrayListItemNewlineFixer.php | 7 ++--- .../ArrayOpenerAndCloserNewlineFixer.php | 7 ++--- .../StandaloneLineInMultilineArrayFixer.php | 7 ++--- .../ParamReturnAndVarTagMalformsFixer.php | 10 +++---- .../RemoveUselessDefaultCommentFixer.php | 7 ++--- src/Fixer/LineLength/LineLengthFixer.php | 21 +++++-------- .../Spacing/MethodChainingNewlineFixer.php | 7 ++--- .../SpaceAfterCommaHereNowDocFixer.php | 5 +--- .../StandaloneLineConstructorParamFixer.php | 7 ++--- .../StandaloneLinePromotedPropertyFixer.php | 7 ++--- .../Strict/BlankLineAfterStrictTypesFixer.php | 5 +--- .../Analyzer/FixerAnalyzer/BlockFinder.php | 4 +-- .../MalformWorker/InlineVarMalformWorker.php | 3 +- .../InlineVariableDocBlockMalformWorker.php | 9 ++---- .../MissingParamNameMalformWorker.php | 9 ++---- .../MissingVarNameMalformWorker.php | 3 +- .../ParamNameReferenceMalformWorker.php | 3 +- .../ParamNameTypoMalformWorker.php | 3 +- .../SuperfluousReturnNameMalformWorker.php | 13 +++----- .../SuperfluousVarNameMalformWorker.php | 6 ++-- .../SwitchedTypeAndNameMalformWorker.php | 3 +- src/TokenRunner/Enum/LineKind.php | 10 ++----- src/TokenRunner/ValueObject/TokenKinds.php | 2 +- .../Wrapper/FixerWrapper/ArrayWrapper.php | 2 +- src/ValueObject/CodingStandardConfig.php | 5 +--- 33 files changed, 86 insertions(+), 164 deletions(-) diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml index da111f3e8..e536767d7 100644 --- a/.github/workflows/code_analysis.yaml +++ b/.github/workflows/code_analysis.yaml @@ -49,7 +49,7 @@ jobs: # see https://github.com/shivammathur/setup-php - uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.4 coverage: none # composer install cache - https://github.com/ramsey/composer-install diff --git a/composer.json b/composer.json index fb384df08..07544ea6d 100644 --- a/composer.json +++ b/composer.json @@ -3,21 +3,21 @@ "description": "Set of Symplify rules for PHP_CodeSniffer and PHP CS Fixer.", "license": "MIT", "require": { - "php": ">=8.2", - "nette/utils": "^4.0", - "friendsofphp/php-cs-fixer": "^3.89" + "php": ">=8.4", + "nette/utils": "^4.1", + "friendsofphp/php-cs-fixer": "^3.95.4" }, "require-dev": { - "symplify/easy-coding-standard": "^12.6", + "symplify/easy-coding-standard": "^13.1", "squizlabs/php_codesniffer": "^4.0", - "phpunit/phpunit": "^11.5|^12.0", + "phpunit/phpunit": "^12.5", "phpstan/extension-installer": "^1.4", - "phpstan/phpstan": "^2.1", - "rector/rector": "^2.2", + "phpstan/phpstan": "^2.2", + "rector/rector": "^2.4", "symplify/phpstan-extensions": "^12.0", - "tomasvotruba/class-leak": "^2.0", - "rector/jack": "^0.2", - "tracy/tracy": "^2.11" + "tomasvotruba/class-leak": "^2.1.5", + "rector/jack": "^1.0", + "tracy/tracy": "^2.12" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index 9dbaf7a7e..f461f1833 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -24,7 +24,7 @@ parameters: # conditional check to allow various php versions - - message: '#Comparison operation ">\=" between int<80200, 80599> and (.*?) is always true#' + message: '#Comparison operation ">\=" between int<\d+, \d+> and (.*?) is always true#' path: src/TokenAnalyzer/DocblockRelatedParamNamesResolver.php # array filter issue diff --git a/src/DocBlock/UselessDocBlockCleaner.php b/src/DocBlock/UselessDocBlockCleaner.php index 39adceeca..a7ceb77b1 100644 --- a/src/DocBlock/UselessDocBlockCleaner.php +++ b/src/DocBlock/UselessDocBlockCleaner.php @@ -12,7 +12,7 @@ final class UselessDocBlockCleaner /** * @var string[] */ - private const CLEANING_REGEXES = [ + private const array CLEANING_REGEXES = [ self::TODO_COMMENT_BY_PHPSTORM_REGEX, self::TODO_IMPLEMENT_METHOD_COMMENT_BY_PHPSTORM_REGEX, self::COMMENT_CONSTRUCTOR_CLASS_REGEX, @@ -28,49 +28,37 @@ final class UselessDocBlockCleaner /** * @see https://regex101.com/r/5fQJkz/2 - * @var string */ - private const TODO_IMPLEMENT_METHOD_COMMENT_BY_PHPSTORM_REGEX = '#\/\/ TODO: Implement .*\(\) method.$#'; + private const string TODO_IMPLEMENT_METHOD_COMMENT_BY_PHPSTORM_REGEX = '#\/\/ TODO: Implement .*\(\) method.$#'; /** * @see https://regex101.com/r/zayQpv/1 - * @var string */ - private const TODO_COMMENT_BY_PHPSTORM_REGEX = '#\/\/ TODO: Change the autogenerated stub$#'; + private const string TODO_COMMENT_BY_PHPSTORM_REGEX = '#\/\/ TODO: Change the autogenerated stub$#'; /** * @see https://regex101.com/r/RzTdFH/4 - * @var string */ - private const STANDALONE_DOCBLOCK_CLASS_REGEX = '#(\/\*\*\s+)\*\s+[cC]lass\s+[^\s]*(\s+\*\/)$#'; + private const string STANDALONE_DOCBLOCK_CLASS_REGEX = '#(\/\*\*\s+)\*\s+[cC]lass\s+[^\s]*(\s+\*\/)$#'; /** * @see https://regex101.com/r/RzTdFH/4 - * @var string */ - private const STANDALONE_COMMENT_CLASS_REGEX = '#\/\/\s+(class|trait|interface)\s+\w+$#i'; + private const string STANDALONE_COMMENT_CLASS_REGEX = '#\/\/\s+(class|trait|interface)\s+\w+$#i'; /** * @see https://regex101.com/r/RzTdFH/4 - * @var string */ - private const INLINE_COMMENT_CLASS_REGEX = '#\s\*\s(class|trait|interface)\s+(\w)+$#i'; + private const string INLINE_COMMENT_CLASS_REGEX = '#\s\*\s(class|trait|interface)\s+(\w)+$#i'; - /** - * @var string - */ - private const COMMENT_CONSTRUCTOR_CLASS_REGEX = '#^(\/\/|(\s|\*)+)(\s\w+\s)?constructor(\.)?$#i'; + private const string COMMENT_CONSTRUCTOR_CLASS_REGEX = '#^(\/\/|(\s|\*)+)(\s\w+\s)?constructor(\.)?$#i'; /** * @see https://regex101.com/r/1kcgR5/1 - * @var string */ - private const DOCTRINE_GENERATED_COMMENT_REGEX = '#^(\/\*{2}\s+?)?(\*|\/\/)\s+This class was generated by the Doctrine ORM\. Add your own custom\r?\n\s+\*\s+repository methods below\.(\s+\*\/)$#'; + private const string DOCTRINE_GENERATED_COMMENT_REGEX = '#^(\/\*{2}\s+?)?(\*|\/\/)\s+This class was generated by the Doctrine ORM\. Add your own custom\r?\n\s+\*\s+repository methods below\.(\s+\*\/)$#'; - /** - * @var string - */ - private const CLASS_REPRESENTING_REGEX = '#\s\*\sClass\s+representing\s+([\w]+)$#i'; + private const string CLASS_REPRESENTING_REGEX = '#\s\*\sClass\s+representing\s+([\w]+)$#i'; public function clearDocTokenContent(Token $currentToken, ?string $classLikeName): string { diff --git a/src/Enum/BlockBorderType.php b/src/Enum/BlockBorderType.php index c5a4b4e2f..18e39b86e 100644 --- a/src/Enum/BlockBorderType.php +++ b/src/Enum/BlockBorderType.php @@ -6,13 +6,7 @@ final class BlockBorderType { - /** - * @var string - */ - public const OPENER = 'opener'; + public const string OPENER = 'opener'; - /** - * @var string - */ - public const CLOSER = 'closer'; + public const string CLOSER = 'closer'; } diff --git a/src/Fixer/Annotation/RemoveMethodNameDuplicateDescriptionFixer.php b/src/Fixer/Annotation/RemoveMethodNameDuplicateDescriptionFixer.php index cd76e73e3..065fd2a21 100644 --- a/src/Fixer/Annotation/RemoveMethodNameDuplicateDescriptionFixer.php +++ b/src/Fixer/Annotation/RemoveMethodNameDuplicateDescriptionFixer.php @@ -19,10 +19,7 @@ */ final class RemoveMethodNameDuplicateDescriptionFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Remove docblock descriptions which duplicate their method name'; + private const string ERROR_MESSAGE = 'Remove docblock descriptions which duplicate their method name'; private readonly MethodNameResolver $methodNameResolver; diff --git a/src/Fixer/Annotation/RemovePHPStormAnnotationFixer.php b/src/Fixer/Annotation/RemovePHPStormAnnotationFixer.php index 52d90c887..83bafa4c4 100644 --- a/src/Fixer/Annotation/RemovePHPStormAnnotationFixer.php +++ b/src/Fixer/Annotation/RemovePHPStormAnnotationFixer.php @@ -20,14 +20,10 @@ final class RemovePHPStormAnnotationFixer extends AbstractSymplifyFixer { /** * @see https://regex101.com/r/nGZBzj/2 - * @var string */ - private const CREATED_BY_PHPSTORM_DOC_REGEX = '#\/\*\*\s+\*\s+Created by PHPStorm(.*?)\*\/#msi'; + private const string CREATED_BY_PHPSTORM_DOC_REGEX = '#\/\*\*\s+\*\s+Created by PHPStorm(.*?)\*\/#msi'; - /** - * @var string - */ - private const ERROR_MESSAGE = 'Remove "Created by PhpStorm" annotations'; + private const string ERROR_MESSAGE = 'Remove "Created by PhpStorm" annotations'; public function __construct( private readonly TokenReverser $tokenReverser diff --git a/src/Fixer/Annotation/RemovePropertyVariableNameDescriptionFixer.php b/src/Fixer/Annotation/RemovePropertyVariableNameDescriptionFixer.php index f4a9acc51..49844f784 100644 --- a/src/Fixer/Annotation/RemovePropertyVariableNameDescriptionFixer.php +++ b/src/Fixer/Annotation/RemovePropertyVariableNameDescriptionFixer.php @@ -19,16 +19,12 @@ */ final class RemovePropertyVariableNameDescriptionFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Remove useless "$variable" from @var tag'; + private const string ERROR_MESSAGE = 'Remove useless "$variable" from @var tag'; /** - * @var string * @see https://regex101.com/r/2PxeKF/1 */ - private const VAR_REGEX = '#@(?:psalm-|phpstan-)?var#'; + private const string VAR_REGEX = '#@(?:psalm-|phpstan-)?var#'; private readonly PropertyNameResolver $propertyNameResolver; diff --git a/src/Fixer/ArrayNotation/ArrayListItemNewlineFixer.php b/src/Fixer/ArrayNotation/ArrayListItemNewlineFixer.php index 99be3382c..29cbb5dd0 100644 --- a/src/Fixer/ArrayNotation/ArrayListItemNewlineFixer.php +++ b/src/Fixer/ArrayNotation/ArrayListItemNewlineFixer.php @@ -4,6 +4,7 @@ namespace Symplify\CodingStandard\Fixer\ArrayNotation; +use Override; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; use PhpCsFixer\Tokenizer\Token; @@ -20,10 +21,7 @@ */ final class ArrayListItemNewlineFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Indexed PHP array item has to have one line per item'; + private const string ERROR_MESSAGE = 'Indexed PHP array item has to have one line per item'; public function __construct( private readonly ArrayItemNewliner $arrayItemNewliner, @@ -37,6 +35,7 @@ public function getDefinition(): FixerDefinitionInterface return new FixerDefinition(self::ERROR_MESSAGE, []); } + #[Override] public function getPriority(): int { return 40; diff --git a/src/Fixer/ArrayNotation/ArrayOpenerAndCloserNewlineFixer.php b/src/Fixer/ArrayNotation/ArrayOpenerAndCloserNewlineFixer.php index 76eec60ac..121c7770c 100644 --- a/src/Fixer/ArrayNotation/ArrayOpenerAndCloserNewlineFixer.php +++ b/src/Fixer/ArrayNotation/ArrayOpenerAndCloserNewlineFixer.php @@ -4,6 +4,7 @@ namespace Symplify\CodingStandard\Fixer\ArrayNotation; +use Override; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; use PhpCsFixer\Tokenizer\Token; @@ -22,10 +23,7 @@ */ final class ArrayOpenerAndCloserNewlineFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Indexed PHP array opener [ and closer ] must be on own line'; + private const string ERROR_MESSAGE = 'Indexed PHP array opener [ and closer ] must be on own line'; public function __construct( private readonly ArrayBlockInfoFinder $arrayBlockInfoFinder, @@ -44,6 +42,7 @@ public function getDefinition(): FixerDefinitionInterface * * @see \PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer::getPriority() */ + #[Override] public function getPriority(): int { return 34; diff --git a/src/Fixer/ArrayNotation/StandaloneLineInMultilineArrayFixer.php b/src/Fixer/ArrayNotation/StandaloneLineInMultilineArrayFixer.php index 8ffdc7ff0..63b1c11d0 100644 --- a/src/Fixer/ArrayNotation/StandaloneLineInMultilineArrayFixer.php +++ b/src/Fixer/ArrayNotation/StandaloneLineInMultilineArrayFixer.php @@ -4,6 +4,7 @@ namespace Symplify\CodingStandard\Fixer\ArrayNotation; +use Override; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; use PhpCsFixer\Tokenizer\Token; @@ -22,10 +23,7 @@ */ final class StandaloneLineInMultilineArrayFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Indexed arrays must have 1 item per line'; + private const string ERROR_MESSAGE = 'Indexed arrays must have 1 item per line'; public function __construct( private readonly ArrayWrapperFactory $arrayWrapperFactory, @@ -44,6 +42,7 @@ public function getDefinition(): FixerDefinitionInterface * * @see \PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer::getPriority() */ + #[Override] public function getPriority(): int { return 5; diff --git a/src/Fixer/Commenting/ParamReturnAndVarTagMalformsFixer.php b/src/Fixer/Commenting/ParamReturnAndVarTagMalformsFixer.php index bc6aa556e..80ec64980 100644 --- a/src/Fixer/Commenting/ParamReturnAndVarTagMalformsFixer.php +++ b/src/Fixer/Commenting/ParamReturnAndVarTagMalformsFixer.php @@ -5,6 +5,7 @@ namespace Symplify\CodingStandard\Fixer\Commenting; use Nette\Utils\Strings; +use Override; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; use PhpCsFixer\Tokenizer\Token; @@ -28,16 +29,12 @@ */ final class ParamReturnAndVarTagMalformsFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Fixes @param, @return, @var and inline @var annotations broken formats'; + private const string ERROR_MESSAGE = 'Fixes @param, @return, @var and inline @var annotations broken formats'; /** - * @var string * @see https://regex101.com/r/Nlxkd9/1 */ - private const TYPE_ANNOTATION_REGEX = '#@(psalm-|phpstan-)?(param|return|var)#'; + private const string TYPE_ANNOTATION_REGEX = '#@(psalm-|phpstan-)?(param|return|var)#'; /** * @var MalformWorkerInterface[] @@ -135,6 +132,7 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void * * @see \PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer::getPriority() */ + #[Override] public function getPriority(): int { return -37; diff --git a/src/Fixer/Commenting/RemoveUselessDefaultCommentFixer.php b/src/Fixer/Commenting/RemoveUselessDefaultCommentFixer.php index 64ebe62b7..730834775 100644 --- a/src/Fixer/Commenting/RemoveUselessDefaultCommentFixer.php +++ b/src/Fixer/Commenting/RemoveUselessDefaultCommentFixer.php @@ -4,6 +4,7 @@ namespace Symplify\CodingStandard\Fixer\Commenting; +use Override; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; use PhpCsFixer\Tokenizer\Token; @@ -19,10 +20,7 @@ */ final class RemoveUselessDefaultCommentFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Remove useless PHPStorm-generated @todo comments, redundant "Class XY" or "gets service" comments etc.'; + private const string ERROR_MESSAGE = 'Remove useless PHPStorm-generated @todo comments, redundant "Class XY" or "gets service" comments etc.'; public function __construct( private readonly UselessDocBlockCleaner $uselessDocBlockCleaner, @@ -44,6 +42,7 @@ public function isCandidate(Tokens $tokens): bool return $tokens->isAnyTokenKindsFound([T_DOC_COMMENT, T_COMMENT]); } + #[Override] public function getPriority(): int { /** must run before @see \PhpCsFixer\Fixer\Basic\BracesFixer to cleanup spaces */ diff --git a/src/Fixer/LineLength/LineLengthFixer.php b/src/Fixer/LineLength/LineLengthFixer.php index 5a20cf46f..b5423090b 100644 --- a/src/Fixer/LineLength/LineLengthFixer.php +++ b/src/Fixer/LineLength/LineLengthFixer.php @@ -4,6 +4,7 @@ namespace Symplify\CodingStandard\Fixer\LineLength; +use Override; use PhpCsFixer\Fixer\ConfigurableFixerInterface; use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface; use PhpCsFixer\FixerDefinition\FixerDefinition; @@ -30,31 +31,22 @@ final class LineLengthFixer extends AbstractSymplifyFixer implements Configurabl { /** * @api - * @var string */ - public const LINE_LENGTH = 'line_length'; + public const string LINE_LENGTH = 'line_length'; /** * @api - * @var string */ - public const BREAK_LONG_LINES = 'break_long_lines'; + public const string BREAK_LONG_LINES = 'break_long_lines'; /** * @api - * @var string */ - public const INLINE_SHORT_LINES = 'inline_short_lines'; + public const string INLINE_SHORT_LINES = 'inline_short_lines'; - /** - * @var string - */ - private const ERROR_MESSAGE = 'Array items, method parameters, method call arguments, new arguments should be on same/standalone line to fit line length.'; + private const string ERROR_MESSAGE = 'Array items, method parameters, method call arguments, new arguments should be on same/standalone line to fit line length.'; - /** - * @var int - */ - private const DEFAULT_LINE_LENGHT = 120; + private const int DEFAULT_LINE_LENGHT = 120; private int $lineLength = self::DEFAULT_LINE_LENGHT; @@ -139,6 +131,7 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void * * @see \PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer::getPriority() */ + #[Override] public function getPriority(): int { return 5; diff --git a/src/Fixer/Spacing/MethodChainingNewlineFixer.php b/src/Fixer/Spacing/MethodChainingNewlineFixer.php index 6455a2044..26e65d84c 100644 --- a/src/Fixer/Spacing/MethodChainingNewlineFixer.php +++ b/src/Fixer/Spacing/MethodChainingNewlineFixer.php @@ -4,6 +4,7 @@ namespace Symplify\CodingStandard\Fixer\Spacing; +use Override; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; use PhpCsFixer\Tokenizer\Token; @@ -20,10 +21,7 @@ */ final class MethodChainingNewlineFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Each chain method call must be on own line'; + private const string ERROR_MESSAGE = 'Each chain method call must be on own line'; public function __construct( private readonly WhitespacesFixerConfig $whitespacesFixerConfig, @@ -42,6 +40,7 @@ public function getDefinition(): FixerDefinitionInterface * * @see \PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer::getPriority() */ + #[Override] public function getPriority(): int { return 39; diff --git a/src/Fixer/Spacing/SpaceAfterCommaHereNowDocFixer.php b/src/Fixer/Spacing/SpaceAfterCommaHereNowDocFixer.php index e93d6c499..1d8a60289 100644 --- a/src/Fixer/Spacing/SpaceAfterCommaHereNowDocFixer.php +++ b/src/Fixer/Spacing/SpaceAfterCommaHereNowDocFixer.php @@ -17,10 +17,7 @@ */ final class SpaceAfterCommaHereNowDocFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = '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'; + private const string ERROR_MESSAGE = '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'; public function getDefinition(): FixerDefinitionInterface { diff --git a/src/Fixer/Spacing/StandaloneLineConstructorParamFixer.php b/src/Fixer/Spacing/StandaloneLineConstructorParamFixer.php index 92c80682c..8a92d706e 100644 --- a/src/Fixer/Spacing/StandaloneLineConstructorParamFixer.php +++ b/src/Fixer/Spacing/StandaloneLineConstructorParamFixer.php @@ -4,6 +4,7 @@ namespace Symplify\CodingStandard\Fixer\Spacing; +use Override; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; use PhpCsFixer\Tokenizer\Token; @@ -18,10 +19,7 @@ */ final class StandaloneLineConstructorParamFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Constructor param should be on a standalone line to ease git diffs on new dependency'; + private const string ERROR_MESSAGE = 'Constructor param should be on a standalone line to ease git diffs on new dependency'; public function __construct( private readonly ParamNewliner $paramNewliner, @@ -34,6 +32,7 @@ public function __construct( * * @see \PhpCsFixer\Fixer\Basic\BracesFixer::getPriority() */ + #[Override] public function getPriority(): int { return 40; diff --git a/src/Fixer/Spacing/StandaloneLinePromotedPropertyFixer.php b/src/Fixer/Spacing/StandaloneLinePromotedPropertyFixer.php index 7f12c3485..f21b1b6ce 100644 --- a/src/Fixer/Spacing/StandaloneLinePromotedPropertyFixer.php +++ b/src/Fixer/Spacing/StandaloneLinePromotedPropertyFixer.php @@ -4,6 +4,7 @@ namespace Symplify\CodingStandard\Fixer\Spacing; +use Override; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; use PhpCsFixer\Tokenizer\CT; @@ -19,10 +20,7 @@ */ final class StandaloneLinePromotedPropertyFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Promoted property should be on standalone line'; + private const string ERROR_MESSAGE = 'Promoted property should be on standalone line'; public function __construct( private readonly ParamNewliner $paramNewliner, @@ -35,6 +33,7 @@ public function __construct( * * @see \PhpCsFixer\Fixer\Basic\BracesFixer::getPriority() */ + #[Override] public function getPriority(): int { return 40; diff --git a/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php b/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php index e46eefc0a..ed18505d2 100644 --- a/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php +++ b/src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php @@ -21,10 +21,7 @@ */ final class BlankLineAfterStrictTypesFixer extends AbstractSymplifyFixer { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Strict type declaration has to be followed by empty line'; + private const string ERROR_MESSAGE = 'Strict type declaration has to be followed by empty line'; /** * Generates: "declare(strict_types=1);" diff --git a/src/TokenRunner/Analyzer/FixerAnalyzer/BlockFinder.php b/src/TokenRunner/Analyzer/FixerAnalyzer/BlockFinder.php index 8373f7bfe..4d02dfaa9 100644 --- a/src/TokenRunner/Analyzer/FixerAnalyzer/BlockFinder.php +++ b/src/TokenRunner/Analyzer/FixerAnalyzer/BlockFinder.php @@ -16,7 +16,7 @@ final class BlockFinder /** * @var array */ - private const CONTENT_TO_BLOCK_TYPE = [ + private const array CONTENT_TO_BLOCK_TYPE = [ '(' => Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, ')' => Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, '[' => Tokens::BLOCK_TYPE_ARRAY_SQUARE_BRACE, @@ -29,7 +29,7 @@ final class BlockFinder /** * @var string[] */ - private const START_EDGES = ['(', '[', '{']; + private const array START_EDGES = ['(', '[', '{']; /** * Accepts position to both start and end token, e.g. (, ), [, ], {, } also to: "array"(, "function" ...(, "use"(, diff --git a/src/TokenRunner/DocBlock/MalformWorker/InlineVarMalformWorker.php b/src/TokenRunner/DocBlock/MalformWorker/InlineVarMalformWorker.php index 59563defb..cd3ec3626 100644 --- a/src/TokenRunner/DocBlock/MalformWorker/InlineVarMalformWorker.php +++ b/src/TokenRunner/DocBlock/MalformWorker/InlineVarMalformWorker.php @@ -12,10 +12,9 @@ final class InlineVarMalformWorker implements MalformWorkerInterface { /** - * @var string * @see https://regex101.com/r/cj95e6/1 */ - private const SINGLE_ASTERISK_START_REGEX = '#^/\*(\n?\s+@(?:psalm-|phpstan-)?var)#'; + private const string SINGLE_ASTERISK_START_REGEX = '#^/\*(\n?\s+@(?:psalm-|phpstan-)?var)#'; /** * @param Tokens $tokens diff --git a/src/TokenRunner/DocBlock/MalformWorker/InlineVariableDocBlockMalformWorker.php b/src/TokenRunner/DocBlock/MalformWorker/InlineVariableDocBlockMalformWorker.php index ea26296ec..af822b39a 100644 --- a/src/TokenRunner/DocBlock/MalformWorker/InlineVariableDocBlockMalformWorker.php +++ b/src/TokenRunner/DocBlock/MalformWorker/InlineVariableDocBlockMalformWorker.php @@ -12,22 +12,19 @@ final class InlineVariableDocBlockMalformWorker implements MalformWorkerInterface { /** - * @var string * @see https://regex101.com/r/GkyV1C/1 */ - private const SINGLE_ASTERISK_START_REGEX = '#^/\*\s+\*(\s+@(?:psalm-|phpstan-)?var)#'; + private const string SINGLE_ASTERISK_START_REGEX = '#^/\*\s+\*(\s+@(?:psalm-|phpstan-)?var)#'; /** - * @var string * @see https://regex101.com/r/9cfhFI/1 */ - private const SPACE_REGEX = '#\s+#m'; + private const string SPACE_REGEX = '#\s+#m'; /** - * @var string * @see https://regex101.com/r/VpTDCd/1 */ - private const ASTERISK_LEFTOVERS_REGEX = '#(\*\*)(\s+\*)#'; + private const string ASTERISK_LEFTOVERS_REGEX = '#(\*\*)(\s+\*)#'; /** * @param Tokens $tokens diff --git a/src/TokenRunner/DocBlock/MalformWorker/MissingParamNameMalformWorker.php b/src/TokenRunner/DocBlock/MalformWorker/MissingParamNameMalformWorker.php index 361df30d6..208ed8ac2 100644 --- a/src/TokenRunner/DocBlock/MalformWorker/MissingParamNameMalformWorker.php +++ b/src/TokenRunner/DocBlock/MalformWorker/MissingParamNameMalformWorker.php @@ -15,22 +15,19 @@ final readonly class MissingParamNameMalformWorker implements MalformWorkerInterface { /** - * @var string * @see https://regex101.com/r/QtWnWv/6 */ - private const PARAM_WITHOUT_NAME_REGEX = '#@param ([^${<]*?)( ([^$]*?))?\n#'; + private const string PARAM_WITHOUT_NAME_REGEX = '#@param ([^${<]*?)( ([^$]*?))?\n#'; /** - * @var string * @see https://regex101.com/r/58YJNy/1 */ - private const PARAM_ANNOTATOIN_START_REGEX = '@param '; + private const string PARAM_ANNOTATOIN_START_REGEX = '@param '; /** - * @var string * @see https://regex101.com/r/JhugsI/1 */ - private const PARAM_WITH_NAME_REGEX = '#@param(.*?)\$[\w]+(.*?)\n#'; + private const string PARAM_WITH_NAME_REGEX = '#@param(.*?)\$[\w]+(.*?)\n#'; public function __construct( private DocblockRelatedParamNamesResolver $docblockRelatedParamNamesResolver diff --git a/src/TokenRunner/DocBlock/MalformWorker/MissingVarNameMalformWorker.php b/src/TokenRunner/DocBlock/MalformWorker/MissingVarNameMalformWorker.php index d08736fe0..72ab21152 100644 --- a/src/TokenRunner/DocBlock/MalformWorker/MissingVarNameMalformWorker.php +++ b/src/TokenRunner/DocBlock/MalformWorker/MissingVarNameMalformWorker.php @@ -12,10 +12,9 @@ final class MissingVarNameMalformWorker implements MalformWorkerInterface { /** - * @var string * @see https://regex101.com/r/s1UkZs/1 */ - private const VAR_WITHOUT_NAME_REGEX = '#^(?\/\*\* @(?:psalm-|phpstan-)?var )(?[\\\\\w\|-|]+)(?\s+\*\/)$#'; + private const string VAR_WITHOUT_NAME_REGEX = '#^(?\/\*\* @(?:psalm-|phpstan-)?var )(?[\\\\\w\|-|]+)(?\s+\*\/)$#'; /** * @param Tokens $tokens diff --git a/src/TokenRunner/DocBlock/MalformWorker/ParamNameReferenceMalformWorker.php b/src/TokenRunner/DocBlock/MalformWorker/ParamNameReferenceMalformWorker.php index c3a0c62ad..650ad112f 100644 --- a/src/TokenRunner/DocBlock/MalformWorker/ParamNameReferenceMalformWorker.php +++ b/src/TokenRunner/DocBlock/MalformWorker/ParamNameReferenceMalformWorker.php @@ -12,10 +12,9 @@ final class ParamNameReferenceMalformWorker implements MalformWorkerInterface { /** - * @var string * @see https://regex101.com/r/B4rWNk/3 */ - private const PARAM_NAME_REGEX = '#(?@param(.*?))&(?\$\w+)#'; + private const string PARAM_NAME_REGEX = '#(?@param(.*?))&(?\$\w+)#'; /** * @param Tokens $tokens diff --git a/src/TokenRunner/DocBlock/MalformWorker/ParamNameTypoMalformWorker.php b/src/TokenRunner/DocBlock/MalformWorker/ParamNameTypoMalformWorker.php index 1358f6478..294700437 100644 --- a/src/TokenRunner/DocBlock/MalformWorker/ParamNameTypoMalformWorker.php +++ b/src/TokenRunner/DocBlock/MalformWorker/ParamNameTypoMalformWorker.php @@ -15,10 +15,9 @@ final readonly class ParamNameTypoMalformWorker implements MalformWorkerInterface { /** - * @var string * @see https://regex101.com/r/5szHlw/1 */ - private const PARAM_NAME_REGEX = '#@param(\s+)(?callable)?(.*?)(?\$\w+)#'; + private const string PARAM_NAME_REGEX = '#@param(\s+)(?callable)?(.*?)(?\$\w+)#'; public function __construct( private DocblockRelatedParamNamesResolver $docblockRelatedParamNamesResolver diff --git a/src/TokenRunner/DocBlock/MalformWorker/SuperfluousReturnNameMalformWorker.php b/src/TokenRunner/DocBlock/MalformWorker/SuperfluousReturnNameMalformWorker.php index ea56c98d8..716bebbbc 100644 --- a/src/TokenRunner/DocBlock/MalformWorker/SuperfluousReturnNameMalformWorker.php +++ b/src/TokenRunner/DocBlock/MalformWorker/SuperfluousReturnNameMalformWorker.php @@ -13,26 +13,21 @@ final class SuperfluousReturnNameMalformWorker implements MalformWorkerInterface { /** - * @var string * @see https://regex101.com/r/4qyd2j/1 */ - private const RETURN_VARIABLE_NAME_REGEX = '#(?@(?:psalm-|phpstan-)?return)(?\s+[|\\\\\w]+)?(\s+)(?<' . self::VARIABLE_NAME_PART . '>\$[\w]+)#'; + private const string RETURN_VARIABLE_NAME_REGEX = '#(?@(?:psalm-|phpstan-)?return)(?\s+[|\\\\\w]+)?(\s+)(?<' . self::VARIABLE_NAME_PART . '>\$[\w]+)#'; /** * @var string[] */ - private const ALLOWED_VARIABLE_NAMES = ['$this']; + private const array ALLOWED_VARIABLE_NAMES = ['$this']; /** - * @var string * @see https://regex101.com/r/IE9fA6/1 */ - private const VARIABLE_NAME_REGEX = '#\$\w+#'; + private const string VARIABLE_NAME_REGEX = '#\$\w+#'; - /** - * @var string - */ - private const VARIABLE_NAME_PART = 'variableName'; + private const string VARIABLE_NAME_PART = 'variableName'; /** * @param Tokens $tokens diff --git a/src/TokenRunner/DocBlock/MalformWorker/SuperfluousVarNameMalformWorker.php b/src/TokenRunner/DocBlock/MalformWorker/SuperfluousVarNameMalformWorker.php index 8f17fbf9a..78b05289e 100644 --- a/src/TokenRunner/DocBlock/MalformWorker/SuperfluousVarNameMalformWorker.php +++ b/src/TokenRunner/DocBlock/MalformWorker/SuperfluousVarNameMalformWorker.php @@ -13,16 +13,14 @@ final class SuperfluousVarNameMalformWorker implements MalformWorkerInterface { /** - * @var string * @see https://regex101.com/r/euhrn8/1 */ - private const THIS_VARIABLE_REGEX = '#\$this$#'; + private const string THIS_VARIABLE_REGEX = '#\$this$#'; /** - * @var string * @see https://regex101.com/r/6XuSGV/1 */ - private const VAR_VARIABLE_NAME_REGEX = '#(?@(?:psalm-|phpstan-)?var)(?\s+[|\\\\\w]+)?(\s+)(?\$[\w]+)#'; + private const string VAR_VARIABLE_NAME_REGEX = '#(?@(?:psalm-|phpstan-)?var)(?\s+[|\\\\\w]+)?(\s+)(?\$[\w]+)#'; /** * @param Tokens $tokens diff --git a/src/TokenRunner/DocBlock/MalformWorker/SwitchedTypeAndNameMalformWorker.php b/src/TokenRunner/DocBlock/MalformWorker/SwitchedTypeAndNameMalformWorker.php index b9cb60953..9e36caf8c 100644 --- a/src/TokenRunner/DocBlock/MalformWorker/SwitchedTypeAndNameMalformWorker.php +++ b/src/TokenRunner/DocBlock/MalformWorker/SwitchedTypeAndNameMalformWorker.php @@ -13,10 +13,9 @@ final class SwitchedTypeAndNameMalformWorker implements MalformWorkerInterface { /** - * @var string * @see https://regex101.com/r/4us32A/1 */ - private const NAME_THEN_TYPE_REGEX = '#@((?:psalm-|phpstan-)?(?:param|var))(\s+)(?\$\w+)(\s+)(?[|\\\\\w\[\]\<\>]+)#'; + private const string NAME_THEN_TYPE_REGEX = '#@((?:psalm-|phpstan-)?(?:param|var))(\s+)(?\$\w+)(\s+)(?[|\\\\\w\[\]\<\>]+)#'; /** * @param Tokens $tokens diff --git a/src/TokenRunner/Enum/LineKind.php b/src/TokenRunner/Enum/LineKind.php index a456a8f92..d06ff4c1e 100644 --- a/src/TokenRunner/Enum/LineKind.php +++ b/src/TokenRunner/Enum/LineKind.php @@ -9,13 +9,7 @@ */ final class LineKind { - /** - * @var int - */ - public const ARRAYS = 1; + public const int ARRAYS = 1; - /** - * @var int - */ - public const CALLS = 2; + public const int CALLS = 2; } diff --git a/src/TokenRunner/ValueObject/TokenKinds.php b/src/TokenRunner/ValueObject/TokenKinds.php index 2239a0d1c..bf2b7c21c 100644 --- a/src/TokenRunner/ValueObject/TokenKinds.php +++ b/src/TokenRunner/ValueObject/TokenKinds.php @@ -11,5 +11,5 @@ final class TokenKinds /** * @var int[] */ - public const ARRAY_OPEN_TOKENS = [T_ARRAY, CT::T_ARRAY_SQUARE_BRACE_OPEN]; + public const array ARRAY_OPEN_TOKENS = [T_ARRAY, CT::T_ARRAY_SQUARE_BRACE_OPEN]; } diff --git a/src/TokenRunner/ValueObject/Wrapper/FixerWrapper/ArrayWrapper.php b/src/TokenRunner/ValueObject/Wrapper/FixerWrapper/ArrayWrapper.php index 978e2ac53..5ca048bdc 100644 --- a/src/TokenRunner/ValueObject/Wrapper/FixerWrapper/ArrayWrapper.php +++ b/src/TokenRunner/ValueObject/Wrapper/FixerWrapper/ArrayWrapper.php @@ -15,7 +15,7 @@ /** * @var int[] */ - private const ARRAY_OPEN_TOKENS = [T_ARRAY, CT::T_ARRAY_SQUARE_BRACE_OPEN]; + private const array ARRAY_OPEN_TOKENS = [T_ARRAY, CT::T_ARRAY_SQUARE_BRACE_OPEN]; /** * @param Tokens $tokens diff --git a/src/ValueObject/CodingStandardConfig.php b/src/ValueObject/CodingStandardConfig.php index 5edef09b6..784677732 100644 --- a/src/ValueObject/CodingStandardConfig.php +++ b/src/ValueObject/CodingStandardConfig.php @@ -9,8 +9,5 @@ */ final class CodingStandardConfig { - /** - * @var string - */ - public const FILE_PATH = __DIR__ . '/../../config/config.php'; + public const string FILE_PATH = __DIR__ . '/../../config/config.php'; }