Menu

← Back to parameter.*

Error Identifier: parameter.variadic

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

class Foo
{
	public function doFoo(int $i, string $j): void
	{
	}
}

class Bar extends Foo
{
	public function doFoo(int ...$i): void
	{
	}
}

Why is it reported? #

The overriding method declares a parameter as variadic (...), but the corresponding parameter in the parent method is not variadic. In the example above, Bar::doFoo() declares ...$i as variadic, while Foo::doFoo() declares $i as a regular parameter.

This changes the method signature in a way that is incompatible with the parent. A variadic parameter accepts zero or more arguments, while the parent method expects a fixed number of arguments at specific positions.

How to fix it #

Match the parent method’s parameter list instead of using a variadic parameter:

 class Bar extends Foo
 {
-	public function doFoo(int ...$i): void
+	public function doFoo(int $i, string $j): void
 	{
 	}
 }

How to ignore this error #

You can use the identifier parameter.variadic to ignore this error using a comment:

// @phpstan-ignore parameter.variadic
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: parameter.variadic

Rules that report this error #

  • PHPStan\Rules\Methods\ConsistentConstructorRule [1]
  • PHPStan\Rules\Methods\OverridingMethodRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.