Skip to content

Commit 35e3325

Browse files
committed
simplify
1 parent 683ff3f commit 35e3325

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Analyser/NodeScopeResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4070,7 +4070,7 @@ private function processNodesForTraitUse($node, ClassReflection $traitReflection
40704070
}
40714071

40724072
/**
4073-
* @return array{TemplateTypeMap, Type[], ?Type, ?Type, ?string, bool, bool, bool, bool|null, bool, bool, string|null, Assertions, ?Type, Type[]}
4073+
* @return array{TemplateTypeMap, array<string, Type>, ?Type, ?Type, ?string, bool, bool, bool, bool|null, bool, bool, string|null, Assertions, ?Type, array<string, Type>}
40744074
*/
40754075
public function getPhpDocs(Scope $scope, Node\FunctionLike|Node\Stmt\Property $node): array
40764076
{

src/Reflection/SignatureMap/NativeFunctionReflectionProvider.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use PHPStan\Type\Type;
2727
use PHPStan\Type\TypehintHelper;
2828
use PHPStan\Type\UnionType;
29+
use function array_key_exists;
2930
use function array_map;
3031
use function strtolower;
3132

@@ -153,7 +154,7 @@ public function findFunctionReflection(string $functionName): ?NativeFunctionRef
153154
);
154155
}, $functionSignature->getParameters()),
155156
$functionSignature->isVariadic(),
156-
TypehintHelper::decideType($functionSignature->getReturnType(), $phpDoc !== null ? $this->getReturnTypeFromPhpDoc($phpDoc) : null),
157+
TypehintHelper::decideType($functionSignature->getReturnType(), $phpDocReturnType),
157158
$phpDocReturnType ?? new MixedType(),
158159
$functionSignature->getReturnType(),
159160
);
@@ -191,11 +192,12 @@ private function getReturnTypeFromPhpDoc(ResolvedPhpDocBlock $phpDoc): ?Type
191192

192193
private static function getParamOutTypeFromPhpDoc(string $paramName, ResolvedPhpDocBlock $stubPhpDoc): ?Type
193194
{
194-
foreach ($stubPhpDoc->getParamOutTags() as $name => $paramOutTag) {
195-
if ($paramName === $name) {
196-
return $paramOutTag->getType();
197-
}
195+
$paramOutTags = $stubPhpDoc->getParamOutTags();
196+
197+
if (array_key_exists($paramName, $paramOutTags)) {
198+
return $paramOutTags[$paramName]->getType();
198199
}
200+
199201
return null;
200202
}
201203

0 commit comments

Comments
 (0)