-
- Notifications
You must be signed in to change notification settings - Fork 89
Closed
Labels
Description
Describe the bug
Status of short_open_tag impact how phpcs determine if a file is php or not, despite --extensions being set.
To reproduce
- Create an file
touch foo - Run phpcs with any ruleset and short open tags allowed
php -d short_open_tag=On src/vendor/bin/phpcs -s --extensions=php --standard=Squiz foo - phpcs ignore
fooas non php file. - Run phpcs without short open tags:
php -d short_open_tag=Off src/vendor/bin/phpcs -s --extensions=php --standard=Squiz foo - phpcs raise an error:
FILE: 'foo --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 | WARNING | No PHP code was found in this file and short open tags are not allowed by this install of PHP. This file may be using short open tags but PHP does not allow them. (Internal.NoCodeFound) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Time: 29ms; Memory: 16MB Expected behavior
As file has no extension, it should be ignored, regardless of the status of short_open_tag
Versions (please complete the following information)
| Operating System | Nix |
| PHP version | 8.4.13 |
| PHP_CodeSniffer version | 4.0.0 |
| Standard | anyone |
| Install type | composer local |
Additional context
I face this issue because I run phpcs in the context of CI and, in order to speed up the process, I pass to the CLI the list of files modified in a change. I caught the issue because I modified a .gitignore file and this was flagged with reported error.
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
4.xbranch of PHP_CodeSniffer.