Skip to content

Commit f1e8eba

Browse files
[TypeDeclaration] Skip param already typed on AddMethodCallBasedStrictParamTypeRector (#7176)
* [TypeDeclaration] Skip param already typed on AddMethodCallBasedStrictParamTypeRector * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <actions@github.com>
1 parent ade5d19 commit f1e8eba

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class RemoveDuplicatedCaseInSwitchRector extends AbstractRector
2222
private bool $hasChanged = false;
2323

2424
public function __construct(
25-
private BetterStandardPrinter $betterStandardPrinter
25+
private readonly BetterStandardPrinter $betterStandardPrinter
2626
) {
2727
}
2828

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)