Add check for Emacs UTF-8 file header #77
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This actually prevents the usage of that declaration in every comment, not only on the same line of PHP tag opening.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce?
New Feature
What is the current behavior?
The declaration can be used
-*- coding: utf-8 -*-
everywhere without any prevention.What is the new behavior?
The new custom sniff raises a warning if the declaration
-*- coding: utf-8 -*-
is found in a comment.Note: Since the declaration would be removed from the first line anyway by
PSR12.Files.OpenTag.NotAlone
, this new sniff actually search for it in every comment in the file.If found,
phpcbf
will get rid of the whole comment line. I think it is safe enough to assume that there won't be anything else in the same comment.Does this PR introduce a breaking change?
No
Other information:
As usual, any suggestion to improve the sniff name or the error message are more than welcome 👂