Menu

← Back to symfonyConsole.*

Error Identifier: symfonyConsole.argumentNotFound

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

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

final class MyCommand extends Command
{
	protected function configure(): void
	{
		$this->setName('my-command');
		$this->addArgument('name');
	}

	protected function execute(InputInterface $input, OutputInterface $output): int
	{
		$input->getArgument('undefined');

		return 0;
	}
}

Why is it reported? #

The getArgument() call references an argument name that was not defined in the command’s configure() method. At runtime, this would throw an InvalidArgumentException.

This error is reported by the phpstan-symfony extension, which resolves Symfony Console commands and validates that referenced arguments exist in the command’s definition.

How to fix it #

Use an argument name that matches one defined via addArgument() in the configure() method:

-$input->getArgument('undefined');
+$input->getArgument('name');

Or add the missing argument definition:

 protected function configure(): void
 {
 	$this->setName('my-command');
 	$this->addArgument('name');
+	$this->addArgument('undefined');
 }

How to ignore this error #

You can use the identifier symfonyConsole.argumentNotFound to ignore this error using a comment:

// @phpstan-ignore symfonyConsole.argumentNotFound
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: symfonyConsole.argumentNotFound

Rules that report this error #

  • PHPStan\Rules\Symfony\UndefinedArgumentRule [1] phpstan/phpstan-symfony

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.