Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP fatal error when user passes an invalid filter #775

Open
1 of 2 tasks
rodrigoprimo opened this issue Dec 18, 2024 · 0 comments
Open
1 of 2 tasks

PHP fatal error when user passes an invalid filter #775

rodrigoprimo opened this issue Dec 18, 2024 · 0 comments

Comments

@rodrigoprimo
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants