Skip to content

PHP fatal error when user passes an invalid filter #775

Open
@rodrigoprimo

Description

@rodrigoprimo

Is your feature request related to a problem?

PHPCS throws a fatal error when the user passes an invalid filter:

$ bin/phpcs --filter=InvalidFilter .
PHP Fatal error:  Uncaught Error: Class "\PHP_CodeSniffer\Filters\InvalidFilter" not found in src/Files/FileList.php:90
Stack trace:
#0 src/Runner.php(402): PHP_CodeSniffer\Files\FileList->__construct()
#1 src/Runner.php(120): PHP_CodeSniffer\Runner->run()
#2 bin/phpcs(14): PHP_CodeSniffer\Runner->runPHPCS()
#3 {main}
  thrown in src/Files/FileList.php on line 90

Describe the solution you'd like

PHPCS should display a user-friendly error message informing the user that the filter does not exist and potentially list the available filters.

Additional context

Similar issue but for generators: #709.

While working on this issue, it is probably worth testing the other PHPCS CLI arguments to see if there are more arguments that cause a fatal error when passed invalid input and address them as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions