diff --git a/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php b/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php index 70e6e836484..2461eff9636 100644 --- a/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php +++ b/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php @@ -22,7 +22,7 @@ final class RemoveDuplicatedCaseInSwitchRector extends AbstractRector private bool $hasChanged = false; public function __construct( - private BetterStandardPrinter $betterStandardPrinter + private readonly BetterStandardPrinter $betterStandardPrinter ) { } diff --git a/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php b/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php index 78e370091a3..c6753f7d1db 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php +++ b/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php @@ -60,11 +60,6 @@ private function resolveStrictArgValueType(Arg $arg): Type // "self" in another object is not correct, this make it independent $argValueType = $this->correctSelfType($argValueType); - $type = $this->nodeTypeResolver->getType($arg->value); - if (! $type->equals($argValueType) && $this->typeComparator->isSubtype($type, $argValueType)) { - return $type; - } - if (! $argValueType instanceof ObjectType) { return $argValueType; } @@ -74,6 +69,11 @@ private function resolveStrictArgValueType(Arg $arg): Type return new MixedType(); } + $type = $this->nodeTypeResolver->getType($arg->value); + if (! $type->equals($argValueType) && $this->typeComparator->isSubtype($type, $argValueType)) { + return $type; + } + return $argValueType; } diff --git a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php index dc02e3386a5..16092575b30 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php +++ b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php @@ -6,7 +6,6 @@ use PhpParser\Node; use PhpParser\Node\Expr; -use PhpParser\Node\Identifier; use PhpParser\Node\Param; use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Type\MixedType; @@ -55,7 +54,7 @@ public function complete(ClassMethod $classMethod, array $classParameterTypes, i } // skip if param type already filled - if ($param->type instanceof Identifier) { + if ($param->type instanceof Node) { continue; }