From 2007757faac759a020a0d30af1b60921aaed9037 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 10 Mar 2025 03:46:44 +0700 Subject: [PATCH 1/2] Change deprecated ClassReflection::isSubClassOf() to ClassReflection::is() for PHPStan ^2.1.8 --- .../Class_/CommandGetByTypeToConstructorInjectionRector.php | 2 +- .../ControllerGetByTypeToConstructorInjectionRector.php | 2 +- .../Class_/GetBySymfonyStringToConstructorInjectionRector.php | 4 ++-- .../Rector/Class_/DowngradeSymfonyCommandAttributeRector.php | 2 +- .../ClassMethod/EventDispatcherParentConstructRector.php | 2 +- .../Rector/ClassMethod/CommandConstantReturnCodeRector.php | 2 +- .../ErrorNamesPropertyToConstantRector.php | 2 +- .../Twig134/Rector/Return_/SimpleFunctionAndFilterRector.php | 2 +- src/NodeAnalyzer/SymfonyTestCaseAnalyzer.php | 4 ++-- src/TypeAnalyzer/ControllerAnalyzer.php | 4 ++-- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/rules/DependencyInjection/Rector/Class_/CommandGetByTypeToConstructorInjectionRector.php b/rules/DependencyInjection/Rector/Class_/CommandGetByTypeToConstructorInjectionRector.php index ba303b87..86a5ba6a 100644 --- a/rules/DependencyInjection/Rector/Class_/CommandGetByTypeToConstructorInjectionRector.php +++ b/rules/DependencyInjection/Rector/Class_/CommandGetByTypeToConstructorInjectionRector.php @@ -134,6 +134,6 @@ private function shouldSkipClass(Class_ $class): bool return true; } - return ! $classReflection->isSubclassOf(SymfonyClass::CONTAINER_AWARE_COMMAND); + return ! $classReflection->is(SymfonyClass::CONTAINER_AWARE_COMMAND); } } diff --git a/rules/DependencyInjection/Rector/Class_/ControllerGetByTypeToConstructorInjectionRector.php b/rules/DependencyInjection/Rector/Class_/ControllerGetByTypeToConstructorInjectionRector.php index 3147ee9f..b1aedc02 100644 --- a/rules/DependencyInjection/Rector/Class_/ControllerGetByTypeToConstructorInjectionRector.php +++ b/rules/DependencyInjection/Rector/Class_/ControllerGetByTypeToConstructorInjectionRector.php @@ -130,6 +130,6 @@ private function shouldSkipClass(Class_ $class): bool return true; } - return ! $classReflection->isSubclassOf(SymfonyClass::CONTROLLER); + return ! $classReflection->is(SymfonyClass::CONTROLLER); } } diff --git a/rules/DependencyInjection/Rector/Class_/GetBySymfonyStringToConstructorInjectionRector.php b/rules/DependencyInjection/Rector/Class_/GetBySymfonyStringToConstructorInjectionRector.php index 769dcd86..0a2ced0a 100644 --- a/rules/DependencyInjection/Rector/Class_/GetBySymfonyStringToConstructorInjectionRector.php +++ b/rules/DependencyInjection/Rector/Class_/GetBySymfonyStringToConstructorInjectionRector.php @@ -155,10 +155,10 @@ private function shouldSkipClass(Class_ $class): bool return true; } - if ($classReflection->isSubclassOf(SymfonyClass::CONTAINER_AWARE_COMMAND)) { + if ($classReflection->is(SymfonyClass::CONTAINER_AWARE_COMMAND)) { return false; } - return ! $classReflection->isSubclassOf(SymfonyClass::CONTROLLER); + return ! $classReflection->is(SymfonyClass::CONTROLLER); } } diff --git a/rules/DowngradeSymfony70/Rector/Class_/DowngradeSymfonyCommandAttributeRector.php b/rules/DowngradeSymfony70/Rector/Class_/DowngradeSymfonyCommandAttributeRector.php index 3552074d..d0753f95 100644 --- a/rules/DowngradeSymfony70/Rector/Class_/DowngradeSymfonyCommandAttributeRector.php +++ b/rules/DowngradeSymfony70/Rector/Class_/DowngradeSymfonyCommandAttributeRector.php @@ -77,7 +77,7 @@ public function refactor(Node $node): ?Node return null; } - if (! $classReflection->isSubClassOf('Symfony\Component\Console\Command\Command')) { + if (! $classReflection->is('Symfony\Component\Console\Command\Command')) { return null; } diff --git a/rules/Symfony43/Rector/ClassMethod/EventDispatcherParentConstructRector.php b/rules/Symfony43/Rector/ClassMethod/EventDispatcherParentConstructRector.php index 81d6d0ed..341b4409 100644 --- a/rules/Symfony43/Rector/ClassMethod/EventDispatcherParentConstructRector.php +++ b/rules/Symfony43/Rector/ClassMethod/EventDispatcherParentConstructRector.php @@ -86,7 +86,7 @@ public function refactor(Node $node): ?Node } $classReflection = $scope->getClassReflection(); - if (! $classReflection->isSubclassOf('Symfony\Contracts\EventDispatcher\EventDispatcherInterface')) { + if (! $classReflection->is('Symfony\Contracts\EventDispatcher\EventDispatcherInterface')) { return null; } diff --git a/rules/Symfony51/Rector/ClassMethod/CommandConstantReturnCodeRector.php b/rules/Symfony51/Rector/ClassMethod/CommandConstantReturnCodeRector.php index 4ce8cc17..96ebf6f0 100644 --- a/rules/Symfony51/Rector/ClassMethod/CommandConstantReturnCodeRector.php +++ b/rules/Symfony51/Rector/ClassMethod/CommandConstantReturnCodeRector.php @@ -80,7 +80,7 @@ public function refactor(Node $node): ?Node return null; } - if (! $classReflection->isSubclassOf('Symfony\Component\Console\Command\Command')) { + if (! $classReflection->is('Symfony\Component\Console\Command\Command')) { return null; } diff --git a/rules/Symfony61/Rector/StaticPropertyFetch/ErrorNamesPropertyToConstantRector.php b/rules/Symfony61/Rector/StaticPropertyFetch/ErrorNamesPropertyToConstantRector.php index 0e8e6b88..a9671a38 100644 --- a/rules/Symfony61/Rector/StaticPropertyFetch/ErrorNamesPropertyToConstantRector.php +++ b/rules/Symfony61/Rector/StaticPropertyFetch/ErrorNamesPropertyToConstantRector.php @@ -73,7 +73,7 @@ public function refactor(Node $node): ?Node if (! $classReflection instanceof ClassReflection) { return null; } - if (! $classReflection->isSubclassOf('Symfony\Component\Validator\Constraint')) { + if (! $classReflection->is('Symfony\Component\Validator\Constraint')) { return null; } if (! $this->nodeNameResolver->isName($node->name, 'errorNames')) { diff --git a/rules/Twig134/Rector/Return_/SimpleFunctionAndFilterRector.php b/rules/Twig134/Rector/Return_/SimpleFunctionAndFilterRector.php index bea17abc..0fe25901 100644 --- a/rules/Twig134/Rector/Return_/SimpleFunctionAndFilterRector.php +++ b/rules/Twig134/Rector/Return_/SimpleFunctionAndFilterRector.php @@ -151,7 +151,7 @@ private function shouldSkip(ClassMethod $classMethod): bool return true; } - if (! $classReflection->isSubclassOf('Twig_Extension')) { + if (! $classReflection->is('Twig_Extension')) { return true; } diff --git a/src/NodeAnalyzer/SymfonyTestCaseAnalyzer.php b/src/NodeAnalyzer/SymfonyTestCaseAnalyzer.php index 7e1a211e..645efbc6 100644 --- a/src/NodeAnalyzer/SymfonyTestCaseAnalyzer.php +++ b/src/NodeAnalyzer/SymfonyTestCaseAnalyzer.php @@ -22,7 +22,7 @@ public function isInWebTestCase(Node $node): bool return false; } - return $classReflection->isSubclassOf('Symfony\Bundle\FrameworkBundle\Test\WebTestCase'); + return $classReflection->is('Symfony\Bundle\FrameworkBundle\Test\WebTestCase'); } /** @@ -35,6 +35,6 @@ public function isInKernelTestCase(Node $node): bool return false; } - return $classReflection->isSubclassOf('Symfony\Bundle\FrameworkBundle\Test\KernelTestCase'); + return $classReflection->is('Symfony\Bundle\FrameworkBundle\Test\KernelTestCase'); } } diff --git a/src/TypeAnalyzer/ControllerAnalyzer.php b/src/TypeAnalyzer/ControllerAnalyzer.php index a452e5ff..e24ecde4 100644 --- a/src/TypeAnalyzer/ControllerAnalyzer.php +++ b/src/TypeAnalyzer/ControllerAnalyzer.php @@ -68,11 +68,11 @@ public function isInsideController(Node $node): bool private function isControllerClassReflection(ClassReflection $classReflection): bool { - if ($classReflection->isSubclassOf('Symfony\Bundle\FrameworkBundle\Controller\Controller')) { + if ($classReflection->is('Symfony\Bundle\FrameworkBundle\Controller\Controller')) { return true; } - return $classReflection->isSubclassOf('Symfony\Bundle\FrameworkBundle\Controller\AbstractController'); + return $classReflection->is('Symfony\Bundle\FrameworkBundle\Controller\AbstractController'); } private function isControllerClass(Class_ $class): bool From 4c80837d6aa587bddd2259db8b411644dfb461c2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 10 Mar 2025 03:47:28 +0700 Subject: [PATCH 2/2] bump --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5bfccf2e..6c7c26dc 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ }, "require-dev": { "phpstan/extension-installer": "^1.4", - "phpstan/phpstan": "^2.0", + "phpstan/phpstan": "^2.1.8", "phpstan/phpstan-webmozart-assert": "^2.0", "phpunit/phpunit": "^11.4", "rector/rector-src": "dev-main",