You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that when running the sniffer (PSR2) against a file with short tags, that it does not find the problem.
When Processing the PS1 ruleset it shows that it is ignoring the DisallowShortOpenTag except for the EchoFound check.
.\.vendor\bin\phpcs --standard=PSR2 --exclude=PSR1.Methods.CamelCapsMethodName -vv -- .\ShortTagFile.php
...
Processing rule "Generic.PHP.DisallowShortOpenTag.EchoFound"
=> .vendor\squizlabs\php_codesniffer\src\Standards\Generic\Sniffs\PHP\DisallowShortOpenTagSniff.php
Excluding sniff "Generic.PHP.DisallowShortOpenTag" except for "EchoFound"
=> severity set to 0
It does this because the PSR1\ruleset.xml has this line:
.\.vendor\bin\phpcs --standard=PSR2 -- .\ShortTagFile.php
FILE: .\ShortTagFile.php
-----------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------
1 | ERROR | [x] Short PHP opening tag used; expected "<?php" but found "<?"
-----------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------
Is this expected behavior?
It seems like anyone trying to enforce PSR1/PSR2 will silently fail on this particular sniff.
I have short_open_tag set to on:
php -i | grep short
short_open_tag => On => On
ShortTagFile.php is this:
<?$that = "page just has a short tag.";
The text was updated successfully, but these errors were encountered:
gsherwood
changed the title
DisallowShortOpenTagSniff does not show an error or fix short tags (Standard: PSR1/PSR2)
PSR1/PSR2 not reporting or fixing short open tags
Apr 17, 2018
Thanks a lot for reporting this. The standard was not including the sniff properly before muting the error message. It now does what it is supposed to, which is ban short open tags except for short echo tags.
I noticed that when running the sniffer (PSR2) against a file with short tags, that it does not find the problem.
When Processing the PS1 ruleset it shows that it is ignoring the DisallowShortOpenTag except for the EchoFound check.
It does this because the PSR1\ruleset.xml has this line:
If you change that rule to look like this:
Then it works and produces this:
Is this expected behavior?
It seems like anyone trying to enforce PSR1/PSR2 will silently fail on this particular sniff.
I have short_open_tag set to on:
ShortTagFile.php is this:
The text was updated successfully, but these errors were encountered: