PHPCSStandards / PHP_CodeSniffer

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

`<file>` should be scan also for exact match, not only with configured endings #526

Closed mvorisek closed 3 months ago

mvorisek commented 3 months ago

Is your feature request related to a problem?

see https://github.com/doctrine/sql-formatter/pull/129#discussion_r1634725933

Describe the solution you'd like

<file> matches all <file><ending like .php> but also <file>

Additional context (optional)

jrfnl commented 3 months ago

@mvorisek Scanning files without extension is already on the roadmap for the 4.0 release (and has already been committed to the 4.0 branch). See: https://github.com/squizlabs/PHP_CodeSniffer/issues/2916

Note: this will still only scan files without extension which are explicitly requested (by name). It will not automatically scan files without extension. See the issue I referred to for a more detailed reasoning about this.

Also: this will not be addressed in the 3.x branch as without extension, PHPCS would not know what tokenizer to use for the file. This problem does not exist in the 4.x branch where support for JS and CSS has been dropped.

I suggest closing this issue.

mvorisek commented 3 months ago

Thank you for your detailed and quick reply.

As there is no v4 yet and per your answer the issue for v3 is tokenizer detection, what about backporting it to v3 for PHP files by detecting <?php on 1st or 2nd line if shebang line is present?

jrfnl commented 3 months ago

@mvorisek I'm working on getting v4 ready for release, but there are quite some things still to be done, so it will definitely be a few more months for sure, though fingers crossed we'll have a release before the end of the year.

Having said that, no, I will not accept a backport as just looking for <?php on the first/second line is totally unreliable as:

So, no, I'm not prepared to take on the headache of accepting a backport which will only raise a lot of support questions. Sorry. You'll just have to be a little patient.

mvorisek commented 3 months ago

Thank you for this detailed roadmap.

jrfnl commented 3 months ago

@mvorisek Hmm... not sure what you see as a roadmap, but if you want info on the things which are expected to go into the v4 release (aside from what's already there and fixing what's already there), have a look at the milestone: https://github.com/PHPCSStandards/PHP_CodeSniffer/milestone/3

If you want to stay informed, consider adding yourself to the community cc list. See the CONTRIBUTING GUIDE on how that works.