Skip to content

Commit 840445a

Browse files
committed
Resolve @param-out type in ResolvedFunctionVariant
1 parent 5ac0fb2 commit 840445a

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3783,26 +3783,8 @@ private function processArgs(
37833783
?MutatingScope $closureBindScope = null,
37843784
): ExpressionResult
37853785
{
3786-
$paramOutTypes = [];
37873786
if ($parametersAcceptor !== null) {
37883787
$parameters = $parametersAcceptor->getParameters();
3789-
3790-
foreach ($parameters as $parameter) {
3791-
if (!$parameter instanceof ParameterReflectionWithPhpDocs) {
3792-
continue;
3793-
}
3794-
3795-
if ($parameter->getOutType() === null) {
3796-
continue;
3797-
}
3798-
3799-
$paramOutTypes[$parameter->getName()] = TemplateTypeHelper::resolveTemplateTypes(
3800-
$parameter->getOutType(),
3801-
$parametersAcceptor->getResolvedTemplateTypeMap(),
3802-
$parametersAcceptor instanceof ParametersAcceptorWithPhpDocs ? $parametersAcceptor->getCallSiteVarianceMap() : TemplateTypeVarianceMap::createEmpty(),
3803-
TemplateTypeVariance::createCovariant(),
3804-
);
3805-
}
38063788
}
38073789

38083790
$hasYield = false;
@@ -3879,14 +3861,14 @@ private function processArgs(
38793861
$assignByReference = false;
38803862
if (isset($parameters[$i])) {
38813863
$assignByReference = $parameters[$i]->passedByReference()->createsNewVariable();
3882-
if (isset($paramOutTypes[$parameters[$i]->getName()])) {
3883-
$byRefType = $paramOutTypes[$parameters[$i]->getName()];
3864+
if ($parameters[$i] instanceof ParameterReflectionWithPhpDocs && $parameters[$i]->getOutType() !== null) {
3865+
$byRefType = $parameters[$i]->getOutType();
38843866
}
38853867
} elseif (count($parameters) > 0 && $parametersAcceptor->isVariadic()) {
38863868
$lastParameter = $parameters[count($parameters) - 1];
38873869
$assignByReference = $lastParameter->passedByReference()->createsNewVariable();
3888-
if (isset($paramOutTypes[$lastParameter->getName()])) {
3889-
$byRefType = $paramOutTypes[$lastParameter->getName()];
3870+
if ($lastParameter instanceof ParameterReflectionWithPhpDocs && $lastParameter->getOutType() !== null) {
3871+
$byRefType = $lastParameter->getOutType();
38903872
}
38913873
}
38923874

src/Reflection/ResolvedFunctionVariant.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ function (ParameterReflectionWithPhpDocs $param): ParameterReflectionWithPhpDocs
8282
false,
8383
);
8484

85+
$paramOutType = $param->getOutType();
86+
if ($paramOutType !== null) {
87+
$paramOutType = TemplateTypeHelper::resolveTemplateTypes(
88+
$paramOutType,
89+
$this->resolvedTemplateTypeMap,
90+
$this->callSiteVarianceMap,
91+
TemplateTypeVariance::createCovariant(),
92+
);
93+
}
94+
8595
return new DummyParameterWithPhpDocs(
8696
$param->getName(),
8797
$paramType,
@@ -91,7 +101,7 @@ function (ParameterReflectionWithPhpDocs $param): ParameterReflectionWithPhpDocs
91101
$param->getDefaultValue(),
92102
$param->getNativeType(),
93103
$param->getPhpDocType(),
94-
$param->getOutType(),
104+
$paramOutType,
95105
);
96106
},
97107
$this->parametersAcceptor->getParameters(),

0 commit comments

Comments
 (0)