squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.69k stars 1.48k forks source link

--filter={gitmodified, gitstaged} is case-sensitive #3877

Closed simonsan closed 1 year ago

simonsan commented 1 year ago

Describe the bug

2023-08-19 03_45_26-Usage · squizlabs_PHP_CodeSniffer Wiki — Mozilla Firefox

The documentation says, that a filter parameter can have one of the values {gitmodified, gitstaged}.

Code sample

phpcs -q --report=checkstyle --standard=PSR12 --filter=gitmodified --file-list=.phpcsinclude --tab-width=4 --parallel=10 | cs2pr

To reproduce

Steps to reproduce the behavior:

  1. run the command above
  2. See error message displayed
PHP Fatal error:  Uncaught Error: Class "\PHP_CodeSniffer\Filters\gitmodified" not found in phar:///usr/local/bin/phpcs/src/Files/FileList.php:3
Stack trace:
#0 phar:///usr/local/bin/phpcs/src/Files/FileList.php(3): PHP_CodeSniffer\Files\FileList->addFile()
#1 phar:///usr/local/bin/phpcs/src/Runner.php(3): PHP_CodeSniffer\Files\FileList->__construct()
#2 phar:///usr/local/bin/phpcs/src/Runner.php(3): PHP_CodeSniffer\Runner->run()
#3 /usr/local/bin/phpcs(6): PHP_CodeSniffer\Runner->runPHPCS()
#4 {main}
  thrown in phar:///usr/local/bin/phpcs/src/Files/FileList.php on line 3

Expected behaviour

The documentation states valid values. In this case: {GitModified, GitStaged}. Or the input value is converted to PascalCase.

Please confirm:

jrfnl commented 1 year ago

@simonsan Good catch! Would you like to submit a PR to fix this ? (the CLI documentation)

jrfnl commented 1 year ago

FYI: For the Wiki, I've just fixed it: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage

simonsan commented 1 year ago

@simonsan Good catch! Would you like to submit a PR to fix this ? (the CLI documentation)

Done

jrfnl commented 1 year ago

FYI: the fix for this issue is included in today's PHP_CodeSniffer 3.8.0 release.

As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).