44
55use PhpParser \Node ;
66use PhpParser \Node \Expr ;
7+ use PHPStan \Analyser \CollectedDataEmitter ;
78use PHPStan \Analyser \MutatingScope ;
9+ use PHPStan \Analyser \NodeCallbackInvoker ;
810use PHPStan \Analyser \Scope ;
911use PHPStan \DependencyInjection \AutowiredParameter ;
1012use PHPStan \DependencyInjection \AutowiredService ;
1416use PHPStan \Reflection \ParametersAcceptor ;
1517use PHPStan \Reflection \ReflectionProvider ;
1618use PHPStan \Reflection \ResolvedFunctionVariant ;
19+ use PHPStan \Rules \Methods \NamedArgumentParameterMethodCallsCollector ;
1720use PHPStan \Rules \PhpDoc \UnresolvableTypeHelper ;
1821use PHPStan \Rules \Properties \PropertyReflectionFinder ;
1922use PHPStan \ShouldNotHappenException ;
3235use function array_fill ;
3336use function array_key_exists ;
3437use function array_last ;
38+ use function array_merge ;
3539use function count ;
3640use function implode ;
3741use function in_array ;
@@ -65,11 +69,12 @@ public function __construct(
6569
6670 /**
6771 * @param 'attribute'|'callable'|'method'|'staticMethod'|'function'|'new' $nodeType
72+ * @param array{class-string, string}|null $renamedNamedArgumentParameterData
6873 * @return list<IdentifierRuleError>
6974 */
7075 public function check (
7176 ParametersAcceptor $ parametersAcceptor ,
72- Scope $ scope ,
77+ Scope & NodeCallbackInvoker & CollectedDataEmitter $ scope ,
7378 bool $ isBuiltin ,
7479 Node \Expr \FuncCall |Node \Expr \MethodCall |Node \Expr \StaticCall |Node \Expr \New_ $ funcCall ,
7580 string $ nodeType ,
@@ -92,6 +97,7 @@ public function check(
9297 string $ invalidConstantMessage ,
9398 string $ exclusiveConstantsMessage ,
9499 string $ bitmaskNotAllowedMessage ,
100+ ?array $ renamedNamedArgumentParameterData ,
95101 ): array
96102 {
97103 if ($ funcCall instanceof Node \Expr \MethodCall || $ funcCall instanceof Node \Expr \StaticCall || $ funcCall instanceof Node \Expr \FuncCall) {
@@ -359,6 +365,11 @@ public function check(
359365 ->build ();
360366 }
361367 }
368+ } elseif ($ argumentName !== null && $ renamedNamedArgumentParameterData !== null ) {
369+ $ scope ->emitCollectedData (NamedArgumentParameterMethodCallsCollector::class, array_merge (
370+ $ renamedNamedArgumentParameterData ,
371+ [$ parameter ->getName (), $ argumentLine ],
372+ ));
362373 }
363374
364375 if ($ this ->checkArgumentTypes ) {
0 commit comments