diff --git a/.github/workflows/build_scoped_rector.yaml b/.github/workflows/build_scoped_rector.yaml index 3b8cf64c641..80d1624af84 100644 --- a/.github/workflows/build_scoped_rector.yaml +++ b/.github/workflows/build_scoped_rector.yaml @@ -38,7 +38,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none # fixes https://github.com/rectorphp/rector/pull/4559/checks?check_run_id=1359814403, see https://github.com/shivammathur/setup-php#composer-github-oauth diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml index 9ad51d433fc..f28b22c379c 100644 --- a/.github/workflows/code_analysis.yaml +++ b/.github/workflows/code_analysis.yaml @@ -89,7 +89,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none - uses: "ramsey/composer-install@v3" diff --git a/.github/workflows/code_analysis_no_dev.yaml b/.github/workflows/code_analysis_no_dev.yaml index b895b04c256..19bb5787803 100644 --- a/.github/workflows/code_analysis_no_dev.yaml +++ b/.github/workflows/code_analysis_no_dev.yaml @@ -17,7 +17,7 @@ jobs: # see https://github.com/shivammathur/setup-php - uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none - run: | diff --git a/.github/workflows/compat_test.yaml b/.github/workflows/compat_test.yaml index c4e0aa2c08f..d44f4f85736 100644 --- a/.github/workflows/compat_test.yaml +++ b/.github/workflows/compat_test.yaml @@ -15,7 +15,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none - run: composer create-project "rector/rector-compat-tests:dev-main" . diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index f45dc8cf8f5..d69ffcaa76a 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - php_version: ['8.2'] + php_version: ['8.3'] directory: - 'e2e/applied-auto-import' - 'e2e/applied-polyfill-php80' diff --git a/.github/workflows/e2e_command_with_option.yaml b/.github/workflows/e2e_command_with_option.yaml index 7b38a6d75de..a3e4c4cb871 100644 --- a/.github/workflows/e2e_command_with_option.yaml +++ b/.github/workflows/e2e_command_with_option.yaml @@ -27,7 +27,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none - uses: "ramsey/composer-install@v3" @@ -60,4 +60,3 @@ jobs: ../../bin/rector some_file.php --output-format=json php ../../bin/rector some_file.php --output-format json php ../../bin/rector some_file.php --output-format=json - diff --git a/.github/workflows/e2e_with_cache.yaml b/.github/workflows/e2e_with_cache.yaml index 66a38d05ef4..19a045fb8a2 100644 --- a/.github/workflows/e2e_with_cache.yaml +++ b/.github/workflows/e2e_with_cache.yaml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - php_version: ['8.2'] + php_version: ['8.3'] directory: - 'e2e/applied-rule-removed-node-with-cache' - 'e2e/timeout-file-not-cached' diff --git a/.github/workflows/e2e_with_no_diffs.yaml b/.github/workflows/e2e_with_no_diffs.yaml index 3006f84a593..5abc4fad179 100644 --- a/.github/workflows/e2e_with_no_diffs.yaml +++ b/.github/workflows/e2e_with_no_diffs.yaml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - php_version: ['8.2'] + php_version: ['8.3'] directory: - 'e2e/applied-rule-removed-node-no-diffs' diff --git a/.github/workflows/packages_tests.yaml b/.github/workflows/packages_tests.yaml index 10b45db2e83..ea071e6befe 100644 --- a/.github/workflows/packages_tests.yaml +++ b/.github/workflows/packages_tests.yaml @@ -45,7 +45,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none - run: composer config minimum-stability dev diff --git a/.github/workflows/phpstan_printer_test.yaml b/.github/workflows/phpstan_printer_test.yaml index ff080c000c9..fcc011be97d 100644 --- a/.github/workflows/phpstan_printer_test.yaml +++ b/.github/workflows/phpstan_printer_test.yaml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - php-versions: ['8.2'] + php-versions: ['8.3'] runs-on: ${{ matrix.os }} timeout-minutes: 3 diff --git a/.github/workflows/rector.yaml b/.github/workflows/rector.yaml index 14db4184701..743cb3ebc33 100644 --- a/.github/workflows/rector.yaml +++ b/.github/workflows/rector.yaml @@ -24,8 +24,8 @@ jobs: - uses: shivammathur/setup-php@v2 with: - # PHP 8.2 is required, so Rector's code is PHP 8.2 compatible even after refactoring - php-version: 8.2 + # PHP 8.3 is required, so Rector's code is PHP 8.3 compatible even after refactoring + php-version: 8.3 coverage: none - run: composer install --no-progress --ansi diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index cd1a0c804b0..cb696a36aeb 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - php-versions: ['8.2', '8.3', '8.4', '8.5'] + php-versions: ['8.3', '8.4', '8.5'] runs-on: ${{ matrix.os }} timeout-minutes: 3 diff --git a/.github/workflows/weekly_pull_requests.yaml b/.github/workflows/weekly_pull_requests.yaml index ba315315fa8..2e2f5a2351f 100644 --- a/.github/workflows/weekly_pull_requests.yaml +++ b/.github/workflows/weekly_pull_requests.yaml @@ -41,7 +41,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none - uses: "ramsey/composer-install@v3" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ea9e95aa61f..8f336e9e58b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ git clone git@github.com:/rector-src.git cd rector-src ``` -2. We use PHP 8.2 and composer +2. We use PHP 8.3 and composer Install dependencies and verify your local environment: diff --git a/Dockerfile b/Dockerfile index ed8e2a41465..446f4d3c9c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.2-cli-alpine +FROM php:8.3-cli-alpine WORKDIR /etc/rector diff --git a/README.md b/README.md index a922f5cc53d..49960ee5ef9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Head to [`rectorphp/rector`](http://github.com/rectorphp/rector) for documentati ## Building `rectorphp/rector` -Code of this repository requires PHP 8.2. For `rector/rector` package the builder downgrades code to PHP 7.4+. +Code of this repository requires PHP 8.3. For `rector/rector` package the builder downgrades code to PHP 7.4+.
diff --git a/build/build-preload.php b/build/build-preload.php index de87adabbbc..c7c62f96787 100755 --- a/build/build-preload.php +++ b/build/build-preload.php @@ -43,10 +43,7 @@ final class PreloadBuilder { - /** - * @var string - */ - private const PRELOAD_FILE_TEMPLATE = <<<'CODE_SAMPLE' + private const string PRELOAD_FILE_TEMPLATE = <<<'CODE_SAMPLE' $position diff --git a/rules/Assert/Enum/AssertClassName.php b/rules/Assert/Enum/AssertClassName.php index 47160416bdf..5efd9b28779 100644 --- a/rules/Assert/Enum/AssertClassName.php +++ b/rules/Assert/Enum/AssertClassName.php @@ -6,13 +6,7 @@ final class AssertClassName { - /** - * @var string - */ - public const WEBMOZART = 'Webmozart\Assert\Assert'; + public const string WEBMOZART = 'Webmozart\Assert\Assert'; - /** - * @var string - */ - public const BEBERLEI = 'Assert\Assertion'; + public const string BEBERLEI = 'Assert\Assertion'; } diff --git a/rules/Carbon/NodeFactory/CarbonCallFactory.php b/rules/Carbon/NodeFactory/CarbonCallFactory.php index 3b6145bad2b..3d0180a2ee2 100644 --- a/rules/Carbon/NodeFactory/CarbonCallFactory.php +++ b/rules/Carbon/NodeFactory/CarbonCallFactory.php @@ -16,16 +16,14 @@ final class CarbonCallFactory { /** - * @var string * @see https://regex101.com/r/LLMrFw/1 */ - private const PLUS_MINUS_COUNT_REGEX = '#(?\+|-)(\\s+)?(?\\d+)(\s+)?(?seconds|second|sec|minutes|minute|min|hours|hour|days|day|weeks|week|months|month|years|year)#'; + private const string PLUS_MINUS_COUNT_REGEX = '#(?\+|-)(\\s+)?(?\\d+)(\s+)?(?seconds|second|sec|minutes|minute|min|hours|hour|days|day|weeks|week|months|month|years|year)#'; /** - * @var string * @see https://regex101.com/r/IhxHTO/1 */ - private const STATIC_DATE_REGEX = '#now|yesterday|today|tomorrow#'; + private const string STATIC_DATE_REGEX = '#now|yesterday|today|tomorrow#'; public function createFromDateTimeString( FullyQualified $carbonFullyQualified, diff --git a/rules/Carbon/Rector/FuncCall/DateFuncCallToCarbonRector.php b/rules/Carbon/Rector/FuncCall/DateFuncCallToCarbonRector.php index 479bb6ea713..e0d311b8604 100644 --- a/rules/Carbon/Rector/FuncCall/DateFuncCallToCarbonRector.php +++ b/rules/Carbon/Rector/FuncCall/DateFuncCallToCarbonRector.php @@ -24,7 +24,7 @@ */ final class DateFuncCallToCarbonRector extends AbstractRector { - private const TIME_UNITS = [ + private const array TIME_UNITS = [ ['weeks', 604800], ['days', 86400], ['hours', 3600], diff --git a/rules/CodeQuality/NodeAnalyzer/LocalPropertyAnalyzer.php b/rules/CodeQuality/NodeAnalyzer/LocalPropertyAnalyzer.php index 5da0da35e68..07332188075 100644 --- a/rules/CodeQuality/NodeAnalyzer/LocalPropertyAnalyzer.php +++ b/rules/CodeQuality/NodeAnalyzer/LocalPropertyAnalyzer.php @@ -28,10 +28,7 @@ final readonly class LocalPropertyAnalyzer { - /** - * @var string - */ - private const LARAVEL_COLLECTION_CLASS = 'Illuminate\Support\Collection'; + private const string LARAVEL_COLLECTION_CLASS = 'Illuminate\Support\Collection'; public function __construct( private SimpleCallableNodeTraverser $simpleCallableNodeTraverser, diff --git a/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php b/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php index 90109dc2b8b..b534616713f 100644 --- a/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php +++ b/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php @@ -29,10 +29,7 @@ */ final class ThrowWithPreviousExceptionRector extends AbstractRector { - /** - * @var int - */ - private const DEFAULT_EXCEPTION_ARGUMENT_POSITION = 2; + private const int DEFAULT_EXCEPTION_ARGUMENT_POSITION = 2; public function __construct( private readonly ReflectionProvider $reflectionProvider diff --git a/rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php b/rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php index 8c8d7177c87..60103f05bba 100644 --- a/rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php +++ b/rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php @@ -18,17 +18,13 @@ */ final class JoinStringConcatRector extends AbstractRector { - /** - * @var int - */ - private const LINE_BREAK_POINT = 100; + private const int LINE_BREAK_POINT = 100; /** - * @var string * @see https://regex101.com/r/VaXM1t/1 * @see https://stackoverflow.com/questions/4147646/determine-if-utf-8-text-is-all-ascii */ - private const ASCII_REGEX = '#[^\x00-\x7F]#'; + private const string ASCII_REGEX = '#[^\x00-\x7F]#'; public function getRuleDefinition(): RuleDefinition { diff --git a/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php b/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php index 3d205ab88a3..0b751bcd5c9 100644 --- a/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php +++ b/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php @@ -24,10 +24,7 @@ */ final class ForRepeatedCountToOwnVariableRector extends AbstractRector { - /** - * @var string - */ - private const COUNTER_NAME = 'counter'; + private const string COUNTER_NAME = 'counter'; public function getRuleDefinition(): RuleDefinition { diff --git a/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php b/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php index ffe3dfcac71..9bb2e01fd80 100644 --- a/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php @@ -28,7 +28,7 @@ final class SetTypeToCastRector extends AbstractRector /** * @var array> */ - private const TYPE_TO_CAST = [ + private const array TYPE_TO_CAST = [ 'array' => Array_::class, 'bool' => Bool_::class, 'boolean' => Bool_::class, diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php index e245aefc7d7..4c29d7a9853 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php @@ -23,7 +23,7 @@ final class SimplifyRegexPatternRector extends AbstractRector * * @var array */ - private const COMPLEX_PATTERN_TO_SIMPLE = [ + private const array COMPLEX_PATTERN_TO_SIMPLE = [ '[0-9]' => "\d", '[a-zA-Z0-9_]' => "\w", '[A-Za-z0-9_]' => "\w", diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php index 8df0f8e277f..62bb4f07eac 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php @@ -19,10 +19,9 @@ final class SimplifyStrposLowerRector extends AbstractRector { /** - * @var string * @see https://regex101.com/r/Jokjt8/1 */ - private const UPPERCASE_REGEX = '#[A-Z]#'; + private const string UPPERCASE_REGEX = '#[A-Z]#'; public function getRuleDefinition(): RuleDefinition { diff --git a/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php b/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php index 263d194d155..ee5d6b8c685 100644 --- a/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php +++ b/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php @@ -32,9 +32,8 @@ final class SimplifyUselessVariableRector extends AbstractRector implements Conf { /** * @api - * @var string */ - public const ONLY_DIRECT_ASSIGN = 'only_direct_assign'; + public const string ONLY_DIRECT_ASSIGN = 'only_direct_assign'; private bool $onlyDirectAssign = false; diff --git a/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php b/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php index 449af2cdc22..34713e3e9e6 100644 --- a/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php +++ b/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php @@ -25,10 +25,7 @@ */ final class SimplifyIfElseToTernaryRector extends AbstractRector { - /** - * @var int - */ - private const LINE_LENGTH_LIMIT = 120; + private const int LINE_LENGTH_LIMIT = 120; public function __construct( private readonly BetterStandardPrinter $betterStandardPrinter, diff --git a/rules/CodeQuality/Rector/Include_/AbsolutizeRequireAndIncludePathRector.php b/rules/CodeQuality/Rector/Include_/AbsolutizeRequireAndIncludePathRector.php index 93a9ae843ec..d34a8294716 100644 --- a/rules/CodeQuality/Rector/Include_/AbsolutizeRequireAndIncludePathRector.php +++ b/rules/CodeQuality/Rector/Include_/AbsolutizeRequireAndIncludePathRector.php @@ -22,10 +22,9 @@ final class AbsolutizeRequireAndIncludePathRector extends AbstractRector { /** - * @var string * @see https://regex101.com/r/N8oLqv/1 */ - private const WINDOWS_DRIVE_REGEX = '#^[a-zA-z]\:[\/\\\]#'; + private const string WINDOWS_DRIVE_REGEX = '#^[a-zA-z]\:[\/\\\]#'; public function __construct( private readonly ValueResolver $valueResolver diff --git a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/ReservedClassNameImportSkipVoter.php b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/ReservedClassNameImportSkipVoter.php index 34363397893..7e618f832fe 100644 --- a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/ReservedClassNameImportSkipVoter.php +++ b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/ReservedClassNameImportSkipVoter.php @@ -14,7 +14,7 @@ /** * @var string[] */ - private const RESERVED_CLASS_NAMES = [ + private const array RESERVED_CLASS_NAMES = [ 'bool', 'false', 'float', diff --git a/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php b/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php index b002461f60d..f1a53de2cc7 100644 --- a/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php +++ b/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php @@ -19,12 +19,10 @@ final readonly class UseImportNameMatcher { /** - * @var string - * * @see https://regex101.com/r/ZxFSlc/1 for last name, eg: Entity and UniqueEntity * @see https://regex101.com/r/OLO0Un/1 for inside namespace, eg: ORM for ORM\Id or ORM\Column */ - private const SHORT_NAME_REGEX = '#^%s(\\\\[\w]+)?$#i'; + private const string SHORT_NAME_REGEX = '#^%s(\\\\[\w]+)?$#i'; public function __construct( private BetterNodeFinder $betterNodeFinder, diff --git a/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php b/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php index 3048f8cba55..6502f7b67a8 100644 --- a/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php +++ b/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php @@ -32,10 +32,9 @@ final class CatchExceptionNameMatchingTypeRector extends AbstractRector { /** - * @var string * @see https://regex101.com/r/xmfMAX/1 */ - private const STARTS_WITH_ABBREVIATION_REGEX = '#^([A-Za-z]+?)([A-Z]{1}[a-z]{1})([A-Za-z]*)#'; + private const string STARTS_WITH_ABBREVIATION_REGEX = '#^([A-Za-z]+?)([A-Z]{1}[a-z]{1})([A-Za-z]*)#'; public function __construct( private readonly PropertyNaming $propertyNaming, diff --git a/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php b/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php index 656d159e88a..dd176f40d0c 100644 --- a/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php +++ b/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php @@ -30,14 +30,13 @@ final class EncapsedStringsToSprintfRector extends AbstractRector implements Con { /** * @api - * @var string */ - public const ALWAYS = 'always'; + public const string ALWAYS = 'always'; /** * @var array>> */ - private const FORMAT_SPECIFIERS = [ + private const array FORMAT_SPECIFIERS = [ '%s' => ['PHPStan\Type\StringType'], '%d' => [ 'PHPStan\Type\Constant\ConstantIntegerType', diff --git a/rules/CodingStyle/Rector/FuncCall/VersionCompareFuncCallToConstantRector.php b/rules/CodingStyle/Rector/FuncCall/VersionCompareFuncCallToConstantRector.php index 5a8edef1911..4e2afeff160 100644 --- a/rules/CodingStyle/Rector/FuncCall/VersionCompareFuncCallToConstantRector.php +++ b/rules/CodingStyle/Rector/FuncCall/VersionCompareFuncCallToConstantRector.php @@ -31,7 +31,7 @@ final class VersionCompareFuncCallToConstantRector extends AbstractRector /** * @var array> */ - private const OPERATOR_TO_COMPARISON = [ + private const array OPERATOR_TO_COMPARISON = [ '=' => Identical::class, '==' => Identical::class, 'eq' => Identical::class, diff --git a/rules/CodingStyle/Rector/String_/SimplifyQuoteEscapeRector.php b/rules/CodingStyle/Rector/String_/SimplifyQuoteEscapeRector.php index 86e1cadbda1..db117848c10 100644 --- a/rules/CodingStyle/Rector/String_/SimplifyQuoteEscapeRector.php +++ b/rules/CodingStyle/Rector/String_/SimplifyQuoteEscapeRector.php @@ -18,17 +18,15 @@ final class SimplifyQuoteEscapeRector extends AbstractRector { /** - * @var string * @see https://regex101.com/r/qEkCe9/2 */ - private const ESCAPED_CHAR_REGEX = '#\\\\|\$|\\n|\\t#sim'; + private const string ESCAPED_CHAR_REGEX = '#\\\\|\$|\\n|\\t#sim'; /** - * @var string * @see https://alvinalexander.com/php/how-to-remove-non-printable-characters-in-string-regex/ * @see https://regex101.com/r/lGUhRb/1 */ - private const HAS_NON_PRINTABLE_CHARS = '#[\x00-\x1F\x80-\xFF]#'; + private const string HAS_NON_PRINTABLE_CHARS = '#[\x00-\x1F\x80-\xFF]#'; private bool $hasChanged = false; diff --git a/rules/CodingStyle/Rector/String_/UseClassKeywordForClassNameResolutionRector.php b/rules/CodingStyle/Rector/String_/UseClassKeywordForClassNameResolutionRector.php index 9c2c0fd928b..a26405b154e 100644 --- a/rules/CodingStyle/Rector/String_/UseClassKeywordForClassNameResolutionRector.php +++ b/rules/CodingStyle/Rector/String_/UseClassKeywordForClassNameResolutionRector.php @@ -21,10 +21,9 @@ final class UseClassKeywordForClassNameResolutionRector extends AbstractRector { /** - * @var string * @see https://regex101.com/r/Vv41Qr/1/ */ - private const CLASS_BEFORE_STATIC_ACCESS_REGEX = '#(?[\\\\a-zA-Z0-9_\\x80-\\xff]*)::#'; + private const string CLASS_BEFORE_STATIC_ACCESS_REGEX = '#(?[\\\\a-zA-Z0-9_\\x80-\\xff]*)::#'; public function __construct( private readonly ReflectionProvider $reflectionProvider diff --git a/rules/CodingStyle/ValueObject/ObjectMagicMethods.php b/rules/CodingStyle/ValueObject/ObjectMagicMethods.php index c12d3686028..b4b9a9cfa48 100644 --- a/rules/CodingStyle/ValueObject/ObjectMagicMethods.php +++ b/rules/CodingStyle/ValueObject/ObjectMagicMethods.php @@ -11,7 +11,7 @@ final class ObjectMagicMethods /** * @var string[] */ - public const METHOD_NAMES = [ + public const array METHOD_NAMES = [ '__call', '__callStatic', MethodName::CLONE, diff --git a/rules/DeadCode/PhpDoc/Guard/StandaloneTypeRemovalGuard.php b/rules/DeadCode/PhpDoc/Guard/StandaloneTypeRemovalGuard.php index 396e68ce81d..3d73c1fec7f 100644 --- a/rules/DeadCode/PhpDoc/Guard/StandaloneTypeRemovalGuard.php +++ b/rules/DeadCode/PhpDoc/Guard/StandaloneTypeRemovalGuard.php @@ -14,7 +14,7 @@ final class StandaloneTypeRemovalGuard /** * @var string[] */ - private const ALLOWED_TYPES = ['false', 'true']; + private const array ALLOWED_TYPES = ['false', 'true']; public function isLegal(TypeNode $typeNode, Node $node): bool { diff --git a/rules/DeadCode/Rector/Cast/RecastingRemovalRector.php b/rules/DeadCode/Rector/Cast/RecastingRemovalRector.php index 627d513b057..1d8f6184cc5 100644 --- a/rules/DeadCode/Rector/Cast/RecastingRemovalRector.php +++ b/rules/DeadCode/Rector/Cast/RecastingRemovalRector.php @@ -41,7 +41,7 @@ final class RecastingRemovalRector extends AbstractRector /** * @var array, class-string> */ - private const CAST_CLASS_TO_NODE_TYPE = [ + private const array CAST_CLASS_TO_NODE_TYPE = [ String_::class => StringType::class, Bool_::class => BooleanType::class, Array_::class => ArrayType::class, diff --git a/rules/DeadCode/Rector/Node/RemoveNonExistingVarAnnotationRector.php b/rules/DeadCode/Rector/Node/RemoveNonExistingVarAnnotationRector.php index ab5d807e861..bee534d6154 100644 --- a/rules/DeadCode/Rector/Node/RemoveNonExistingVarAnnotationRector.php +++ b/rules/DeadCode/Rector/Node/RemoveNonExistingVarAnnotationRector.php @@ -41,7 +41,7 @@ final class RemoveNonExistingVarAnnotationRector extends AbstractRector /** * @var array> */ - private const NODE_TYPES = [ + private const array NODE_TYPES = [ Foreach_::class, Static_::class, Echo_::class, diff --git a/rules/DeadCode/SideEffect/SideEffectNodeDetector.php b/rules/DeadCode/SideEffect/SideEffectNodeDetector.php index 40529e5ec00..6e7b83276d6 100644 --- a/rules/DeadCode/SideEffect/SideEffectNodeDetector.php +++ b/rules/DeadCode/SideEffect/SideEffectNodeDetector.php @@ -27,7 +27,7 @@ /** * @var array> */ - private const CALL_EXPR_SIDE_EFFECT_NODE_TYPES = [ + private const array CALL_EXPR_SIDE_EFFECT_NODE_TYPES = [ MethodCall::class, New_::class, NullsafeMethodCall::class, diff --git a/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php b/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php index 9ff74709afe..639e3ec1a6f 100644 --- a/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php +++ b/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php @@ -16,26 +16,21 @@ /** * @var array */ - private const SINGULARIZE_MAP = [ + private const array SINGULARIZE_MAP = [ 'news' => 'new', ]; /** - * @var string * @see https://regex101.com/r/lbQaGC/3 */ - private const CAMELCASE_REGEX = '#(?([a-z\d]+|[A-Z\d]{1,}[a-z\d]+|_))#'; + private const string CAMELCASE_REGEX = '#(?([a-z\d]+|[A-Z\d]{1,}[a-z\d]+|_))#'; /** - * @var string * @see https://regex101.com/r/2aGdkZ/2 */ - private const BY_MIDDLE_REGEX = '#(?By[A-Z][a-zA-Z]+)#'; + private const string BY_MIDDLE_REGEX = '#(?By[A-Z][a-zA-Z]+)#'; - /** - * @var string - */ - private const CAMELCASE = 'camelcase'; + private const string CAMELCASE = 'camelcase'; public function __construct( private Inflector $inflector diff --git a/rules/Naming/Guard/BreakingVariableRenameGuard.php b/rules/Naming/Guard/BreakingVariableRenameGuard.php index 4030085a807..a266c9f3975 100644 --- a/rules/Naming/Guard/BreakingVariableRenameGuard.php +++ b/rules/Naming/Guard/BreakingVariableRenameGuard.php @@ -31,10 +31,9 @@ final readonly class BreakingVariableRenameGuard { /** - * @var string * @see https://regex101.com/r/1pKLgf/1 */ - public const AT_NAMING_REGEX = '#[\w+]At$#'; + public const string AT_NAMING_REGEX = '#[\w+]At$#'; public function __construct( private BetterNodeFinder $betterNodeFinder, diff --git a/rules/Naming/Naming/PropertyNaming.php b/rules/Naming/Naming/PropertyNaming.php index 4dff3f8d39a..27a72688f91 100644 --- a/rules/Naming/Naming/PropertyNaming.php +++ b/rules/Naming/Naming/PropertyNaming.php @@ -28,31 +28,26 @@ /** * @var string[] */ - private const EXCLUDED_CLASSES = ['#Closure#', '#^Spl#', '#FileInfo#', '#^std#', '#Iterator#', '#SimpleXML#']; + private const array EXCLUDED_CLASSES = ['#Closure#', '#^Spl#', '#FileInfo#', '#^std#', '#Iterator#', '#SimpleXML#']; /** * @var array */ - private const CONTEXT_AWARE_NAMES_BY_TYPE = [ + private const array CONTEXT_AWARE_NAMES_BY_TYPE = [ 'Twig\Environment' => 'twigEnvironment', ]; - /** - * @var string - */ - private const INTERFACE = 'Interface'; + private const string INTERFACE = 'Interface'; /** - * @var string * @see https://regex101.com/r/U78rUF/1 */ - private const I_PREFIX_REGEX = '#^I[A-Z]#'; + private const string I_PREFIX_REGEX = '#^I[A-Z]#'; /** * @see https://regex101.com/r/hnU5pm/2/ - * @var string */ - private const GET_PREFIX_REGEX = '#^get(?[A-Z].+)#'; + private const string GET_PREFIX_REGEX = '#^get(?[A-Z].+)#'; public function __construct( private RectorNamingInflector $rectorNamingInflector, diff --git a/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php b/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php index c3fe0241608..6e8fd77b4c6 100644 --- a/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php +++ b/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php @@ -31,16 +31,14 @@ final class RenameVariableToMatchMethodCallReturnTypeRector extends AbstractRector { /** - * @var string * @see https://regex101.com/r/JG5w9j/1 */ - private const OR_BETWEEN_WORDS_REGEX = '#[a-z]Or[A-Z]#'; + private const string OR_BETWEEN_WORDS_REGEX = '#[a-z]Or[A-Z]#'; /** - * @var string * @see https://regex101.com/r/TV8YXZ/1 */ - private const VALID_VARIABLE_NAME_REGEX = '#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$#'; + private const string VALID_VARIABLE_NAME_REGEX = '#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$#'; public function __construct( private readonly BreakingVariableRenameGuard $breakingVariableRenameGuard, diff --git a/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchMethodCallReturnTypeRector.php b/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchMethodCallReturnTypeRector.php index 9cfb46718ad..4f28ac5619e 100644 --- a/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchMethodCallReturnTypeRector.php +++ b/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchMethodCallReturnTypeRector.php @@ -29,7 +29,7 @@ final class RenameForeachValueVariableToMatchMethodCallReturnTypeRector extends /** * @var string[] */ - private const UNREADABLE_GENERIC_NAMES = ['traversable', 'iterable', 'generator', 'rewindableGenerator']; + private const array UNREADABLE_GENERIC_NAMES = ['traversable', 'iterable', 'generator', 'rewindableGenerator']; public function __construct( private readonly BreakingVariableRenameGuard $breakingVariableRenameGuard, diff --git a/rules/Naming/RectorNamingInflector.php b/rules/Naming/RectorNamingInflector.php index c40f40423d2..8ea3d2b17db 100644 --- a/rules/Naming/RectorNamingInflector.php +++ b/rules/Naming/RectorNamingInflector.php @@ -10,10 +10,9 @@ final readonly class RectorNamingInflector { /** - * @var string * @see https://regex101.com/r/VqVvke/3 */ - private const DATA_INFO_SUFFIX_REGEX = '#^(?.+)(?Data|Info)$#'; + private const string DATA_INFO_SUFFIX_REGEX = '#^(?.+)(?Data|Info)$#'; public function __construct( private Inflector $inflector diff --git a/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php b/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php index 0e3e8b7120e..5e3eee9798a 100644 --- a/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php +++ b/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php @@ -20,7 +20,7 @@ final class ReplaceHttpServerVarsByServerRector extends AbstractRector implement /** * @var array */ - private const VARIABLE_RENAME_MAP = [ + private const array VARIABLE_RENAME_MAP = [ 'HTTP_SERVER_VARS' => '_SERVER', 'HTTP_GET_VARS' => '_GET', 'HTTP_POST_VARS' => '_POST', diff --git a/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php b/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php index e0fc179fcc2..267e07d6dcf 100644 --- a/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php +++ b/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php @@ -25,9 +25,8 @@ final class StringClassNameToClassConstantRector extends AbstractRector implemen { /** * @deprecated since 2.2.12. Default behavior now. - * @var string */ - public const SHOULD_KEEP_PRE_SLASH = 'should_keep_pre_slash'; + public const string SHOULD_KEEP_PRE_SLASH = 'should_keep_pre_slash'; /** * @var string[] diff --git a/rules/Php55/RegexMatcher.php b/rules/Php55/RegexMatcher.php index 83a1f6e29cd..b53cceda040 100644 --- a/rules/Php55/RegexMatcher.php +++ b/rules/Php55/RegexMatcher.php @@ -12,22 +12,20 @@ final readonly class RegexMatcher { /** - * @var string * @see https://regex101.com/r/Ok4wuE/1 */ - private const LAST_E_REGEX = '#(\w+)?e(\w+)?$#'; + private const string LAST_E_REGEX = '#(\w+)?e(\w+)?$#'; /** - * @var string * @see https://regex101.com/r/2NWVwT/1 */ - private const LETTER_SUFFIX_REGEX = '#(?\w+)$#'; + private const string LETTER_SUFFIX_REGEX = '#(?\w+)$#'; /** * @var string[] * @see https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php */ - private const ALL_MODIFIERS_VALUES = ['i', 'm', 's', 'x', 'e', 'A', 'D', 'S', 'U', 'X', 'J', 'u']; + private const array ALL_MODIFIERS_VALUES = ['i', 'm', 's', 'x', 'e', 'A', 'D', 'S', 'U', 'X', 'J', 'u']; public function resolvePatternExpressionWithoutEIfFound(Expr $expr): Concat|String_|null { diff --git a/rules/Php70/Enum/BattleshipCompareOrder.php b/rules/Php70/Enum/BattleshipCompareOrder.php index 6a7d92ac9f3..46e31cd8fc7 100644 --- a/rules/Php70/Enum/BattleshipCompareOrder.php +++ b/rules/Php70/Enum/BattleshipCompareOrder.php @@ -6,13 +6,7 @@ final class BattleshipCompareOrder { - /** - * @var string - */ - public const ASC = 'asc'; + public const string ASC = 'asc'; - /** - * @var string - */ - public const DESC = 'desc'; + public const string DESC = 'desc'; } diff --git a/rules/Php70/EregToPcreTransformer.php b/rules/Php70/EregToPcreTransformer.php index 4c1c68aadad..4a27bbedfa1 100644 --- a/rules/Php70/EregToPcreTransformer.php +++ b/rules/Php70/EregToPcreTransformer.php @@ -17,7 +17,7 @@ final class EregToPcreTransformer /** * @var array */ - private const CHARACTER_CLASS_MAP = [ + private const array CHARACTER_CLASS_MAP = [ ':alnum:' => '[:alnum:]', ':alpha:' => '[:alpha:]', ':blank:' => '[:blank:]', @@ -34,23 +34,16 @@ final class EregToPcreTransformer ]; /** - * @var string * @see https://regex101.com/r/htpXFg/1 */ - private const BOUND_REGEX = '/^(?<' . self::MINIMAL_NUMBER_PART . '>\d|[1-9]\d|1\d\d| + private const string BOUND_REGEX = '/^(?<' . self::MINIMAL_NUMBER_PART . '>\d|[1-9]\d|1\d\d| 2[0-4]\d|25[0-5]) (?,(?<' . self::MAXIMAL_NUMBER_PART . '>\d|[1-9]\d|1\d\d| 2[0-4]\d|25[0-5])?)?$/x'; - /** - * @var string - */ - private const MINIMAL_NUMBER_PART = 'minimal_number'; + private const string MINIMAL_NUMBER_PART = 'minimal_number'; - /** - * @var string - */ - private const MAXIMAL_NUMBER_PART = 'maximal_number'; + private const string MAXIMAL_NUMBER_PART = 'maximal_number'; /** * @var array diff --git a/rules/Php70/Rector/FuncCall/CallUserMethodRector.php b/rules/Php70/Rector/FuncCall/CallUserMethodRector.php index 3cd9809bb2c..606414df951 100644 --- a/rules/Php70/Rector/FuncCall/CallUserMethodRector.php +++ b/rules/Php70/Rector/FuncCall/CallUserMethodRector.php @@ -22,7 +22,7 @@ final class CallUserMethodRector extends AbstractRector implements MinPhpVersion /** * @var array */ - private const OLD_TO_NEW_FUNCTIONS = [ + private const array OLD_TO_NEW_FUNCTIONS = [ 'call_user_method' => 'call_user_func', 'call_user_method_array' => 'call_user_func_array', ]; diff --git a/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php b/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php index 9dd3a0d2853..e66507b4bf3 100644 --- a/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php +++ b/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php @@ -32,7 +32,7 @@ final class EregToPregMatchRector extends AbstractRector implements MinPhpVersio /** * @var array */ - private const OLD_NAMES_TO_NEW_ONES = [ + private const array OLD_NAMES_TO_NEW_ONES = [ 'ereg' => 'preg_match', 'eregi' => 'preg_match', 'ereg_replace' => 'preg_replace', diff --git a/rules/Php70/Rector/FuncCall/MultiDirnameRector.php b/rules/Php70/Rector/FuncCall/MultiDirnameRector.php index 49a2f37a9b1..c9e5705e676 100644 --- a/rules/Php70/Rector/FuncCall/MultiDirnameRector.php +++ b/rules/Php70/Rector/FuncCall/MultiDirnameRector.php @@ -19,10 +19,7 @@ */ final class MultiDirnameRector extends AbstractRector implements MinPhpVersionInterface { - /** - * @var string - */ - private const DIRNAME = 'dirname'; + private const string DIRNAME = 'dirname'; private int $nestingLevel = 0; diff --git a/rules/Php70/Rector/FuncCall/RandomFunctionRector.php b/rules/Php70/Rector/FuncCall/RandomFunctionRector.php index 6d6542a6899..4d7d5800153 100644 --- a/rules/Php70/Rector/FuncCall/RandomFunctionRector.php +++ b/rules/Php70/Rector/FuncCall/RandomFunctionRector.php @@ -24,7 +24,7 @@ final class RandomFunctionRector extends AbstractRector implements MinPhpVersion /** * @var array */ - private const OLD_TO_NEW_FUNCTION_NAMES = [ + private const array OLD_TO_NEW_FUNCTION_NAMES = [ 'getrandmax' => 'mt_getrandmax', 'srand' => 'mt_srand', 'rand' => 'random_int', diff --git a/rules/Php70/Rector/FunctionLike/ExceptionHandlerTypehintRector.php b/rules/Php70/Rector/FunctionLike/ExceptionHandlerTypehintRector.php index 95bce1deb6f..0e1aef8950d 100644 --- a/rules/Php70/Rector/FunctionLike/ExceptionHandlerTypehintRector.php +++ b/rules/Php70/Rector/FunctionLike/ExceptionHandlerTypehintRector.php @@ -22,10 +22,9 @@ final class ExceptionHandlerTypehintRector extends AbstractRector implements MinPhpVersionInterface { /** - * @var string * @see https://regex101.com/r/VBFXCR/1 */ - private const HANDLE_INSENSITIVE_REGEX = '#handle#i'; + private const string HANDLE_INSENSITIVE_REGEX = '#handle#i'; public function getRuleDefinition(): RuleDefinition { diff --git a/rules/Php72/NodeFactory/AnonymousFunctionFactory.php b/rules/Php72/NodeFactory/AnonymousFunctionFactory.php index 3b790afe09e..be6c9ba511b 100644 --- a/rules/Php72/NodeFactory/AnonymousFunctionFactory.php +++ b/rules/Php72/NodeFactory/AnonymousFunctionFactory.php @@ -33,10 +33,9 @@ final readonly class AnonymousFunctionFactory { /** - * @var string * @see https://regex101.com/r/jkLLlM/2 */ - private const DIM_FETCH_REGEX = '#(\\$|\\\\|\\x0)(?\d+)#'; + private const string DIM_FETCH_REGEX = '#(\\$|\\\\|\\x0)(?\d+)#'; public function __construct( private NodeNameResolver $nodeNameResolver, diff --git a/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php b/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php index 5078e8caebd..938d8633698 100644 --- a/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php +++ b/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php @@ -25,10 +25,7 @@ */ final class ReplaceEachAssignmentWithKeyCurrentRector extends AbstractRector implements MinPhpVersionInterface { - /** - * @var string - */ - private const KEY = 'key'; + private const string KEY = 'key'; public function provideMinPhpVersion(): int { diff --git a/rules/Php73/Rector/ConstFetch/SensitiveConstantNameRector.php b/rules/Php73/Rector/ConstFetch/SensitiveConstantNameRector.php index 57f661331c3..eb7f86a01aa 100644 --- a/rules/Php73/Rector/ConstFetch/SensitiveConstantNameRector.php +++ b/rules/Php73/Rector/ConstFetch/SensitiveConstantNameRector.php @@ -24,7 +24,7 @@ final class SensitiveConstantNameRector extends AbstractRector implements MinPhp * @see http://php.net/manual/en/reserved.constants.php * @var string[] */ - private const PHP_RESERVED_CONSTANTS = [ + private const array PHP_RESERVED_CONSTANTS = [ 'PHP_VERSION', 'PHP_MAJOR_VERSION', 'PHP_MINOR_VERSION', diff --git a/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php b/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php index eda752d8e91..efdda21a873 100644 --- a/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php +++ b/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php @@ -28,20 +28,14 @@ */ final class ArrayKeyFirstLastRector extends AbstractRector implements MinPhpVersionInterface, RelatedPolyfillInterface { - /** - * @var string - */ - private const ARRAY_KEY_FIRST = 'array_key_first'; + private const string ARRAY_KEY_FIRST = 'array_key_first'; - /** - * @var string - */ - private const ARRAY_KEY_LAST = 'array_key_last'; + private const string ARRAY_KEY_LAST = 'array_key_last'; /** * @var array */ - private const PREVIOUS_TO_NEW_FUNCTIONS = [ + private const array PREVIOUS_TO_NEW_FUNCTIONS = [ 'reset' => self::ARRAY_KEY_FIRST, 'end' => self::ARRAY_KEY_LAST, ]; diff --git a/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php b/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php index 0c12bebf731..f7b4b477664 100644 --- a/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php +++ b/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php @@ -21,24 +21,21 @@ final class RegexDashEscapeRector extends AbstractRector implements MinPhpVersionInterface { /** - * @var string * @see https://regex101.com/r/iQbGgZ/1 * * Use {2} as detected only 2 after $this->regexPatternArgumentManipulator->matchCallArgumentWithRegexPattern() call */ - private const THREE_BACKSLASH_FOR_ESCAPE_NEXT_REGEX = '#(?<=[^\\\\])\\\\{2}(?=[^\\\\])#'; + private const string THREE_BACKSLASH_FOR_ESCAPE_NEXT_REGEX = '#(?<=[^\\\\])\\\\{2}(?=[^\\\\])#'; /** - * @var string * @see https://regex101.com/r/YgVJFp/1 */ - private const LEFT_HAND_UNESCAPED_DASH_REGEX = '#(\[.*?\\\\(w|s|d))-(?!\])#i'; + private const string LEFT_HAND_UNESCAPED_DASH_REGEX = '#(\[.*?\\\\(w|s|d))-(?!\])#i'; /** - * @var string * @see https://regex101.com/r/TBVme9/9 */ - private const RIGHT_HAND_UNESCAPED_DASH_REGEX = '#(? */ - private const KNOWN_OPTIONS = [ + private const array KNOWN_OPTIONS = [ 2 => 'expires', 3 => 'path', 4 => 'domain', diff --git a/rules/Php73/Rector/FuncCall/StringifyStrNeedlesRector.php b/rules/Php73/Rector/FuncCall/StringifyStrNeedlesRector.php index ecffdd814e8..aa145b36db7 100644 --- a/rules/Php73/Rector/FuncCall/StringifyStrNeedlesRector.php +++ b/rules/Php73/Rector/FuncCall/StringifyStrNeedlesRector.php @@ -23,7 +23,7 @@ final class StringifyStrNeedlesRector extends AbstractRector implements MinPhpVe /** * @var string[] */ - private const NEEDLE_STRING_SENSITIVE_FUNCTIONS = [ + private const array NEEDLE_STRING_SENSITIVE_FUNCTIONS = [ 'strpos', 'strrpos', 'stripos', diff --git a/rules/Php73/Rector/String_/SensitiveHereNowDocRector.php b/rules/Php73/Rector/String_/SensitiveHereNowDocRector.php index ab30e1336ec..b5c59dd5814 100644 --- a/rules/Php73/Rector/String_/SensitiveHereNowDocRector.php +++ b/rules/Php73/Rector/String_/SensitiveHereNowDocRector.php @@ -18,10 +18,7 @@ */ final class SensitiveHereNowDocRector extends AbstractRector implements MinPhpVersionInterface { - /** - * @var string - */ - private const WRAP_SUFFIX = '_WRAP'; + private const string WRAP_SUFFIX = '_WRAP'; public function provideMinPhpVersion(): int { diff --git a/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php b/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php index 35838340981..48261170523 100644 --- a/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php +++ b/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php @@ -26,9 +26,8 @@ final class AddLiteralSeparatorToNumberRector extends AbstractRector implements { /** * @api - * @var string */ - public const LIMIT_VALUE = 'limit_value'; + public const string LIMIT_VALUE = 'limit_value'; /** * @param array $configuration diff --git a/rules/Php80/Enum/MatchKind.php b/rules/Php80/Enum/MatchKind.php index 97b5f12aab2..19a522b78f6 100644 --- a/rules/Php80/Enum/MatchKind.php +++ b/rules/Php80/Enum/MatchKind.php @@ -6,23 +6,11 @@ final class MatchKind { - /** - * @var string - */ - public const NORMAL = 'normal'; + public const string NORMAL = 'normal'; - /** - * @var string - */ - public const ASSIGN = 'assign'; + public const string ASSIGN = 'assign'; - /** - * @var string - */ - public const RETURN = 'return'; + public const string RETURN = 'return'; - /** - * @var string - */ - public const THROW = 'throw'; + public const string THROW = 'throw'; } diff --git a/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrncmpMatchAndRefactor.php b/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrncmpMatchAndRefactor.php index e428e184771..52ccdefc4af 100644 --- a/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrncmpMatchAndRefactor.php +++ b/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrncmpMatchAndRefactor.php @@ -21,10 +21,7 @@ final readonly class StrncmpMatchAndRefactor implements StrStartWithMatchAndRefactorInterface { - /** - * @var string - */ - private const FUNCTION_NAME = 'strncmp'; + private const string FUNCTION_NAME = 'strncmp'; public function __construct( private NodeNameResolver $nodeNameResolver, diff --git a/rules/Php80/Rector/Class_/AttributeValueResolver.php b/rules/Php80/Rector/Class_/AttributeValueResolver.php index 077d1b45e9b..7d9d46cc5ef 100644 --- a/rules/Php80/Rector/Class_/AttributeValueResolver.php +++ b/rules/Php80/Rector/Class_/AttributeValueResolver.php @@ -14,10 +14,9 @@ final class AttributeValueResolver { /** - * @var string * @see https://regex101.com/r/CL9ktz/4 */ - private const END_SLASH_REGEX = '#\\\\$#'; + private const string END_SLASH_REGEX = '#\\\\$#'; public function resolve( AnnotationToAttribute $annotationToAttribute, diff --git a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php index 8870f2cb4b2..bbea7ac7198 100644 --- a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php +++ b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php @@ -47,21 +47,18 @@ final class ClassPropertyAssignToConstructorPromotionRector extends AbstractRect { /** * @api - * @var string */ - public const INLINE_PUBLIC = 'inline_public'; + public const string INLINE_PUBLIC = 'inline_public'; /** * @api - * @var string */ - public const RENAME_PROPERTY = 'rename_property'; + public const string RENAME_PROPERTY = 'rename_property'; /** * @api - * @var string */ - public const ALLOW_MODEL_BASED_CLASSES = 'allow_model_based_classes'; + public const string ALLOW_MODEL_BASED_CLASSES = 'allow_model_based_classes'; /** * Default to false, which only apply changes: diff --git a/rules/Php80/Rector/Class_/StringableForToStringRector.php b/rules/Php80/Rector/Class_/StringableForToStringRector.php index 0835b228806..ea8c4618d19 100644 --- a/rules/Php80/Rector/Class_/StringableForToStringRector.php +++ b/rules/Php80/Rector/Class_/StringableForToStringRector.php @@ -32,10 +32,7 @@ */ final class StringableForToStringRector extends AbstractRector implements MinPhpVersionInterface { - /** - * @var string - */ - private const STRINGABLE = 'Stringable'; + private const string STRINGABLE = 'Stringable'; private bool $hasChanged = false; diff --git a/rules/Php80/Rector/NotIdentical/MbStrContainsRector.php b/rules/Php80/Rector/NotIdentical/MbStrContainsRector.php index ac0ba3cb985..31084285b5d 100644 --- a/rules/Php80/Rector/NotIdentical/MbStrContainsRector.php +++ b/rules/Php80/Rector/NotIdentical/MbStrContainsRector.php @@ -32,7 +32,7 @@ final class MbStrContainsRector extends AbstractRector implements MinPhpVersionI /** * @var string[] */ - private const OLD_STR_NAMES = ['mb_strpos', 'mb_strstr']; + private const array OLD_STR_NAMES = ['mb_strpos', 'mb_strstr']; public function __construct( private readonly StrFalseComparisonResolver $strFalseComparisonResolver diff --git a/rules/Php80/Rector/NotIdentical/StrContainsRector.php b/rules/Php80/Rector/NotIdentical/StrContainsRector.php index e226fb15d7e..11d2bb7b708 100644 --- a/rules/Php80/Rector/NotIdentical/StrContainsRector.php +++ b/rules/Php80/Rector/NotIdentical/StrContainsRector.php @@ -32,7 +32,7 @@ final class StrContainsRector extends AbstractRector implements MinPhpVersionInt /** * @var string[] */ - private const OLD_STR_NAMES = ['strpos', 'strstr']; + private const array OLD_STR_NAMES = ['strpos', 'strstr']; public function __construct( private readonly StrFalseComparisonResolver $strFalseComparisonResolver diff --git a/rules/Php81/Enum/AttributeName.php b/rules/Php81/Enum/AttributeName.php index b53e1972650..9d46ad7b7c6 100644 --- a/rules/Php81/Enum/AttributeName.php +++ b/rules/Php81/Enum/AttributeName.php @@ -9,12 +9,8 @@ final class AttributeName /** * Available since PHP 8.1 * @see https://php.watch/versions/8.1/ReturnTypeWillChange - * @var string */ - public const RETURN_TYPE_WILL_CHANGE = 'ReturnTypeWillChange'; + public const string RETURN_TYPE_WILL_CHANGE = 'ReturnTypeWillChange'; - /** - * @var string - */ - public const ALLOW_DYNAMIC_PROPERTIES = 'AllowDynamicProperties'; + public const string ALLOW_DYNAMIC_PROPERTIES = 'AllowDynamicProperties'; } diff --git a/rules/Php81/Enum/NameNullToStrictNullFunctionMap.php b/rules/Php81/Enum/NameNullToStrictNullFunctionMap.php index 72479e004a3..0a199d8c366 100644 --- a/rules/Php81/Enum/NameNullToStrictNullFunctionMap.php +++ b/rules/Php81/Enum/NameNullToStrictNullFunctionMap.php @@ -9,7 +9,7 @@ final class NameNullToStrictNullFunctionMap /** * @var array */ - public const FUNCTION_TO_PARAM_NAMES = [ + public const array FUNCTION_TO_PARAM_NAMES = [ 'preg_split' => ['subject'], 'preg_match' => ['subject'], 'preg_match_all' => ['subject'], diff --git a/rules/Php81/NodeFactory/EnumFactory.php b/rules/Php81/NodeFactory/EnumFactory.php index 85f104b0952..6a45a35d207 100644 --- a/rules/Php81/NodeFactory/EnumFactory.php +++ b/rules/Php81/NodeFactory/EnumFactory.php @@ -27,19 +27,17 @@ final readonly class EnumFactory { /** - * @var string * @see https://stackoverflow.com/a/2560017 * @see https://regex101.com/r/2xEQVj/1 for changing iso9001 to iso_9001 * @see https://regex101.com/r/Ykm6ub/1 for changing XMLParser to XML_Parser * @see https://regex101.com/r/Zv4JhD/1 for changing needsReview to needs_Review */ - private const PASCAL_CASE_TO_UNDERSCORE_REGEX = '/(?<=[A-Z])(?=[A-Z][a-z])|(?<=[^A-Z])(?=[A-Z])|(?<=[A-Za-z])(?=[^A-Za-z])/'; + private const string PASCAL_CASE_TO_UNDERSCORE_REGEX = '/(?<=[A-Z])(?=[A-Z][a-z])|(?<=[^A-Z])(?=[A-Z])|(?<=[A-Za-z])(?=[^A-Za-z])/'; /** - * @var string * @see https://regex101.com/r/FneU33/1 */ - private const MULTI_UNDERSCORES_REGEX = '#_{2,}#'; + private const string MULTI_UNDERSCORES_REGEX = '#_{2,}#'; public function __construct( private NodeNameResolver $nodeNameResolver, diff --git a/rules/Php81/Rector/Array_/FirstClassCallableRector.php b/rules/Php81/Rector/Array_/FirstClassCallableRector.php index acd663ad5e5..146d510fd32 100644 --- a/rules/Php81/Rector/Array_/FirstClassCallableRector.php +++ b/rules/Php81/Rector/Array_/FirstClassCallableRector.php @@ -4,6 +4,7 @@ namespace Rector\Php81\Rector\Array_; +use Override; use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\StaticCall; @@ -15,6 +16,7 @@ */ final class FirstClassCallableRector extends ArrayToFirstClassCallableRector implements DeprecatedInterface { + #[Override] public function refactor(Node $node): StaticCall|MethodCall|null { throw new ShouldNotHappenException(sprintf( diff --git a/rules/Php81/Rector/Class_/SpatieEnumClassToEnumRector.php b/rules/Php81/Rector/Class_/SpatieEnumClassToEnumRector.php index 921a628a9c1..2290c89f825 100644 --- a/rules/Php81/Rector/Class_/SpatieEnumClassToEnumRector.php +++ b/rules/Php81/Rector/Class_/SpatieEnumClassToEnumRector.php @@ -21,10 +21,7 @@ */ final class SpatieEnumClassToEnumRector extends AbstractRector implements MinPhpVersionInterface, ConfigurableRectorInterface { - /** - * @var string - */ - public const TO_UPPER_SNAKE_CASE = 'toUpperSnakeCase'; + public const string TO_UPPER_SNAKE_CASE = 'toUpperSnakeCase'; private bool $toUpperSnakeCase = false; diff --git a/rules/Php81/Rector/MethodCall/MyCLabsMethodCallToEnumConstRector.php b/rules/Php81/Rector/MethodCall/MyCLabsMethodCallToEnumConstRector.php index 40d7320af27..c09ab986c2f 100644 --- a/rules/Php81/Rector/MethodCall/MyCLabsMethodCallToEnumConstRector.php +++ b/rules/Php81/Rector/MethodCall/MyCLabsMethodCallToEnumConstRector.php @@ -29,7 +29,7 @@ final class MyCLabsMethodCallToEnumConstRector extends AbstractRector implements /** * @var string[] */ - private const ENUM_METHODS = ['from', 'values', 'keys', 'isValid', 'search', 'toArray', 'assertValidValue']; + private const array ENUM_METHODS = ['from', 'values', 'keys', 'isValid', 'search', 'toArray', 'assertValidValue']; public function __construct( private readonly ReflectionProvider $reflectionProvider, diff --git a/rules/Php81/Rector/MethodCall/SpatieEnumMethodCallToEnumConstRector.php b/rules/Php81/Rector/MethodCall/SpatieEnumMethodCallToEnumConstRector.php index 722f4da3628..852255272f4 100644 --- a/rules/Php81/Rector/MethodCall/SpatieEnumMethodCallToEnumConstRector.php +++ b/rules/Php81/Rector/MethodCall/SpatieEnumMethodCallToEnumConstRector.php @@ -21,15 +21,12 @@ */ final class SpatieEnumMethodCallToEnumConstRector extends AbstractRector implements MinPhpVersionInterface { - /** - * @var string - */ - private const SPATIE_FQN = 'Spatie\Enum\Enum'; + private const string SPATIE_FQN = 'Spatie\Enum\Enum'; /** * @var string[] */ - private const ENUM_METHODS = ['from', 'values', 'keys', 'isValid', 'search', 'toArray', 'assertValidValue']; + private const array ENUM_METHODS = ['from', 'values', 'keys', 'isValid', 'search', 'toArray', 'assertValidValue']; public function getRuleDefinition(): RuleDefinition { diff --git a/rules/Php81/Rector/New_/MyCLabsConstructorCallToEnumFromRector.php b/rules/Php81/Rector/New_/MyCLabsConstructorCallToEnumFromRector.php index 833a08b6410..21954686454 100644 --- a/rules/Php81/Rector/New_/MyCLabsConstructorCallToEnumFromRector.php +++ b/rules/Php81/Rector/New_/MyCLabsConstructorCallToEnumFromRector.php @@ -24,9 +24,9 @@ */ final class MyCLabsConstructorCallToEnumFromRector extends AbstractRector implements MinPhpVersionInterface { - private const MY_C_LABS_CLASS = 'MyCLabs\Enum\Enum'; + private const string MY_C_LABS_CLASS = 'MyCLabs\Enum\Enum'; - private const DEFAULT_ENUM_CONSTRUCTOR = 'from'; + private const string DEFAULT_ENUM_CONSTRUCTOR = 'from'; public function __construct( private readonly ReflectionProvider $reflectionProvider, diff --git a/rules/Php82/Rector/Param/AddSensitiveParameterAttributeRector.php b/rules/Php82/Rector/Param/AddSensitiveParameterAttributeRector.php index e3e0c681933..7578c57cc3a 100644 --- a/rules/Php82/Rector/Param/AddSensitiveParameterAttributeRector.php +++ b/rules/Php82/Rector/Param/AddSensitiveParameterAttributeRector.php @@ -23,7 +23,7 @@ */ final class AddSensitiveParameterAttributeRector extends AbstractRector implements ConfigurableRectorInterface, MinPhpVersionInterface { - public const SENSITIVE_PARAMETERS = 'sensitive_parameters'; + public const string SENSITIVE_PARAMETERS = 'sensitive_parameters'; /** * @var string[] diff --git a/rules/Php83/Rector/BooleanAnd/JsonValidateRector.php b/rules/Php83/Rector/BooleanAnd/JsonValidateRector.php index e8de9004d72..efecc86c5fa 100644 --- a/rules/Php83/Rector/BooleanAnd/JsonValidateRector.php +++ b/rules/Php83/Rector/BooleanAnd/JsonValidateRector.php @@ -28,7 +28,7 @@ */ final class JsonValidateRector extends AbstractRector implements MinPhpVersionInterface, RelatedPolyfillInterface { - private const JSON_MAX_DEPTH = 0x7FFFFFFF; + private const int JSON_MAX_DEPTH = 0x7FFFFFFF; public function __construct( private readonly BinaryOpManipulator $binaryOpManipulator, diff --git a/rules/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector.php b/rules/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector.php index 6855933ca0c..74775a64a75 100644 --- a/rules/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector.php +++ b/rules/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector.php @@ -39,14 +39,10 @@ final class AddOverrideAttributeToOverriddenMethodsRector extends AbstractRector { /** * @api - * @var string */ - public const ALLOW_OVERRIDE_EMPTY_METHOD = 'allow_override_empty_method'; + public const string ALLOW_OVERRIDE_EMPTY_METHOD = 'allow_override_empty_method'; - /** - * @var string - */ - private const OVERRIDE_CLASS = 'Override'; + private const string OVERRIDE_CLASS = 'Override'; private bool $allowOverrideEmptyMethod = false; diff --git a/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php b/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php index 0a9e21f563c..68b55641995 100644 --- a/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php +++ b/rules/Php85/Rector/ArrayDimFetch/ArrayFirstLastRector.php @@ -21,15 +21,9 @@ */ final class ArrayFirstLastRector extends AbstractRector implements MinPhpVersionInterface { - /** - * @var string - */ - private const ARRAY_KEY_FIRST = 'array_key_first'; + private const string ARRAY_KEY_FIRST = 'array_key_first'; - /** - * @var string - */ - private const ARRAY_KEY_LAST = 'array_key_last'; + private const string ARRAY_KEY_LAST = 'array_key_last'; public function getRuleDefinition(): RuleDefinition { diff --git a/rules/Privatization/Guard/LaravelModelGuard.php b/rules/Privatization/Guard/LaravelModelGuard.php index bd0ec7eef56..330c0722b79 100644 --- a/rules/Privatization/Guard/LaravelModelGuard.php +++ b/rules/Privatization/Guard/LaravelModelGuard.php @@ -20,16 +20,14 @@ final readonly class LaravelModelGuard { /** - * @var string * @see https://regex101.com/r/Dx0WN5/2 */ - private const LARAVEL_MODEL_ATTRIBUTE_REGEX = '#^[gs]et.+Attribute$#'; + private const string LARAVEL_MODEL_ATTRIBUTE_REGEX = '#^[gs]et.+Attribute$#'; /** - * @var string * @see https://regex101.com/r/hxOGeN/2 */ - private const LARAVEL_MODEL_SCOPE_REGEX = '#^scope.+$#'; + private const string LARAVEL_MODEL_SCOPE_REGEX = '#^scope.+$#'; public function __construct( private PhpAttributeAnalyzer $phpAttributeAnalyzer, diff --git a/rules/Privatization/Guard/ParentClassMagicCallGuard.php b/rules/Privatization/Guard/ParentClassMagicCallGuard.php index 083b11504e8..0245c0e6557 100644 --- a/rules/Privatization/Guard/ParentClassMagicCallGuard.php +++ b/rules/Privatization/Guard/ParentClassMagicCallGuard.php @@ -20,7 +20,7 @@ final class ParentClassMagicCallGuard * To speed up analysis * @var string[] */ - private const KNOWN_DYNAMIC_CALL_CLASSES = [Standard::class, PrettyPrinterAbstract::class]; + private const array KNOWN_DYNAMIC_CALL_CLASSES = [Standard::class, PrettyPrinterAbstract::class]; /** * @var array diff --git a/rules/Privatization/TypeManipulator/TypeNormalizer.php b/rules/Privatization/TypeManipulator/TypeNormalizer.php index 06a05f53294..11ce83a5cc5 100644 --- a/rules/Privatization/TypeManipulator/TypeNormalizer.php +++ b/rules/Privatization/TypeManipulator/TypeNormalizer.php @@ -31,10 +31,7 @@ final readonly class TypeNormalizer { - /** - * @var int - */ - private const MAX_PRINTED_UNION_DOC_LENGTH = 77; + private const int MAX_PRINTED_UNION_DOC_LENGTH = 77; public function __construct( private TypeFactory $typeFactory, diff --git a/rules/Transform/Enum/MagicPropertyHandler.php b/rules/Transform/Enum/MagicPropertyHandler.php index 06732be5d0e..031c848d065 100644 --- a/rules/Transform/Enum/MagicPropertyHandler.php +++ b/rules/Transform/Enum/MagicPropertyHandler.php @@ -6,11 +6,11 @@ final class MagicPropertyHandler { - public const GET = 'get'; + public const string GET = 'get'; - public const SET = 'set'; + public const string SET = 'set'; - public const ISSET_ = 'exists'; + public const string ISSET_ = 'exists'; - public const UNSET = 'unset'; + public const string UNSET = 'unset'; } diff --git a/rules/TypeDeclaration/Enum/NativeFuncCallPositions.php b/rules/TypeDeclaration/Enum/NativeFuncCallPositions.php index fe17bd9c1b4..1e21d1fb32d 100644 --- a/rules/TypeDeclaration/Enum/NativeFuncCallPositions.php +++ b/rules/TypeDeclaration/Enum/NativeFuncCallPositions.php @@ -9,7 +9,7 @@ final class NativeFuncCallPositions /** * @var array> */ - public const ARRAY_AND_CALLBACK_POSITIONS = [ + public const array ARRAY_AND_CALLBACK_POSITIONS = [ 'array_walk' => [ 'array' => 0, 'callback' => 1, diff --git a/rules/TypeDeclaration/NodeTypeAnalyzer/DetailedTypeAnalyzer.php b/rules/TypeDeclaration/NodeTypeAnalyzer/DetailedTypeAnalyzer.php index b90b93c3654..d44fa1ce1bc 100644 --- a/rules/TypeDeclaration/NodeTypeAnalyzer/DetailedTypeAnalyzer.php +++ b/rules/TypeDeclaration/NodeTypeAnalyzer/DetailedTypeAnalyzer.php @@ -13,9 +13,8 @@ final class DetailedTypeAnalyzer { /** * Use this constant to avoid overly detailed long-dragging union types across whole universe - * @var int */ - private const MAX_NUMBER_OF_TYPES = 3; + private const int MAX_NUMBER_OF_TYPES = 3; public function isTooDetailed(Type $type): bool { diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector.php index 9844bf4c371..c7c3fa92aaf 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector.php @@ -20,10 +20,7 @@ */ final class AddMethodCallBasedStrictParamTypeRector extends AbstractRector { - /** - * @var int - */ - private const MAX_UNION_TYPES = 3; + private const int MAX_UNION_TYPES = 3; public function __construct( private readonly CallTypesResolver $callTypesResolver, diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeBasedOnPHPUnitDataProviderRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeBasedOnPHPUnitDataProviderRector.php index 95d8d2534cf..6c0d198254b 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeBasedOnPHPUnitDataProviderRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeBasedOnPHPUnitDataProviderRector.php @@ -23,10 +23,7 @@ */ final class AddParamTypeBasedOnPHPUnitDataProviderRector extends AbstractRector { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Adds param type declaration based on PHPUnit provider return type declaration'; + private const string ERROR_MESSAGE = 'Adds param type declaration based on PHPUnit provider return type declaration'; public function __construct( private readonly TestsNodeAnalyzer $testsNodeAnalyzer, diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php index 82eecff300e..ae587099264 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php @@ -29,10 +29,7 @@ */ final class AddParamTypeFromPropertyTypeRector extends AbstractRector implements MinPhpVersionInterface { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Add param type declaration based on property type'; + private const string ERROR_MESSAGE = 'Add param type declaration based on property type'; public function __construct( private readonly PropertyFetchAnalyzer $propertyFetchAnalyzer, diff --git a/rules/TypeDeclaration/Rector/FunctionLike/AddParamTypeSplFixedArrayRector.php b/rules/TypeDeclaration/Rector/FunctionLike/AddParamTypeSplFixedArrayRector.php index 823533a1ec1..310c1e4bae3 100644 --- a/rules/TypeDeclaration/Rector/FunctionLike/AddParamTypeSplFixedArrayRector.php +++ b/rules/TypeDeclaration/Rector/FunctionLike/AddParamTypeSplFixedArrayRector.php @@ -26,7 +26,7 @@ final class AddParamTypeSplFixedArrayRector extends AbstractRector /** * @var array */ - private const SPL_FIXED_ARRAY_TO_SINGLE = [ + private const array SPL_FIXED_ARRAY_TO_SINGLE = [ 'PhpCsFixer\Tokenizer\Tokens' => 'PhpCsFixer\Tokenizer\Token', 'PhpCsFixer\Doctrine\Annotation\Tokens' => 'PhpCsFixer\Doctrine\Annotation\Token', ]; diff --git a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector.php b/rules/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector.php index 7d670e0c6a1..bbfe3fbf536 100644 --- a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector.php +++ b/rules/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector.php @@ -41,9 +41,8 @@ final class TypedPropertyFromAssignsRector extends AbstractRector implements Min { /** * @api - * @var string */ - public const INLINE_PUBLIC = 'inline_public'; + public const string INLINE_PUBLIC = 'inline_public'; /** * Default to false, which only apply changes: diff --git a/rules/TypeDeclaration/Rector/StmtsAwareInterface/IncreaseDeclareStrictTypesRector.php b/rules/TypeDeclaration/Rector/StmtsAwareInterface/IncreaseDeclareStrictTypesRector.php index 95fa9b18b95..ff5a37f5401 100644 --- a/rules/TypeDeclaration/Rector/StmtsAwareInterface/IncreaseDeclareStrictTypesRector.php +++ b/rules/TypeDeclaration/Rector/StmtsAwareInterface/IncreaseDeclareStrictTypesRector.php @@ -18,7 +18,7 @@ */ final class IncreaseDeclareStrictTypesRector extends AbstractRector implements ConfigurableRectorInterface, DeprecatedInterface { - public const LIMIT = 'limit'; + public const string LIMIT = 'limit'; public function getRuleDefinition(): RuleDefinition { diff --git a/rules/TypeDeclaration/ValueObject/DataProviderNodes.php b/rules/TypeDeclaration/ValueObject/DataProviderNodes.php index a3f59ea58d5..bb1ed23a9f1 100644 --- a/rules/TypeDeclaration/ValueObject/DataProviderNodes.php +++ b/rules/TypeDeclaration/ValueObject/DataProviderNodes.php @@ -17,9 +17,8 @@ { /** * @see https://regex101.com/r/hW09Vt/1 - * @var string */ - private const METHOD_NAME_REGEX = '#^(?\w+)(\(\))?#'; + private const string METHOD_NAME_REGEX = '#^(?\w+)(\(\))?#'; /** * @param Attribute[] $attributes diff --git a/rules/TypeDeclarationDocblocks/Enum/NetteClassName.php b/rules/TypeDeclarationDocblocks/Enum/NetteClassName.php index 93fe01c0101..3d64f4862b2 100644 --- a/rules/TypeDeclarationDocblocks/Enum/NetteClassName.php +++ b/rules/TypeDeclarationDocblocks/Enum/NetteClassName.php @@ -6,8 +6,5 @@ final class NetteClassName { - /** - * @var string - */ - public const JSON = 'Nette\Utils\Json'; + public const string JSON = 'Nette\Utils\Json'; } diff --git a/rules/TypeDeclarationDocblocks/Enum/TestClassName.php b/rules/TypeDeclarationDocblocks/Enum/TestClassName.php index 46d52440678..8229420985e 100644 --- a/rules/TypeDeclarationDocblocks/Enum/TestClassName.php +++ b/rules/TypeDeclarationDocblocks/Enum/TestClassName.php @@ -6,8 +6,5 @@ final class TestClassName { - /** - * @var string - */ - public const DATA_PROVIDER = 'PHPUnit\Framework\Attributes\DataProvider'; + public const string DATA_PROVIDER = 'PHPUnit\Framework\Attributes\DataProvider'; } diff --git a/rules/TypeDeclarationDocblocks/TypeResolver/ConstantArrayTypeGeneralizer.php b/rules/TypeDeclarationDocblocks/TypeResolver/ConstantArrayTypeGeneralizer.php index 00b5a938987..3ca83ab2218 100644 --- a/rules/TypeDeclarationDocblocks/TypeResolver/ConstantArrayTypeGeneralizer.php +++ b/rules/TypeDeclarationDocblocks/TypeResolver/ConstantArrayTypeGeneralizer.php @@ -22,7 +22,7 @@ final class ConstantArrayTypeGeneralizer * Using 10-level array @return docblocks makes code very hard to read, * lets limit it to reasonable level */ - private const MAX_NESTING = 3; + private const int MAX_NESTING = 3; private int $currentNesting = 0; diff --git a/scripts/no-php-file-in-fixtures.php b/scripts/no-php-file-in-fixtures.php index d356a310d4e..d363b557ff7 100644 --- a/scripts/no-php-file-in-fixtures.php +++ b/scripts/no-php-file-in-fixtures.php @@ -17,7 +17,7 @@ /** * @var string[] */ - private const EXCLUDED_FILES = [ + private const array EXCLUDED_FILES = [ // on-purpose as same namespace text 'rules-tests/Renaming/Rector/Name/RenameClassRector/FixtureAutoImportNames/SomeShort.php', ]; diff --git a/src/Application/ApplicationFileProcessor.php b/src/Application/ApplicationFileProcessor.php index d2caa1ae89e..932593d032f 100644 --- a/src/Application/ApplicationFileProcessor.php +++ b/src/Application/ApplicationFileProcessor.php @@ -31,10 +31,7 @@ final class ApplicationFileProcessor { - /** - * @var string - */ - private const ARGV = 'argv'; + private const string ARGV = 'argv'; /** * @var SystemError[] diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index d3daf3a63e9..dffbe0bb260 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,20 +19,15 @@ final class VersionResolver { /** * @api - * @var string */ - public const PACKAGE_VERSION = '@package_version@'; + public const string PACKAGE_VERSION = '@package_version@'; /** * @api - * @var string */ - public const RELEASE_DATE = '@release_date@'; + public const string RELEASE_DATE = '@release_date@'; - /** - * @var int - */ - private const SUCCESS_CODE = 0; + private const int SUCCESS_CODE = 0; public static function resolvePackageVersion(): string { diff --git a/src/BetterPhpDocParser/Attributes/AttributeMirrorer.php b/src/BetterPhpDocParser/Attributes/AttributeMirrorer.php index 0fd22287bde..60323cdb868 100644 --- a/src/BetterPhpDocParser/Attributes/AttributeMirrorer.php +++ b/src/BetterPhpDocParser/Attributes/AttributeMirrorer.php @@ -12,7 +12,7 @@ final class AttributeMirrorer /** * @var string[] */ - private const ATTRIBUTES_TO_MIRROR = [ + private const array ATTRIBUTES_TO_MIRROR = [ PhpDocAttributeKey::PARENT, PhpDocAttributeKey::START_AND_END, PhpDocAttributeKey::ORIG_NODE, diff --git a/src/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php b/src/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php index 70647241499..d7928efd494 100644 --- a/src/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php +++ b/src/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php @@ -4,6 +4,7 @@ namespace Rector\BetterPhpDocParser\PhpDoc; +use Override; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; use Stringable; @@ -13,6 +14,7 @@ */ final class SpacelessPhpDocTagNode extends PhpDocTagNode implements Stringable { + #[Override] public function __toString(): string { return $this->name . $this->value; diff --git a/src/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php b/src/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php index 6bf45874b6a..750845c3473 100644 --- a/src/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php +++ b/src/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php @@ -44,7 +44,7 @@ final class PhpDocInfo /** * @var array, string> */ - private const TAGS_TYPES_TO_NAMES = [ + private const array TAGS_TYPES_TO_NAMES = [ ReturnTagValueNode::class => '@return', ParamTagValueNode::class => '@param', VarTagValueNode::class => '@var', diff --git a/src/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php b/src/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php index f5ec4ac1410..f268cdeb472 100644 --- a/src/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php +++ b/src/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php @@ -37,7 +37,7 @@ /** * @var array> */ - private const ALLOWED_TYPES = [ + private const array ALLOWED_TYPES = [ GenericTypeNode::class, SpacingAwareArrayTypeNode::class, SpacingAwareCallableTypeNode::class, @@ -47,7 +47,7 @@ /** * @var string[] */ - private const ALLOWED_IDENTIFIER_TYPENODE_TYPES = ['class-string']; + private const array ALLOWED_IDENTIFIER_TYPENODE_TYPES = ['class-string']; public function __construct( private StaticTypeMapper $staticTypeMapper, diff --git a/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php b/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php index 9674baf0802..da65d242540 100644 --- a/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php +++ b/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php @@ -5,6 +5,7 @@ namespace Rector\BetterPhpDocParser\PhpDocParser; use Nette\Utils\Strings; +use Override; use PhpParser\Node; use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode; @@ -33,16 +34,14 @@ final class BetterPhpDocParser extends PhpDocParser { /** - * @var string * @see https://regex101.com/r/JDzr0c/1 */ - private const NEW_LINE_REGEX = "#(?\r\n|\n)#"; + private const string NEW_LINE_REGEX = "#(?\r\n|\n)#"; /** - * @var string * @see https://regex101.com/r/JOKSmr/5 */ - private const MULTI_NEW_LINES_REGEX = '#(?\r\n|\n){2,}#'; + private const string MULTI_NEW_LINES_REGEX = '#(?\r\n|\n){2,}#'; /** * @param PhpDocNodeDecoratorInterface[] $phpDocNodeDecorators @@ -92,6 +91,7 @@ public function parseWithNode(BetterTokenIterator $betterTokenIterator, Node $no return $phpDocNode; } + #[Override] public function parseTag(TokenIterator $tokenIterator): PhpDocTagNode { // replace generic nodes with DoctrineAnnotations @@ -108,6 +108,7 @@ public function parseTag(TokenIterator $tokenIterator): PhpDocTagNode /** * @param BetterTokenIterator $tokenIterator */ + #[Override] public function parseTagValue(TokenIterator $tokenIterator, string $tag): PhpDocTagValueNode { $isPrecededByHorizontalWhitespace = $tokenIterator->isPrecededByHorizontalWhitespace(); diff --git a/src/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php b/src/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php index 16cb445d954..505c86f9165 100644 --- a/src/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php +++ b/src/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php @@ -35,33 +35,29 @@ { /** * @see https://regex101.com/r/bGp2V0/2 - * @var string */ - public const LONG_ANNOTATION_REGEX = '#@\\\\(?.*?)(?\(.*?\)|,|\r?\n|$)#'; + public const string LONG_ANNOTATION_REGEX = '#@\\\\(?.*?)(?\(.*?\)|,|\r?\n|$)#'; /** * Special short annotations, that are resolved as FQN by Doctrine annotation parser * @var string[] */ - private const ALLOWED_SHORT_ANNOTATIONS = ['Target']; + private const array ALLOWED_SHORT_ANNOTATIONS = ['Target']; /** * @see https://regex101.com/r/xWaLOz/1 - * @var string */ - private const NESTED_ANNOTATION_END_REGEX = '#(\s+)?\}\)(\s+)?#'; + private const string NESTED_ANNOTATION_END_REGEX = '#(\s+)?\}\)(\s+)?#'; /** * @see https://regex101.com/r/8rWY4r/1 - * @var string */ - private const NEWLINE_ANNOTATION_FQCN_REGEX = '#\r?\n@\\\\#'; + private const string NEWLINE_ANNOTATION_FQCN_REGEX = '#\r?\n@\\\\#'; /** - * @var string * @see https://regex101.com/r/3zXEh7/1 */ - private const STAR_COMMENT_REGEX = '#^\s*\*#ms'; + private const string STAR_COMMENT_REGEX = '#^\s*\*#ms'; public function __construct( private ClassAnnotationMatcher $classAnnotationMatcher, diff --git a/src/BetterPhpDocParser/Printer/DocBlockInliner.php b/src/BetterPhpDocParser/Printer/DocBlockInliner.php index 8d19822d0ab..9d456690c56 100644 --- a/src/BetterPhpDocParser/Printer/DocBlockInliner.php +++ b/src/BetterPhpDocParser/Printer/DocBlockInliner.php @@ -9,16 +9,14 @@ final class DocBlockInliner { /** - * @var string * @see https://regex101.com/r/Mjb0qi/3 */ - private const NEWLINE_CLOSING_DOC_REGEX = "#(?:\r\n|\n) \*\/$#"; + private const string NEWLINE_CLOSING_DOC_REGEX = "#(?:\r\n|\n) \*\/$#"; /** - * @var string * @see https://regex101.com/r/U5OUV4/4 */ - private const NEWLINE_MIDDLE_DOC_REGEX = "#(?:\r\n|\n) \* #"; + private const string NEWLINE_MIDDLE_DOC_REGEX = "#(?:\r\n|\n) \* #"; public function inline(string $docContent): string { diff --git a/src/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php b/src/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php index be691ed4f28..3ad49312553 100644 --- a/src/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php +++ b/src/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php @@ -30,32 +30,29 @@ final class PhpDocInfoPrinter { /** - * @var string * @see https://regex101.com/r/Ab0Vey/1 */ - private const CLOSING_DOCBLOCK_REGEX = '#\*\/(\s+)?$#'; + private const string CLOSING_DOCBLOCK_REGEX = '#\*\/(\s+)?$#'; /** - * @var string * @see https://regex101.com/r/5fJyws/1 */ - private const CALLABLE_REGEX = '#callable(\s+)\(#'; + private const string CALLABLE_REGEX = '#callable(\s+)\(#'; /** * @var string[] */ - private const DOCBLOCK_STARTS = ['//', '/**', '/*', '#']; + private const array DOCBLOCK_STARTS = ['//', '/**', '/*', '#']; /** * @var string Uses a hardcoded unix-newline since most codes use it (even on windows) - otherwise we would need to normalize newlines */ - private const NEWLINE_WITH_ASTERISK = "\n" . ' *'; + private const string NEWLINE_WITH_ASTERISK = "\n" . ' *'; /** - * @var string * @see https://regex101.com/r/ME5Fcn/1 */ - private const NEW_LINE_WITH_SPACE_REGEX = "# (?\r\n|\n)#"; + private const string NEW_LINE_WITH_SPACE_REGEX = "# (?\r\n|\n)#"; private int $tokenCount = 0; diff --git a/src/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php b/src/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php index 7709e836626..364a122078b 100644 --- a/src/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php +++ b/src/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php @@ -9,7 +9,7 @@ final class SilentKeyMap /** * @var array */ - public const CLASS_NAMES_TO_SILENT_KEYS = [ + public const array CLASS_NAMES_TO_SILENT_KEYS = [ 'Symfony\Component\Routing\Annotation\Route' => 'path', ]; } diff --git a/src/BetterPhpDocParser/ValueObject/NodeTypes.php b/src/BetterPhpDocParser/ValueObject/NodeTypes.php index 262dcbd6655..be56587e82c 100644 --- a/src/BetterPhpDocParser/ValueObject/NodeTypes.php +++ b/src/BetterPhpDocParser/ValueObject/NodeTypes.php @@ -18,7 +18,7 @@ final class NodeTypes /** * @var array> */ - public const TYPE_AWARE_NODES = [ + public const array TYPE_AWARE_NODES = [ VarTagValueNode::class, ParamTagValueNode::class, ReturnTagValueNode::class, @@ -30,7 +30,7 @@ final class NodeTypes /** * @var string[] */ - public const TYPE_AWARE_DOCTRINE_ANNOTATION_CLASSES = [ + public const array TYPE_AWARE_DOCTRINE_ANNOTATION_CLASSES = [ ClassName::JMS_TYPE, 'Doctrine\ORM\Mapping\OneToMany', 'Symfony\Component\Validator\Constraints\Choice', diff --git a/src/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php b/src/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php index 92dd63ae7ac..d0fa17733b9 100644 --- a/src/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php +++ b/src/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php @@ -4,6 +4,7 @@ namespace Rector\BetterPhpDocParser\ValueObject\PhpDoc; +use Override; use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use Stringable; @@ -19,6 +20,7 @@ public function __construct( parent::__construct($name, $typeNode, $description); } + #[Override] public function __toString(): string { // @see https://github.com/rectorphp/rector/issues/3438 diff --git a/src/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php b/src/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php index 42aee9fe0e1..3311c8273a0 100644 --- a/src/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php +++ b/src/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php @@ -8,29 +8,16 @@ final class PhpDocAttributeKey { - /** - * @var string - */ - public const START_AND_END = 'start_and_end'; + public const string START_AND_END = 'start_and_end'; /** * Fully qualified name of identifier type class - * @var string */ - public const RESOLVED_CLASS = 'resolved_class'; + public const string RESOLVED_CLASS = 'resolved_class'; - /** - * @var string - */ - public const PARENT = NativePhpDocAttributeKey::PARENT; + public const string PARENT = NativePhpDocAttributeKey::PARENT; - /** - * @var string - */ - public const LAST_PHP_DOC_TOKEN_POSITION = 'last_token_position'; + public const string LAST_PHP_DOC_TOKEN_POSITION = 'last_token_position'; - /** - * @var string - */ - public const ORIG_NODE = NativePhpDocAttributeKey::ORIG_NODE; + public const string ORIG_NODE = NativePhpDocAttributeKey::ORIG_NODE; } diff --git a/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php b/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php index d1a0afae706..f0544b25f94 100644 --- a/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php +++ b/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php @@ -4,11 +4,13 @@ namespace Rector\BetterPhpDocParser\ValueObject\Type; +use Override; use PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode; use Stringable; final class BracketsAwareIntersectionTypeNode extends IntersectionTypeNode implements Stringable { + #[Override] public function __toString(): string { return implode('&', $this->types); diff --git a/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php b/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php index 6d8d8e617ae..e4bff800d1a 100644 --- a/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php +++ b/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php @@ -4,6 +4,7 @@ namespace Rector\BetterPhpDocParser\ValueObject\Type; +use Override; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode; use Stringable; @@ -23,6 +24,7 @@ public function __construct( /** * Preserve common format */ + #[Override] public function __toString(): string { $types = []; diff --git a/src/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php b/src/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php index 59c050c2099..ba15a85d3df 100644 --- a/src/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php +++ b/src/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php @@ -4,11 +4,13 @@ namespace Rector\BetterPhpDocParser\ValueObject\Type; +use Override; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use Stringable; final class FullyQualifiedIdentifierTypeNode extends IdentifierTypeNode implements Stringable { + #[Override] public function __toString(): string { return '\\' . ltrim($this->name, '\\'); diff --git a/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php b/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php index 4e33184ab26..1a7da5c9ef2 100644 --- a/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php +++ b/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php @@ -4,6 +4,7 @@ namespace Rector\BetterPhpDocParser\ValueObject\Type; +use Override; use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode; use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; @@ -14,6 +15,7 @@ final class SpacingAwareArrayTypeNode extends ArrayTypeNode implements Stringable { + #[Override] public function __toString(): string { if ($this->type instanceof CallableTypeNode) { diff --git a/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php b/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php index 3b7957d6413..7eb7ddf16ec 100644 --- a/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php +++ b/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php @@ -4,11 +4,13 @@ namespace Rector\BetterPhpDocParser\ValueObject\Type; +use Override; use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode; use Stringable; final class SpacingAwareCallableTypeNode extends CallableTypeNode implements Stringable { + #[Override] public function __toString(): string { // keep original (Psalm?) format, see https://github.com/rectorphp/rector/issues/2841 diff --git a/src/Caching/Enum/CacheKey.php b/src/Caching/Enum/CacheKey.php index 66512c05905..eaffc1c6c09 100644 --- a/src/Caching/Enum/CacheKey.php +++ b/src/Caching/Enum/CacheKey.php @@ -9,13 +9,7 @@ */ final class CacheKey { - /** - * @var string - */ - public const CONFIGURATION_HASH_KEY = 'configuration_hash'; + public const string CONFIGURATION_HASH_KEY = 'configuration_hash'; - /** - * @var string - */ - public const FILE_HASH_KEY = 'file_hash'; + public const string FILE_HASH_KEY = 'file_hash'; } diff --git a/src/ChangesReporting/Output/ConsoleOutputFormatter.php b/src/ChangesReporting/Output/ConsoleOutputFormatter.php index 4efe600dacf..44c4b351b67 100644 --- a/src/ChangesReporting/Output/ConsoleOutputFormatter.php +++ b/src/ChangesReporting/Output/ConsoleOutputFormatter.php @@ -17,16 +17,12 @@ final readonly class ConsoleOutputFormatter implements OutputFormatterInterface { - /** - * @var string - */ - public const NAME = 'console'; + public const string NAME = 'console'; /** - * @var string * @see https://regex101.com/r/q8I66g/1 */ - private const ON_LINE_REGEX = '# on line #'; + private const string ON_LINE_REGEX = '# on line #'; public function __construct( private SymfonyStyle $symfonyStyle, diff --git a/src/ChangesReporting/Output/GitHubOutputFormatter.php b/src/ChangesReporting/Output/GitHubOutputFormatter.php index 0c78cc11252..f0d3bb8359a 100644 --- a/src/ChangesReporting/Output/GitHubOutputFormatter.php +++ b/src/ChangesReporting/Output/GitHubOutputFormatter.php @@ -23,9 +23,9 @@ */ final readonly class GitHubOutputFormatter implements OutputFormatterInterface { - private const NAME = 'github'; + private const string NAME = 'github'; - private const GROUP_NAME = 'Rector report'; + private const string GROUP_NAME = 'Rector report'; public function getName(): string { diff --git a/src/ChangesReporting/Output/GitlabOutputFormatter.php b/src/ChangesReporting/Output/GitlabOutputFormatter.php index 7911570bd3b..b0e8530153b 100644 --- a/src/ChangesReporting/Output/GitlabOutputFormatter.php +++ b/src/ChangesReporting/Output/GitlabOutputFormatter.php @@ -17,17 +17,17 @@ final readonly class GitlabOutputFormatter implements OutputFormatterInterface { - private const NAME = 'gitlab'; + private const string NAME = 'gitlab'; - private const ERROR_TYPE_ISSUE = 'issue'; + private const string ERROR_TYPE_ISSUE = 'issue'; - private const ERROR_CATEGORY_BUG_RISK = 'Bug Risk'; + private const string ERROR_CATEGORY_BUG_RISK = 'Bug Risk'; - private const ERROR_CATEGORY_STYLE = 'Style'; + private const string ERROR_CATEGORY_STYLE = 'Style'; - private const ERROR_SEVERITY_BLOCKER = 'blocker'; + private const string ERROR_SEVERITY_BLOCKER = 'blocker'; - private const ERROR_SEVERITY_MINOR = 'minor'; + private const string ERROR_SEVERITY_MINOR = 'minor'; public function __construct( private Filehasher $filehasher, diff --git a/src/ChangesReporting/Output/JUnitOutputFormatter.php b/src/ChangesReporting/Output/JUnitOutputFormatter.php index 1b881c2a3bc..7ef6cd12477 100644 --- a/src/ChangesReporting/Output/JUnitOutputFormatter.php +++ b/src/ChangesReporting/Output/JUnitOutputFormatter.php @@ -18,21 +18,21 @@ final readonly class JUnitOutputFormatter implements OutputFormatterInterface { - private const NAME = 'junit'; + private const string NAME = 'junit'; - private const XML_ATTRIBUTE_FILE = 'file'; + private const string XML_ATTRIBUTE_FILE = 'file'; - private const XML_ATTRIBUTE_NAME = 'name'; + private const string XML_ATTRIBUTE_NAME = 'name'; - private const XML_ATTRIBUTE_TYPE = 'type'; + private const string XML_ATTRIBUTE_TYPE = 'type'; - private const XML_ELEMENT_TESTSUITES = 'testsuites'; + private const string XML_ELEMENT_TESTSUITES = 'testsuites'; - private const XML_ELEMENT_TESTSUITE = 'testsuite'; + private const string XML_ELEMENT_TESTSUITE = 'testsuite'; - private const XML_ELEMENT_TESTCASE = 'testcase'; + private const string XML_ELEMENT_TESTCASE = 'testcase'; - private const XML_ELEMENT_ERROR = 'error'; + private const string XML_ELEMENT_ERROR = 'error'; public function __construct( private SymfonyStyle $symfonyStyle, diff --git a/src/ChangesReporting/Output/JsonOutputFormatter.php b/src/ChangesReporting/Output/JsonOutputFormatter.php index 65062a4bb8e..521208a7ba2 100644 --- a/src/ChangesReporting/Output/JsonOutputFormatter.php +++ b/src/ChangesReporting/Output/JsonOutputFormatter.php @@ -13,10 +13,7 @@ final readonly class JsonOutputFormatter implements OutputFormatterInterface { - /** - * @var string - */ - public const NAME = 'json'; + public const string NAME = 'json'; public function getName(): string { diff --git a/src/ChangesReporting/ValueObject/RectorWithLineChange.php b/src/ChangesReporting/ValueObject/RectorWithLineChange.php index f5c0a71b6bf..6db365bd4ef 100644 --- a/src/ChangesReporting/ValueObject/RectorWithLineChange.php +++ b/src/ChangesReporting/ValueObject/RectorWithLineChange.php @@ -11,15 +11,9 @@ final readonly class RectorWithLineChange implements SerializableInterface { - /** - * @var string - */ - private const KEY_RECTOR_CLASS = 'rector_class'; + private const string KEY_RECTOR_CLASS = 'rector_class'; - /** - * @var string - */ - private const KEY_LINE = 'line'; + private const string KEY_LINE = 'line'; /** * @param class-string $rectorClass diff --git a/src/Config/Level/CodeQualityLevel.php b/src/Config/Level/CodeQualityLevel.php index b2aa1c8a9e6..d895def1c81 100644 --- a/src/Config/Level/CodeQualityLevel.php +++ b/src/Config/Level/CodeQualityLevel.php @@ -104,7 +104,7 @@ final class CodeQualityLevel * * @var array> */ - public const RULES = [ + public const array RULES = [ CombinedAssignRector::class, SimplifyEmptyArrayCheckRector::class, ReplaceMultipleBooleanNotRector::class, @@ -188,7 +188,7 @@ final class CodeQualityLevel /** * @var array, mixed[]> */ - public const RULES_WITH_CONFIGURATION = [ + public const array RULES_WITH_CONFIGURATION = [ RenameFunctionRector::class => [ 'split' => 'explode', 'join' => 'implode', diff --git a/src/Config/Level/CodingStyleLevel.php b/src/Config/Level/CodingStyleLevel.php index 6512edeaa36..718feff2505 100644 --- a/src/Config/Level/CodingStyleLevel.php +++ b/src/Config/Level/CodingStyleLevel.php @@ -53,7 +53,7 @@ final class CodingStyleLevel * * @var array> */ - public const RULES = [ + public const array RULES = [ SeparateMultiUseImportsRector::class, NewlineBetweenClassLikeStmtsRector::class, NewlineAfterStatementRector::class, @@ -86,7 +86,7 @@ final class CodingStyleLevel /** * @var array, mixed[]> */ - public const RULES_WITH_CONFIGURATION = [ + public const array RULES_WITH_CONFIGURATION = [ FuncCallToConstFetchRector::class => [ 'php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI', diff --git a/src/Config/Level/DeadCodeLevel.php b/src/Config/Level/DeadCodeLevel.php index e59264dae1a..2beee307b47 100644 --- a/src/Config/Level/DeadCodeLevel.php +++ b/src/Config/Level/DeadCodeLevel.php @@ -84,7 +84,7 @@ final class DeadCodeLevel * * @var array> */ - public const RULES = [ + public const array RULES = [ // easy picks RemoveUnusedForeachKeyRector::class, RemoveDuplicatedArrayKeyRector::class, diff --git a/src/Config/Level/TypeDeclarationDocblocksLevel.php b/src/Config/Level/TypeDeclarationDocblocksLevel.php index d95a2f3b0ff..42155b30aaf 100644 --- a/src/Config/Level/TypeDeclarationDocblocksLevel.php +++ b/src/Config/Level/TypeDeclarationDocblocksLevel.php @@ -30,7 +30,7 @@ final class TypeDeclarationDocblocksLevel /** * @var array> */ - public const RULES = [ + public const array RULES = [ // start with rules based on native code // property var DocblockVarArrayFromPropertyDefaultsRector::class, diff --git a/src/Config/Level/TypeDeclarationLevel.php b/src/Config/Level/TypeDeclarationLevel.php index 96fab757ee9..630af35b4a2 100644 --- a/src/Config/Level/TypeDeclarationLevel.php +++ b/src/Config/Level/TypeDeclarationLevel.php @@ -77,7 +77,7 @@ final class TypeDeclarationLevel * * @var array> */ - public const RULES = [ + public const array RULES = [ // php 7.1, start with closure first, as safest AddClosureVoidReturnTypeWhereNoReturnRector::class, AddFunctionVoidReturnTypeWhereNoReturnRector::class, diff --git a/src/Config/RectorConfig.php b/src/Config/RectorConfig.php index f74e0dd0dbe..39ea996da58 100644 --- a/src/Config/RectorConfig.php +++ b/src/Config/RectorConfig.php @@ -5,6 +5,7 @@ namespace Rector\Config; use Illuminate\Container\Container; +use Override; use Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; @@ -406,6 +407,7 @@ public function autotagInterface(string $interface): void /** * @param string $abstract */ + #[Override] public function singleton($abstract, mixed $concrete = null): void { parent::singleton($abstract, $concrete); diff --git a/src/Configuration/Option.php b/src/Configuration/Option.php index 30f2d3d794c..c815eeaa88e 100644 --- a/src/Configuration/Option.php +++ b/src/Configuration/Option.php @@ -9,135 +9,109 @@ final class Option { - /** - * @var string - */ - public const SOURCE = 'source'; + public const string SOURCE = 'source'; - /** - * @var string - */ - public const AUTOLOAD_FILE = 'autoload-file'; + public const string AUTOLOAD_FILE = 'autoload-file'; /** * @internal Use @see \Rector\Config\RectorConfig::bootstrapFiles() instead * @var string */ - public const BOOTSTRAP_FILES = 'bootstrap_files'; + public const string BOOTSTRAP_FILES = 'bootstrap_files'; - /** - * @var string - */ - public const DRY_RUN = 'dry-run'; + public const string DRY_RUN = 'dry-run'; - /** - * @var string - */ - public const DRY_RUN_SHORT = 'n'; + public const string DRY_RUN_SHORT = 'n'; - /** - * @var string - */ - public const OUTPUT_FORMAT = 'output-format'; + public const string OUTPUT_FORMAT = 'output-format'; - /** - * @var string - */ - public const NO_PROGRESS_BAR = 'no-progress-bar'; + public const string NO_PROGRESS_BAR = 'no-progress-bar'; /** * @internal Use @see \Rector\Config\RectorConfig::phpVersion() instead * @var string */ - public const PHP_VERSION_FEATURES = 'php_version_features'; + public const string PHP_VERSION_FEATURES = 'php_version_features'; /** * @internal Use @see \Rector\Config\RectorConfig::importNames() instead * @var string */ - public const AUTO_IMPORT_NAMES = 'auto_import_names'; + public const string AUTO_IMPORT_NAMES = 'auto_import_names'; /** * @internal Use @see \Rector\Config\RectorConfig::polyfillPackages() instead * @var string */ - public const POLYFILL_PACKAGES = 'polyfill_packages'; + public const string POLYFILL_PACKAGES = 'polyfill_packages'; /** * @internal Use @see \Rector\Config\RectorConfig::importNames() instead * @var string */ - public const AUTO_IMPORT_DOC_BLOCK_NAMES = 'auto_import_doc_block_names'; + public const string AUTO_IMPORT_DOC_BLOCK_NAMES = 'auto_import_doc_block_names'; /** * @internal Use @see \Rector\Config\RectorConfig::importShortClasses() instead * @var string */ - public const IMPORT_SHORT_CLASSES = 'import_short_classes'; + public const string IMPORT_SHORT_CLASSES = 'import_short_classes'; /** * @internal Use @see \Rector\Config\RectorConfig::symfonyContainerXml() instead * @var string */ - public const SYMFONY_CONTAINER_XML_PATH_PARAMETER = 'symfony_container_xml_path'; + public const string SYMFONY_CONTAINER_XML_PATH_PARAMETER = 'symfony_container_xml_path'; /** * @internal Use @see \Rector\Config\RectorConfig::symfonyContainerPhp() * @var string */ - public const SYMFONY_CONTAINER_PHP_PATH_PARAMETER = 'symfony_container_php_path'; + public const string SYMFONY_CONTAINER_PHP_PATH_PARAMETER = 'symfony_container_php_path'; /** * @internal Use @see \Rector\Config\RectorConfig::newLineOnFluentCall() * @var string */ - public const NEW_LINE_ON_FLUENT_CALL = 'new_line_on_fluent_call'; + public const string NEW_LINE_ON_FLUENT_CALL = 'new_line_on_fluent_call'; - /** - * @var string - */ - public const CLEAR_CACHE = 'clear-cache'; + public const string CLEAR_CACHE = 'clear-cache'; - /** - * @var string - */ - public const ONLY = 'only'; + public const string ONLY = 'only'; /** * @internal Use @see \Rector\Config\RectorConfig::parallel() instead * @var string */ - public const PARALLEL = 'parallel'; + public const string PARALLEL = 'parallel'; /** * @internal Use @see \Rector\Config\RectorConfig::paths() instead * @var string */ - public const PATHS = 'paths'; + public const string PATHS = 'paths'; /** * @internal Use @see \Rector\Config\RectorConfig::autoloadPaths() instead * @var string */ - public const AUTOLOAD_PATHS = 'autoload_paths'; + public const string AUTOLOAD_PATHS = 'autoload_paths'; /** * @internal Use @see \Rector\Config\RectorConfig::skip() instead * @var string */ - public const SKIP = 'skip'; + public const string SKIP = 'skip'; /** * @internal Use RectorConfig::fileExtensions() instead - * @var string */ - public const FILE_EXTENSIONS = 'file_extensions'; + public const string FILE_EXTENSIONS = 'file_extensions'; /** * @internal Use RectorConfig::cacheDirectory() instead - * @var string */ - public const CACHE_DIR = 'cache_dir'; + public const string CACHE_DIR = 'cache_dir'; /** * Cache backend. Most of the time we cache in files, but in ephemeral environment (e.g. CI), a faster `MemoryCacheStorage` can be useful. @@ -146,176 +120,144 @@ final class Option * @var class-string * @internal */ - public const CACHE_CLASS = FileCacheStorage::class; + public const string CACHE_CLASS = FileCacheStorage::class; - /** - * @var string - */ - public const DEBUG = 'debug'; + public const string DEBUG = 'debug'; - /** - * @var string - */ - public const XDEBUG = 'xdebug'; + public const string XDEBUG = 'xdebug'; - /** - * @var string - */ - public const CONFIG = 'config'; + public const string CONFIG = 'config'; /** * @internal Use @see \Rector\Config\RectorConfig::phpstanConfig() instead * @var string */ - public const PHPSTAN_FOR_RECTOR_PATHS = 'phpstan_for_rector_paths'; + public const string PHPSTAN_FOR_RECTOR_PATHS = 'phpstan_for_rector_paths'; - /** - * @var string - */ - public const NO_DIFFS = 'no-diffs'; + public const string NO_DIFFS = 'no-diffs'; - /** - * @var string - */ - public const AUTOLOAD_FILE_SHORT = 'a'; + public const string AUTOLOAD_FILE_SHORT = 'a'; - /** - * @var string - */ - public const PARALLEL_IDENTIFIER = 'identifier'; + public const string PARALLEL_IDENTIFIER = 'identifier'; - /** - * @var string - */ - public const PARALLEL_PORT = 'port'; + public const string PARALLEL_PORT = 'port'; /** * @internal Use @see \Rector\Config\RectorConfig::parallel() instead with pass int $jobSize parameter * @var string */ - public const PARALLEL_JOB_SIZE = 'parallel-job-size'; + public const string PARALLEL_JOB_SIZE = 'parallel-job-size'; /** * @internal Use @see \Rector\Config\RectorConfig::parallel() instead with pass int $maxNumberOfProcess parameter * @var string */ - public const PARALLEL_MAX_NUMBER_OF_PROCESSES = 'parallel-max-number-of-processes'; + public const string PARALLEL_MAX_NUMBER_OF_PROCESSES = 'parallel-max-number-of-processes'; /** * @internal Use @see \Rector\Config\RectorConfig::parallel() instead with pass int $seconds parameter * @var string */ - public const PARALLEL_JOB_TIMEOUT_IN_SECONDS = 'parallel-job-timeout-in-seconds'; + public const string PARALLEL_JOB_TIMEOUT_IN_SECONDS = 'parallel-job-timeout-in-seconds'; - /** - * @var string - */ - public const MEMORY_LIMIT = 'memory-limit'; + public const string MEMORY_LIMIT = 'memory-limit'; /** * @internal Use @see \Rector\Config\RectorConfig::indent() method * @var string */ - public const INDENT_CHAR = 'indent-char'; + public const string INDENT_CHAR = 'indent-char'; /** * @internal Use @see \Rector\Config\RectorConfig::indent() method * @var string */ - public const INDENT_SIZE = 'indent-size'; + public const string INDENT_SIZE = 'indent-size'; /** * @internal Use @see \Rector\Config\RectorConfig::removeUnusedImports() method * @var string */ - public const REMOVE_UNUSED_IMPORTS = 'remove-unused-imports'; + public const string REMOVE_UNUSED_IMPORTS = 'remove-unused-imports'; /** * @internal Use @see \Rector\Config\RectorConfig::containerCacheDirectory() method * @var string */ - public const CONTAINER_CACHE_DIRECTORY = 'container-cache-directory'; + public const string CONTAINER_CACHE_DIRECTORY = 'container-cache-directory'; /** * @internal For cache invalidation in case of change - * @var string */ - public const REGISTERED_RECTOR_RULES = 'registered_rector_rules'; + public const string REGISTERED_RECTOR_RULES = 'registered_rector_rules'; /** * @internal For cache invalidation in case of change - * @var string */ - public const REGISTERED_RECTOR_SETS = 'registered_rector_sets'; + public const string REGISTERED_RECTOR_SETS = 'registered_rector_sets'; /** * @internal For verify RectorConfigBuilder instance recreated - * @var string */ - public const IS_RECTORCONFIG_BUILDER_RECREATED = 'is_rectorconfig_builder_recreated'; + public const string IS_RECTORCONFIG_BUILDER_RECREATED = 'is_rectorconfig_builder_recreated'; /** * @internal For verify skipped rules exists in registered rules - * @var string */ - public const SKIPPED_RECTOR_RULES = 'skipped_rector_rules'; + public const string SKIPPED_RECTOR_RULES = 'skipped_rector_rules'; /** * @internal For collect skipped start with short open tag files to be reported - * @var string */ - public const SKIPPED_START_WITH_SHORT_OPEN_TAG_FILES = 'skipped_start_with_short_open_tag_files'; + public const string SKIPPED_START_WITH_SHORT_OPEN_TAG_FILES = 'skipped_start_with_short_open_tag_files'; /** * @internal For reporting with absolute paths instead of relative paths (default behaviour) * @see \Rector\Config\RectorConfig::reportingRealPath() - * @var string */ - public const ABSOLUTE_FILE_PATH = 'absolute_file_path'; + public const string ABSOLUTE_FILE_PATH = 'absolute_file_path'; /** * @internal To add editor links to console output * @see \Rector\Config\RectorConfig::editorUrl() - * @var string */ - public const EDITOR_URL = 'editor_url'; + public const string EDITOR_URL = 'editor_url'; /** * @internal Use @see \Rector\Config\RectorConfig::treatClassesAsFinal() method * @var string */ - public const TREAT_CLASSES_AS_FINAL = 'treat_classes_as_final'; + public const string TREAT_CLASSES_AS_FINAL = 'treat_classes_as_final'; /** * @internal To report composer based loaded sets * @see \Rector\Configuration\RectorConfigBuilder::withComposerBased() - * @var string */ - public const COMPOSER_BASED_SETS = 'composer_based_sets'; + public const string COMPOSER_BASED_SETS = 'composer_based_sets'; /** * @internal To filter files by specific suffix */ - public const ONLY_SUFFIX = 'only-suffix'; + public const string ONLY_SUFFIX = 'only-suffix'; /** * @internal To report overflow levels in ->with*Level() methods */ - public const LEVEL_OVERFLOWS = 'level_overflows'; + public const string LEVEL_OVERFLOWS = 'level_overflows'; /** * @internal To avoid registering rules via ->withRules(), that are already loaded in sets, * and keep rector.php clean */ - public const ROOT_STANDALONE_REGISTERED_RULES = 'root_standalone_registered_rules'; + public const string ROOT_STANDALONE_REGISTERED_RULES = 'root_standalone_registered_rules'; /** * @internal The other half of ROOT_STANDALONE_REGISTERED_RULES to compare */ - public const SET_REGISTERED_RULES = 'set_registered_rules'; + public const string SET_REGISTERED_RULES = 'set_registered_rules'; /** * @internal to allow process file without extension if explicitly registered */ - public const FILES_WITHOUT_EXTENSION = 'files_without_extension'; + public const string FILES_WITHOUT_EXTENSION = 'files_without_extension'; } diff --git a/src/Configuration/PhpLevelSetResolver.php b/src/Configuration/PhpLevelSetResolver.php index 27c55fed2a0..d79e92c1452 100644 --- a/src/Configuration/PhpLevelSetResolver.php +++ b/src/Configuration/PhpLevelSetResolver.php @@ -18,7 +18,7 @@ final class PhpLevelSetResolver /** * @var array */ - private const VERSION_LOWER_BOUND_CONFIGS = [ + private const array VERSION_LOWER_BOUND_CONFIGS = [ PhpVersion::PHP_52 => SetList::PHP_52, PhpVersion::PHP_53 => SetList::PHP_53, PhpVersion::PHP_54 => SetList::PHP_54, diff --git a/src/Configuration/RectorConfigBuilder.php b/src/Configuration/RectorConfigBuilder.php index a3eca69a08c..6a5474b1f9b 100644 --- a/src/Configuration/RectorConfigBuilder.php +++ b/src/Configuration/RectorConfigBuilder.php @@ -50,10 +50,7 @@ */ final class RectorConfigBuilder { - /** - * @var int - */ - private const MAX_LEVEL_GAP = 10; + private const int MAX_LEVEL_GAP = 10; /** * @var string[] diff --git a/src/Console/Command/WorkerCommand.php b/src/Console/Command/WorkerCommand.php index 4ed1aac0ee9..24e4cfae9ae 100644 --- a/src/Console/Command/WorkerCommand.php +++ b/src/Console/Command/WorkerCommand.php @@ -37,10 +37,7 @@ */ final class WorkerCommand extends Command { - /** - * @var string - */ - private const RESULT = 'result'; + private const string RESULT = 'result'; public function __construct( private readonly AdditionalAutoloader $additionalAutoloader, diff --git a/src/Console/ConsoleApplication.php b/src/Console/ConsoleApplication.php index c142cd3a69d..954c0645c12 100644 --- a/src/Console/ConsoleApplication.php +++ b/src/Console/ConsoleApplication.php @@ -5,6 +5,7 @@ namespace Rector\Console; use Composer\XdebugHandler\XdebugHandler; +use Override; use Rector\Application\VersionResolver; use Rector\ChangesReporting\Output\ConsoleOutputFormatter; use Rector\Configuration\Option; @@ -19,10 +20,7 @@ final class ConsoleApplication extends Application { - /** - * @var string - */ - private const NAME = 'Rector'; + private const string NAME = 'Rector'; /** * @param Command[] $commands @@ -40,6 +38,7 @@ public function __construct(array $commands) $this->setDefaultCommand('process'); } + #[Override] public function doRun(InputInterface $input, OutputInterface $output): int { $this->enableXdebug($input); @@ -79,6 +78,7 @@ public function doRun(InputInterface $input, OutputInterface $output): int return parent::doRun($input, $output); } + #[Override] protected function getDefaultInputDefinition(): InputDefinition { $defaultInputDefinition = parent::getDefaultInputDefinition(); diff --git a/src/Console/ExitCode.php b/src/Console/ExitCode.php index fa15e5afe69..046efbd7711 100644 --- a/src/Console/ExitCode.php +++ b/src/Console/ExitCode.php @@ -11,18 +11,9 @@ */ final class ExitCode { - /** - * @var int - */ - public const SUCCESS = Command::SUCCESS; + public const int SUCCESS = Command::SUCCESS; - /** - * @var int - */ - public const FAILURE = Command::FAILURE; + public const int FAILURE = Command::FAILURE; - /** - * @var int - */ - public const CHANGED_CODE = 2; + public const int CHANGED_CODE = 2; } diff --git a/src/Console/Formatter/ColorConsoleDiffFormatter.php b/src/Console/Formatter/ColorConsoleDiffFormatter.php index dfc6c7cb4ab..42635b2e8ac 100644 --- a/src/Console/Formatter/ColorConsoleDiffFormatter.php +++ b/src/Console/Formatter/ColorConsoleDiffFormatter.php @@ -17,28 +17,24 @@ final readonly class ColorConsoleDiffFormatter { /** - * @var string * @see https://regex101.com/r/ovLMDF/1 */ - private const PLUS_START_REGEX = '#^(\+.*)#'; + private const string PLUS_START_REGEX = '#^(\+.*)#'; /** - * @var string * @see https://regex101.com/r/xwywpa/1 */ - private const MINUS_START_REGEX = '#^(\-.*)#'; + private const string MINUS_START_REGEX = '#^(\-.*)#'; /** - * @var string * @see https://regex101.com/r/CMlwa8/1 */ - private const AT_START_REGEX = '#^(@.*)#'; + private const string AT_START_REGEX = '#^(@.*)#'; /** - * @var string * @see https://regex101.com/r/8MXnfa/2 */ - private const AT_DIFF_LINE_REGEX = '#^\@@ \-\d+,\d+ \+\d+,\d+ @@\<\/fg=cyan\>$#'; + private const string AT_DIFF_LINE_REGEX = '#^\@@ \-\d+,\d+ \+\d+,\d+ @@\<\/fg=cyan\>$#'; private string $template; diff --git a/src/Console/Style/RectorStyle.php b/src/Console/Style/RectorStyle.php index 0b8b5d7c4dc..e3a4db616b8 100644 --- a/src/Console/Style/RectorStyle.php +++ b/src/Console/Style/RectorStyle.php @@ -5,6 +5,7 @@ namespace Rector\Console\Style; use OndraM\CiDetector\CiDetector; +use Override; use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputInterface; @@ -30,6 +31,7 @@ public function __construct(InputInterface $input, OutputInterface $output) /** * @see https://github.com/phpstan/phpstan-src/commit/0993d180e5a15a17631d525909356081be59ffeb */ + #[Override] public function createProgressBar(int $max = 0): ProgressBar { $progressBar = parent::createProgressBar($max); @@ -56,6 +58,7 @@ public function createProgressBar(int $max = 0): ProgressBar return $progressBar; } + #[Override] public function progressAdvance(int $step = 1): void { // hide progress bar in tests diff --git a/src/CustomRules/SimpleNodeDumper.php b/src/CustomRules/SimpleNodeDumper.php index 28878ad11b9..1cbe1b9773c 100644 --- a/src/CustomRules/SimpleNodeDumper.php +++ b/src/CustomRules/SimpleNodeDumper.php @@ -23,7 +23,7 @@ final class SimpleNodeDumper /** * @var array */ - private const INCLUDE_TYPE_MAP = [ + private const array INCLUDE_TYPE_MAP = [ Include_::TYPE_INCLUDE => 'TYPE_INCLUDE', Include_::TYPE_INCLUDE_ONCE => 'TYPE_INCLUDE_ONCE', Include_::TYPE_REQUIRE => 'TYPE_REQUIRE', diff --git a/src/DependencyInjection/LazyContainerFactory.php b/src/DependencyInjection/LazyContainerFactory.php index f0c7fb6c643..0b771550e68 100644 --- a/src/DependencyInjection/LazyContainerFactory.php +++ b/src/DependencyInjection/LazyContainerFactory.php @@ -201,7 +201,7 @@ final class LazyContainerFactory /** * @var array> */ - private const NODE_NAME_RESOLVER_CLASSES = [ + private const array NODE_NAME_RESOLVER_CLASSES = [ ClassConstFetchNameResolver::class, ClassConstNameResolver::class, ClassNameResolver::class, @@ -217,7 +217,7 @@ final class LazyContainerFactory /** * @var array> */ - private const BASE_PHP_DOC_NODE_VISITORS = [ + private const array BASE_PHP_DOC_NODE_VISITORS = [ ArrayTypePhpDocNodeVisitor::class, CallableTypePhpDocNodeVisitor::class, IntersectionTypeNodePhpDocNodeVisitor::class, @@ -228,7 +228,7 @@ final class LazyContainerFactory /** * @var array> */ - private const ANNOTATION_TO_ATTRIBUTE_MAPPER_CLASSES = [ + private const array ANNOTATION_TO_ATTRIBUTE_MAPPER_CLASSES = [ ArrayAnnotationToAttributeMapper::class, ArrayItemNodeAnnotationToAttributeMapper::class, ClassConstFetchAnnotationToAttributeMapper::class, @@ -242,7 +242,7 @@ final class LazyContainerFactory /** * @var array> */ - private const DECORATING_NODE_VISITOR_CLASSES = [ + private const array DECORATING_NODE_VISITOR_CLASSES = [ ArgNodeVisitor::class, ClosureWithVariadicParametersNodeVisitor::class, PhpVersionConditionNodeVisitor::class, @@ -263,7 +263,7 @@ final class LazyContainerFactory /** * @var array> */ - private const PHPDOC_TYPE_MAPPER_CLASSES = [ + private const array PHPDOC_TYPE_MAPPER_CLASSES = [ IdentifierPhpDocTypeMapper::class, IntersectionPhpDocTypeMapper::class, NullablePhpDocTypeMapper::class, @@ -273,7 +273,7 @@ final class LazyContainerFactory /** * @var array> */ - private const CLASS_NAME_IMPORT_SKIPPER_CLASSES = [ + private const array CLASS_NAME_IMPORT_SKIPPER_CLASSES = [ AliasClassNameImportSkipVoter::class, ClassLikeNameClassNameImportSkipVoter::class, FullyQualifiedNameClassNameImportSkipVoter::class, @@ -286,7 +286,7 @@ final class LazyContainerFactory /** * @var array> */ - private const TYPE_MAPPER_CLASSES = [ + private const array TYPE_MAPPER_CLASSES = [ AccessoryLiteralStringTypeMapper::class, AccessoryNonEmptyStringTypeMapper::class, AccessoryNonFalsyStringTypeMapper::class, @@ -330,7 +330,7 @@ final class LazyContainerFactory /** * @var array> */ - private const PHP_DOC_NODE_DECORATOR_CLASSES = [ + private const array PHP_DOC_NODE_DECORATOR_CLASSES = [ ConstExprClassNameDecorator::class, DoctrineAnnotationDecorator::class, ArrayItemClassNameDecorator::class, @@ -340,7 +340,7 @@ final class LazyContainerFactory /** * @var array */ - private const PUBLIC_PHPSTAN_SERVICE_TYPES = [ + private const array PUBLIC_PHPSTAN_SERVICE_TYPES = [ ScopeFactory::class, TypeNodeResolver::class, NodeScopeResolver::class, @@ -350,7 +350,7 @@ final class LazyContainerFactory /** * @var array> */ - private const OUTPUT_FORMATTER_CLASSES = [ + private const array OUTPUT_FORMATTER_CLASSES = [ ConsoleOutputFormatter::class, JsonOutputFormatter::class, GitlabOutputFormatter::class, @@ -361,7 +361,7 @@ final class LazyContainerFactory /** * @var array> */ - private const NODE_TYPE_RESOLVER_CLASSES = [ + private const array NODE_TYPE_RESOLVER_CLASSES = [ CastTypeResolver::class, StaticCallMethodCallTypeResolver::class, ClassAndInterfaceTypeResolver::class, @@ -379,7 +379,7 @@ final class LazyContainerFactory /** * @var array> */ - private const PHP_PARSER_NODE_MAPPER_CLASSES = [ + private const array PHP_PARSER_NODE_MAPPER_CLASSES = [ FullyQualifiedNodeMapper::class, IdentifierNodeMapper::class, IntersectionTypeNodeMapper::class, @@ -393,7 +393,7 @@ final class LazyContainerFactory /** * @var array> */ - private const CONVERTER_ATTRIBUTE_DECORATOR_CLASSES = [ + private const array CONVERTER_ATTRIBUTE_DECORATOR_CLASSES = [ SensioParamConverterAttributeDecorator::class, DoctrineConverterAttributeDecorator::class, ]; diff --git a/src/Enum/ClassName.php b/src/Enum/ClassName.php index 08ba0930df2..f3a71087f6f 100644 --- a/src/Enum/ClassName.php +++ b/src/Enum/ClassName.php @@ -6,33 +6,15 @@ final class ClassName { - /** - * @var string - */ - public const TEST_CASE_CLASS = 'PHPUnit\Framework\TestCase'; - - /** - * @var string - */ - public const MOCK_OBJECT = 'PHPUnit\Framework\MockObject\MockObject'; - - /** - * @var string - */ - public const DATE_TIME_INTERFACE = 'DateTimeInterface'; - - /** - * @var string - */ - public const JMS_TYPE = 'JMS\Serializer\Annotation\Type'; - - /** - * @var string - */ - public const DOCTRINE_ENTITY = 'Doctrine\ORM\Mapping\Entity'; - - /** - * @var string - */ - public const DATA_PROVIDER = 'PHPUnit\Framework\Attributes\DataProvider'; + public const string TEST_CASE_CLASS = 'PHPUnit\Framework\TestCase'; + + public const string MOCK_OBJECT = 'PHPUnit\Framework\MockObject\MockObject'; + + public const string DATE_TIME_INTERFACE = 'DateTimeInterface'; + + public const string JMS_TYPE = 'JMS\Serializer\Annotation\Type'; + + public const string DOCTRINE_ENTITY = 'Doctrine\ORM\Mapping\Entity'; + + public const string DATA_PROVIDER = 'PHPUnit\Framework\Attributes\DataProvider'; } diff --git a/src/Enum/Config/Defaults.php b/src/Enum/Config/Defaults.php index f2f26009edc..4478d35b0b1 100644 --- a/src/Enum/Config/Defaults.php +++ b/src/Enum/Config/Defaults.php @@ -6,8 +6,5 @@ final class Defaults { - /** - * @var int - */ - public const PARALLEL_MAX_NUMBER_OF_PROCESS = 32; + public const int PARALLEL_MAX_NUMBER_OF_PROCESS = 32; } diff --git a/src/Enum/LaravelClassName.php b/src/Enum/LaravelClassName.php index 70eedaaac4a..5331fa49a2f 100644 --- a/src/Enum/LaravelClassName.php +++ b/src/Enum/LaravelClassName.php @@ -6,9 +6,9 @@ final class LaravelClassName { - public const MODEL = 'Illuminate\Database\Eloquent\Model'; + public const string MODEL = 'Illuminate\Database\Eloquent\Model'; - public const CAST_ATTRIBUTE = 'Illuminate\Database\Eloquent\Casts\Attribute'; + public const string CAST_ATTRIBUTE = 'Illuminate\Database\Eloquent\Casts\Attribute'; - public const ATTRIBUTES_SCOPE = 'Illuminate\Database\Eloquent\Attributes\Scope'; + public const string ATTRIBUTES_SCOPE = 'Illuminate\Database\Eloquent\Attributes\Scope'; } diff --git a/src/Enum/ObjectReference.php b/src/Enum/ObjectReference.php index 241e12a7584..a6b97b0c98d 100644 --- a/src/Enum/ObjectReference.php +++ b/src/Enum/ObjectReference.php @@ -6,18 +6,9 @@ final class ObjectReference { - /** - * @var string - */ - public const SELF = 'self'; + public const string SELF = 'self'; - /** - * @var string - */ - public const PARENT = 'parent'; + public const string PARENT = 'parent'; - /** - * @var string - */ - public const STATIC = 'static'; + public const string STATIC = 'static'; } diff --git a/src/FileSystem/FilePathHelper.php b/src/FileSystem/FilePathHelper.php index a2e9125254a..83d1d72e0d7 100644 --- a/src/FileSystem/FilePathHelper.php +++ b/src/FileSystem/FilePathHelper.php @@ -16,20 +16,15 @@ { /** * @see https://regex101.com/r/d4F5Fm/1 - * @var string */ - private const SCHEME_PATH_REGEX = '#^([a-z]+)\\:\\/\\/(.+)#'; + private const string SCHEME_PATH_REGEX = '#^([a-z]+)\\:\\/\\/(.+)#'; /** * @see https://regex101.com/r/no28vw/1 - * @var string */ - private const TWO_AND_MORE_SLASHES_REGEX = '#/{2,}#'; + private const string TWO_AND_MORE_SLASHES_REGEX = '#/{2,}#'; - /** - * @var string - */ - private const SCHEME_UNDEFINED = 'undefined'; + private const string SCHEME_UNDEFINED = 'undefined'; public function __construct( private Filesystem $filesystem, diff --git a/src/FileSystem/InitFilePathsResolver.php b/src/FileSystem/InitFilePathsResolver.php index 3fa9eedb4b4..69d51f4ce72 100644 --- a/src/FileSystem/InitFilePathsResolver.php +++ b/src/FileSystem/InitFilePathsResolver.php @@ -13,10 +13,9 @@ final class InitFilePathsResolver { /** - * @var string * @see https://regex101.com/r/XkQ6Pe/1 */ - private const DO_NOT_INCLUDE_PATHS_REGEX = '#(vendor|var|stubs|temp|templates|tmp|e2e|bin|build|Migrations|data(?:base)?|storage|migrations|writable|node_modules)#'; + private const string DO_NOT_INCLUDE_PATHS_REGEX = '#(vendor|var|stubs|temp|templates|tmp|e2e|bin|build|Migrations|data(?:base)?|storage|migrations|writable|node_modules)#'; /** * @return string[] diff --git a/src/Git/RepositoryHelper.php b/src/Git/RepositoryHelper.php index 1a9bac72c6c..207ee28ad59 100644 --- a/src/Git/RepositoryHelper.php +++ b/src/Git/RepositoryHelper.php @@ -10,10 +10,9 @@ final class RepositoryHelper { /** - * @var string * @see https://regex101.com/r/etcmog/2 */ - private const GITHUB_REPOSITORY_REGEX = '#github\.com[:\/](?.*?)\.git#'; + private const string GITHUB_REPOSITORY_REGEX = '#github\.com[:\/](?.*?)\.git#'; public static function resolveGithubRepositoryName(string $currentDirectory): ?string { diff --git a/src/NodeAnalyzer/CallAnalyzer.php b/src/NodeAnalyzer/CallAnalyzer.php index 4c0af017bf8..641f6fee790 100644 --- a/src/NodeAnalyzer/CallAnalyzer.php +++ b/src/NodeAnalyzer/CallAnalyzer.php @@ -22,7 +22,7 @@ /** * @var array> */ - private const OBJECT_CALL_TYPES = [MethodCall::class, NullsafeMethodCall::class, StaticCall::class]; + private const array OBJECT_CALL_TYPES = [MethodCall::class, NullsafeMethodCall::class, StaticCall::class]; public function __construct( private ReflectionProvider $reflectionProvider diff --git a/src/NodeAnalyzer/DoctrineEntityAnalyzer.php b/src/NodeAnalyzer/DoctrineEntityAnalyzer.php index a7c52013804..5f3c18cd402 100644 --- a/src/NodeAnalyzer/DoctrineEntityAnalyzer.php +++ b/src/NodeAnalyzer/DoctrineEntityAnalyzer.php @@ -18,7 +18,7 @@ /** * @var string[] */ - private const DOCTRINE_MAPPING_CLASSES = [ + private const array DOCTRINE_MAPPING_CLASSES = [ 'Doctrine\ORM\Mapping\Entity', 'Doctrine\ORM\Mapping\Embeddable', 'Doctrine\ODM\MongoDB\Mapping\Annotations\Document', diff --git a/src/NodeAnalyzer/ParamAnalyzer.php b/src/NodeAnalyzer/ParamAnalyzer.php index de6e28418f4..779a125fd85 100644 --- a/src/NodeAnalyzer/ParamAnalyzer.php +++ b/src/NodeAnalyzer/ParamAnalyzer.php @@ -29,7 +29,12 @@ /** * @var string[] */ - private const VARIADIC_FUNCTION_NAMES = ['func_get_arg', 'func_get_args', 'func_num_args', 'get_defined_vars']; + private const array VARIADIC_FUNCTION_NAMES = [ + 'func_get_arg', + 'func_get_args', + 'func_num_args', + 'get_defined_vars', + ]; public function __construct( private NodeComparator $nodeComparator, diff --git a/src/NodeAnalyzer/PropertyFetchAnalyzer.php b/src/NodeAnalyzer/PropertyFetchAnalyzer.php index 16049b10428..9c612d652ed 100644 --- a/src/NodeAnalyzer/PropertyFetchAnalyzer.php +++ b/src/NodeAnalyzer/PropertyFetchAnalyzer.php @@ -33,10 +33,7 @@ final readonly class PropertyFetchAnalyzer { - /** - * @var string - */ - private const THIS = 'this'; + private const string THIS = 'this'; public function __construct( private NodeNameResolver $nodeNameResolver, diff --git a/src/NodeAnalyzer/ScopeAnalyzer.php b/src/NodeAnalyzer/ScopeAnalyzer.php index c039f5efa78..8bc7252f827 100644 --- a/src/NodeAnalyzer/ScopeAnalyzer.php +++ b/src/NodeAnalyzer/ScopeAnalyzer.php @@ -14,7 +14,7 @@ final class ScopeAnalyzer /** * @var array> */ - private const NON_REFRESHABLE_NODES = [Name::class, Identifier::class, ComplexType::class]; + private const array NON_REFRESHABLE_NODES = [Name::class, Identifier::class, ComplexType::class]; public function isRefreshable(Node $node): bool { diff --git a/src/NodeAnalyzer/TerminatedNodeAnalyzer.php b/src/NodeAnalyzer/TerminatedNodeAnalyzer.php index a37f829f3c1..444df395921 100644 --- a/src/NodeAnalyzer/TerminatedNodeAnalyzer.php +++ b/src/NodeAnalyzer/TerminatedNodeAnalyzer.php @@ -32,17 +32,17 @@ final class TerminatedNodeAnalyzer /** * @var array> */ - private const TERMINABLE_NODES = [Return_::class, Break_::class, Continue_::class]; + private const array TERMINABLE_NODES = [Return_::class, Break_::class, Continue_::class]; /** * @var array> */ - private const TERMINABLE_NODES_BY_ITS_STMTS = [TryCatch::class, If_::class, Switch_::class]; + private const array TERMINABLE_NODES_BY_ITS_STMTS = [TryCatch::class, If_::class, Switch_::class]; /** * @var array> */ - private const ALLOWED_CONTINUE_CURRENT_STMTS = [InlineHTML::class, Nop::class]; + private const array ALLOWED_CONTINUE_CURRENT_STMTS = [InlineHTML::class, Nop::class]; /** * @param StmtsAware $stmtsAware diff --git a/src/NodeManipulator/PropertyManipulator.php b/src/NodeManipulator/PropertyManipulator.php index defc0fa3209..0e2819a8356 100644 --- a/src/NodeManipulator/PropertyManipulator.php +++ b/src/NodeManipulator/PropertyManipulator.php @@ -41,7 +41,7 @@ /** * @var string[]|class-string[] */ - private const ALLOWED_NOT_READONLY_CLASS_ANNOTATIONS = [ + private const array ALLOWED_NOT_READONLY_CLASS_ANNOTATIONS = [ 'ApiPlatform\Core\Annotation\ApiResource', 'ApiPlatform\Metadata\ApiResource', 'Doctrine\ORM\Mapping\Entity', diff --git a/src/NodeNameResolver/NodeNameResolver.php b/src/NodeNameResolver/NodeNameResolver.php index 586ef978533..51d8c62ba52 100644 --- a/src/NodeNameResolver/NodeNameResolver.php +++ b/src/NodeNameResolver/NodeNameResolver.php @@ -34,7 +34,7 @@ final class NodeNameResolver /** * Used to check if a string might contain a regex or fnmatch pattern */ - private const REGEX_WILDCARD_CHARS = ['*', '#', '~', '/']; + private const array REGEX_WILDCARD_CHARS = ['*', '#', '~', '/']; /** * @var array diff --git a/src/NodeNameResolver/Regex/RegexPatternDetector.php b/src/NodeNameResolver/Regex/RegexPatternDetector.php index 075354ef858..4a9e87dd5a8 100644 --- a/src/NodeNameResolver/Regex/RegexPatternDetector.php +++ b/src/NodeNameResolver/Regex/RegexPatternDetector.php @@ -11,12 +11,12 @@ final class RegexPatternDetector * * This prevents miss matching like "aMethoda" */ - private const POSSIBLE_DELIMITERS = ['#', '~', '/']; + private const array POSSIBLE_DELIMITERS = ['#', '~', '/']; /** * @var array */ - private const START_AND_END_DELIMITERS = [ + private const array START_AND_END_DELIMITERS = [ '(' => ')', '{' => '}', '[' => ']', diff --git a/src/NodeNestingScope/ValueObject/ControlStructure.php b/src/NodeNestingScope/ValueObject/ControlStructure.php index 58a70621263..187a5103fd6 100644 --- a/src/NodeNestingScope/ValueObject/ControlStructure.php +++ b/src/NodeNestingScope/ValueObject/ControlStructure.php @@ -22,7 +22,7 @@ final class ControlStructure * These situations happens only if condition is met * @var array> */ - public const CONDITIONAL_NODE_SCOPE_TYPES = [ + public const array CONDITIONAL_NODE_SCOPE_TYPES = [ If_::class, While_::class, Do_::class, diff --git a/src/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php b/src/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php index 253bf742701..79396c755e6 100644 --- a/src/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php +++ b/src/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php @@ -29,10 +29,7 @@ */ final readonly class PHPStanServicesFactory { - /** - * @var string - */ - private const INVALID_BLEEDING_EDGE_PATH_MESSAGE = <<, NodeTypeResolverInterface> diff --git a/src/NodeTypeResolver/NodeTypeResolver/CastTypeResolver.php b/src/NodeTypeResolver/NodeTypeResolver/CastTypeResolver.php index d66eeaca621..aa0fbb2812c 100644 --- a/src/NodeTypeResolver/NodeTypeResolver/CastTypeResolver.php +++ b/src/NodeTypeResolver/NodeTypeResolver/CastTypeResolver.php @@ -31,7 +31,7 @@ final class CastTypeResolver implements NodeTypeResolverInterface /** * @var array, class-string> */ - private const CAST_CLASS_TO_TYPE_MAP = [ + private const array CAST_CLASS_TO_TYPE_MAP = [ Bool_::class => BooleanType::class, String_::class => StringType::class, Int_::class => IntegerType::class, diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 67bf6a55b93..0a36d5f8607 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -116,10 +116,7 @@ */ final readonly class PHPStanNodeScopeResolver { - /** - * @var string - */ - private const CONTEXT = 'context'; + private const string CONTEXT = 'context'; private NodeTraverser $nodeTraverser; diff --git a/src/PHPStanStaticTypeMapper/Enum/TypeKind.php b/src/PHPStanStaticTypeMapper/Enum/TypeKind.php index d821c8ac18e..49d6de14834 100644 --- a/src/PHPStanStaticTypeMapper/Enum/TypeKind.php +++ b/src/PHPStanStaticTypeMapper/Enum/TypeKind.php @@ -6,23 +6,11 @@ final class TypeKind { - /** - * @var string - */ - public const PROPERTY = 'property'; + public const string PROPERTY = 'property'; - /** - * @var string - */ - public const RETURN = 'return'; + public const string RETURN = 'return'; - /** - * @var string - */ - public const PARAM = 'param'; + public const string PARAM = 'param'; - /** - * @var string - */ - public const UNION = 'union'; + public const string UNION = 'union'; } diff --git a/src/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php b/src/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php index 4b1d91f49a3..43e6b4931b2 100644 --- a/src/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php +++ b/src/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php @@ -32,10 +32,7 @@ */ final class ArrayTypeMapper implements TypeMapperInterface { - /** - * @var string - */ - public const HAS_GENERIC_TYPE_PARENT = 'has_generic_type_parent'; + public const string HAS_GENERIC_TYPE_PARENT = 'has_generic_type_parent'; private PHPStanStaticTypeMapper $phpStanStaticTypeMapper; diff --git a/src/PHPStanStaticTypeMapper/TypeMapper/StrictMixedTypeMapper.php b/src/PHPStanStaticTypeMapper/TypeMapper/StrictMixedTypeMapper.php index e20a68e4ab7..71fc70c5bd5 100644 --- a/src/PHPStanStaticTypeMapper/TypeMapper/StrictMixedTypeMapper.php +++ b/src/PHPStanStaticTypeMapper/TypeMapper/StrictMixedTypeMapper.php @@ -19,10 +19,7 @@ */ final readonly class StrictMixedTypeMapper implements TypeMapperInterface { - /** - * @var string - */ - private const MIXED = 'mixed'; + private const string MIXED = 'mixed'; public function __construct( private PhpVersionProvider $phpVersionProvider diff --git a/src/PHPStanStaticTypeMapper/TypeMapper/VoidTypeMapper.php b/src/PHPStanStaticTypeMapper/TypeMapper/VoidTypeMapper.php index 76080551dd6..649d40025b2 100644 --- a/src/PHPStanStaticTypeMapper/TypeMapper/VoidTypeMapper.php +++ b/src/PHPStanStaticTypeMapper/TypeMapper/VoidTypeMapper.php @@ -19,10 +19,7 @@ */ final readonly class VoidTypeMapper implements TypeMapperInterface { - /** - * @var string - */ - private const VOID = 'void'; + private const string VOID = 'void'; public function __construct( private PhpVersionProvider $phpVersionProvider diff --git a/src/Parallel/Application/ParallelFileProcessor.php b/src/Parallel/Application/ParallelFileProcessor.php index 406f663dc04..a1c8d3e0696 100644 --- a/src/Parallel/Application/ParallelFileProcessor.php +++ b/src/Parallel/Application/ParallelFileProcessor.php @@ -37,18 +37,13 @@ */ final class ParallelFileProcessor { - /** - * @var int - */ - private const SYSTEM_ERROR_LIMIT = 50; + private const int SYSTEM_ERROR_LIMIT = 50; /** * The number of chunks a worker can process before getting killed. * In contrast the jobSize defines the maximum size of a chunk, a worker process at a time. - * - * @var int */ - private const MAX_CHUNKS_PER_WORKER = 8; + private const int MAX_CHUNKS_PER_WORKER = 8; private ProcessPool|null $processPool = null; diff --git a/src/Parallel/Command/WorkerCommandLineFactory.php b/src/Parallel/Command/WorkerCommandLineFactory.php index 72b2e484441..eb3ae448531 100644 --- a/src/Parallel/Command/WorkerCommandLineFactory.php +++ b/src/Parallel/Command/WorkerCommandLineFactory.php @@ -18,10 +18,7 @@ */ final readonly class WorkerCommandLineFactory { - /** - * @var string - */ - private const OPTION_DASHES = '--'; + private const string OPTION_DASHES = '--'; public function __construct( private CommandFromReflectionFactory $commandFromReflectionFactory, diff --git a/src/Parallel/ValueObject/Bridge.php b/src/Parallel/ValueObject/Bridge.php index b35cd93af83..0d581733025 100644 --- a/src/Parallel/ValueObject/Bridge.php +++ b/src/Parallel/ValueObject/Bridge.php @@ -9,33 +9,15 @@ */ final class Bridge { - /** - * @var string - */ - public const FILE_DIFFS = 'file_diffs'; - - /** - * @var string - */ - public const SYSTEM_ERRORS = 'system_errors'; - - /** - * @var string - */ - public const SYSTEM_ERRORS_COUNT = 'system_errors_count'; - - /** - * @var string - */ - public const FILES = 'files'; - - /** - * @var string - */ - public const FILES_COUNT = 'files_count'; - - /** - * @var string - */ - public const TOTAL_CHANGED = 'total_changed'; + public const string FILE_DIFFS = 'file_diffs'; + + public const string SYSTEM_ERRORS = 'system_errors'; + + public const string SYSTEM_ERRORS_COUNT = 'system_errors_count'; + + public const string FILES = 'files'; + + public const string FILES_COUNT = 'files_count'; + + public const string TOTAL_CHANGED = 'total_changed'; } diff --git a/src/Parallel/ValueObject/BridgeItem.php b/src/Parallel/ValueObject/BridgeItem.php index ae00491248e..e743242e190 100644 --- a/src/Parallel/ValueObject/BridgeItem.php +++ b/src/Parallel/ValueObject/BridgeItem.php @@ -10,48 +10,21 @@ */ final class BridgeItem { - /** - * @var string - */ - public const LINE = 'line'; - - /** - * @var string - */ - public const MESSAGE = 'message'; - - /** - * @var string - */ - public const RELATIVE_FILE_PATH = 'relative_file_path'; - - /** - * @var string - */ - public const ABSOLUTE_FILE_PATH = 'absolute_file_path'; - - /** - * @var string - */ - public const DIFF = 'diff'; - - /** - * @var string - */ - public const DIFF_CONSOLE_FORMATTED = 'diff_console_formatted'; - - /** - * @var string - */ - public const APPLIED_RECTORS = 'applied_rectors'; - - /** - * @var string - */ - public const RECTOR_CLASS = 'rector_class'; - - /** - * @var string - */ - public const RECTORS_WITH_LINE_CHANGES = 'rectors_with_line_changes'; + public const string LINE = 'line'; + + public const string MESSAGE = 'message'; + + public const string RELATIVE_FILE_PATH = 'relative_file_path'; + + public const string ABSOLUTE_FILE_PATH = 'absolute_file_path'; + + public const string DIFF = 'diff'; + + public const string DIFF_CONSOLE_FORMATTED = 'diff_console_formatted'; + + public const string APPLIED_RECTORS = 'applied_rectors'; + + public const string RECTOR_CLASS = 'rector_class'; + + public const string RECTORS_WITH_LINE_CHANGES = 'rectors_with_line_changes'; } diff --git a/src/Php/PhpVersionProvider.php b/src/Php/PhpVersionProvider.php index fd82ffaad6d..674c236bd83 100644 --- a/src/Php/PhpVersionProvider.php +++ b/src/Php/PhpVersionProvider.php @@ -19,10 +19,9 @@ final class PhpVersionProvider { /** - * @var string * @see https://regex101.com/r/qBMnbl/1 */ - private const VALID_PHP_VERSION_REGEX = '#^\d{5,6}$#'; + private const string VALID_PHP_VERSION_REGEX = '#^\d{5,6}$#'; private int|null $phpVersionFeatures = null; diff --git a/src/PhpAttribute/AttributeArrayNameInliner.php b/src/PhpAttribute/AttributeArrayNameInliner.php index e98f0ca736d..6ee6a72b284 100644 --- a/src/PhpAttribute/AttributeArrayNameInliner.php +++ b/src/PhpAttribute/AttributeArrayNameInliner.php @@ -18,7 +18,7 @@ final class AttributeArrayNameInliner /** * @var class-string */ - private const OPEN_API_PROPERTY_ATTRIBUTE = 'OpenApi\Attributes\Property'; + private const string OPEN_API_PROPERTY_ATTRIBUTE = 'OpenApi\Attributes\Property'; /** * @param Array_|list $array diff --git a/src/PhpAttribute/DeprecatedAnnotationToDeprecatedAttributeConverter.php b/src/PhpAttribute/DeprecatedAnnotationToDeprecatedAttributeConverter.php index 154fce0da30..7fbf2b22448 100644 --- a/src/PhpAttribute/DeprecatedAnnotationToDeprecatedAttributeConverter.php +++ b/src/PhpAttribute/DeprecatedAnnotationToDeprecatedAttributeConverter.php @@ -30,15 +30,13 @@ { /** * @see https://regex101.com/r/qNytVk/1 - * @var string */ - private const VERSION_MATCH_REGEX = '/^(?:(\d+\.\d+\.\d+)\s+)?(.*)$/'; + private const string VERSION_MATCH_REGEX = '/^(?:(\d+\.\d+\.\d+)\s+)?(.*)$/'; /** * @see https://regex101.com/r/SVDPOB/1 - * @var string */ - private const START_STAR_SPACED_REGEX = '#^ *\*#ms'; + private const string START_STAR_SPACED_REGEX = '#^ *\*#ms'; public function __construct( private PhpDocTagRemover $phpDocTagRemover, diff --git a/src/PhpAttribute/Enum/DocTagNodeState.php b/src/PhpAttribute/Enum/DocTagNodeState.php index 6afd10a3784..26fae37fcd0 100644 --- a/src/PhpAttribute/Enum/DocTagNodeState.php +++ b/src/PhpAttribute/Enum/DocTagNodeState.php @@ -6,8 +6,5 @@ final class DocTagNodeState { - /** - * @var string - */ - public const REMOVE_ARRAY = '__remove_array__'; + public const string REMOVE_ARRAY = '__remove_array__'; } diff --git a/src/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php b/src/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php index 9d1d3df5cc4..e668268c27b 100644 --- a/src/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php +++ b/src/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php @@ -27,9 +27,8 @@ final class PhpDocNodeTraverser * for the current node. * * @api - * @var int */ - public const DONT_TRAVERSE_CHILDREN = 1; + public const int DONT_TRAVERSE_CHILDREN = 1; /** * If NodeVisitor::enterNode() or NodeVisitor::leaveNode() returns STOP_TRAVERSAL, traversal is aborted. @@ -37,9 +36,8 @@ final class PhpDocNodeTraverser * The afterTraverse() method will still be invoked. * * @api - * @var int */ - public const STOP_TRAVERSAL = 2; + public const int STOP_TRAVERSAL = 2; /** * If NodeVisitor::leaveNode() returns NODE_REMOVE for a node that occurs in an array, it will be removed from the @@ -48,9 +46,8 @@ final class PhpDocNodeTraverser * For subsequent visitors leaveNode() will still be invoked for the removed node. * * @api - * @var int */ - public const NODE_REMOVE = 3; + public const int NODE_REMOVE = 3; /** * If NodeVisitor::enterNode() returns DONT_TRAVERSE_CURRENT_AND_CHILDREN, child nodes of the current node will not @@ -60,9 +57,8 @@ final class PhpDocNodeTraverser * enterNode() method invoked. * * @api - * @var int */ - public const DONT_TRAVERSE_CURRENT_AND_CHILDREN = 4; + public const int DONT_TRAVERSE_CURRENT_AND_CHILDREN = 4; /** * @var bool Whether traversal should be stopped diff --git a/src/PhpDocParser/PhpDocParser/ValueObject/PhpDocAttributeKey.php b/src/PhpDocParser/PhpDocParser/ValueObject/PhpDocAttributeKey.php index c5ac04342c3..4ab931c5325 100644 --- a/src/PhpDocParser/PhpDocParser/ValueObject/PhpDocAttributeKey.php +++ b/src/PhpDocParser/PhpDocParser/ValueObject/PhpDocAttributeKey.php @@ -6,13 +6,7 @@ final class PhpDocAttributeKey { - /** - * @var string - */ - public const PARENT = 'parent'; + public const string PARENT = 'parent'; - /** - * @var string - */ - public const ORIG_NODE = 'orig_node'; + public const string ORIG_NODE = 'orig_node'; } diff --git a/src/PhpDocParser/ValueObject/AttributeKey.php b/src/PhpDocParser/ValueObject/AttributeKey.php index ccb70da2d58..6525de98375 100644 --- a/src/PhpDocParser/ValueObject/AttributeKey.php +++ b/src/PhpDocParser/ValueObject/AttributeKey.php @@ -11,40 +11,26 @@ final class AttributeKey { /** * Used in php-parser, do not change - * - * @var string */ - public const KIND = 'kind'; + public const string KIND = 'kind'; /** * Used by php-parser, do not change - * - * @var string */ - public const COMMENTS = 'comments'; + public const string COMMENTS = 'comments'; /** * PHPStan @api Used in PHPStan for printed node content. Useful for printing error messages without need to reprint * it again. - * - * @var string */ - public const PHPSTAN_CACHE_PRINTER = 'phpstan_cache_printer'; + public const string PHPSTAN_CACHE_PRINTER = 'phpstan_cache_printer'; - /** - * @var string - */ - public const ASSIGNED_TO = 'assigned_to'; + public const string ASSIGNED_TO = 'assigned_to'; - /** - * @var string - */ - public const NULLSAFE_CHECKED = 'nullsafe_checked'; + public const string NULLSAFE_CHECKED = 'nullsafe_checked'; /** * PHPStan @api - * - * @var string */ - public const PARENT_STMT_TYPES = 'parentStmtTypes'; + public const string PARENT_STMT_TYPES = 'parentStmtTypes'; } diff --git a/src/PhpParser/Enum/NodeGroup.php b/src/PhpParser/Enum/NodeGroup.php index 0b109437487..fce2d1cec8f 100644 --- a/src/PhpParser/Enum/NodeGroup.php +++ b/src/PhpParser/Enum/NodeGroup.php @@ -39,7 +39,7 @@ final class NodeGroup * * @var array> */ - public const STMTS_AWARE = [ + public const array STMTS_AWARE = [ Block::class, Closure::class, Case_::class, @@ -63,7 +63,7 @@ final class NodeGroup /** * @var array> */ - public const STMTS_TO_HAVE_NEXT_NEWLINE = [ + public const array STMTS_TO_HAVE_NEXT_NEWLINE = [ ClassMethod::class, Function_::class, Property::class, diff --git a/src/PhpParser/Node/AssignAndBinaryMap.php b/src/PhpParser/Node/AssignAndBinaryMap.php index baebc2fb8dd..4da7e629619 100644 --- a/src/PhpParser/Node/AssignAndBinaryMap.php +++ b/src/PhpParser/Node/AssignAndBinaryMap.php @@ -49,7 +49,7 @@ final class AssignAndBinaryMap /** * @var array, class-string> */ - private const BINARY_OP_TO_INVERSE_CLASSES = [ + private const array BINARY_OP_TO_INVERSE_CLASSES = [ Identical::class => NotIdentical::class, NotIdentical::class => Identical::class, Equal::class => NotEqual::class, @@ -63,7 +63,7 @@ final class AssignAndBinaryMap /** * @var array, class-string> */ - private const ASSIGN_OP_TO_BINARY_OP_CLASSES = [ + private const array ASSIGN_OP_TO_BINARY_OP_CLASSES = [ AssignBitwiseOr::class => BitwiseOr::class, AssignBitwiseAnd::class => BitwiseAnd::class, AssignBitwiseXor::class => BitwiseXor::class, diff --git a/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php b/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php index 5bb6093891d..da4c17f529f 100644 --- a/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php +++ b/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php @@ -4,6 +4,7 @@ namespace Rector\PhpParser\Node\CustomNode; +use Override; use Rector\Contract\PhpParser\Node\StmtsAwareInterface; use Rector\PhpParser\Node\FileNode; @@ -15,6 +16,7 @@ */ final class FileWithoutNamespace extends FileNode implements StmtsAwareInterface { + #[Override] public function getType(): string { return 'FileWithoutNamespace'; @@ -23,6 +25,7 @@ public function getType(): string /** * @return string[] */ + #[Override] public function getSubNodeNames(): array { return ['stmts']; diff --git a/src/PhpParser/Node/NodeFactory.php b/src/PhpParser/Node/NodeFactory.php index 0c3f22e8cac..311ac81bac1 100644 --- a/src/PhpParser/Node/NodeFactory.php +++ b/src/PhpParser/Node/NodeFactory.php @@ -66,10 +66,7 @@ */ final readonly class NodeFactory { - /** - * @var string - */ - private const THIS = 'this'; + private const string THIS = 'this'; public function __construct( private BuilderFactory $builderFactory, diff --git a/src/PhpParser/NodeTransformer.php b/src/PhpParser/NodeTransformer.php index dfb535273e2..278b65c1b28 100644 --- a/src/PhpParser/NodeTransformer.php +++ b/src/PhpParser/NodeTransformer.php @@ -25,10 +25,9 @@ final class NodeTransformer { /** - * @var string * @see https://regex101.com/r/XFc3qA/1 */ - private const PERCENT_TEXT_REGEX = '#^%\w$#'; + private const string PERCENT_TEXT_REGEX = '#^%\w$#'; /** * @api used in phpunit symfony diff --git a/src/PhpParser/Parser/InlineCodeParser.php b/src/PhpParser/Parser/InlineCodeParser.php index 324da77feec..18bfe874ee3 100644 --- a/src/PhpParser/Parser/InlineCodeParser.php +++ b/src/PhpParser/Parser/InlineCodeParser.php @@ -18,46 +18,39 @@ final readonly class InlineCodeParser { /** - * @var string * @see https://regex101.com/r/dwe4OW/1 */ - private const PRESLASHED_DOLLAR_REGEX = '#\\\\\$#'; + private const string PRESLASHED_DOLLAR_REGEX = '#\\\\\$#'; /** - * @var string * @see https://regex101.com/r/tvwhWq/1 */ - private const CURLY_BRACKET_WRAPPER_REGEX = "#'{(\\\$.*?)}'#"; + private const string CURLY_BRACKET_WRAPPER_REGEX = "#'{(\\\$.*?)}'#"; /** - * @var string * @see https://regex101.com/r/TBlhoR/1 */ - private const OPEN_PHP_TAG_REGEX = '#^\<\?php\s+#'; + private const string OPEN_PHP_TAG_REGEX = '#^\<\?php\s+#'; /** - * @var string * @see https://regex101.com/r/TUWwKw/1/ */ - private const ENDING_SEMI_COLON_REGEX = '#;(\s+)?$#'; + private const string ENDING_SEMI_COLON_REGEX = '#;(\s+)?$#'; /** - * @var string * @see https://regex101.com/r/8fDjnR/1 */ - private const VARIABLE_IN_SINGLE_QUOTED_REGEX = '#\'(?\$.*)\'#U'; + private const string VARIABLE_IN_SINGLE_QUOTED_REGEX = '#\'(?\$.*)\'#U'; /** - * @var string * @see https://regex101.com/r/1lzQZv/1 */ - private const BACKREFERENCE_NO_QUOTE_REGEX = '#(?\\\\\d+)(?!")#'; + private const string BACKREFERENCE_NO_QUOTE_REGEX = '#(?\\\\\d+)(?!")#'; /** - * @var string * @see https://regex101.com/r/nSO3Eq/1 */ - private const BACKREFERENCE_NO_DOUBLE_QUOTE_START_REGEX = '#(?\$\d+)#'; + private const string BACKREFERENCE_NO_DOUBLE_QUOTE_START_REGEX = '#(?\$\d+)#'; public function __construct( private BetterStandardPrinter $betterStandardPrinter, diff --git a/src/PhpParser/Printer/BetterStandardPrinter.php b/src/PhpParser/Printer/BetterStandardPrinter.php index a3347d3553c..293a4d4fe1b 100644 --- a/src/PhpParser/Printer/BetterStandardPrinter.php +++ b/src/PhpParser/Printer/BetterStandardPrinter.php @@ -5,6 +5,7 @@ namespace Rector\PhpParser\Printer; use Nette\Utils\Strings; +use Override; use PhpParser\Comment; use PhpParser\Internal\TokenStream; use PhpParser\Node; @@ -48,9 +49,8 @@ final class BetterStandardPrinter extends Standard /** * Remove extra spaces before new Nop_ nodes * @see https://regex101.com/r/iSvroO/1 - * @var string */ - private const EXTRA_SPACE_BEFORE_NOP_REGEX = '#^[ \t]+$#m'; + private const string EXTRA_SPACE_BEFORE_NOP_REGEX = '#^[ \t]+$#m'; public function __construct( private readonly ExprAnalyzer $exprAnalyzer, @@ -64,6 +64,7 @@ public function __construct( * @param Node[] $origStmts * @param mixed[] $origTokens */ + #[Override] public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens): string { $newStmts = $this->unwrapFileNode($stmts); @@ -101,6 +102,7 @@ public function print(Node | array | null $node): string /** * @param Node[] $stmts */ + #[Override] public function prettyPrintFile(array $stmts): string { // to keep indexes from 0 @@ -118,6 +120,7 @@ protected function pInterpolatedStringPart(InterpolatedStringPart $interpolatedS return $interpolatedStringPart->value; } + #[Override] protected function p( Node $node, int $precedence = self::MAX_PRECEDENCE, @@ -162,6 +165,7 @@ protected function pStmt_FileNode(FileNode $fileNode): string return $this->pStmts($fileNode->stmts); } + #[Override] protected function pExpr_ArrowFunction(ArrowFunction $arrowFunction, int $precedence, int $lhsPrecedence): string { if (! $arrowFunction->hasAttribute(AttributeKey::COMMENTS)) { @@ -197,6 +201,7 @@ protected function pExpr_ArrowFunction(ArrowFunction $arrowFunction, int $preced /** * This allows to use both spaces and tabs vs. original space-only */ + #[Override] protected function setIndentLevel(int $level): void { $level = max($level, 0); @@ -207,6 +212,7 @@ protected function setIndentLevel(int $level): void /** * This allows to use both spaces and tabs vs. original space-only */ + #[Override] protected function indent(): void { $indentSize = SimpleParameterProvider::provideIntParameter(Option::INDENT_SIZE); @@ -218,6 +224,7 @@ protected function indent(): void /** * This allows to use both spaces and tabs vs. original space-only */ + #[Override] protected function outdent(): void { if ($this->getIndentCharacter() === ' ') { @@ -237,6 +244,7 @@ protected function outdent(): void * @param mixed[] $nodes * @param mixed[] $origNodes */ + #[Override] protected function pArray( array $nodes, array $origNodes, @@ -265,6 +273,7 @@ protected function pArray( * Do not add "()" on Expressions * @see https://github.com/rectorphp/rector/pull/401#discussion_r181487199 */ + #[Override] protected function pExpr_Yield(Yield_ $yield, int $precedence, int $lhsPrecedence): string { if (! $yield->value instanceof Expr) { @@ -286,6 +295,7 @@ protected function pExpr_Yield(Yield_ $yield, int $precedence, int $lhsPrecedenc /** * Print new lined array items when newlined_array_print is set to true */ + #[Override] protected function pExpr_Array(Array_ $array): string { if ($array->getAttribute(AttributeKey::NEWLINED_ARRAY_PRINT) === true) { @@ -298,6 +308,7 @@ protected function pExpr_Array(Array_ $array): string return parent::pExpr_Array($array); } + #[Override] protected function pExpr_BinaryOp_Pipe(Pipe $node, int $precedence, int $lhsPrecedence): string { return $this->pInfixOp( @@ -313,6 +324,7 @@ protected function pExpr_BinaryOp_Pipe(Pipe $node, int $precedence, int $lhsPrec /** * Fixes escaping of regular patterns */ + #[Override] protected function pScalar_String(String_ $string): string { if ($string->getAttribute(AttributeKey::DOC_INDENTATION) === '__REMOVED__') { @@ -340,6 +352,7 @@ protected function pScalar_String(String_ $string): string /** * It remove all spaces extra to parent */ + #[Override] protected function pStmt_Declare(Declare_ $declare): string { $declareString = parent::pStmt_Declare($declare); @@ -347,6 +360,7 @@ protected function pStmt_Declare(Declare_ $declare): string return Strings::replace($declareString, '#\s+#'); } + #[Override] protected function pExpr_Ternary(Ternary $ternary, int $precedence, int $lhsPrecedence): string { $kind = $ternary->getAttribute(AttributeKey::KIND); @@ -361,6 +375,7 @@ protected function pExpr_Ternary(Ternary $ternary, int $precedence, int $lhsPrec /** * Used in rector-downgrade-php */ + #[Override] protected function pScalar_InterpolatedString(InterpolatedString $interpolatedString): string { $content = parent::pScalar_InterpolatedString($interpolatedString); @@ -372,6 +387,7 @@ protected function pScalar_InterpolatedString(InterpolatedString $interpolatedSt return $content; } + #[Override] protected function pExpr_MethodCall(MethodCall $methodCall): string { if (! $methodCall->var instanceof CallLike) { @@ -396,6 +412,7 @@ protected function pExpr_MethodCall(MethodCall $methodCall): string . '(' . $this->pMaybeMultiline($methodCall->args) . ')'; } + #[Override] protected function pInfixOp( string $class, Node $leftNode, @@ -408,6 +425,7 @@ protected function pInfixOp( return parent::pInfixOp($class, $leftNode, $operatorString, $rightNode, $precedence, $lhsPrecedence); } + #[Override] protected function pExpr_Instanceof(Instanceof_ $instanceof, int $precedence, int $lhsPrecedence): string { $this->wrapAssign($instanceof->expr, $instanceof->class); diff --git a/src/PostRector/Rector/ClassRenamingPostRector.php b/src/PostRector/Rector/ClassRenamingPostRector.php index 32e8251e528..51622e7e14d 100644 --- a/src/PostRector/Rector/ClassRenamingPostRector.php +++ b/src/PostRector/Rector/ClassRenamingPostRector.php @@ -4,6 +4,7 @@ namespace Rector\PostRector\Rector; +use Override; use PhpParser\Node; use PhpParser\Node\Stmt\Namespace_; use PhpParser\NodeVisitor; @@ -62,6 +63,7 @@ public function enterNode(Node $node): Namespace_|FileNode|int|null return NodeVisitor::STOP_TRAVERSAL; } + #[Override] public function shouldTraverse(array $stmts): bool { $this->oldToNewClasses = $this->renamedClassesDataCollector->getOldToNewClasses(); diff --git a/src/PostRector/Rector/DocblockNameImportingPostRector.php b/src/PostRector/Rector/DocblockNameImportingPostRector.php index 407f8de47db..2089d5f0d89 100644 --- a/src/PostRector/Rector/DocblockNameImportingPostRector.php +++ b/src/PostRector/Rector/DocblockNameImportingPostRector.php @@ -4,6 +4,7 @@ namespace Rector\PostRector\Rector; +use Override; use PhpParser\Node; use PhpParser\Node\Param; use PhpParser\Node\Stmt; @@ -47,6 +48,7 @@ public function enterNode(Node $node): Node|null /** * @param Stmt[] $stmts */ + #[Override] public function shouldTraverse(array $stmts): bool { return $this->addUseStatementGuard->shouldTraverse($stmts, $this->getFile()->getFilePath()); diff --git a/src/PostRector/Rector/NameImportingPostRector.php b/src/PostRector/Rector/NameImportingPostRector.php index 7c63e54b217..7052b406ba3 100644 --- a/src/PostRector/Rector/NameImportingPostRector.php +++ b/src/PostRector/Rector/NameImportingPostRector.php @@ -4,6 +4,7 @@ namespace Rector\PostRector\Rector; +use Override; use PhpParser\Node; use PhpParser\Node\Name; use PhpParser\Node\Name\FullyQualified; @@ -56,6 +57,7 @@ public function enterNode(Node $node): Name|null /** * @param Stmt[] $stmts */ + #[Override] public function shouldTraverse(array $stmts): bool { return $this->addUseStatementGuard->shouldTraverse($stmts, $this->getFile()->getFilePath()); diff --git a/src/Rector/AbstractRector.php b/src/Rector/AbstractRector.php index 6395e627b68..e7d0db63273 100644 --- a/src/Rector/AbstractRector.php +++ b/src/Rector/AbstractRector.php @@ -36,10 +36,7 @@ abstract class AbstractRector extends NodeVisitorAbstract implements RectorInterface { - /** - * @var string - */ - private const EMPTY_NODE_ARRAY_MESSAGE = <<refactor()" returns non-empty array for Nodes. A) Direct return null for no change: diff --git a/src/Set/Enum/SetGroup.php b/src/Set/Enum/SetGroup.php index 5a0f4bba5b4..a3ea3ecb1e6 100644 --- a/src/Set/Enum/SetGroup.php +++ b/src/Set/Enum/SetGroup.php @@ -9,54 +9,39 @@ */ final class SetGroup { - /** - * @var string - */ - public const CORE = 'core'; + public const string CORE = 'core'; - /** - * @var string - */ - public const PHP = 'php'; + public const string PHP = 'php'; /** * Version-based set provider - * @var string */ - public const TWIG = 'twig'; + public const string TWIG = 'twig'; /** * Version-based set provider - * @var string */ - public const PHPUNIT = 'phpunit'; + public const string PHPUNIT = 'phpunit'; /** * Version-based set provider - * @var string */ - public const DOCTRINE = 'doctrine'; + public const string DOCTRINE = 'doctrine'; /** * Version-based set provider - * @var string */ - public const SYMFONY = 'symfony'; + public const string SYMFONY = 'symfony'; /** * Version-based set provider - * @var string */ - public const NETTE_UTILS = 'nette-utils'; + public const string NETTE_UTILS = 'nette-utils'; /** * Version-based set provider - * @var string */ - public const LARAVEL = 'laravel'; + public const string LARAVEL = 'laravel'; - /** - * @var string - */ - public const ATTRIBUTES = 'attributes'; + public const string ATTRIBUTES = 'attributes'; } diff --git a/src/Set/ValueObject/ComposerTriggeredSet.php b/src/Set/ValueObject/ComposerTriggeredSet.php index 0298cac38c4..3964c7865be 100644 --- a/src/Set/ValueObject/ComposerTriggeredSet.php +++ b/src/Set/ValueObject/ComposerTriggeredSet.php @@ -15,10 +15,9 @@ final readonly class ComposerTriggeredSet implements SetInterface { /** - * @var string * @see https://regex101.com/r/ioYomu/1 */ - private const PACKAGE_REGEX = '#^[a-z0-9-]+\/([a-z0-9-_]+|\*)$#'; + private const string PACKAGE_REGEX = '#^[a-z0-9-]+\/([a-z0-9-_]+|\*)$#'; public function __construct( private string $groupName, diff --git a/src/Set/ValueObject/LevelSetList.php b/src/Set/ValueObject/LevelSetList.php index 1480caaf361..2286d668f8c 100644 --- a/src/Set/ValueObject/LevelSetList.php +++ b/src/Set/ValueObject/LevelSetList.php @@ -9,78 +9,33 @@ */ final class LevelSetList { - /** - * @var string - */ - public const UP_TO_PHP_85 = __DIR__ . '/../../../config/set/level/up-to-php85.php'; - - /** - * @var string - */ - public const UP_TO_PHP_84 = __DIR__ . '/../../../config/set/level/up-to-php84.php'; - - /** - * @var string - */ - public const UP_TO_PHP_83 = __DIR__ . '/../../../config/set/level/up-to-php83.php'; - - /** - * @var string - */ - public const UP_TO_PHP_82 = __DIR__ . '/../../../config/set/level/up-to-php82.php'; - - /** - * @var string - */ - public const UP_TO_PHP_81 = __DIR__ . '/../../../config/set/level/up-to-php81.php'; - - /** - * @var string - */ - public const UP_TO_PHP_80 = __DIR__ . '/../../../config/set/level/up-to-php80.php'; - - /** - * @var string - */ - public const UP_TO_PHP_74 = __DIR__ . '/../../../config/set/level/up-to-php74.php'; - - /** - * @var string - */ - public const UP_TO_PHP_73 = __DIR__ . '/../../../config/set/level/up-to-php73.php'; - - /** - * @var string - */ - public const UP_TO_PHP_72 = __DIR__ . '/../../../config/set/level/up-to-php72.php'; - - /** - * @var string - */ - public const UP_TO_PHP_71 = __DIR__ . '/../../../config/set/level/up-to-php71.php'; - - /** - * @var string - */ - public const UP_TO_PHP_70 = __DIR__ . '/../../../config/set/level/up-to-php70.php'; - - /** - * @var string - */ - public const UP_TO_PHP_56 = __DIR__ . '/../../../config/set/level/up-to-php56.php'; - - /** - * @var string - */ - public const UP_TO_PHP_55 = __DIR__ . '/../../../config/set/level/up-to-php55.php'; - - /** - * @var string - */ - public const UP_TO_PHP_54 = __DIR__ . '/../../../config/set/level/up-to-php54.php'; - - /** - * @var string - */ - public const UP_TO_PHP_53 = __DIR__ . '/../../../config/set/level/up-to-php53.php'; + public const string UP_TO_PHP_85 = __DIR__ . '/../../../config/set/level/up-to-php85.php'; + + public const string UP_TO_PHP_84 = __DIR__ . '/../../../config/set/level/up-to-php84.php'; + + public const string UP_TO_PHP_83 = __DIR__ . '/../../../config/set/level/up-to-php83.php'; + + public const string UP_TO_PHP_82 = __DIR__ . '/../../../config/set/level/up-to-php82.php'; + + public const string UP_TO_PHP_81 = __DIR__ . '/../../../config/set/level/up-to-php81.php'; + + public const string UP_TO_PHP_80 = __DIR__ . '/../../../config/set/level/up-to-php80.php'; + + public const string UP_TO_PHP_74 = __DIR__ . '/../../../config/set/level/up-to-php74.php'; + + public const string UP_TO_PHP_73 = __DIR__ . '/../../../config/set/level/up-to-php73.php'; + + public const string UP_TO_PHP_72 = __DIR__ . '/../../../config/set/level/up-to-php72.php'; + + public const string UP_TO_PHP_71 = __DIR__ . '/../../../config/set/level/up-to-php71.php'; + + public const string UP_TO_PHP_70 = __DIR__ . '/../../../config/set/level/up-to-php70.php'; + + public const string UP_TO_PHP_56 = __DIR__ . '/../../../config/set/level/up-to-php56.php'; + + public const string UP_TO_PHP_55 = __DIR__ . '/../../../config/set/level/up-to-php55.php'; + + public const string UP_TO_PHP_54 = __DIR__ . '/../../../config/set/level/up-to-php54.php'; + + public const string UP_TO_PHP_53 = __DIR__ . '/../../../config/set/level/up-to-php53.php'; } diff --git a/src/Set/ValueObject/SetList.php b/src/Set/ValueObject/SetList.php index 5dc2a7ce781..2fc8199cddb 100644 --- a/src/Set/ValueObject/SetList.php +++ b/src/Set/ValueObject/SetList.php @@ -11,167 +11,77 @@ final class SetList { /** * @internal - * @var string */ - public const PHP_POLYFILLS = __DIR__ . '/../../../config/set/php-polyfills.php'; + public const string PHP_POLYFILLS = __DIR__ . '/../../../config/set/php-polyfills.php'; - /** - * @var string - */ - public const CODE_QUALITY = __DIR__ . '/../../../config/set/code-quality.php'; + public const string CODE_QUALITY = __DIR__ . '/../../../config/set/code-quality.php'; - /** - * @var string - */ - public const CODING_STYLE = __DIR__ . '/../../../config/set/coding-style.php'; + public const string CODING_STYLE = __DIR__ . '/../../../config/set/coding-style.php'; - /** - * @var string - */ - public const DEAD_CODE = __DIR__ . '/../../../config/set/dead-code.php'; + public const string DEAD_CODE = __DIR__ . '/../../../config/set/dead-code.php'; /** * @deprecated As too strict and not practical. Use code quality and coding style sets instead. - * @var string */ - public const STRICT_BOOLEANS = __DIR__ . '/../../../config/set/strict-booleans.php'; + public const string STRICT_BOOLEANS = __DIR__ . '/../../../config/set/strict-booleans.php'; - /** - * @var string - */ - public const GMAGICK_TO_IMAGICK = __DIR__ . '/../../../config/set/gmagick-to-imagick.php'; + public const string GMAGICK_TO_IMAGICK = __DIR__ . '/../../../config/set/gmagick-to-imagick.php'; - /** - * @var string - */ - public const NAMING = __DIR__ . '/../../../config/set/naming.php'; + public const string NAMING = __DIR__ . '/../../../config/set/naming.php'; /** * Opinionated rules that match rector coding standard - * - * @var string */ - public const RECTOR_PRESET = __DIR__ . '/../../../config/set/rector-preset.php'; + public const string RECTOR_PRESET = __DIR__ . '/../../../config/set/rector-preset.php'; - /** - * @var string - */ - public const PHP_52 = __DIR__ . '/../../../config/set/php52.php'; + public const string PHP_52 = __DIR__ . '/../../../config/set/php52.php'; - /** - * @var string - */ - public const PHP_53 = __DIR__ . '/../../../config/set/php53.php'; + public const string PHP_53 = __DIR__ . '/../../../config/set/php53.php'; - /** - * @var string - */ - public const PHP_54 = __DIR__ . '/../../../config/set/php54.php'; + public const string PHP_54 = __DIR__ . '/../../../config/set/php54.php'; - /** - * @var string - */ - public const PHP_55 = __DIR__ . '/../../../config/set/php55.php'; + public const string PHP_55 = __DIR__ . '/../../../config/set/php55.php'; - /** - * @var string - */ - public const PHP_56 = __DIR__ . '/../../../config/set/php56.php'; + public const string PHP_56 = __DIR__ . '/../../../config/set/php56.php'; - /** - * @var string - */ - public const PHP_70 = __DIR__ . '/../../../config/set/php70.php'; + public const string PHP_70 = __DIR__ . '/../../../config/set/php70.php'; - /** - * @var string - */ - public const PHP_71 = __DIR__ . '/../../../config/set/php71.php'; + public const string PHP_71 = __DIR__ . '/../../../config/set/php71.php'; - /** - * @var string - */ - public const PHP_72 = __DIR__ . '/../../../config/set/php72.php'; + public const string PHP_72 = __DIR__ . '/../../../config/set/php72.php'; - /** - * @var string - */ - public const PHP_73 = __DIR__ . '/../../../config/set/php73.php'; + public const string PHP_73 = __DIR__ . '/../../../config/set/php73.php'; - /** - * @var string - */ - public const PHP_74 = __DIR__ . '/../../../config/set/php74.php'; + public const string PHP_74 = __DIR__ . '/../../../config/set/php74.php'; - /** - * @var string - */ - public const PHP_80 = __DIR__ . '/../../../config/set/php80.php'; + public const string PHP_80 = __DIR__ . '/../../../config/set/php80.php'; - /** - * @var string - */ - public const PHP_81 = __DIR__ . '/../../../config/set/php81.php'; + public const string PHP_81 = __DIR__ . '/../../../config/set/php81.php'; - /** - * @var string - */ - public const PHP_82 = __DIR__ . '/../../../config/set/php82.php'; + public const string PHP_82 = __DIR__ . '/../../../config/set/php82.php'; - /** - * @var string - */ - public const PHP_83 = __DIR__ . '/../../../config/set/php83.php'; + public const string PHP_83 = __DIR__ . '/../../../config/set/php83.php'; - /** - * @var string - */ - public const PHP_84 = __DIR__ . '/../../../config/set/php84.php'; + public const string PHP_84 = __DIR__ . '/../../../config/set/php84.php'; - /** - * @var string - */ - public const PHP_85 = __DIR__ . '/../../../config/set/php85.php'; + public const string PHP_85 = __DIR__ . '/../../../config/set/php85.php'; - /** - * @var string - */ - public const PRIVATIZATION = __DIR__ . '/../../../config/set/privatization.php'; + public const string PRIVATIZATION = __DIR__ . '/../../../config/set/privatization.php'; - /** - * @var string - */ - public const TYPE_DECLARATION = __DIR__ . '/../../../config/set/type-declaration.php'; + public const string TYPE_DECLARATION = __DIR__ . '/../../../config/set/type-declaration.php'; - /** - * @var string - */ - public const TYPE_DECLARATION_DOCBLOCKS = __DIR__ . '/../../../config/set/type-declaration-docblocks.php'; + public const string TYPE_DECLARATION_DOCBLOCKS = __DIR__ . '/../../../config/set/type-declaration-docblocks.php'; - /** - * @var string - */ - public const EARLY_RETURN = __DIR__ . '/../../../config/set/early-return.php'; + public const string EARLY_RETURN = __DIR__ . '/../../../config/set/early-return.php'; - /** - * @var string - */ - public const INSTANCEOF = __DIR__ . '/../../../config/set/instanceof.php'; + public const string INSTANCEOF = __DIR__ . '/../../../config/set/instanceof.php'; - /** - * @var string - */ - public const CARBON = __DIR__ . '/../../../config/set/datetime-to-carbon.php'; + public const string CARBON = __DIR__ . '/../../../config/set/datetime-to-carbon.php'; - /** - * @var string - */ - public const BEHAT_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../../config/set/behat-annotations-to-attributes.php'; + public const string BEHAT_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../../config/set/behat-annotations-to-attributes.php'; /** * @experimental Check generic types in runtime with assert. Generics for impatient people. - * - * @var string */ - public const ASSERT = __DIR__ . '/../../../config/set/assert.php'; + public const string ASSERT = __DIR__ . '/../../../config/set/assert.php'; } diff --git a/src/StaticTypeMapper/Mapper/ScalarStringToTypeMapper.php b/src/StaticTypeMapper/Mapper/ScalarStringToTypeMapper.php index 1d424c366b0..36d0e79d0e8 100644 --- a/src/StaticTypeMapper/Mapper/ScalarStringToTypeMapper.php +++ b/src/StaticTypeMapper/Mapper/ScalarStringToTypeMapper.php @@ -32,7 +32,7 @@ final class ScalarStringToTypeMapper /** * @var array, string[]> */ - private const SCALAR_NAME_BY_TYPE = [ + private const array SCALAR_NAME_BY_TYPE = [ StringType::class => ['string'], AccessoryNonEmptyStringType::class => ['non-empty-string'], NonEmptyArrayType::class => ['non-empty-array'], diff --git a/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php b/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php index ca1bc7028d5..c9a14f997fe 100644 --- a/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php +++ b/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php @@ -4,6 +4,7 @@ namespace Rector\StaticTypeMapper\ValueObject\Type; +use Override; use PhpParser\Node\Name; use PhpParser\Node\Stmt\Use_; use PhpParser\Node\UseItem; @@ -53,6 +54,7 @@ public function areShortNamesEqual(self | FullyQualifiedObjectType $comparedObje return $this->getShortName() === $comparedObjectType->getShortName(); } + #[Override] public function equals(Type $type): bool { $className = ClassNameFromObjectTypeResolver::resolve($type); diff --git a/src/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php b/src/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php index 916ba0da943..b4ebf1d0183 100644 --- a/src/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php +++ b/src/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php @@ -4,6 +4,7 @@ namespace Rector\StaticTypeMapper\ValueObject\Type; +use Override; use PHPStan\Type\Generic\GenericObjectType; use PHPStan\Type\IsSuperTypeOfResult; use PHPStan\Type\Type; @@ -24,6 +25,7 @@ public function __construct( parent::__construct($shortName, $types); } + #[Override] public function isSuperTypeOf(Type $type): IsSuperTypeOfResult { $genericObjectType = new GenericObjectType($this->fullyQualifiedName, $this->getTypes()); diff --git a/src/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php b/src/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php index 208bd9ce896..f5e7108eb80 100644 --- a/src/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php +++ b/src/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php @@ -4,6 +4,7 @@ namespace Rector\StaticTypeMapper\ValueObject\Type; +use Override; use PHPStan\Type\IsSuperTypeOfResult; use PHPStan\Type\ObjectType; use PHPStan\Type\Type; @@ -23,6 +24,7 @@ public function __construct( parent::__construct($shortName); } + #[Override] public function isSuperTypeOf(Type $type): IsSuperTypeOfResult { $fullyQualifiedObjectType = new ObjectType($this->fullyQualifiedName); diff --git a/src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php b/src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php index d975c714b86..d97ba4c2d84 100644 --- a/src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php +++ b/src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php @@ -4,6 +4,7 @@ namespace Rector\StaticTypeMapper\ValueObject\Type; +use Override; use PHPStan\Type\StaticType; final class SimpleStaticType extends StaticType @@ -13,6 +14,7 @@ public function __construct( ) { } + #[Override] public function getClassName(): string { return $this->className; diff --git a/src/Testing/PHPUnit/AbstractRectorTestCase.php b/src/Testing/PHPUnit/AbstractRectorTestCase.php index f0477faa32e..72d97541fef 100644 --- a/src/Testing/PHPUnit/AbstractRectorTestCase.php +++ b/src/Testing/PHPUnit/AbstractRectorTestCase.php @@ -8,6 +8,7 @@ use Iterator; use Nette\Utils\FileSystem; use Nette\Utils\Strings; +use Override; use PHPUnit\Framework\ExpectationFailedException; use Rector\Application\ApplicationFileProcessor; use Rector\Autoloading\AdditionalAutoloader; @@ -63,6 +64,7 @@ public static function tearDownAfterClass(): void SimpleParameterProvider::setParameter(Option::TREAT_CLASSES_AS_FINAL, false); } + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/src/Util/MemoryLimiter.php b/src/Util/MemoryLimiter.php index 6c302192cf7..17f06b75fd5 100644 --- a/src/Util/MemoryLimiter.php +++ b/src/Util/MemoryLimiter.php @@ -14,10 +14,9 @@ final class MemoryLimiter { /** - * @var string * @see https://regex101.com/r/pmiGUM/1 */ - private const VALID_MEMORY_LIMIT_REGEX = '#^-?\d+[kMG]?$#i'; + private const string VALID_MEMORY_LIMIT_REGEX = '#^-?\d+[kMG]?$#i'; public function adjust(Configuration $configuration): void { diff --git a/src/Util/NewLineSplitter.php b/src/Util/NewLineSplitter.php index 3b3ef1856f6..af11ca9a66e 100644 --- a/src/Util/NewLineSplitter.php +++ b/src/Util/NewLineSplitter.php @@ -9,10 +9,9 @@ final class NewLineSplitter { /** - * @var string * @see https://regex101.com/r/qduj2O/4 */ - private const NEWLINES_REGEX = "#\r?\n#"; + private const string NEWLINES_REGEX = "#\r?\n#"; /** * @return string[] diff --git a/src/Util/NodePrinter.php b/src/Util/NodePrinter.php index 82b28e37bf3..e914692dcc4 100644 --- a/src/Util/NodePrinter.php +++ b/src/Util/NodePrinter.php @@ -12,16 +12,14 @@ final readonly class NodePrinter { /** - * @var string * @see https://regex101.com/r/Fe8n73/1 */ - private const CLASS_NAME_REGEX = '#(?PhpParser(.*?))\(#ms'; + private const string CLASS_NAME_REGEX = '#(?PhpParser(.*?))\(#ms'; /** - * @var string * @see https://regex101.com/r/uQFuvL/1 */ - private const PROPERTY_KEY_REGEX = '#(?[\w\d]+)\:#'; + private const string PROPERTY_KEY_REGEX = '#(?[\w\d]+)\:#'; public function __construct( private SymfonyStyle $symfonyStyle diff --git a/src/Validation/RectorAssert.php b/src/Validation/RectorAssert.php index d950ebe9537..3cd55b4f17b 100644 --- a/src/Validation/RectorAssert.php +++ b/src/Validation/RectorAssert.php @@ -15,42 +15,33 @@ final class RectorAssert /** * @see https://stackoverflow.com/a/12011255/1348344 * @see https://regex101.com/r/PYQaPF/1 - * @var string */ - private const CLASS_NAME_REGEX = '#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*$#'; + private const string CLASS_NAME_REGEX = '#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*$#'; /** * @see https://stackoverflow.com/a/60470526/1348344 * @see https://regex101.com/r/37aUWA/1 - * - * @var string */ - private const NAKED_NAMESPACE_REGEX = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff\\\\]*[a-zA-Z0-9_\x7f-\xff]'; + private const string NAKED_NAMESPACE_REGEX = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff\\\\]*[a-zA-Z0-9_\x7f-\xff]'; /** * @see https://www.php.net/manual/en/language.variables.basics.php * @see https://regex101.com/r/hFw17T/1 - * - * @var string */ - private const PROPERTY_NAME_REGEX = '#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$#'; + private const string PROPERTY_NAME_REGEX = '#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$#'; /** * @see https://regex101.com/r/uh5B0S/2 * @see https://www.php.net/manual/en/functions.user-defined.php * @see https://www.php.net/manual/en/language.constants.php - * - * @var string */ - private const METHOD_OR_CONSTANT_NAME_REGEX = '#^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$#'; + private const string METHOD_OR_CONSTANT_NAME_REGEX = '#^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$#'; /** * @see https://regex101.com/r/uh5B0S/1 * @see https://www.php.net/manual/en/functions.user-defined.php - * - * @var string */ - private const FUNCTION_NAME_REGEX = '#^(' . self::NAKED_NAMESPACE_REGEX . '\\\\)?([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)$#'; + private const string FUNCTION_NAME_REGEX = '#^(' . self::NAKED_NAMESPACE_REGEX . '\\\\)?([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)$#'; public static function constantName(string $name): void { diff --git a/src/ValueObject/MethodName.php b/src/ValueObject/MethodName.php index 7bd3daf4faa..7119ab7b8c2 100644 --- a/src/ValueObject/MethodName.php +++ b/src/ValueObject/MethodName.php @@ -10,76 +10,38 @@ */ final class MethodName { - /** - * @var string - */ - public const __SET = '__set'; + public const string __SET = '__set'; - /** - * @var string - */ - public const __GET = '__get'; + public const string __GET = '__get'; - /** - * @var string - */ - public const CONSTRUCT = '__construct'; + public const string CONSTRUCT = '__construct'; - /** - * @var string - */ - public const DESTRUCT = '__destruct'; + public const string DESTRUCT = '__destruct'; - /** - * @var string - */ - public const CLONE = '__clone'; + public const string CLONE = '__clone'; /** * Mostly used in unit tests * @see https://phpunit.readthedocs.io/en/9.3/fixtures.html#more-setup-than-teardown - * @var string */ - public const SET_UP = 'setUp'; + public const string SET_UP = 'setUp'; - /** - * @var string - */ - public const SET_STATE = '__set_state'; + public const string SET_STATE = '__set_state'; /** * @see https://phpunit.readthedocs.io/en/9.3/fixtures.html#fixtures-sharing-fixture-examples-databasetest-php - * @var string */ - public const SET_UP_BEFORE_CLASS = 'setUpBeforeClass'; + public const string SET_UP_BEFORE_CLASS = 'setUpBeforeClass'; - /** - * @var string - */ - public const CALL = '__call'; + public const string CALL = '__call'; - /** - * @var string - */ - public const CALL_STATIC = '__callStatic'; + public const string CALL_STATIC = '__callStatic'; - /** - * @var string - */ - public const TO_STRING = '__toString'; + public const string TO_STRING = '__toString'; - /** - * @var string - */ - public const INVOKE = '__invoke'; + public const string INVOKE = '__invoke'; - /** - * @var string - */ - public const ISSET = '__isset'; + public const string ISSET = '__isset'; - /** - * @var string - */ - public const UNSET = '__unset'; + public const string UNSET = '__unset'; } diff --git a/src/ValueObject/PhpVersion.php b/src/ValueObject/PhpVersion.php index 6903e9aac76..629483b5b16 100644 --- a/src/ValueObject/PhpVersion.php +++ b/src/ValueObject/PhpVersion.php @@ -9,88 +9,37 @@ */ final class PhpVersion { - /** - * @var int - */ - public const PHP_52 = 50200; - - /** - * @var int - */ - public const PHP_53 = 50300; - - /** - * @var int - */ - public const PHP_54 = 50400; - - /** - * @var int - */ - public const PHP_55 = 50500; - - /** - * @var int - */ - public const PHP_56 = 50600; - - /** - * @var int - */ - public const PHP_70 = 70000; - - /** - * @var int - */ - public const PHP_71 = 70100; - - /** - * @var int - */ - public const PHP_72 = 70200; - - /** - * @var int - */ - public const PHP_73 = 70300; - - /** - * @var int - */ - public const PHP_74 = 70400; - - /** - * @var int - */ - public const PHP_80 = 80000; - - /** - * @var int - */ - public const PHP_81 = 80100; - - /** - * @var int - */ - public const PHP_82 = 80200; - - /** - * @var int - */ - public const PHP_83 = 80300; - - /** - * @var int - */ - public const PHP_84 = 80400; - - /** - * @var int - */ - public const PHP_85 = 80500; - - /** - * @var int - */ - public const PHP_10 = 100000; + public const int PHP_52 = 50200; + + public const int PHP_53 = 50300; + + public const int PHP_54 = 50400; + + public const int PHP_55 = 50500; + + public const int PHP_56 = 50600; + + public const int PHP_70 = 70000; + + public const int PHP_71 = 70100; + + public const int PHP_72 = 70200; + + public const int PHP_73 = 70300; + + public const int PHP_74 = 70400; + + public const int PHP_80 = 80000; + + public const int PHP_81 = 80100; + + public const int PHP_82 = 80200; + + public const int PHP_83 = 80300; + + public const int PHP_84 = 80400; + + public const int PHP_85 = 80500; + + public const int PHP_10 = 100000; } diff --git a/src/ValueObject/PhpVersionFeature.php b/src/ValueObject/PhpVersionFeature.php index cbda1f5cba6..1cfe19b9df6 100644 --- a/src/ValueObject/PhpVersionFeature.php +++ b/src/ValueObject/PhpVersionFeature.php @@ -9,841 +9,490 @@ */ final class PhpVersionFeature { - /** - * @var int - */ - public const PROPERTY_MODIFIER = PhpVersion::PHP_52; + public const int PROPERTY_MODIFIER = PhpVersion::PHP_52; - /** - * @var int - */ - public const CONTINUE_TO_BREAK = PhpVersion::PHP_52; + public const int CONTINUE_TO_BREAK = PhpVersion::PHP_52; - /** - * @var int - */ - public const NO_REFERENCE_IN_NEW = PhpVersion::PHP_53; + public const int NO_REFERENCE_IN_NEW = PhpVersion::PHP_53; - /** - * @var int - */ - public const SERVER_VAR = PhpVersion::PHP_53; + public const int SERVER_VAR = PhpVersion::PHP_53; - /** - * @var int - */ - public const DIR_CONSTANT = PhpVersion::PHP_53; + public const int DIR_CONSTANT = PhpVersion::PHP_53; - /** - * @var int - */ - public const ELVIS_OPERATOR = PhpVersion::PHP_53; + public const int ELVIS_OPERATOR = PhpVersion::PHP_53; - /** - * @var int - */ - public const ANONYMOUS_FUNCTION_PARAM_TYPE = PhpVersion::PHP_53; + public const int ANONYMOUS_FUNCTION_PARAM_TYPE = PhpVersion::PHP_53; - /** - * @var int - */ - public const NO_ZERO_BREAK = PhpVersion::PHP_54; + public const int NO_ZERO_BREAK = PhpVersion::PHP_54; - /** - * @var int - */ - public const NO_REFERENCE_IN_ARG = PhpVersion::PHP_54; + public const int NO_REFERENCE_IN_ARG = PhpVersion::PHP_54; - /** - * @var int - */ - public const SHORT_ARRAY = PhpVersion::PHP_54; + public const int SHORT_ARRAY = PhpVersion::PHP_54; - /** - * @var int - */ - public const DATE_TIME_INTERFACE = PhpVersion::PHP_55; + public const int DATE_TIME_INTERFACE = PhpVersion::PHP_55; /** * @see https://wiki.php.net/rfc/class_name_scalars - * @var int */ - public const CLASSNAME_CONSTANT = PhpVersion::PHP_55; + public const int CLASSNAME_CONSTANT = PhpVersion::PHP_55; - /** - * @var int - */ - public const PREG_REPLACE_CALLBACK_E_MODIFIER = PhpVersion::PHP_55; + public const int PREG_REPLACE_CALLBACK_E_MODIFIER = PhpVersion::PHP_55; - /** - * @var int - */ - public const EXP_OPERATOR = PhpVersion::PHP_56; + public const int EXP_OPERATOR = PhpVersion::PHP_56; - /** - * @var int - */ - public const REQUIRE_DEFAULT_VALUE = PhpVersion::PHP_56; + public const int REQUIRE_DEFAULT_VALUE = PhpVersion::PHP_56; - /** - * @var int - */ - public const SCALAR_TYPES = PhpVersion::PHP_70; + public const int SCALAR_TYPES = PhpVersion::PHP_70; - /** - * @var int - */ - public const HAS_RETURN_TYPE = PhpVersion::PHP_70; + public const int HAS_RETURN_TYPE = PhpVersion::PHP_70; - /** - * @var int - */ - public const NULL_COALESCE = PhpVersion::PHP_70; + public const int NULL_COALESCE = PhpVersion::PHP_70; - /** - * @var int - */ - public const LIST_SWAP_ORDER = PhpVersion::PHP_70; + public const int LIST_SWAP_ORDER = PhpVersion::PHP_70; - /** - * @var int - */ - public const SPACESHIP = PhpVersion::PHP_70; + public const int SPACESHIP = PhpVersion::PHP_70; - /** - * @var int - */ - public const DIRNAME_LEVELS = PhpVersion::PHP_70; + public const int DIRNAME_LEVELS = PhpVersion::PHP_70; - /** - * @var int - */ - public const CSPRNG_FUNCTIONS = PhpVersion::PHP_70; + public const int CSPRNG_FUNCTIONS = PhpVersion::PHP_70; - /** - * @var int - */ - public const THROWABLE_TYPE = PhpVersion::PHP_70; + public const int THROWABLE_TYPE = PhpVersion::PHP_70; - /** - * @var int - */ - public const NO_LIST_SPLIT_STRING = PhpVersion::PHP_70; + public const int NO_LIST_SPLIT_STRING = PhpVersion::PHP_70; - /** - * @var int - */ - public const NO_BREAK_OUTSIDE_LOOP = PhpVersion::PHP_70; + public const int NO_BREAK_OUTSIDE_LOOP = PhpVersion::PHP_70; - /** - * @var int - */ - public const NO_PHP4_CONSTRUCTOR = PhpVersion::PHP_70; + public const int NO_PHP4_CONSTRUCTOR = PhpVersion::PHP_70; - /** - * @var int - */ - public const NO_CALL_USER_METHOD = PhpVersion::PHP_70; + public const int NO_CALL_USER_METHOD = PhpVersion::PHP_70; - /** - * @var int - */ - public const NO_EREG_FUNCTION = PhpVersion::PHP_70; + public const int NO_EREG_FUNCTION = PhpVersion::PHP_70; - /** - * @var int - */ - public const VARIABLE_ON_FUNC_CALL = PhpVersion::PHP_70; + public const int VARIABLE_ON_FUNC_CALL = PhpVersion::PHP_70; - /** - * @var int - */ - public const NO_MKTIME_WITHOUT_ARG = PhpVersion::PHP_70; + public const int NO_MKTIME_WITHOUT_ARG = PhpVersion::PHP_70; - /** - * @var int - */ - public const NO_EMPTY_LIST = PhpVersion::PHP_70; + public const int NO_EMPTY_LIST = PhpVersion::PHP_70; /** * @see https://php.watch/versions/8.0/non-static-static-call-fatal-error * Deprecated since PHP 7.0 - * - * @var int */ - public const STATIC_CALL_ON_NON_STATIC = PhpVersion::PHP_70; + public const int STATIC_CALL_ON_NON_STATIC = PhpVersion::PHP_70; - /** - * @var int - */ - public const INSTANCE_CALL = PhpVersion::PHP_70; + public const int INSTANCE_CALL = PhpVersion::PHP_70; - /** - * @var int - */ - public const NO_MULTIPLE_DEFAULT_SWITCH = PhpVersion::PHP_70; + public const int NO_MULTIPLE_DEFAULT_SWITCH = PhpVersion::PHP_70; - /** - * @var int - */ - public const WRAP_VARIABLE_VARIABLE = PhpVersion::PHP_70; + public const int WRAP_VARIABLE_VARIABLE = PhpVersion::PHP_70; - /** - * @var int - */ - public const ANONYMOUS_FUNCTION_RETURN_TYPE = PhpVersion::PHP_70; + public const int ANONYMOUS_FUNCTION_RETURN_TYPE = PhpVersion::PHP_70; - /** - * @var int - */ - public const ITERABLE_TYPE = PhpVersion::PHP_71; + public const int ITERABLE_TYPE = PhpVersion::PHP_71; - /** - * @var int - */ - public const VOID_TYPE = PhpVersion::PHP_71; + public const int VOID_TYPE = PhpVersion::PHP_71; - /** - * @var int - */ - public const CONSTANT_VISIBILITY = PhpVersion::PHP_71; + public const int CONSTANT_VISIBILITY = PhpVersion::PHP_71; - /** - * @var int - */ - public const ARRAY_DESTRUCT = PhpVersion::PHP_71; + public const int ARRAY_DESTRUCT = PhpVersion::PHP_71; - /** - * @var int - */ - public const MULTI_EXCEPTION_CATCH = PhpVersion::PHP_71; + public const int MULTI_EXCEPTION_CATCH = PhpVersion::PHP_71; - /** - * @var int - */ - public const NO_ASSIGN_ARRAY_TO_STRING = PhpVersion::PHP_71; + public const int NO_ASSIGN_ARRAY_TO_STRING = PhpVersion::PHP_71; - /** - * @var int - */ - public const BINARY_OP_NUMBER_STRING = PhpVersion::PHP_71; + public const int BINARY_OP_NUMBER_STRING = PhpVersion::PHP_71; - /** - * @var int - */ - public const NO_EXTRA_PARAMETERS = PhpVersion::PHP_71; + public const int NO_EXTRA_PARAMETERS = PhpVersion::PHP_71; - /** - * @var int - */ - public const RESERVED_OBJECT_KEYWORD = PhpVersion::PHP_71; + public const int RESERVED_OBJECT_KEYWORD = PhpVersion::PHP_71; - /** - * @var int - */ - public const DEPRECATE_EACH = PhpVersion::PHP_72; + public const int DEPRECATE_EACH = PhpVersion::PHP_72; - /** - * @var int - */ - public const OBJECT_TYPE = PhpVersion::PHP_72; + public const int OBJECT_TYPE = PhpVersion::PHP_72; - /** - * @var int - */ - public const NO_EACH_OUTSIDE_LOOP = PhpVersion::PHP_72; + public const int NO_EACH_OUTSIDE_LOOP = PhpVersion::PHP_72; - /** - * @var int - */ - public const DEPRECATE_CREATE_FUNCTION = PhpVersion::PHP_72; + public const int DEPRECATE_CREATE_FUNCTION = PhpVersion::PHP_72; - /** - * @var int - */ - public const NO_NULL_ON_GET_CLASS = PhpVersion::PHP_72; + public const int NO_NULL_ON_GET_CLASS = PhpVersion::PHP_72; - /** - * @var int - */ - public const INVERTED_BOOL_IS_OBJECT_INCOMPLETE_CLASS = PhpVersion::PHP_72; + public const int INVERTED_BOOL_IS_OBJECT_INCOMPLETE_CLASS = PhpVersion::PHP_72; - /** - * @var int - */ - public const RESULT_ARG_IN_PARSE_STR = PhpVersion::PHP_72; + public const int RESULT_ARG_IN_PARSE_STR = PhpVersion::PHP_72; - /** - * @var int - */ - public const STRING_IN_FIRST_DEFINE_ARG = PhpVersion::PHP_72; + public const int STRING_IN_FIRST_DEFINE_ARG = PhpVersion::PHP_72; - /** - * @var int - */ - public const STRING_IN_ASSERT_ARG = PhpVersion::PHP_72; + public const int STRING_IN_ASSERT_ARG = PhpVersion::PHP_72; - /** - * @var int - */ - public const NO_UNSET_CAST = PhpVersion::PHP_72; + public const int NO_UNSET_CAST = PhpVersion::PHP_72; - /** - * @var int - */ - public const IS_COUNTABLE = PhpVersion::PHP_73; + public const int IS_COUNTABLE = PhpVersion::PHP_73; - /** - * @var int - */ - public const ARRAY_KEY_FIRST_LAST = PhpVersion::PHP_73; + public const int ARRAY_KEY_FIRST_LAST = PhpVersion::PHP_73; /** - * @var int * @see https://php.watch/versions/8.5/array_first-array_last */ - public const ARRAY_FIRST_LAST = PhpVersion::PHP_85; + public const int ARRAY_FIRST_LAST = PhpVersion::PHP_85; - /** - * @var int - */ - public const JSON_EXCEPTION = PhpVersion::PHP_73; + public const int JSON_EXCEPTION = PhpVersion::PHP_73; - /** - * @var int - */ - public const SETCOOKIE_ACCEPT_ARRAY_OPTIONS = PhpVersion::PHP_73; + public const int SETCOOKIE_ACCEPT_ARRAY_OPTIONS = PhpVersion::PHP_73; - /** - * @var int - */ - public const DEPRECATE_INSENSITIVE_CONSTANT_NAME = PhpVersion::PHP_73; + public const int DEPRECATE_INSENSITIVE_CONSTANT_NAME = PhpVersion::PHP_73; - /** - * @var int - */ - public const ESCAPE_DASH_IN_REGEX = PhpVersion::PHP_73; + public const int ESCAPE_DASH_IN_REGEX = PhpVersion::PHP_73; - /** - * @var int - */ - public const DEPRECATE_INSENSITIVE_CONSTANT_DEFINE = PhpVersion::PHP_73; + public const int DEPRECATE_INSENSITIVE_CONSTANT_DEFINE = PhpVersion::PHP_73; - /** - * @var int - */ - public const DEPRECATE_INT_IN_STR_NEEDLES = PhpVersion::PHP_73; + public const int DEPRECATE_INT_IN_STR_NEEDLES = PhpVersion::PHP_73; - /** - * @var int - */ - public const SENSITIVE_HERE_NOW_DOC = PhpVersion::PHP_73; + public const int SENSITIVE_HERE_NOW_DOC = PhpVersion::PHP_73; - /** - * @var int - */ - public const ARROW_FUNCTION = PhpVersion::PHP_74; + public const int ARROW_FUNCTION = PhpVersion::PHP_74; - /** - * @var int - */ - public const LITERAL_SEPARATOR = PhpVersion::PHP_74; + public const int LITERAL_SEPARATOR = PhpVersion::PHP_74; - /** - * @var int - */ - public const NULL_COALESCE_ASSIGN = PhpVersion::PHP_74; + public const int NULL_COALESCE_ASSIGN = PhpVersion::PHP_74; - /** - * @var int - */ - public const TYPED_PROPERTIES = PhpVersion::PHP_74; + public const int TYPED_PROPERTIES = PhpVersion::PHP_74; /** * @see https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters - * @var int */ - public const COVARIANT_RETURN = PhpVersion::PHP_74; + public const int COVARIANT_RETURN = PhpVersion::PHP_74; - /** - * @var int - */ - public const ARRAY_SPREAD = PhpVersion::PHP_74; + public const int ARRAY_SPREAD = PhpVersion::PHP_74; - /** - * @var int - */ - public const DEPRECATE_CURLY_BRACKET_ARRAY_STRING = PhpVersion::PHP_74; + public const int DEPRECATE_CURLY_BRACKET_ARRAY_STRING = PhpVersion::PHP_74; - /** - * @var int - */ - public const DEPRECATE_REAL = PhpVersion::PHP_74; + public const int DEPRECATE_REAL = PhpVersion::PHP_74; - /** - * @var int - */ - public const DEPRECATE_MONEY_FORMAT = PhpVersion::PHP_74; + public const int DEPRECATE_MONEY_FORMAT = PhpVersion::PHP_74; - /** - * @var int - */ - public const ARRAY_KEY_EXISTS_TO_PROPERTY_EXISTS = PhpVersion::PHP_74; + public const int ARRAY_KEY_EXISTS_TO_PROPERTY_EXISTS = PhpVersion::PHP_74; - /** - * @var int - */ - public const FILTER_VAR_TO_ADD_SLASHES = PhpVersion::PHP_74; + public const int FILTER_VAR_TO_ADD_SLASHES = PhpVersion::PHP_74; - /** - * @var int - */ - public const CHANGE_MB_STRPOS_ARG_POSITION = PhpVersion::PHP_74; + public const int CHANGE_MB_STRPOS_ARG_POSITION = PhpVersion::PHP_74; - /** - * @var int - */ - public const RESERVED_FN_FUNCTION_NAME = PhpVersion::PHP_74; + public const int RESERVED_FN_FUNCTION_NAME = PhpVersion::PHP_74; - /** - * @var int - */ - public const REFLECTION_TYPE_GETNAME = PhpVersion::PHP_74; + public const int REFLECTION_TYPE_GETNAME = PhpVersion::PHP_74; - /** - * @var int - */ - public const EXPORT_TO_REFLECTION_FUNCTION = PhpVersion::PHP_74; + public const int EXPORT_TO_REFLECTION_FUNCTION = PhpVersion::PHP_74; - /** - * @var int - */ - public const DEPRECATE_NESTED_TERNARY = PhpVersion::PHP_74; + public const int DEPRECATE_NESTED_TERNARY = PhpVersion::PHP_74; - /** - * @var int - */ - public const DEPRECATE_RESTORE_INCLUDE_PATH = PhpVersion::PHP_74; + public const int DEPRECATE_RESTORE_INCLUDE_PATH = PhpVersion::PHP_74; - /** - * @var int - */ - public const DEPRECATE_HEBREVC = PhpVersion::PHP_74; + public const int DEPRECATE_HEBREVC = PhpVersion::PHP_74; - /** - * @var int - */ - public const UNION_TYPES = PhpVersion::PHP_80; + public const int UNION_TYPES = PhpVersion::PHP_80; - /** - * @var int - */ - public const CLASS_ON_OBJECT = PhpVersion::PHP_80; + public const int CLASS_ON_OBJECT = PhpVersion::PHP_80; - /** - * @var int - */ - public const STATIC_RETURN_TYPE = PhpVersion::PHP_80; + public const int STATIC_RETURN_TYPE = PhpVersion::PHP_80; - /** - * @var int - */ - public const NO_FINAL_PRIVATE = PhpVersion::PHP_80; + public const int NO_FINAL_PRIVATE = PhpVersion::PHP_80; - /** - * @var int - */ - public const DEPRECATE_REQUIRED_PARAMETER_AFTER_OPTIONAL = PhpVersion::PHP_80; + public const int DEPRECATE_REQUIRED_PARAMETER_AFTER_OPTIONAL = PhpVersion::PHP_80; - /** - * @var int - */ - public const STATIC_VISIBILITY_SET_STATE = PhpVersion::PHP_80; + public const int STATIC_VISIBILITY_SET_STATE = PhpVersion::PHP_80; - /** - * @var int - */ - public const NULLSAFE_OPERATOR = PhpVersion::PHP_80; + public const int NULLSAFE_OPERATOR = PhpVersion::PHP_80; - /** - * @var int - */ - public const IS_ITERABLE = PhpVersion::PHP_71; + public const int IS_ITERABLE = PhpVersion::PHP_71; - /** - * @var int - */ - public const NULLABLE_TYPE = PhpVersion::PHP_71; + public const int NULLABLE_TYPE = PhpVersion::PHP_71; - /** - * @var int - */ - public const PARENT_VISIBILITY_OVERRIDE = PhpVersion::PHP_72; + public const int PARENT_VISIBILITY_OVERRIDE = PhpVersion::PHP_72; - /** - * @var int - */ - public const COUNT_ON_NULL = PhpVersion::PHP_71; + public const int COUNT_ON_NULL = PhpVersion::PHP_71; /** * @see https://wiki.php.net/rfc/constructor_promotion - * @var int */ - public const PROPERTY_PROMOTION = PhpVersion::PHP_80; + public const int PROPERTY_PROMOTION = PhpVersion::PHP_80; /** * @see https://wiki.php.net/rfc/attributes_v2 - * @var int */ - public const ATTRIBUTES = PhpVersion::PHP_80; + public const int ATTRIBUTES = PhpVersion::PHP_80; - /** - * @var int - */ - public const STRINGABLE = PhpVersion::PHP_80; + public const int STRINGABLE = PhpVersion::PHP_80; - /** - * @var int - */ - public const PHP_TOKEN = PhpVersion::PHP_80; + public const int PHP_TOKEN = PhpVersion::PHP_80; - /** - * @var int - */ - public const STR_ENDS_WITH = PhpVersion::PHP_80; + public const int STR_ENDS_WITH = PhpVersion::PHP_80; - /** - * @var int - */ - public const STR_STARTS_WITH = PhpVersion::PHP_80; + public const int STR_STARTS_WITH = PhpVersion::PHP_80; - /** - * @var int - */ - public const STR_CONTAINS = PhpVersion::PHP_80; + public const int STR_CONTAINS = PhpVersion::PHP_80; - /** - * @var int - */ - public const GET_DEBUG_TYPE = PhpVersion::PHP_80; + public const int GET_DEBUG_TYPE = PhpVersion::PHP_80; /** * @see https://wiki.php.net/rfc/noreturn_type - * @var int */ - public const NEVER_TYPE = PhpVersion::PHP_81; + public const int NEVER_TYPE = PhpVersion::PHP_81; /** * @see https://wiki.php.net/rfc/variadics - * @var int */ - public const VARIADIC_PARAM = PhpVersion::PHP_56; + public const int VARIADIC_PARAM = PhpVersion::PHP_56; /** * @see https://wiki.php.net/rfc/readonly_and_immutable_properties - * @var int */ - public const READONLY_PROPERTY = PhpVersion::PHP_81; + public const int READONLY_PROPERTY = PhpVersion::PHP_81; /** * @see https://wiki.php.net/rfc/final_class_const - * @var int */ - public const FINAL_CLASS_CONSTANTS = PhpVersion::PHP_81; + public const int FINAL_CLASS_CONSTANTS = PhpVersion::PHP_81; /** * @see https://wiki.php.net/rfc/enumerations - * @var int */ - public const ENUM = PhpVersion::PHP_81; + public const int ENUM = PhpVersion::PHP_81; /** * @see https://wiki.php.net/rfc/match_expression_v2 - * @var int */ - public const MATCH_EXPRESSION = PhpVersion::PHP_80; + public const int MATCH_EXPRESSION = PhpVersion::PHP_80; /** * @see https://wiki.php.net/rfc/non-capturing_catches - * @var int */ - public const NON_CAPTURING_CATCH = PhpVersion::PHP_80; + public const int NON_CAPTURING_CATCH = PhpVersion::PHP_80; /** * @see https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.resource2object - * @var int */ - public const PHP8_RESOURCE_TO_OBJECT = PhpVersion::PHP_80; + public const int PHP8_RESOURCE_TO_OBJECT = PhpVersion::PHP_80; /** * @see https://wiki.php.net/rfc/lsp_errors - * @var int */ - public const FATAL_ERROR_ON_INCOMPATIBLE_METHOD_SIGNATURE = PhpVersion::PHP_80; + public const int FATAL_ERROR_ON_INCOMPATIBLE_METHOD_SIGNATURE = PhpVersion::PHP_80; /** * @see https://www.php.net/manual/en/migration81.incompatible.php#migration81.incompatible.resource2object - * @var int */ - public const PHP81_RESOURCE_TO_OBJECT = PhpVersion::PHP_81; + public const int PHP81_RESOURCE_TO_OBJECT = PhpVersion::PHP_81; /** * @see https://wiki.php.net/rfc/new_in_initializers - * @var int */ - public const NEW_INITIALIZERS = PhpVersion::PHP_81; + public const int NEW_INITIALIZERS = PhpVersion::PHP_81; /** * @see https://wiki.php.net/rfc/pure-intersection-types - * @var int */ - public const INTERSECTION_TYPES = PhpVersion::PHP_81; + public const int INTERSECTION_TYPES = PhpVersion::PHP_81; /** * @see https://php.watch/versions/8.2/dnf-types - * @var int */ - public const UNION_INTERSECTION_TYPES = PhpVersion::PHP_82; + public const int UNION_INTERSECTION_TYPES = PhpVersion::PHP_82; /** * @see https://wiki.php.net/rfc/array_unpacking_string_keys - * @var int */ - public const ARRAY_SPREAD_STRING_KEYS = PhpVersion::PHP_81; + public const int ARRAY_SPREAD_STRING_KEYS = PhpVersion::PHP_81; /** * @see https://wiki.php.net/rfc/internal_method_return_types - * @var int */ - public const RETURN_TYPE_WILL_CHANGE_ATTRIBUTE = PhpVersion::PHP_81; + public const int RETURN_TYPE_WILL_CHANGE_ATTRIBUTE = PhpVersion::PHP_81; /** * @see https://wiki.php.net/rfc/first_class_callable_syntax - * @var int */ - public const FIRST_CLASS_CALLABLE_SYNTAX = PhpVersion::PHP_81; + public const int FIRST_CLASS_CALLABLE_SYNTAX = PhpVersion::PHP_81; /** * @see https://wiki.php.net/rfc/deprecate_dynamic_properties - * @var int */ - public const DEPRECATE_DYNAMIC_PROPERTIES = PhpVersion::PHP_82; + public const int DEPRECATE_DYNAMIC_PROPERTIES = PhpVersion::PHP_82; /** * @see https://wiki.php.net/rfc/readonly_classes - * @var int */ - public const READONLY_CLASS = PhpVersion::PHP_82; + public const int READONLY_CLASS = PhpVersion::PHP_82; /** * @see https://www.php.net/manual/en/migration83.new-features.php#migration83.new-features.core.readonly-modifier-improvements - * @var int */ - public const READONLY_ANONYMOUS_CLASS = PhpVersion::PHP_83; + public const int READONLY_ANONYMOUS_CLASS = PhpVersion::PHP_83; /** - * @var int * @see https://wiki.php.net/rfc/json_validate */ - public const JSON_VALIDATE = PhpVersion::PHP_83; + public const int JSON_VALIDATE = PhpVersion::PHP_83; /** * @see https://wiki.php.net/rfc/mixed_type_v2 - * @var int */ - public const MIXED_TYPE = PhpVersion::PHP_80; + public const int MIXED_TYPE = PhpVersion::PHP_80; /** * @see https://3v4l.org/OWtO5 - * @var int */ - public const ARRAY_ON_ARRAY_MERGE = PhpVersion::PHP_80; + public const int ARRAY_ON_ARRAY_MERGE = PhpVersion::PHP_80; - /** - * @var int - */ - public const DEPRECATE_NULL_ARG_IN_STRING_FUNCTION = PhpVersion::PHP_81; + public const int DEPRECATE_NULL_ARG_IN_STRING_FUNCTION = PhpVersion::PHP_81; /** * @see https://wiki.php.net/rfc/remove_utf8_decode_and_utf8_encode - * @var int */ - public const DEPRECATE_UTF8_DECODE_ENCODE_FUNCTION = PhpVersion::PHP_82; + public const int DEPRECATE_UTF8_DECODE_ENCODE_FUNCTION = PhpVersion::PHP_82; /** * @see https://www.php.net/manual/en/filesystemiterator.construct - * @var int */ - public const FILESYSTEM_ITERATOR_SKIP_DOTS = PhpVersion::PHP_82; + public const int FILESYSTEM_ITERATOR_SKIP_DOTS = PhpVersion::PHP_82; /** * @see https://wiki.php.net/rfc/null-false-standalone-types * @see https://wiki.php.net/rfc/true-type - * - * @var int */ - public const NULL_FALSE_TRUE_STANDALONE_TYPE = PhpVersion::PHP_82; + public const int NULL_FALSE_TRUE_STANDALONE_TYPE = PhpVersion::PHP_82; /** * @see https://wiki.php.net/rfc/redact_parameters_in_back_traces - * @var int */ - public const SENSITIVE_PARAMETER_ATTRIBUTE = PhpVersion::PHP_82; + public const int SENSITIVE_PARAMETER_ATTRIBUTE = PhpVersion::PHP_82; /** * @see https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation - * @var int */ - public const DEPRECATE_VARIABLE_IN_STRING_INTERPOLATION = PhpVersion::PHP_82; + public const int DEPRECATE_VARIABLE_IN_STRING_INTERPOLATION = PhpVersion::PHP_82; /** * @see https://wiki.php.net/rfc/marking_overriden_methods - * @var int */ - public const OVERRIDE_ATTRIBUTE = PhpVersion::PHP_83; + public const int OVERRIDE_ATTRIBUTE = PhpVersion::PHP_83; /** * @see https://wiki.php.net/rfc/typed_class_constants - * @var int */ - public const TYPED_CLASS_CONSTANTS = PhpVersion::PHP_83; + public const int TYPED_CLASS_CONSTANTS = PhpVersion::PHP_83; /** * @see https://wiki.php.net/rfc/dynamic_class_constant_fetch - * @var int */ - public const DYNAMIC_CLASS_CONST_FETCH = PhpVersion::PHP_83; + public const int DYNAMIC_CLASS_CONST_FETCH = PhpVersion::PHP_83; /** * @see https://wiki.php.net/rfc/deprecate-implicitly-nullable-types - * @var int */ - public const DEPRECATE_IMPLICIT_NULLABLE_PARAM_TYPE = PhpVersion::PHP_84; + public const int DEPRECATE_IMPLICIT_NULLABLE_PARAM_TYPE = PhpVersion::PHP_84; /** * @see https://wiki.php.net/rfc/new_without_parentheses - * @var int */ - public const NEW_METHOD_CALL_WITHOUT_PARENTHESES = PhpVersion::PHP_84; + public const int NEW_METHOD_CALL_WITHOUT_PARENTHESES = PhpVersion::PHP_84; /** * @see https://wiki.php.net/rfc/correctly_name_the_rounding_mode_and_make_it_an_enum - * @var int */ - public const ROUNDING_MODES = PhpVersion::PHP_84; + public const int ROUNDING_MODES = PhpVersion::PHP_84; /** * @see https://php.watch/versions/8.4/csv-functions-escape-parameter - * @var int */ - public const REQUIRED_ESCAPE_PARAMETER = PhpVersion::PHP_84; + public const int REQUIRED_ESCAPE_PARAMETER = PhpVersion::PHP_84; /** * @see https://www.php.net/manual/en/migration83.deprecated.php#migration83.deprecated.ldap - * @var int */ - public const DEPRECATE_HOST_PORT_SEPARATE_ARGS = PhpVersion::PHP_83; + public const int DEPRECATE_HOST_PORT_SEPARATE_ARGS = PhpVersion::PHP_83; /** * @see https://www.php.net/manual/en/migration83.deprecated.php#migration83.deprecated.core.get-class * @see https://php.watch/versions/8.3/get_class-get_parent_class-parameterless-deprecated - * @var int */ - public const DEPRECATE_GET_CLASS_WITHOUT_ARGS = PhpVersion::PHP_83; + public const int DEPRECATE_GET_CLASS_WITHOUT_ARGS = PhpVersion::PHP_83; /** * @see https://wiki.php.net/rfc/deprecated_attribute - * @var int */ - public const DEPRECATED_ATTRIBUTE = PhpVersion::PHP_84; + public const int DEPRECATED_ATTRIBUTE = PhpVersion::PHP_84; /** * @see https://php.watch/versions/8.4/array_find-array_find_key-array_any-array_all - * @var int */ - public const ARRAY_FIND = PhpVersion::PHP_84; + public const int ARRAY_FIND = PhpVersion::PHP_84; /** * @see https://php.watch/versions/8.4/array_find-array_find_key-array_any-array_all - * @var int */ - public const ARRAY_FIND_KEY = PhpVersion::PHP_84; + public const int ARRAY_FIND_KEY = PhpVersion::PHP_84; /** * @see https://php.watch/versions/8.4/array_find-array_find_key-array_any-array_all - * @var int */ - public const ARRAY_ALL = PhpVersion::PHP_84; + public const int ARRAY_ALL = PhpVersion::PHP_84; /** * @see https://php.watch/versions/8.4/array_find-array_find_key-array_any-array_all - * @var int */ - public const ARRAY_ANY = PhpVersion::PHP_84; + public const int ARRAY_ANY = PhpVersion::PHP_84; /** * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_context_parameter_for_finfo_buffer - * @var int */ - public const DEPRECATE_FINFO_BUFFER_CONTEXT = PhpVersion::PHP_85; + public const int DEPRECATE_FINFO_BUFFER_CONTEXT = PhpVersion::PHP_85; /** * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_debuginfo_returning_null - * @var int */ - public const DEPRECATED_NULL_DEBUG_INFO_RETURN = PhpVersion::PHP_85; + public const int DEPRECATED_NULL_DEBUG_INFO_RETURN = PhpVersion::PHP_85; /** * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_semicolon_after_case_in_switch_statement - * @var int */ - public const COLON_AFTER_SWITCH_CASE = PhpVersion::PHP_85; + public const int COLON_AFTER_SWITCH_CASE = PhpVersion::PHP_85; /** * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_using_values_null_as_an_array_offset_and_when_calling_array_key_exists - * @var int */ - public const DEPRECATE_NULL_ARG_IN_ARRAY_KEY_EXISTS_FUNCTION = PhpVersion::PHP_85; + public const int DEPRECATE_NULL_ARG_IN_ARRAY_KEY_EXISTS_FUNCTION = PhpVersion::PHP_85; /** * @see https://wiki.php.net/rfc/deprecations_php_8_5#eprecate_passing_integers_outside_the_interval_0_255_to_chr - * @var int */ - public const DEPRECATE_OUTSIDE_INTERVEL_VAL_IN_CHR_FUNCTION = PhpVersion::PHP_85; + public const int DEPRECATE_OUTSIDE_INTERVEL_VAL_IN_CHR_FUNCTION = PhpVersion::PHP_85; /** * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_sleep_and_wakeup_magic_methods - * @var int */ - public const DEPRECATED_METHOD_SLEEP = PhpVersion::PHP_85; + public const int DEPRECATED_METHOD_SLEEP = PhpVersion::PHP_85; /** * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_sleep_and_wakeup_magic_methods - * @var int */ - public const DEPRECATED_METHOD_WAKEUP = PhpVersion::PHP_85; + public const int DEPRECATED_METHOD_WAKEUP = PhpVersion::PHP_85; /** * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_string_which_are_not_one_byte_long_to_ord - * @var int */ - public const DEPRECATE_ORD_WITH_MULTIBYTE_STRING = PhpVersion::PHP_85; + public const int DEPRECATE_ORD_WITH_MULTIBYTE_STRING = PhpVersion::PHP_85; /** * @see https://wiki.php.net/rfc/property-hooks - * @var int */ - public const PROPERTY_HOOKS = PhpVersion::PHP_84; + public const int PROPERTY_HOOKS = PhpVersion::PHP_84; /** * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_backticks_as_an_alias_for_shell_exec - * @var int */ - public const DEPRECATE_BACKTICKS = PhpVersion::PHP_85; + public const int DEPRECATE_BACKTICKS = PhpVersion::PHP_85; /** * @see https://wiki.php.net/rfc/pipe-operator-v3 - * @var int */ - public const PIPE_OPERATOER = PhpVersion::PHP_85; + public const int PIPE_OPERATOER = PhpVersion::PHP_85; } diff --git a/src/ValueObject/PolyfillPackage.php b/src/ValueObject/PolyfillPackage.php index a3772b256ab..4e085e15761 100644 --- a/src/ValueObject/PolyfillPackage.php +++ b/src/ValueObject/PolyfillPackage.php @@ -9,18 +9,9 @@ */ final class PolyfillPackage { - /** - * @var string - */ - public const PHP_83 = 'symfony/polyfill-php83'; + public const string PHP_83 = 'symfony/polyfill-php83'; - /** - * @var string - */ - public const PHP_80 = 'symfony/polyfill-php80'; + public const string PHP_80 = 'symfony/polyfill-php80'; - /** - * @var string - */ - public const PHP_73 = 'symfony/polyfill-php73'; + public const string PHP_73 = 'symfony/polyfill-php73'; } diff --git a/src/ValueObject/Reporting/FileDiff.php b/src/ValueObject/Reporting/FileDiff.php index 5ff6dbc33ab..cac1ec6978b 100644 --- a/src/ValueObject/Reporting/FileDiff.php +++ b/src/ValueObject/Reporting/FileDiff.php @@ -18,18 +18,14 @@ final readonly class FileDiff implements SerializableInterface { /** - * @var string * @see https://en.wikipedia.org/wiki/Diff#Unified_format * @see https://regex101.com/r/AUPIX4/2 */ - private const DIFF_HUNK_HEADER_REGEX = '#@@(.*?)(?<' . self::FIRST_LINE_KEY . '>\d+)(,(?<' . self::LINE_RANGE_KEY . '>\d+))?(.*?)@@#'; + private const string DIFF_HUNK_HEADER_REGEX = '#@@(.*?)(?<' . self::FIRST_LINE_KEY . '>\d+)(,(?<' . self::LINE_RANGE_KEY . '>\d+))?(.*?)@@#'; - /** - * @var string - */ - private const FIRST_LINE_KEY = 'first_line'; + private const string FIRST_LINE_KEY = 'first_line'; - private const LINE_RANGE_KEY = 'line_range'; + private const string LINE_RANGE_KEY = 'line_range'; /** * @param RectorWithLineChange[] $rectorsWithLineChanges diff --git a/src/ValueObject/Visibility.php b/src/ValueObject/Visibility.php index 85b5458a6d2..38cf5c71f00 100644 --- a/src/ValueObject/Visibility.php +++ b/src/ValueObject/Visibility.php @@ -8,38 +8,17 @@ final class Visibility { - /** - * @var int - */ - public const PUBLIC = Modifiers::PUBLIC; - - /** - * @var int - */ - public const PROTECTED = Modifiers::PROTECTED; - - /** - * @var int - */ - public const PRIVATE = Modifiers::PRIVATE; - - /** - * @var int - */ - public const STATIC = Modifiers::STATIC; - - /** - * @var int - */ - public const ABSTRACT = Modifiers::ABSTRACT; - - /** - * @var int - */ - public const FINAL = Modifiers::FINAL; - - /** - * @var int - */ - public const READONLY = Modifiers::READONLY; + public const int PUBLIC = Modifiers::PUBLIC; + + public const int PROTECTED = Modifiers::PROTECTED; + + public const int PRIVATE = Modifiers::PRIVATE; + + public const int STATIC = Modifiers::STATIC; + + public const int ABSTRACT = Modifiers::ABSTRACT; + + public const int FINAL = Modifiers::FINAL; + + public const int READONLY = Modifiers::READONLY; } diff --git a/templates/rector-github-action-check.yaml b/templates/rector-github-action-check.yaml index 2606a4241bf..b315f3c0820 100644 --- a/templates/rector-github-action-check.yaml +++ b/templates/rector-github-action-check.yaml @@ -19,7 +19,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none - uses: "ramsey/composer-install@v3" diff --git a/templates/rector-gitlab-check.yaml b/templates/rector-gitlab-check.yaml index c622917b0d3..13674aac947 100644 --- a/templates/rector-gitlab-check.yaml +++ b/templates/rector-gitlab-check.yaml @@ -3,10 +3,14 @@ stages: - rector - commit_changes +default: + # see https://github.com/thecodingmachine/docker-images-php + image: thecodingmachine/php:8.3-v4-slim-cli + setup: stage: setup - # see https://github.com/thecodingmachine/docker-images-php - image: thecodingmachine/php:8.2-v4-slim-cli + script: + - php -v rector: stage: rector diff --git a/tests/BetterPhpDocParser/PhpDoc/ArrayItemNode/ArrayItemNodeTest.php b/tests/BetterPhpDocParser/PhpDoc/ArrayItemNode/ArrayItemNodeTest.php index 5899c3b4961..38081df04b1 100644 --- a/tests/BetterPhpDocParser/PhpDoc/ArrayItemNode/ArrayItemNodeTest.php +++ b/tests/BetterPhpDocParser/PhpDoc/ArrayItemNode/ArrayItemNodeTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\BetterPhpDocParser\PhpDoc\ArrayItemNode; use Nette\Utils\FileSystem as UtilsFileSystem; +use Override; use PhpParser\Node\Stmt\Class_; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; @@ -28,6 +29,7 @@ final class ArrayItemNodeTest extends AbstractLazyTestCase private NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php b/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php index fb93bd9d6fd..888eda99f79 100644 --- a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php +++ b/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Nette\Utils\FileSystem; +use Override; use PhpParser\Comment\Doc; use PhpParser\Node\Stmt\Nop; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode; @@ -24,6 +25,7 @@ final class PhpDocInfoTest extends AbstractLazyTestCase private DocBlockTagReplacer $docBlockTagReplacer; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfoPrinter/AbstractPhpDocInfoPrinterTestCase.php b/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfoPrinter/AbstractPhpDocInfoPrinterTestCase.php index 997b88b4c5c..6522c8a3389 100644 --- a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfoPrinter/AbstractPhpDocInfoPrinterTestCase.php +++ b/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfoPrinter/AbstractPhpDocInfoPrinterTestCase.php @@ -4,6 +4,7 @@ namespace Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfoPrinter; +use Override; use PhpParser\Comment\Doc; use PhpParser\Node; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; @@ -20,6 +21,7 @@ abstract class AbstractPhpDocInfoPrinterTestCase extends AbstractLazyTestCase private PhpDocInfoFactory $phpDocInfoFactory; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/BetterPhpDocParser/PhpDocNodeMapperTest.php b/tests/BetterPhpDocParser/PhpDocNodeMapperTest.php index fa0092472e7..eafc30bbb1b 100644 --- a/tests/BetterPhpDocParser/PhpDocNodeMapperTest.php +++ b/tests/BetterPhpDocParser/PhpDocNodeMapperTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\BetterPhpDocParser; +use Override; use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; @@ -17,6 +18,7 @@ final class PhpDocNodeMapperTest extends AbstractLazyTestCase { private PhpDocNodeMapper $phpDocNodeMapper; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/BetterPhpDocParser/PhpDocParser/ClassAnnotationMatcher/ResolveTagToKnownFullyQualifiedNameTest.php b/tests/BetterPhpDocParser/PhpDocParser/ClassAnnotationMatcher/ResolveTagToKnownFullyQualifiedNameTest.php index 3436b331692..7aacbd940c4 100644 --- a/tests/BetterPhpDocParser/PhpDocParser/ClassAnnotationMatcher/ResolveTagToKnownFullyQualifiedNameTest.php +++ b/tests/BetterPhpDocParser/PhpDocParser/ClassAnnotationMatcher/ResolveTagToKnownFullyQualifiedNameTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher; use Iterator; +use Override; use PhpParser\Node\Stmt\Property; use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; use PHPUnit\Framework\Attributes\DataProvider; @@ -30,6 +31,7 @@ final class ResolveTagToKnownFullyQualifiedNameTest extends AbstractLazyTestCase private NodeNameResolver $nodeNameResolver; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/ArrayParserTest.php b/tests/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/ArrayParserTest.php index bb3cbe47a77..13513fc61f2 100644 --- a/tests/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/ArrayParserTest.php +++ b/tests/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/ArrayParserTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser; use Iterator; +use Override; use PhpParser\Node\Scalar\String_; use PHPUnit\Framework\Attributes\DataProvider; use Rector\BetterPhpDocParser\PhpDoc\ArrayItemNode; @@ -19,6 +20,7 @@ final class ArrayParserTest extends AbstractLazyTestCase private TokenIteratorFactory $tokenIteratorFactory; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/StaticDoctrineAnnotationParserTest.php b/tests/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/StaticDoctrineAnnotationParserTest.php index fd7c40b3f7c..33fab928bba 100644 --- a/tests/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/StaticDoctrineAnnotationParserTest.php +++ b/tests/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/StaticDoctrineAnnotationParserTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser; use Iterator; +use Override; use PhpParser\Node\Scalar\String_; use PHPUnit\Framework\Attributes\DataProvider; use Rector\BetterPhpDocParser\PhpDoc\ArrayItemNode; @@ -20,6 +21,7 @@ final class StaticDoctrineAnnotationParserTest extends AbstractLazyTestCase private TokenIteratorFactory $tokenIteratorFactory; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TagValueNodeReprintTest.php b/tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TagValueNodeReprintTest.php index 7a3682a18ee..81a40936f9f 100644 --- a/tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TagValueNodeReprintTest.php +++ b/tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TagValueNodeReprintTest.php @@ -6,6 +6,7 @@ use Iterator; use Nette\Utils\FileSystem; +use Override; use PhpParser\Comment\Doc; use PhpParser\Node; use PHPUnit\Framework\Attributes\DataProvider; @@ -32,6 +33,7 @@ final class TagValueNodeReprintTest extends AbstractLazyTestCase private FilePathHelper $filePathHelper; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TestModifyReprintTest.php b/tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TestModifyReprintTest.php index 680bc8729bb..7a3e9b96e1d 100644 --- a/tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TestModifyReprintTest.php +++ b/tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TestModifyReprintTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\BetterPhpDocParser\PhpDocParser\TagValueNodeReprint; use Nette\Utils\FileSystem; +use Override; use PhpParser\Node; use PhpParser\Node\Stmt\ClassMethod; use Rector\BetterPhpDocParser\PhpDoc\ArrayItemNode; @@ -31,6 +32,7 @@ final class TestModifyReprintTest extends AbstractLazyTestCase private PhpDocInfoFactory $phpDocInfoFactory; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Caching/Config/FileHashComputer/FileHashComputerTest.php b/tests/Caching/Config/FileHashComputer/FileHashComputerTest.php index 2d06d77d60b..8f6dba5f09f 100644 --- a/tests/Caching/Config/FileHashComputer/FileHashComputerTest.php +++ b/tests/Caching/Config/FileHashComputer/FileHashComputerTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\Caching\Config\FileHashComputer; +use Override; use Rector\Caching\Config\FileHashComputer; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; @@ -13,6 +14,7 @@ final class FileHashComputerTest extends AbstractLazyTestCase { private FileHashComputer $fileHashComputer; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Caching/Detector/ChangedFilesDetectorTest.php b/tests/Caching/Detector/ChangedFilesDetectorTest.php index dfc95a3176a..51176480dd5 100644 --- a/tests/Caching/Detector/ChangedFilesDetectorTest.php +++ b/tests/Caching/Detector/ChangedFilesDetectorTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\Caching\Detector; +use Override; use Rector\Caching\Detector\ChangedFilesDetector; use Rector\Testing\PHPUnit\AbstractLazyTestCase; @@ -11,6 +12,7 @@ final class ChangedFilesDetectorTest extends AbstractLazyTestCase { private ChangedFilesDetector $changedFilesDetector; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Caching/ValueObject/Storage/FileCacheStorageTest.php b/tests/Caching/ValueObject/Storage/FileCacheStorageTest.php index bfb4281c216..f33d33e7b46 100644 --- a/tests/Caching/ValueObject/Storage/FileCacheStorageTest.php +++ b/tests/Caching/ValueObject/Storage/FileCacheStorageTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\Caching\ValueObject\Storage; +use Override; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use Rector\Caching\ValueObject\Storage\FileCacheStorage; use Rector\Testing\PHPUnit\AbstractLazyTestCase; @@ -13,6 +14,7 @@ final class FileCacheStorageTest extends AbstractLazyTestCase { private FileCacheStorage $fileCacheStorage; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Comments/CommentRemover/CommentRemoverTest.php b/tests/Comments/CommentRemover/CommentRemoverTest.php index eb5e857bbec..0a1b2f71b4c 100644 --- a/tests/Comments/CommentRemover/CommentRemoverTest.php +++ b/tests/Comments/CommentRemover/CommentRemoverTest.php @@ -6,6 +6,7 @@ use Iterator; use Nette\Utils\FileSystem; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use Rector\Comments\CommentRemover; use Rector\PhpParser\Printer\BetterStandardPrinter; @@ -23,6 +24,7 @@ final class CommentRemoverTest extends AbstractLazyTestCase private BetterStandardPrinter $betterStandardPrinter; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Configuration/OnlyRuleResolverTest.php b/tests/Configuration/OnlyRuleResolverTest.php index e835f8e0e3d..edd2c172831 100644 --- a/tests/Configuration/OnlyRuleResolverTest.php +++ b/tests/Configuration/OnlyRuleResolverTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\Configuration; +use Override; use Rector\Configuration\OnlyRuleResolver; use Rector\Contract\Rector\RectorInterface; use Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector; @@ -16,6 +17,7 @@ final class OnlyRuleResolverTest extends AbstractLazyTestCase { private OnlyRuleResolver $onlyRuleResolver; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/FileSystem/FilesFinder/FilesFinderTest.php b/tests/FileSystem/FilesFinder/FilesFinderTest.php index 419ef0c5d9e..df11205d1e6 100644 --- a/tests/FileSystem/FilesFinder/FilesFinderTest.php +++ b/tests/FileSystem/FilesFinder/FilesFinderTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\FileSystem\FilesFinder; use Iterator; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; @@ -15,6 +16,7 @@ final class FilesFinderTest extends AbstractLazyTestCase { private FilesFinder $filesFinder; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Naming/ExpectedNameResolver/InflectorSingularResolverTest.php b/tests/Naming/ExpectedNameResolver/InflectorSingularResolverTest.php index b3410dff31e..fac6b1be1ac 100644 --- a/tests/Naming/ExpectedNameResolver/InflectorSingularResolverTest.php +++ b/tests/Naming/ExpectedNameResolver/InflectorSingularResolverTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\Naming\ExpectedNameResolver; use Iterator; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use Rector\Naming\ExpectedNameResolver\InflectorSingularResolver; use Rector\Testing\PHPUnit\AbstractLazyTestCase; @@ -13,6 +14,7 @@ final class InflectorSingularResolverTest extends AbstractLazyTestCase { private InflectorSingularResolver $inflectorSingularResolver; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/NodeManipulator/ClassDependencyManipulatorTest.php b/tests/NodeManipulator/ClassDependencyManipulatorTest.php index 2d1a89942dc..d54b4a6e3b2 100644 --- a/tests/NodeManipulator/ClassDependencyManipulatorTest.php +++ b/tests/NodeManipulator/ClassDependencyManipulatorTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\NodeManipulator; +use Override; use PhpParser\Modifiers; use PhpParser\Node\Const_; use PhpParser\Node\Identifier; @@ -30,6 +31,7 @@ final class ClassDependencyManipulatorTest extends AbstractLazyTestCase private Standard $printerStandard; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/NodeTypeResolver/PerNodeTypeResolver/AbstractNodeTypeResolverTestCase.php b/tests/NodeTypeResolver/PerNodeTypeResolver/AbstractNodeTypeResolverTestCase.php index 501c4f04872..791d68b5bf9 100644 --- a/tests/NodeTypeResolver/PerNodeTypeResolver/AbstractNodeTypeResolverTestCase.php +++ b/tests/NodeTypeResolver/PerNodeTypeResolver/AbstractNodeTypeResolverTestCase.php @@ -4,6 +4,7 @@ namespace Rector\Tests\NodeTypeResolver\PerNodeTypeResolver; +use Override; use PhpParser\Node; use Rector\NodeTypeResolver\NodeTypeResolver; use Rector\PhpParser\Node\BetterNodeFinder; @@ -18,6 +19,7 @@ abstract class AbstractNodeTypeResolverTestCase extends AbstractLazyTestCase private TestingParser $testingParser; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/NodeTypeResolver/StaticTypeMapper/StaticTypeMapperTest.php b/tests/NodeTypeResolver/StaticTypeMapper/StaticTypeMapperTest.php index 9b48149da29..5624eeaf8d5 100644 --- a/tests/NodeTypeResolver/StaticTypeMapper/StaticTypeMapperTest.php +++ b/tests/NodeTypeResolver/StaticTypeMapper/StaticTypeMapperTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\NodeTypeResolver\StaticTypeMapper; use Iterator; +use Override; use PhpParser\Node; use PhpParser\Node\Identifier; use PhpParser\Node\Scalar\String_; @@ -24,6 +25,7 @@ final class StaticTypeMapperTest extends AbstractLazyTestCase { private StaticTypeMapper $staticTypeMapper; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/NodeTypeResolver/TypeComparator/ArrayTypeComparatorTest.php b/tests/NodeTypeResolver/TypeComparator/ArrayTypeComparatorTest.php index e921af6e436..c2d1a4c1602 100644 --- a/tests/NodeTypeResolver/TypeComparator/ArrayTypeComparatorTest.php +++ b/tests/NodeTypeResolver/TypeComparator/ArrayTypeComparatorTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\NodeTypeResolver\TypeComparator; +use Override; use PHPStan\Reflection\ReflectionProvider; use PHPStan\Type\ArrayType; use PHPStan\Type\ClassStringType; @@ -24,6 +25,7 @@ final class ArrayTypeComparatorTest extends AbstractLazyTestCase private ReflectionProvider $reflectionProvider; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/NodeTypeResolver/TypeComparator/ScalarTypeComparatorTest.php b/tests/NodeTypeResolver/TypeComparator/ScalarTypeComparatorTest.php index dc057d8aa16..fe566275811 100644 --- a/tests/NodeTypeResolver/TypeComparator/ScalarTypeComparatorTest.php +++ b/tests/NodeTypeResolver/TypeComparator/ScalarTypeComparatorTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\NodeTypeResolver\TypeComparator; use Iterator; +use Override; use PHPStan\Type\BooleanType; use PHPStan\Type\ClassStringType; use PHPStan\Type\IntegerRangeType; @@ -19,6 +20,7 @@ final class ScalarTypeComparatorTest extends AbstractLazyTestCase { private ScalarTypeComparator $scalarTypeComparator; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapperTest.php b/tests/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapperTest.php index 32226689504..559a3b56346 100644 --- a/tests/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapperTest.php +++ b/tests/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapperTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\PHPStanStaticTypeMapper\TypeMapper; use Iterator; +use Override; use PHPStan\Type\ArrayType; use PHPStan\Type\IntegerType; use PHPStan\Type\MixedType; @@ -18,6 +19,7 @@ final class ArrayTypeMapperTest extends AbstractLazyTestCase { private ArrayTypeMapper $arrayTypeMapper; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Parallel/Command/WorkerCommandLineFactoryTest.php b/tests/Parallel/Command/WorkerCommandLineFactoryTest.php index 0e818e8d0c9..e51c09903cb 100644 --- a/tests/Parallel/Command/WorkerCommandLineFactoryTest.php +++ b/tests/Parallel/Command/WorkerCommandLineFactoryTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\Parallel\Command; use Iterator; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use Rector\ChangesReporting\Output\ConsoleOutputFormatter; use Rector\Configuration\Option; @@ -17,25 +18,17 @@ final class WorkerCommandLineFactoryTest extends AbstractLazyTestCase { - /** - * @var string - */ - private const COMMAND = 'command'; + private const string COMMAND = 'command'; - /** - * @var string - */ - private const DUMMY_MAIN_SCRIPT = 'main_script'; + private const string DUMMY_MAIN_SCRIPT = 'main_script'; - /** - * @var string - */ - private const SPACED_DUMMY_MAIN_SCRIPT = 'C:\Users\P\Desktop\Web Dev\vendor\bin\rector'; + private const string SPACED_DUMMY_MAIN_SCRIPT = 'C:\Users\P\Desktop\Web Dev\vendor\bin\rector'; private WorkerCommandLineFactory $workerCommandLineFactory; private ProcessCommand $processCommand; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpAttribute/AnnotationToAttributeMapper/AnnotationToAttributeMapperTest.php b/tests/PhpAttribute/AnnotationToAttributeMapper/AnnotationToAttributeMapperTest.php index 387002ee8fc..6dc5b11d2c0 100644 --- a/tests/PhpAttribute/AnnotationToAttributeMapper/AnnotationToAttributeMapperTest.php +++ b/tests/PhpAttribute/AnnotationToAttributeMapper/AnnotationToAttributeMapperTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\PhpAttribute\AnnotationToAttributeMapper; use Iterator; +use Override; use PhpParser\Node\ArrayItem; use PhpParser\Node\Expr; use PhpParser\Node\Expr\Array_; @@ -19,6 +20,7 @@ final class AnnotationToAttributeMapperTest extends AbstractLazyTestCase { private AnnotationToAttributeMapper $annotationToAttributeMapper; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpAttribute/Printer/PhpAttributeGroupFactoryTest.php b/tests/PhpAttribute/Printer/PhpAttributeGroupFactoryTest.php index c6f9df331a8..a81108b63c9 100644 --- a/tests/PhpAttribute/Printer/PhpAttributeGroupFactoryTest.php +++ b/tests/PhpAttribute/Printer/PhpAttributeGroupFactoryTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\PhpAttribute\Printer; +use Override; use PhpParser\Node\Arg; use PhpParser\Node\AttributeGroup; use Rector\BetterPhpDocParser\PhpDoc\ArrayItemNode; @@ -15,6 +16,7 @@ final class PhpAttributeGroupFactoryTest extends AbstractLazyTestCase { private PhpAttributeGroupFactory $phpAttributeGroupFactory; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpAttribute/UseAliasNameMatcherTest.php b/tests/PhpAttribute/UseAliasNameMatcherTest.php index cdf15e3f348..8d345a0d746 100644 --- a/tests/PhpAttribute/UseAliasNameMatcherTest.php +++ b/tests/PhpAttribute/UseAliasNameMatcherTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\PhpAttribute; use Iterator; +use Override; use PhpParser\Node\Name; use PhpParser\Node\Stmt\Use_; use PhpParser\Node\UseItem; @@ -23,6 +24,7 @@ final class UseAliasNameMatcherTest extends AbstractLazyTestCase { private UseAliasNameMatcher $useAliasNameMatcher; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpDocParser/PhpDocParser/PhpDocNodeVisitor/ParentConnectingPhpDocNodeVisitorTest.php b/tests/PhpDocParser/PhpDocParser/PhpDocNodeVisitor/ParentConnectingPhpDocNodeVisitorTest.php index 58455673c1b..e40abc7a601 100644 --- a/tests/PhpDocParser/PhpDocParser/PhpDocNodeVisitor/ParentConnectingPhpDocNodeVisitorTest.php +++ b/tests/PhpDocParser/PhpDocParser/PhpDocNodeVisitor/ParentConnectingPhpDocNodeVisitorTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\PhpDocParser\PhpDocParser\PhpDocNodeVisitor; +use Override; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode; @@ -18,6 +19,7 @@ final class ParentConnectingPhpDocNodeVisitorTest extends AbstractLazyTestCase { private PhpDocNodeTraverser $phpDocNodeTraverser; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpDocParser/PhpDocParser/SimplePhpDocNodeTraverser/PhpDocNodeTraverserTest.php b/tests/PhpDocParser/PhpDocParser/SimplePhpDocNodeTraverser/PhpDocNodeTraverserTest.php index 76267e8ccca..80eca819c73 100644 --- a/tests/PhpDocParser/PhpDocParser/SimplePhpDocNodeTraverser/PhpDocNodeTraverserTest.php +++ b/tests/PhpDocParser/PhpDocParser/SimplePhpDocNodeTraverser/PhpDocNodeTraverserTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\PhpDocParser\PhpDocParser\SimplePhpDocNodeTraverser; +use Override; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; @@ -14,13 +15,11 @@ final class PhpDocNodeTraverserTest extends AbstractLazyTestCase { - /** - * @var string - */ - private const SOME_DESCRIPTION = 'some description'; + private const string SOME_DESCRIPTION = 'some description'; private PhpDocNodeTraverser $phpDocNodeTraverser; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpParser/Node/BetterNodeFinder/BetterNodeFinderTest.php b/tests/PhpParser/Node/BetterNodeFinder/BetterNodeFinderTest.php index afb4a42cb95..8c6344cadc1 100644 --- a/tests/PhpParser/Node/BetterNodeFinder/BetterNodeFinderTest.php +++ b/tests/PhpParser/Node/BetterNodeFinder/BetterNodeFinderTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\PhpParser\Node\BetterNodeFinder; +use Override; use PhpParser\Node; use PhpParser\Node\Expr\Variable; use PhpParser\Node\Stmt\Class_; @@ -20,6 +21,7 @@ final class BetterNodeFinderTest extends AbstractLazyTestCase private BetterNodeFinder $betterNodeFinder; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpParser/Node/NodeFactoryTest.php b/tests/PhpParser/Node/NodeFactoryTest.php index 6b7a40d821e..df5bbafc1d1 100644 --- a/tests/PhpParser/Node/NodeFactoryTest.php +++ b/tests/PhpParser/Node/NodeFactoryTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\PhpParser\Node; use Iterator; +use Override; use PhpParser\Node\ArrayItem; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\ConstFetch; @@ -19,6 +20,7 @@ final class NodeFactoryTest extends AbstractLazyTestCase { private NodeFactory $nodeFactory; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpParser/Node/Value/ValueResolverTest.php b/tests/PhpParser/Node/Value/ValueResolverTest.php index 7b7e72d6b7d..a6a255a354f 100644 --- a/tests/PhpParser/Node/Value/ValueResolverTest.php +++ b/tests/PhpParser/Node/Value/ValueResolverTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\PhpParser\Node\Value; use Iterator; +use Override; use PhpParser\BuilderFactory; use PhpParser\Node\Expr; use PhpParser\Node\Expr\BinaryOp\Plus; @@ -17,6 +18,7 @@ final class ValueResolverTest extends AbstractLazyTestCase { private ValueResolver $valueResolver; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpParser/NodeTraverser/RectorNodeTraverserTest.php b/tests/PhpParser/NodeTraverser/RectorNodeTraverserTest.php index d7e9208ae7d..92cec45558e 100644 --- a/tests/PhpParser/NodeTraverser/RectorNodeTraverserTest.php +++ b/tests/PhpParser/NodeTraverser/RectorNodeTraverserTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\PhpParser\NodeTraverser; +use Override; use PhpParser\Node\Stmt\Class_; use Rector\PhpParser\NodeTraverser\RectorNodeTraverser; use Rector\Testing\PHPUnit\AbstractLazyTestCase; @@ -24,6 +25,7 @@ final class RectorNodeTraverserTest extends AbstractLazyTestCase private RuleUsingClassLikeRector $ruleUsingClassLikeRector; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpParser/NodeTraverser/StopTraverseOnTypeChange/StopTraverseOnTypeChangeTest.php b/tests/PhpParser/NodeTraverser/StopTraverseOnTypeChange/StopTraverseOnTypeChangeTest.php index 53a63257e28..280e3058fbe 100644 --- a/tests/PhpParser/NodeTraverser/StopTraverseOnTypeChange/StopTraverseOnTypeChangeTest.php +++ b/tests/PhpParser/NodeTraverser/StopTraverseOnTypeChange/StopTraverseOnTypeChangeTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\PhpParser\NodeTraverser\StopTraverseOnTypeChange; +use Override; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Trait_; use PhpParser\NodeFinder; @@ -19,6 +20,7 @@ final class StopTraverseOnTypeChangeTest extends AbstractLazyTestCase private TestingParser $testingParser; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpParser/Printer/BetterStandardPrinterTest.php b/tests/PhpParser/Printer/BetterStandardPrinterTest.php index 4a75bc516a3..5ada086e937 100644 --- a/tests/PhpParser/Printer/BetterStandardPrinterTest.php +++ b/tests/PhpParser/Printer/BetterStandardPrinterTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\PhpParser\Printer; use Iterator; +use Override; use PhpParser\Comment; use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; @@ -22,6 +23,7 @@ final class BetterStandardPrinterTest extends AbstractLazyTestCase { private BetterStandardPrinter $betterStandardPrinter; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Skipper/FileSystem/FnMatchPathNormalizerTest.php b/tests/Skipper/FileSystem/FnMatchPathNormalizerTest.php index 1e176a58ae2..3472e48cfc0 100644 --- a/tests/Skipper/FileSystem/FnMatchPathNormalizerTest.php +++ b/tests/Skipper/FileSystem/FnMatchPathNormalizerTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\Skipper\FileSystem; use Iterator; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use Rector\Skipper\FileSystem\FnMatchPathNormalizer; use Rector\Skipper\FileSystem\PathNormalizer; @@ -14,6 +15,7 @@ final class FnMatchPathNormalizerTest extends AbstractLazyTestCase { private FnMatchPathNormalizer $fnMatchPathNormalizer; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Skipper/SkipCriteriaResolver/SkippedPathsResolver/SkippedPathsResolverTest.php b/tests/Skipper/SkipCriteriaResolver/SkippedPathsResolver/SkippedPathsResolverTest.php index a284e17514b..d7e2bfbac35 100644 --- a/tests/Skipper/SkipCriteriaResolver/SkippedPathsResolver/SkippedPathsResolverTest.php +++ b/tests/Skipper/SkipCriteriaResolver/SkippedPathsResolver/SkippedPathsResolverTest.php @@ -4,6 +4,7 @@ namespace Rector\Tests\Skipper\SkipCriteriaResolver\SkippedPathsResolver; +use Override; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; use Rector\Skipper\FileSystem\PathNormalizer; @@ -14,6 +15,7 @@ final class SkippedPathsResolverTest extends AbstractLazyTestCase { private SkippedPathsResolver $skippedPathsResolver; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Skipper/Skipper/SkipperRectorRuleTest.php b/tests/Skipper/Skipper/SkipperRectorRuleTest.php index 414634e9ed3..33bbdfbc9d2 100644 --- a/tests/Skipper/Skipper/SkipperRectorRuleTest.php +++ b/tests/Skipper/Skipper/SkipperRectorRuleTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\Skipper\Skipper; use Illuminate\Container\RewindableGenerator; +use Override; use PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; @@ -14,6 +15,7 @@ final class SkipperRectorRuleTest extends AbstractLazyTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Skipper/Skipper/SkipperTest.php b/tests/Skipper/Skipper/SkipperTest.php index 33dda0fd5a8..72bf1c84f41 100644 --- a/tests/Skipper/Skipper/SkipperTest.php +++ b/tests/Skipper/Skipper/SkipperTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\Skipper\Skipper; use Iterator; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; @@ -19,6 +20,7 @@ final class SkipperTest extends AbstractLazyTestCase { private Skipper $skipper; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/StaticTypeMapper/PhpDoc/PhpDocTypeMapperTest.php b/tests/StaticTypeMapper/PhpDoc/PhpDocTypeMapperTest.php index bd7708d61ce..f84f799204d 100644 --- a/tests/StaticTypeMapper/PhpDoc/PhpDocTypeMapperTest.php +++ b/tests/StaticTypeMapper/PhpDoc/PhpDocTypeMapperTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\StaticTypeMapper\PhpDoc; use Iterator; +use Override; use PhpParser\Node\Stmt\Nop; use PHPStan\PhpDocParser\Ast\Type\ArrayShapeItemNode; use PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode; @@ -22,6 +23,7 @@ final class PhpDocTypeMapperTest extends AbstractLazyTestCase private NameScopeFactory $nameScopeFactory; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Util/FileHasherTest.php b/tests/Util/FileHasherTest.php index c94647469fc..857b996fe90 100644 --- a/tests/Util/FileHasherTest.php +++ b/tests/Util/FileHasherTest.php @@ -5,6 +5,7 @@ namespace Rector\Tests\Util; use Nette\Utils\FileSystem; +use Override; use Rector\Testing\PHPUnit\AbstractLazyTestCase; use Rector\Util\FileHasher; @@ -12,6 +13,7 @@ final class FileHasherTest extends AbstractLazyTestCase { private FileHasher $fileHasher; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/utils/Compiler/Unprefixer.php b/utils/Compiler/Unprefixer.php index 74947643942..b13a09b3165 100644 --- a/utils/Compiler/Unprefixer.php +++ b/utils/Compiler/Unprefixer.php @@ -9,10 +9,9 @@ final class Unprefixer { /** - * @var string * @see https://regex101.com/r/P8sXfr/1 */ - private const QUOTED_VALUE_REGEX = '#\'\\\\(\w|@)#'; + private const string QUOTED_VALUE_REGEX = '#\'\\\\(\w|@)#'; /** * @api diff --git a/utils/Rector/MoveAbstractRectorToChildrenRector.php b/utils/Rector/MoveAbstractRectorToChildrenRector.php index afab8824573..c5500f4c54f 100644 --- a/utils/Rector/MoveAbstractRectorToChildrenRector.php +++ b/utils/Rector/MoveAbstractRectorToChildrenRector.php @@ -24,7 +24,7 @@ final class MoveAbstractRectorToChildrenRector extends AbstractRector /** * @var array */ - private const PROPERTIES_TO_TYPES = [ + private const array PROPERTIES_TO_TYPES = [ 'phpDocInfoFactory' => PhpDocInfoFactory::class, 'valueResolver' => ValueResolver::class, 'betterNodeFinder' => BetterNodeFinder::class,