Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class RemoveDuplicatedCaseInSwitchRector extends AbstractRector
private bool $hasChanged = false;

public function __construct(
private BetterStandardPrinter $betterStandardPrinter
private readonly BetterStandardPrinter $betterStandardPrinter
) {
}

Expand Down
10 changes: 5 additions & 5 deletions rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Loading