Skip to content

Commit

Permalink
Call nodeCallback with original argument with a name after reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 17, 2022
1 parent 2222b63 commit ecc3076
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Analyser/ArgumentsNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
final class ArgumentsNormalizer
{

public const ORIGINAL_ARG_ATTRIBUTE = 'originalArg';

public static function reorderFuncArguments(
ParametersAcceptor $parametersAcceptor,
FuncCall $functionCall,
Expand Down Expand Up @@ -131,11 +133,13 @@ private static function reorderArgs(ParametersAcceptor $parametersAcceptor, Call
} elseif (array_key_exists($arg->name->toString(), $argumentPositions)) {
$argName = $arg->name->toString();
// order named args into the position the signature expects them
$attributes = $arg->getAttributes();
$attributes[self::ORIGINAL_ARG_ATTRIBUTE] = $arg;
$reorderedArgs[$argumentPositions[$argName]] = new Arg(
$arg->value,
$arg->byRef,
$arg->unpack,
$arg->getAttributes(),
$attributes,
null,
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3265,7 +3265,8 @@ private function processArgs(
$hasYield = false;
$throwPoints = [];
foreach ($args as $i => $arg) {
$nodeCallback($arg, $scope);
$originalArg = $arg->getAttribute(ArgumentsNormalizer::ORIGINAL_ARG_ATTRIBUTE) ?? $arg;
$nodeCallback($originalArg, $scope);
if (isset($parameters) && $parametersAcceptor !== null) {
$assignByReference = false;
if (isset($parameters[$i])) {
Expand Down

0 comments on commit ecc3076

Please sign in to comment.