Skip to content

Commit bab0aa6

Browse files
staabmondrejmirtes
authored andcommitted
NodeScopeResolver: Move assignByReference logic out of generic path
1 parent f71b938 commit bab0aa6

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5755,7 +5755,6 @@ private function processArgs(
57555755

57565756
if ($parameters !== null) {
57575757
foreach ($args as $i => $arg) {
5758-
$byRefType = new MixedType();
57595758
$assignByReference = false;
57605759
$currentParameter = null;
57615760
if (isset($parameters[$i])) {
@@ -5766,21 +5765,6 @@ private function processArgs(
57665765

57675766
if ($currentParameter !== null) {
57685767
$assignByReference = $currentParameter->passedByReference()->createsNewVariable();
5769-
if ($assignByReference) {
5770-
if ($currentParameter instanceof ExtendedParameterReflection && $currentParameter->getOutType() !== null) {
5771-
$byRefType = $currentParameter->getOutType();
5772-
} elseif (
5773-
$calleeReflection instanceof MethodReflection
5774-
&& !$calleeReflection->getDeclaringClass()->isBuiltin()
5775-
) {
5776-
$byRefType = $currentParameter->getType();
5777-
} elseif (
5778-
$calleeReflection instanceof FunctionReflection
5779-
&& !$calleeReflection->isBuiltin()
5780-
) {
5781-
$byRefType = $currentParameter->getType();
5782-
}
5783-
}
57845768
}
57855769

57865770
if ($assignByReference) {
@@ -5793,6 +5777,23 @@ private function processArgs(
57935777
$paramOutType = $this->getParameterOutExtensionsType($callLike, $calleeReflection, $currentParameter, $scope);
57945778
if ($paramOutType !== null) {
57955779
$byRefType = $paramOutType;
5780+
} elseif (
5781+
$currentParameter instanceof ExtendedParameterReflection
5782+
&& $currentParameter->getOutType() !== null
5783+
) {
5784+
$byRefType = $currentParameter->getOutType();
5785+
} elseif (
5786+
$calleeReflection instanceof MethodReflection
5787+
&& !$calleeReflection->getDeclaringClass()->isBuiltin()
5788+
) {
5789+
$byRefType = $currentParameter->getType();
5790+
} elseif (
5791+
$calleeReflection instanceof FunctionReflection
5792+
&& !$calleeReflection->isBuiltin()
5793+
) {
5794+
$byRefType = $currentParameter->getType();
5795+
} else {
5796+
$byRefType = new MixedType();
57965797
}
57975798

57985799
$scope = $this->processVirtualAssign(

0 commit comments

Comments
 (0)