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 generator #709

Open
4 tasks done
rodrigoprimo opened this issue Nov 22, 2024 · 1 comment · May be fixed by #771
Open
4 tasks done

PHP fatal error when user passes an invalid generator #709

rodrigoprimo opened this issue Nov 22, 2024 · 1 comment · May be fixed by #771

Comments

@rodrigoprimo
Copy link
Contributor

rodrigoprimo commented Nov 22, 2024

Describe the bug

PHPCS throws a fatal error when the user passes an invalid generator.

To reproduce

Steps to reproduce the behavior:

  1. Run phpcs test.php --generator=InvalidGenerator --standard=Generic
  2. See the error message displayed
$ phpcs test.php --generator=InvalidGenerator --standard=Generic          
PHP Fatal error:  Uncaught Error: Class "PHP_CodeSniffer\Generators\InvalidGenerator" not found in src/Runner.php:98
Stack trace:
#0 bin/phpcs(14): PHP_CodeSniffer\Runner->runPHPCS()
#1 {main}
  thrown in src/Runner.php on line 98

Expected behavior

PHPCS should display a user-friendly error message informing the user that the generator does not exist and potentially listing the available generators.

Please confirm

  • I have searched the issue list and am not opening a duplicate issue.
  • I have read the Contribution Guidelines and this is not a support question.
  • I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
  • I have verified the issue still exists in the master branch of PHP_CodeSniffer.
@jrfnl
Copy link
Member

jrfnl commented Nov 22, 2024

Marking this as an enhancement instead of a bug, as the error is with the user, not with PHPCS, but PHPCS can handle the error in a more user-friendly manner, hence: enhancement.

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