Menu

← Back to argument.*

Error Identifier: argument.unknown

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): void
{
}

foo(i: 1, j: 2, z: 3);

Why is it reported? #

When using named arguments, the argument name must match a declared parameter name in the called function or method. In the example above, foo() declares parameters $i and $j, but the call passes a named argument z which does not correspond to any parameter. PHP throws an Error at runtime for unknown named arguments.

How to fix it #

Use the correct parameter name:

 <?php declare(strict_types = 1);
 
 function foo(int $i, int $j): void
 {
 }

-foo(i: 1, j: 2, z: 3);
+foo(i: 1, j: 2);

Or, if the extra argument is intentional, add a corresponding parameter to the function:

 <?php declare(strict_types = 1);
 
-function foo(int $i, int $j): void
+function foo(int $i, int $j, int $z = 0): void
 {
 }

 foo(i: 1, j: 2, z: 3);

How to ignore this error #

You can use the identifier argument.unknown to ignore this error using a comment:

// @phpstan-ignore argument.unknown
codeThatProducesTheError();

You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:

parameters:
	ignoreErrors:
		-
			identifier: argument.unknown

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.