Make exclusion list more specific for Magento template files #11
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.
When working with a website that we have inherited from another agency, I noticed that the
Generic.PHP.DisallowShortOpenTag
rule was applying to*.php
files, but not to*.phtml
files. After some investigation, I found that the<exclude-pattern>
directive was applying too broadly. When a sniff is in both standards, this<exclude-pattern>
rule meant that it would only apply to PHP files, not Magento2 template files.I made a list of all overlapping sniffs (ie, those in both the
Youwe
andMagento2
standards), and then included only those that made sense to not apply to Magento template files in the exclude list. To see the sniffs included in these standards, one can runvendor/bin/phpcs -e --standard=Youwe
andvendor/bin/phpcs -e --standard=Magento2
.Some examples of a sniffs not marked for exclusion here are:
GlobalPhpUnit.Coverage.CoversTag
- we should not be defining any PHPUnit test classes/methods in template files, so this rule should never match anything anyway.PSR12.Classes.OpeningBraceSpace
- no classes should be declared in template files, so this rule should never match anything anyway.Squiz.WhiteSpace.CastSpacing
- cast syntax should be uniform in all files scanned, not just.php
files.This is a follow-up to #5 and #10.