Skip to content

Commit 3f309ec

Browse files
committed
Fix
1 parent 7c8037e commit 3f309ec

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

rules/TypeDeclaration/NodeAnalyzer/CallerParamMatcher.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
use PHPStan\Analyser\Scope;
2323
use PHPStan\Reflection\ClassReflection;
2424
use PHPStan\Type\MixedType;
25+
use PHPStan\Type\Type;
2526
use Rector\NodeNameResolver\NodeNameResolver;
2627
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
2728
use Rector\PhpParser\AstResolver;
29+
use Rector\PHPStan\ScopeFetcher;
2830
use Rector\StaticTypeMapper\StaticTypeMapper;
2931

3032
final readonly class CallerParamMatcher
@@ -120,6 +122,7 @@ private function matchCallArgPosition(StaticCall | MethodCall | FuncCall $call,
120122
{
121123
$paramName = $this->nodeNameResolver->getName($param);
122124

125+
$scope = ScopeFetcher::fetch($call);
123126
foreach ($call->args as $argPosition => $arg) {
124127
if (! $arg instanceof Arg) {
125128
continue;
@@ -133,6 +136,11 @@ private function matchCallArgPosition(StaticCall | MethodCall | FuncCall $call,
133136
continue;
134137
}
135138

139+
$currentType = $scope->getType($arg->value);
140+
if ($currentType instanceof MixedType && $currentType->getSubtractedType() instanceof Type) {
141+
return null;
142+
}
143+
136144
return $argPosition;
137145
}
138146

0 commit comments

Comments
 (0)