Skip to content

Commit faabb03

Browse files
committed
phpstan fix
1 parent 1f5681f commit faabb03

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Rules/Complexity/NoJustPropertyAssignRule.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PhpParser\Node\Expr\Variable;
1010
use PhpParser\Node\Stmt\Expression;
1111
use PHPStan\Analyser\Scope;
12+
use PHPStan\Reflection\ClassReflection;
1213
use PHPStan\Rules\Rule;
1314
use PHPStan\Rules\RuleError;
1415
use PHPStan\Rules\RuleErrorBuilder;
@@ -59,7 +60,7 @@ public function processNode(Node $node, Scope $scope): array
5960
return [];
6061
}
6162

62-
if ($this->shoulSkipMoreSpecificTypeByDocblock($scope, $node, $node->expr)) {
63+
if ($this->shoulSkipMoreSpecificTypeByDocblock($scope, $node, $expr)) {
6364
return [];
6465
}
6566

@@ -83,7 +84,12 @@ private function shoulSkipMoreSpecificTypeByDocblock(Scope $scope, Expression $e
8384
return false;
8485
}
8586

86-
$resolvedPhpDocBlock = $this->phpDocResolver->resolve($scope, $scope->getClassReflection(), $docComment);
87+
$classReflection = $scope->getClassReflection();
88+
if (! $classReflection instanceof ClassReflection) {
89+
return false;
90+
}
91+
92+
$resolvedPhpDocBlock = $this->phpDocResolver->resolve($scope, $classReflection, $docComment);
8793
$exprType = $scope->getType($assign->expr);
8894

8995
foreach ($resolvedPhpDocBlock->getVarTags() as $key => $varTag) {

0 commit comments

Comments
 (0)