From 97f6f7b41740f890734537758d535e4d629a6824 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 12 Nov 2024 16:01:38 +0100 Subject: [PATCH 1/6] [deprecation] Remove deprecated PublicConstantVisibilityRector --- phpstan.neon | 1 - .../Fixture/SomeClass.php.inc | 29 -------- .../public_visibility_final_const.php.inc | 21 ------ .../PublicConstantVisibilityRectorTest.php | 28 -------- .../config/configured_rule.php | 9 --- .../PublicConstantVisibilityRector.php | 72 ------------------- 6 files changed, 160 deletions(-) delete mode 100644 rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/Fixture/SomeClass.php.inc delete mode 100644 rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/Fixture/public_visibility_final_const.php.inc delete mode 100644 rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/PublicConstantVisibilityRectorTest.php delete mode 100644 rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/config/configured_rule.php delete mode 100644 rules/Php71/Rector/ClassConst/PublicConstantVisibilityRector.php diff --git a/phpstan.neon b/phpstan.neon index 0a838396d42..7398649b35f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -292,7 +292,6 @@ parameters: path: src/VendorLocker/ParentClassMethodTypeOverrideGuard.php # deprecated - - '#Register "Rector\\Php71\\Rector\\ClassConst\\PublicConstantVisibilityRector" service to "php71\.php" config set#' - '#Public method "Rector\\ValueObject\\Error\\SystemError\:\:getFile\(\)" is never used#' # soon to be used diff --git a/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/Fixture/SomeClass.php.inc b/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/Fixture/SomeClass.php.inc deleted file mode 100644 index 71d1936b2c4..00000000000 --- a/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/Fixture/SomeClass.php.inc +++ /dev/null @@ -1,29 +0,0 @@ - ------ - diff --git a/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/Fixture/public_visibility_final_const.php.inc b/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/Fixture/public_visibility_final_const.php.inc deleted file mode 100644 index 45740497da9..00000000000 --- a/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/Fixture/public_visibility_final_const.php.inc +++ /dev/null @@ -1,21 +0,0 @@ - ------ - diff --git a/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/PublicConstantVisibilityRectorTest.php b/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/PublicConstantVisibilityRectorTest.php deleted file mode 100644 index 302b1bcc5cf..00000000000 --- a/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/PublicConstantVisibilityRectorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/config/configured_rule.php b/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/config/configured_rule.php deleted file mode 100644 index b80bfdb6686..00000000000 --- a/rules-tests/Php71/Rector/ClassConst/PublicConstantVisibilityRector/config/configured_rule.php +++ /dev/null @@ -1,9 +0,0 @@ -withRules([PublicConstantVisibilityRector::class]); diff --git a/rules/Php71/Rector/ClassConst/PublicConstantVisibilityRector.php b/rules/Php71/Rector/ClassConst/PublicConstantVisibilityRector.php deleted file mode 100644 index 39139ba7371..00000000000 --- a/rules/Php71/Rector/ClassConst/PublicConstantVisibilityRector.php +++ /dev/null @@ -1,72 +0,0 @@ -> - */ - public function getNodeTypes(): array - { - return [ClassConst::class]; - } - - /** - * @param ClassConst $node - */ - public function refactor(Node $node): ?Node - { - return $this->visibilityManipulator->publicize($node); - } - - public function provideMinPhpVersion(): int - { - return PhpVersionFeature::CONSTANT_VISIBILITY; - } -} From 5bc822f14d879ebefaaed46a8de6191bb52be864 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 12 Nov 2024 16:02:34 +0100 Subject: [PATCH 2/6] remove deprecated SystemError->getFile() --- phpstan.neon | 3 --- .../Rector/FuncCall/NullToStrictStringFuncCallArgRector.php | 3 ++- .../NodeAnalyzer/ClassMethodParamTypeCompleter.php | 3 ++- src/NodeAnalyzer/PropertyAnalyzer.php | 3 ++- src/NodeTypeResolver/NodeTypeResolver.php | 3 ++- src/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php | 4 +++- src/ValueObject/Error/SystemError.php | 5 ----- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 7398649b35f..b01fd261fe5 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -291,9 +291,6 @@ parameters: message: '#Parameters should have "PhpParser\\Node\\Stmt\\ClassMethod" types as the only types passed to this method#' path: src/VendorLocker/ParentClassMethodTypeOverrideGuard.php - # deprecated - - '#Public method "Rector\\ValueObject\\Error\\SystemError\:\:getFile\(\)" is never used#' - # soon to be used - '#Property Rector\\Configuration\\RectorConfigBuilder\:\:\$isWithPhpSetsUsed is never read, only written#' diff --git a/rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php b/rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php index 6dbf7ebdd06..b8fcd3e5925 100644 --- a/rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php +++ b/rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php @@ -262,7 +262,8 @@ private function isValidUnionType(Type $type): bool private function shouldSkipType(Type $type): bool { return ! $type instanceof MixedType && - ! $type->isNull()->yes() && + ! $type->isNull() + ->yes() && ! $this->isValidUnionType($type); } diff --git a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php index 2efac4ae983..dc02e3386a5 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php +++ b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php @@ -129,7 +129,8 @@ private function isClosureAndCallableType(Type $parameterStaticType, Type $argum return true; } - return $argumentStaticType->isCallable()->yes() && $this->isClosureObjectType($parameterStaticType); + return $argumentStaticType->isCallable() + ->yes() && $this->isClosureObjectType($parameterStaticType); } private function isClosureObjectType(Type $type): bool diff --git a/src/NodeAnalyzer/PropertyAnalyzer.php b/src/NodeAnalyzer/PropertyAnalyzer.php index 3b443b5c1d3..b57791347e0 100644 --- a/src/NodeAnalyzer/PropertyAnalyzer.php +++ b/src/NodeAnalyzer/PropertyAnalyzer.php @@ -58,6 +58,7 @@ private function isCallableType(Type $type): bool return false; } - return $type->isCallable()->yes(); + return $type->isCallable() + ->yes(); } } diff --git a/src/NodeTypeResolver/NodeTypeResolver.php b/src/NodeTypeResolver/NodeTypeResolver.php index 390c5d231ca..20e5645dea7 100644 --- a/src/NodeTypeResolver/NodeTypeResolver.php +++ b/src/NodeTypeResolver/NodeTypeResolver.php @@ -431,7 +431,8 @@ private function isAnonymousObjectType(Type $type): bool private function isUnionTypeable(Type $first, Type $second): bool { - return ! $first instanceof UnionType && ! $second instanceof UnionType && ! $second->isNull()->yes(); + return ! $first instanceof UnionType && ! $second instanceof UnionType && ! $second->isNull() + ->yes(); } private function isMatchingUnionType(Type $resolvedType, ObjectType $requiredObjectType): bool diff --git a/src/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php b/src/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php index 0370fb50a24..690b6417716 100644 --- a/src/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php +++ b/src/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php @@ -205,7 +205,9 @@ private function isIntegerKeyAndNonNestedArray(ArrayType $arrayType): bool return false; } - return ! $arrayType->getItemType()->isArray()->yes(); + return ! $arrayType->getItemType() + ->isArray() + ->yes(); } private function isClassStringArrayType(ArrayType $arrayType): bool diff --git a/src/ValueObject/Error/SystemError.php b/src/ValueObject/Error/SystemError.php index 14a70bd2aba..a1339a2a713 100644 --- a/src/ValueObject/Error/SystemError.php +++ b/src/ValueObject/Error/SystemError.php @@ -22,11 +22,6 @@ public function getMessage(): string return $this->message; } - public function getFile(): string|null - { - return $this->relativeFilePath; - } - public function getLine(): int|null { return $this->line; From cb7ae171da013b83b834abfd8020a06834ba6689 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 12 Nov 2024 16:06:40 +0100 Subject: [PATCH 3/6] cleanup --- phpstan.neon | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index b01fd261fe5..96d759236bb 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -289,7 +289,9 @@ parameters: message: '#Parameters should have "PhpParser\\Node\\Expr\\Closure" types as the only types passed to this method#' - message: '#Parameters should have "PhpParser\\Node\\Stmt\\ClassMethod" types as the only types passed to this method#' - path: src/VendorLocker/ParentClassMethodTypeOverrideGuard.php + paths: + - src/VendorLocker/ParentClassMethodTypeOverrideGuard.php + - rules/Privatization/NodeManipulator/VisibilityManipulator.php # soon to be used - '#Property Rector\\Configuration\\RectorConfigBuilder\:\:\$isWithPhpSetsUsed is never read, only written#' @@ -299,7 +301,6 @@ parameters: # rector internal deprecation - '#Class Rector\\Set\\ValueObject\\(Level)?SetList implements deprecated interface#' - - '#Fetching class constant class of deprecated class Rector#' # more advanced usage, but not always working # see https://github.com/rectorphp/rector-src/actions/runs/11798721617/job/32865546672?pr=6422#step:5:110 From c502f195068cd4635755fa3e327981c38fe1623e Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 12 Nov 2024 16:10:04 +0100 Subject: [PATCH 4/6] cleanup deprecated SetListInterface --- phpstan.neon | 9 --------- src/Set/ValueObject/LevelSetList.php | 4 +--- src/Set/ValueObject/SetList.php | 4 +--- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 96d759236bb..2efdb1655e3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -293,15 +293,6 @@ parameters: - src/VendorLocker/ParentClassMethodTypeOverrideGuard.php - rules/Privatization/NodeManipulator/VisibilityManipulator.php - # soon to be used - - '#Property Rector\\Configuration\\RectorConfigBuilder\:\:\$isWithPhpSetsUsed is never read, only written#' - - # used once - - '#Interface "Rector\\Configuration\\Deprecation\\Contract\\DeprecatedInterface" has only single implementer\. Consider using the class directly as there is no point in using the interface#' - - # rector internal deprecation - - '#Class Rector\\Set\\ValueObject\\(Level)?SetList implements deprecated interface#' - # more advanced usage, but not always working # see https://github.com/rectorphp/rector-src/actions/runs/11798721617/job/32865546672?pr=6422#step:5:110 - '#Doing instanceof PHPStan\\Type\\.+ is error\-prone and deprecated#' diff --git a/src/Set/ValueObject/LevelSetList.php b/src/Set/ValueObject/LevelSetList.php index 0211e388483..a86980abeae 100644 --- a/src/Set/ValueObject/LevelSetList.php +++ b/src/Set/ValueObject/LevelSetList.php @@ -4,12 +4,10 @@ namespace Rector\Set\ValueObject; -use Rector\Set\Contract\SetListInterface; - /** * @api */ -final class LevelSetList implements SetListInterface +final class LevelSetList { /** * @var string diff --git a/src/Set/ValueObject/SetList.php b/src/Set/ValueObject/SetList.php index 7f4da81266d..5276117c9e4 100644 --- a/src/Set/ValueObject/SetList.php +++ b/src/Set/ValueObject/SetList.php @@ -4,12 +4,10 @@ namespace Rector\Set\ValueObject; -use Rector\Set\Contract\SetListInterface; - /** * @api */ -final class SetList implements SetListInterface +final class SetList { /** * @internal From 0beb571d575ad946960ffbed40679d828d16b623 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 12 Nov 2024 22:06:43 +0100 Subject: [PATCH 5/6] bump dev deps --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 6a20585392d..a71478e774e 100644 --- a/composer.json +++ b/composer.json @@ -51,15 +51,15 @@ "phpunit/phpunit": "^10.5", "rector/release-notes-generator": "^0.3.0", "rector/swiss-knife": "^0.2.16", - "rector/type-perfect": "^0.1.6", + "rector/type-perfect": "^1.0", "shipmonk/composer-dependency-analyser": "^1.7", "symplify/easy-coding-standard": "^12.3", "symplify/phpstan-extensions": "^11.4", "symplify/phpstan-rules": "^13.0", "symplify/rule-doc-generator": "^12.2.5", "symplify/vendor-patches": "^11.3", - "tomasvotruba/class-leak": "^0.2.15", - "tomasvotruba/unused-public": "^0.3.10", + "tomasvotruba/class-leak": "^1.1.2", + "tomasvotruba/unused-public": "^1.0", "tracy/tracy": "^2.9" }, "replace": { From bcf175b2ea116613d34814fd401476682c8242d5 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 12 Nov 2024 22:06:54 +0100 Subject: [PATCH 6/6] [ci] skip deprecated set list interface --- .github/workflows/code_analysis.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml index bbacddd2e1d..88fc7a2448d 100644 --- a/.github/workflows/code_analysis.yaml +++ b/.github/workflows/code_analysis.yaml @@ -40,7 +40,7 @@ jobs: - name: 'Active Classes' run: | - vendor/bin/class-leak check bin config src rules utils --skip-suffix "Rector" --skip-type="Rector\\Utils\\Compiler\\Unprefixer" --skip-type="Rector\\PhpDocParser\\PhpParser\\SmartPhpParserFactory" --skip-type="Rector\\NodeCollector\\BinaryOpConditionsCollector" + vendor/bin/class-leak check bin config src rules utils --skip-suffix "Rector" --skip-type="Rector\\Utils\\Compiler\\Unprefixer" --skip-type="Rector\\PhpDocParser\\PhpParser\\SmartPhpParserFactory" --skip-type="Rector\\NodeCollector\\BinaryOpConditionsCollector" --skip-type="Rector\\Set\\Contract\\SetListInterface" - name: 'Compatible PHPStan versions'