From e1ceaab737a3eccb5add0f26957f48ff5900aacc Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 11 Jan 2026 18:53:39 +0700 Subject: [PATCH 1/6] Upgrade webmozart/assert to ^2.1 --- build/target-repository/composer.json | 3 +-- composer.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json index c381ac59..e4d2a587 100644 --- a/build/target-repository/composer.json +++ b/build/target-repository/composer.json @@ -5,8 +5,7 @@ "license": "MIT", "require": { "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.1.14", - "webmozart/assert": "^1.11" + "phpstan/phpstan": "^2.1.14" }, "autoload": { "psr-4": { diff --git a/composer.json b/composer.json index d339a3fc..89d51825 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "require": { "php": "^8.2", "phpstan/phpstan": "^2.1.30", - "webmozart/assert": "^1.11" + "webmozart/assert": "^2.1" }, "require-dev": { "nikic/php-parser": "^5.6", From b42622d7d4d3b124bd0907d4325c349768ad58eb Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 11 Jan 2026 18:56:21 +0700 Subject: [PATCH 2/6] allow ^2.1 --- build/target-repository/composer.json | 3 ++- composer.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json index e4d2a587..163eaeba 100644 --- a/build/target-repository/composer.json +++ b/build/target-repository/composer.json @@ -5,7 +5,8 @@ "license": "MIT", "require": { "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.1.14" + "phpstan/phpstan": "^2.1.14", + "webmozart/assert": "^1.11 || ^2.1" }, "autoload": { "psr-4": { diff --git a/composer.json b/composer.json index 89d51825..82b1d73b 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "require": { "php": "^8.2", "phpstan/phpstan": "^2.1.30", - "webmozart/assert": "^2.1" + "webmozart/assert": "^1.11 || ^2.1" }, "require-dev": { "nikic/php-parser": "^5.6", From 949a717600f8c72fa419476754cae9fc0882cd3e Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 11 Jan 2026 18:58:34 +0700 Subject: [PATCH 3/6] Rectify --- src/Matcher/Collector/PublicClassMethodMatcher.php | 3 ++- src/Rules/NoParamTypeRemovalRule.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Matcher/Collector/PublicClassMethodMatcher.php b/src/Matcher/Collector/PublicClassMethodMatcher.php index 80a3d115..42505052 100644 --- a/src/Matcher/Collector/PublicClassMethodMatcher.php +++ b/src/Matcher/Collector/PublicClassMethodMatcher.php @@ -4,6 +4,7 @@ namespace Rector\TypePerfect\Matcher\Collector; +use PHPUnit\Framework\TestCase; use PhpParser\Comment\Doc; use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Reflection\ClassReflection; @@ -14,7 +15,7 @@ final class PublicClassMethodMatcher * @var string[] */ private const SKIPPED_TYPES = [ - 'PHPUnit\Framework\TestCase', + TestCase::class, 'Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator', ]; diff --git a/src/Rules/NoParamTypeRemovalRule.php b/src/Rules/NoParamTypeRemovalRule.php index cb473990..8d64dfae 100644 --- a/src/Rules/NoParamTypeRemovalRule.php +++ b/src/Rules/NoParamTypeRemovalRule.php @@ -82,8 +82,8 @@ public function processNode(Node $node, Scope $scope): array private function resolveParentParamType(PhpMethodReflection $phpMethodReflection, int $paramPosition): Type { - foreach ($phpMethodReflection->getVariants() as $variant) { - foreach ($variant->getParameters() as $parentParamPosition => $parameterReflectionWithPhpDoc) { + foreach ($phpMethodReflection->getVariants() as $extendedParametersAcceptor) { + foreach ($extendedParametersAcceptor->getParameters() as $parentParamPosition => $parameterReflectionWithPhpDoc) { if ($paramPosition !== $parentParamPosition) { continue; } From 57c61012433d4194aef36c4e6f88f0ed6def5ba7 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 11 Jan 2026 18:59:22 +0700 Subject: [PATCH 4/6] cs fix --- src/Matcher/Collector/PublicClassMethodMatcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Matcher/Collector/PublicClassMethodMatcher.php b/src/Matcher/Collector/PublicClassMethodMatcher.php index 42505052..a82fc0b8 100644 --- a/src/Matcher/Collector/PublicClassMethodMatcher.php +++ b/src/Matcher/Collector/PublicClassMethodMatcher.php @@ -4,10 +4,10 @@ namespace Rector\TypePerfect\Matcher\Collector; -use PHPUnit\Framework\TestCase; use PhpParser\Comment\Doc; use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Reflection\ClassReflection; +use PHPUnit\Framework\TestCase; final class PublicClassMethodMatcher { From adf5be51ab0ba3f7bb6b58a1b6784e098fbb1bfd Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 11 Jan 2026 19:02:03 +0700 Subject: [PATCH 5/6] final touch: skip StringClassNameToClassConstantRector --- rector.php | 7 ++++++- src/Matcher/Collector/PublicClassMethodMatcher.php | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rector.php b/rector.php index d8b5f54a..fa417138 100644 --- a/rector.php +++ b/rector.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Rector\Config\RectorConfig; +use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; return RectorConfig::configure() ->withPhpSets() @@ -18,4 +19,8 @@ ) ->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests']) ->withImportNames(removeUnusedImports: true) - ->withSkip(['*/Source/*', '*/Fixture/*']); + ->withSkip([ + '*/Source/*', + '*/Fixture/*', + StringClassNameToClassConstantRector::class, + ]); diff --git a/src/Matcher/Collector/PublicClassMethodMatcher.php b/src/Matcher/Collector/PublicClassMethodMatcher.php index a82fc0b8..80a3d115 100644 --- a/src/Matcher/Collector/PublicClassMethodMatcher.php +++ b/src/Matcher/Collector/PublicClassMethodMatcher.php @@ -7,7 +7,6 @@ use PhpParser\Comment\Doc; use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Reflection\ClassReflection; -use PHPUnit\Framework\TestCase; final class PublicClassMethodMatcher { @@ -15,7 +14,7 @@ final class PublicClassMethodMatcher * @var string[] */ private const SKIPPED_TYPES = [ - TestCase::class, + 'PHPUnit\Framework\TestCase', 'Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator', ]; From 18c1e1de5f407013bdd42c622dd341df6c172670 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 11 Jan 2026 19:56:43 +0700 Subject: [PATCH 6/6] final touch: fix cs --- rector.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/rector.php b/rector.php index fa417138..5ab34842 100644 --- a/rector.php +++ b/rector.php @@ -19,8 +19,4 @@ ) ->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests']) ->withImportNames(removeUnusedImports: true) - ->withSkip([ - '*/Source/*', - '*/Fixture/*', - StringClassNameToClassConstantRector::class, - ]); + ->withSkip(['*/Source/*', '*/Fixture/*', StringClassNameToClassConstantRector::class]);