Skip to content

Commit

Permalink
Simplify access to reflections in SymfonyCmfRoutingInClassMethodSigna…
Browse files Browse the repository at this point in the history
…tureRule and TestClassesProtectedPropertyModulesRule. (#717)
  • Loading branch information
mad-briller authored Jan 17, 2024
1 parent cbed039 commit 7014f5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions src/Rules/Drupal/TestClassesProtectedPropertyModulesRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 [];
}
Expand Down

0 comments on commit 7014f5b

Please sign in to comment.