Skip to content

Commit 17f3f25

Browse files
committed
DRY
1 parent 27a952e commit 17f3f25

File tree

1 file changed

+23
-32
lines changed

1 file changed

+23
-32
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3860,40 +3860,31 @@ private function processArgs(
38603860

38613861
$byRefType = new MixedType();
38623862
$assignByReference = false;
3863+
$currentParameter = null;
38633864
if (isset($parameters[$i])) {
3864-
$assignByReference = $parameters[$i]->passedByReference()->createsNewVariable();
3865-
if ($parameters[$i] instanceof ParameterReflectionWithPhpDocs && $parameters[$i]->getOutType() !== null) {
3866-
$byRefType = $parameters[$i]->getOutType();
3867-
} elseif (
3868-
$calleeReflection instanceof MethodReflection
3869-
&& !$calleeReflection->getDeclaringClass()->isBuiltin()
3870-
&& $this->paramOutType
3871-
) {
3872-
$byRefType = $parameters[$i]->getType();
3873-
} elseif (
3874-
$calleeReflection instanceof FunctionReflection
3875-
&& !$calleeReflection->isBuiltin()
3876-
&& $this->paramOutType
3877-
) {
3878-
$byRefType = $parameters[$i]->getType();
3879-
}
3865+
$currentParameter = $parameters[$i];
38803866
} elseif (count($parameters) > 0 && $parametersAcceptor->isVariadic()) {
3881-
$lastParameter = $parameters[count($parameters) - 1];
3882-
$assignByReference = $lastParameter->passedByReference()->createsNewVariable();
3883-
if ($lastParameter instanceof ParameterReflectionWithPhpDocs && $lastParameter->getOutType() !== null) {
3884-
$byRefType = $lastParameter->getOutType();
3885-
} elseif (
3886-
$calleeReflection instanceof MethodReflection
3887-
&& !$calleeReflection->getDeclaringClass()->isBuiltin()
3888-
&& $this->paramOutType
3889-
) {
3890-
$byRefType = $lastParameter->getType();
3891-
} elseif (
3892-
$calleeReflection instanceof FunctionReflection
3893-
&& !$calleeReflection->isBuiltin()
3894-
&& $this->paramOutType
3895-
) {
3896-
$byRefType = $lastParameter->getType();
3867+
$currentParameter = $parameters[count($parameters) - 1];
3868+
}
3869+
3870+
if ($currentParameter !== null) {
3871+
$assignByReference = $currentParameter->passedByReference()->createsNewVariable();
3872+
if ($assignByReference) {
3873+
if ($currentParameter instanceof ParameterReflectionWithPhpDocs && $currentParameter->getOutType() !== null) {
3874+
$byRefType = $currentParameter->getOutType();
3875+
} elseif (
3876+
$calleeReflection instanceof MethodReflection
3877+
&& !$calleeReflection->getDeclaringClass()->isBuiltin()
3878+
&& $this->paramOutType
3879+
) {
3880+
$byRefType = $currentParameter->getType();
3881+
} elseif (
3882+
$calleeReflection instanceof FunctionReflection
3883+
&& !$calleeReflection->isBuiltin()
3884+
&& $this->paramOutType
3885+
) {
3886+
$byRefType = $currentParameter->getType();
3887+
}
38973888
}
38983889
}
38993890

0 commit comments

Comments
 (0)