Skip to content

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

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

Closed
1 of 2 tasks
mvorisek opened this issue Jun 11, 2024 · 5 comments
Closed
1 of 2 tasks

Comments

@mvorisek
Copy link

Is your feature request related to a problem?

see doctrine/sql-formatter#129 (comment)

Describe the solution you'd like

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

Additional context (optional)

@jrfnl
Copy link
Member

jrfnl commented Jun 11, 2024

@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: squizlabs/PHP_CodeSniffer#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
Copy link
Author

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
Copy link
Member

jrfnl commented Jun 11, 2024

@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:

  • it may be a template-like file with HTML and inline PHP mixed together;
  • it may be a file which doesn't contain a <?php open tag and only uses <?= tags;
  • the short PHP open tag <? could be used;
  • ...which could get confusing with things like <?xml at the start of a file;
  • And for files in which no PHP tag exists at all, we'd be stuck not knowing how to interpret the file as it could be either JS or CSS.

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
Copy link
Author

Thank you for this detailed roadmap.

@jrfnl
Copy link
Member

jrfnl commented Jun 11, 2024

@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.

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

No branches or pull requests

2 participants