Skip to content

Commit eeab58a

Browse files
committed
[TypeDeclaration] Skip param already typed on AddMethodCallBasedStrictParamTypeRector
1 parent ade5d19 commit eeab58a

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ private function resolveStrictArgValueType(Arg $arg): Type
6060
// "self" in another object is not correct, this make it independent
6161
$argValueType = $this->correctSelfType($argValueType);
6262

63-
$type = $this->nodeTypeResolver->getType($arg->value);
64-
if (! $type->equals($argValueType) && $this->typeComparator->isSubtype($type, $argValueType)) {
65-
return $type;
66-
}
67-
6863
if (! $argValueType instanceof ObjectType) {
6964
return $argValueType;
7065
}
@@ -74,6 +69,11 @@ private function resolveStrictArgValueType(Arg $arg): Type
7469
return new MixedType();
7570
}
7671

72+
$type = $this->nodeTypeResolver->getType($arg->value);
73+
if (! $type->equals($argValueType) && $this->typeComparator->isSubtype($type, $argValueType)) {
74+
return $type;
75+
}
76+
7777
return $argValueType;
7878
}
7979

rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use PhpParser\Node;
88
use PhpParser\Node\Expr;
9-
use PhpParser\Node\Identifier;
109
use PhpParser\Node\Param;
1110
use PhpParser\Node\Stmt\ClassMethod;
1211
use PHPStan\Type\MixedType;
@@ -55,7 +54,7 @@ public function complete(ClassMethod $classMethod, array $classParameterTypes, i
5554
}
5655

5756
// skip if param type already filled
58-
if ($param->type instanceof Identifier) {
57+
if ($param->type instanceof Node) {
5958
continue;
6059
}
6160

0 commit comments

Comments
 (0)