Skip to content

Commit ecc3076

Browse files
committed
Call nodeCallback with original argument with a name after reordering
1 parent 2222b63 commit ecc3076

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Analyser/ArgumentsNormalizer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
final class ArgumentsNormalizer
2222
{
2323

24+
public const ORIGINAL_ARG_ATTRIBUTE = 'originalArg';
25+
2426
public static function reorderFuncArguments(
2527
ParametersAcceptor $parametersAcceptor,
2628
FuncCall $functionCall,
@@ -131,11 +133,13 @@ private static function reorderArgs(ParametersAcceptor $parametersAcceptor, Call
131133
} elseif (array_key_exists($arg->name->toString(), $argumentPositions)) {
132134
$argName = $arg->name->toString();
133135
// order named args into the position the signature expects them
136+
$attributes = $arg->getAttributes();
137+
$attributes[self::ORIGINAL_ARG_ATTRIBUTE] = $arg;
134138
$reorderedArgs[$argumentPositions[$argName]] = new Arg(
135139
$arg->value,
136140
$arg->byRef,
137141
$arg->unpack,
138-
$arg->getAttributes(),
142+
$attributes,
139143
null,
140144
);
141145
}

src/Analyser/NodeScopeResolver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3265,7 +3265,8 @@ private function processArgs(
32653265
$hasYield = false;
32663266
$throwPoints = [];
32673267
foreach ($args as $i => $arg) {
3268-
$nodeCallback($arg, $scope);
3268+
$originalArg = $arg->getAttribute(ArgumentsNormalizer::ORIGINAL_ARG_ATTRIBUTE) ?? $arg;
3269+
$nodeCallback($originalArg, $scope);
32693270
if (isset($parameters) && $parametersAcceptor !== null) {
32703271
$assignByReference = false;
32713272
if (isset($parameters[$i])) {

0 commit comments

Comments
 (0)