Menu

← Back to parameter.*

Error Identifier: parameter.notVariadic

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

interface Handler
{
	public function handle(string ...$args): void;
}

class MyHandler implements Handler
{
	public function handle(string $args): void
	{
	}
}

Why is it reported? #

A method parameter is declared as non-variadic, but the corresponding parameter in the parent method or interface is variadic. This violates the Liskov Substitution Principle – code that calls the parent method with multiple arguments would fail when the overriding method is called instead.

In the example above, Handler::handle() accepts any number of string arguments, but MyHandler::handle() accepts only one.

How to fix it #

Make the parameter variadic to match the parent declaration:

 class MyHandler implements Handler
 {
-	public function handle(string $args): void
+	public function handle(string ...$args): void
 	{
 	}
 }

How to ignore this error #

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

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

Rules that report this error #

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

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.