Menu

← Back to argument.*

Error Identifier: argument.named

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);

/** @no-named-arguments */
function createTag(string $name, string ...$classes): string
{
	return '';
}

createTag(name: 'div', classes: 'bold');

Why is it reported? #

A named argument or an array with string keys is being unpacked in a call to a function or method that does not accept named arguments. The function is annotated with @no-named-arguments, which means callers must only use positional arguments.

Named arguments may also be disallowed for internal PHP functions that do not support them.

How to fix it #

Use positional arguments instead of named ones:

 <?php declare(strict_types = 1);
 
 /** @no-named-arguments */
 function createTag(string $name, string ...$classes): string
 {
 	return '';
 }

-createTag(name: 'div', classes: 'bold');
+createTag('div', 'bold');

If unpacking an array with string keys, convert it to a list first:

-createTag(...$arrayWithStringKeys);
+createTag(...array_values($arrayWithStringKeys));

How to ignore this error #

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

// @phpstan-ignore argument.named
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.named

Rules that report this error #

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

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.