Menu

← Back to argument.*

Error Identifier: argument.unpackAfterNamed

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 foo(int $i, int $j, int $k): void {}

$args = ['j' => 2, 'k' => 3];
foo(i: 1, ...$args);

Why is it reported? #

PHP does not allow an unpacked argument (...) to follow a named argument in a function or method call. When you use a named argument like i: 1, all subsequent arguments passed via the spread operator (...) create an ambiguity because the unpacked array might contain keys that conflict with the already-specified named arguments.

This is a compile-level restriction in PHP and will result in a fatal error at runtime.

How to fix it #

Pass all arguments either as named arguments or use unpacking without mixing the two styles:

<?php declare(strict_types = 1);

function foo(int $i, int $j, int $k): void {}

// Option 1: Use only named arguments
foo(i: 1, j: 2, k: 3);

// Option 2: Use only unpacking
$args = ['i' => 1, 'j' => 2, 'k' => 3];
foo(...$args);

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.