Skip to content

Fix rules missing named arguments - #7028

Merged
staabm merged 9 commits into
phpstan:2.3.xfrom
staabm:key-arg
Nov 11, 2026
Merged

staabm merged 9 commits into
phpstan:2.3.xfrom
staabm:key-arg

Conversation

@staabm

@staabm staabm commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

rules which do not need Reflection information should utilize ArgumentsNormalizer::getArgByPositionOrName() to support named arguments.

rules which already make use of reflection can utilize the reflection based variant instead, which does not require hardcoding parameter-names at the rule level (which can be a problem in case parameter names can be different, e.g. in different php-versions or library versions):

$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs(
	$scope,
	$node->getArgs(),
	$functionReflection->getVariants(),
	$functionReflection->getNamedArgumentsVariants(),
);

$normalizedFuncCall = ArgumentsNormalizer::reorderFuncArguments($parametersAcceptor, $node);
if ($normalizedFuncCall === null) {
	return [];
}

@staabm
staabm marked this pull request as ready for review November 11, 2026 05:50
@phpstan-bot

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@staabm staabm changed the title NodeConnectingVisitorAttributesRule misses named arguments Fix rules missing named arguments Nov 11, 2026
@staabm

staabm commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

//cc @SanderMuller

@staabm
staabm merged commit 6379c5a into phpstan:2.3.x Nov 11, 2026
887 of 892 checks passed
@staabm
staabm deleted the key-arg branch November 11, 2026 13:52
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.

3 participants