Menu

← Back to argument.*

Error Identifier: argument.positionalAfterNamed

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

function greet(string $first, string $last): string
{
	return "$first $last";
}

greet(first: 'John', 'Doe');

Why is it reported? #

PHP does not allow positional arguments to follow named arguments in a function or method call. Once a named argument is used, all subsequent arguments must also be named. This is a compile-time error enforced by PHP itself.

In the example above, 'Doe' is a positional argument that follows the named argument first: 'John', which is not valid PHP syntax.

How to fix it #

Make all arguments after the first named argument also named:

 <?php declare(strict_types = 1);
 
 function greet(string $first, string $last): string
 {
 	return "$first $last";
 }

-greet(first: 'John', 'Doe');
+greet(first: 'John', last: 'Doe');

Alternatively, use only positional arguments:

 <?php declare(strict_types = 1);
 
 function greet(string $first, string $last): string
 {
 	return "$first $last";
 }

-greet(first: 'John', 'Doe');
+greet('John', 'Doe');

Non-ignorable error #

This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.

Rules that report this error #

  • PHPStan\Rules\Classes\ClassAttributesRule [1]
  • PHPStan\Rules\Classes\ClassConstantAttributesRule [1]
  • PHPStan\Rules\Classes\InstantiationRule [1]
  • PHPStan\Rules\Constants\ConstantAttributesRule [1]
  • PHPStan\Rules\EnumCases\EnumCaseAttributesRule [1]
  • PHPStan\Rules\Functions\ArrowFunctionAttributesRule [1]
  • PHPStan\Rules\Functions\CallCallablesRule [1]
  • PHPStan\Rules\Functions\CallToFunctionParametersRule [1]
  • PHPStan\Rules\Functions\CallUserFuncRule [1]
  • PHPStan\Rules\Functions\ClosureAttributesRule [1]
  • PHPStan\Rules\Functions\FunctionAttributesRule [1]
  • PHPStan\Rules\Functions\ParamAttributesRule [1]
  • PHPStan\Rules\Methods\CallMethodsRule [1]
  • PHPStan\Rules\Methods\CallStaticMethodsRule [1]
  • PHPStan\Rules\Methods\MethodAttributesRule [1]
  • PHPStan\Rules\Properties\PropertyAttributesRule [1]
  • PHPStan\Rules\Properties\PropertyHookAttributesRule [1]
  • PHPStan\Rules\Traits\TraitAttributesRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.