@@ -89,6 +89,12 @@ public function check(
8989 string $ namedArgumentMessage ,
9090 ): array
9191 {
92+ if ($ funcCall instanceof Node \Expr \MethodCall || $ funcCall instanceof Node \Expr \StaticCall || $ funcCall instanceof Node \Expr \FuncCall) {
93+ $ funcCallLine = $ funcCall ->name ->getStartLine ();
94+ } else {
95+ $ funcCallLine = $ funcCall ->getStartLine ();
96+ }
97+
9298 $ functionParametersMinCount = 0 ;
9399 $ functionParametersMaxCount = 0 ;
94100 foreach ($ parametersAcceptor ->getParameters () as $ parameter ) {
@@ -225,7 +231,7 @@ public function check(
225231 if ($ hasNamedArguments && !$ scope ->getPhpVersion ()->supportsNamedArguments ()->yes () && !(bool ) $ funcCall ->getAttribute ('isAttribute ' , false )) {
226232 $ errors [] = RuleErrorBuilder::message ('Named arguments are supported only on PHP 8.0 and later. ' )
227233 ->identifier ('argument.namedNotSupported ' )
228- ->line ($ funcCall -> getStartLine () )
234+ ->line ($ funcCallLine )
229235 ->nonIgnorable ()
230236 ->build ();
231237 }
@@ -250,7 +256,7 @@ public function check(
250256 $ functionParametersMinCount ,
251257 ))
252258 ->identifier ('arguments.count ' )
253- ->line ($ funcCall -> getStartLine () )
259+ ->line ($ funcCallLine )
254260 ->build ();
255261 } elseif ($ functionParametersMaxCount === -1 && $ invokedParametersCount < $ functionParametersMinCount ) {
256262 $ errors [] = RuleErrorBuilder::message (sprintf (
@@ -259,7 +265,7 @@ public function check(
259265 $ functionParametersMinCount ,
260266 ))
261267 ->identifier ('arguments.count ' )
262- ->line ($ funcCall -> getStartLine () )
268+ ->line ($ funcCallLine )
263269 ->build ();
264270 } elseif ($ functionParametersMaxCount !== -1 ) {
265271 $ errors [] = RuleErrorBuilder::message (sprintf (
@@ -269,7 +275,7 @@ public function check(
269275 $ functionParametersMaxCount ,
270276 ))
271277 ->identifier ('arguments.count ' )
272- ->line ($ funcCall -> getStartLine () )
278+ ->line ($ funcCallLine )
273279 ->build ();
274280 }
275281 }
@@ -282,11 +288,11 @@ public function check(
282288 ) {
283289 $ errors [] = RuleErrorBuilder::message ($ voidReturnTypeUsed )
284290 ->identifier (sprintf ('%s.void ' , $ nodeType ))
285- ->line ($ funcCall -> getStartLine () )
291+ ->line ($ funcCallLine )
286292 ->build ();
287293 }
288294
289- [$ addedErrors , $ argumentsWithParameters ] = $ this ->processArguments ($ parametersAcceptor , $ funcCall -> getStartLine () , $ isBuiltin , $ arguments , $ hasNamedArguments , $ missingParameterMessage , $ unknownParameterMessage );
295+ [$ addedErrors , $ argumentsWithParameters ] = $ this ->processArguments ($ parametersAcceptor , $ funcCallLine , $ isBuiltin , $ arguments , $ hasNamedArguments , $ missingParameterMessage , $ unknownParameterMessage );
290296 foreach ($ addedErrors as $ error ) {
291297 $ errors [] = $ error ;
292298 }
@@ -528,7 +534,7 @@ static function (Type $type, callable $traverse) use (&$returnTemplateTypes): Ty
528534
529535 $ errors [] = RuleErrorBuilder::message (sprintf ($ unresolvableTemplateTypeMessage , $ name ))
530536 ->identifier ('argument.templateType ' )
531- ->line ($ funcCall -> getStartLine () )
537+ ->line ($ funcCallLine )
532538 ->tip ('See: https://phpstan.org/blog/solving-phpstan-error-unable-to-resolve-template-type ' )
533539 ->build ();
534540 }
@@ -540,7 +546,7 @@ static function (Type $type, callable $traverse) use (&$returnTemplateTypes): Ty
540546 ) {
541547 $ errors [] = RuleErrorBuilder::message ($ unresolvableReturnTypeMessage )
542548 ->identifier (sprintf ('%s.unresolvableReturnType ' , $ nodeType ))
543- ->line ($ funcCall -> getStartLine () )
549+ ->line ($ funcCallLine )
544550 ->build ();
545551 }
546552 }
0 commit comments