Skip to content

Conversation

@carlos-granados
Copy link
Contributor

Updates the ArgumentDefaultValueReplacer class (which is used by the ReplaceArgumentDefaultValueRector and FunctionArgumentDefaultValueReplacerRector rules) to handle named arguments

return $this->processParams($node, $replaceArgumentDefaultValue);
}

if (! isset($node->args[$replaceArgumentDefaultValue->getPosition()])) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to do this check later because the position may change if we have named arguments

$replaceArgumentDefaultValue->getValueBefore()
) && $argValue === $replaceArgumentDefaultValue->getValueBefore()) {
$expr->args[$position] = $this->normalizeValueToArgument($replaceArgumentDefaultValue->getValueAfter());
$particularArg->value = $this->normalizeValue($replaceArgumentDefaultValue->getValueAfter());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to create a new argument, instead we just set the value of the existing argument. This allows us to keep named arguments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant