PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

Hidden files ignored even if explicitly defined

Open Rasmus-Bertell opened this issue 5 months ago • 8 comments

Describe the bug

I have two identical files app/Models/Locale.php and app/Models/.Locale.php phpcs only reports the errors on the first one and phpcbf only fixes the first one.

Code sample

<?php return FALSE;

To reproduce

Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above
  2. Copy the file cp test.php .test.php
  3. Run phpcs test.php
  4. Run phpcs .test.php
  5. Run phpcbf test.php
  6. Run phpcbf .test.php
$ phpcs test.php

FILE: /home/rasmus/test.php
--------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
--------------------------------------------------------------------------------------------
 1 | ERROR | [ ] Missing file doc comment
 1 | ERROR | [x] TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
--------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------

Time: 35ms; Memory: 6MB

$ phpcs .test.php
$ phpcbf test.php

PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
/home/rasmus/test.php                                 1      1
----------------------------------------------------------------------
A TOTAL OF 1 ERROR WERE FIXED IN 1 FILE
----------------------------------------------------------------------

Time: 38ms; Memory: 6MB

$ phpcbf .test.php

No fixable errors were found

Time: 33ms; Memory: 6MB

Expected behavior

I expect it to run the same regardless of the filename.

Versions (please complete the following information)

Operating System Archlinux 6.7.9-arch1-1
PHP version 8.3.3
PHP_CodeSniffer version 3.7.2
Standard Not configured
Install type Neovim Mason plugin which still uses the old repository

Please confirm:

  • [x] I have searched the issue list and am not opening a duplicate issue.
  • [x] I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
  • [x] I have verified the issue still exists in the master branch of PHP_CodeSniffer.

Rasmus-Bertell avatar Mar 14 '24 18:03 Rasmus-Bertell