diff --git a/src/Rules/Deprecations/SymfonyCmfRoutingInClassMethodSignatureRule.php b/src/Rules/Deprecations/SymfonyCmfRoutingInClassMethodSignatureRule.php index 8de1deca..1bb4e75d 100644 --- a/src/Rules/Deprecations/SymfonyCmfRoutingInClassMethodSignatureRule.php +++ b/src/Rules/Deprecations/SymfonyCmfRoutingInClassMethodSignatureRule.php @@ -6,7 +6,6 @@ use PhpParser\Node; use PHPStan\Analyser\Scope; use PHPStan\Node\InClassMethodNode; -use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\ParametersAcceptorSelector; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; @@ -30,10 +29,7 @@ public function processNode(Node $node, Scope $scope): array if ($major !== '9' || (int) $minor < 1) { return []; } - $method = $scope->getFunction(); - if (!$method instanceof MethodReflection) { - throw new \PHPStan\ShouldNotHappenException(); - } + $method = $node->getMethodReflection(); $cmfRouteObjectInterfaceType = new ObjectType(\Symfony\Cmf\Component\Routing\RouteObjectInterface::class); $cmfRouteProviderInterfaceType = new ObjectType(\Symfony\Cmf\Component\Routing\RouteProviderInterface::class); diff --git a/src/Rules/Drupal/TestClassesProtectedPropertyModulesRule.php b/src/Rules/Drupal/TestClassesProtectedPropertyModulesRule.php index 4b27be21..e30ca422 100644 --- a/src/Rules/Drupal/TestClassesProtectedPropertyModulesRule.php +++ b/src/Rules/Drupal/TestClassesProtectedPropertyModulesRule.php @@ -9,7 +9,6 @@ use PHPStan\Node\ClassPropertyNode; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; -use PHPStan\ShouldNotHappenException; use PHPUnit\Framework\TestCase; class TestClassesProtectedPropertyModulesRule implements Rule @@ -27,15 +26,11 @@ public function processNode(Node $node, Scope $scope): array { assert($node instanceof ClassPropertyNode); - if (!$scope->isInClass()) { - throw new ShouldNotHappenException(); - } - if ($node->getName() !== 'modules') { return []; } - $scopeClassReflection = $scope->getClassReflection(); + $scopeClassReflection = $node->getClassReflection(); if ($scopeClassReflection->isAnonymous()) { return []; }