Open rodrigoprimo opened 3 days ago
Leaving a single space after a short open tag makes sense to me and a PR to add special handling for short open tags would be welcome. Though as you already said: low priority as it's not a parse error and AFAICS not a cause for fixer conflicts.
Describe the bug
While working on https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/699, I noticed an inconsistency in how the
Generic.CodeAnalysis.EmptyPHPStatement
sniff fixes superfluous semicolons placed right after a PHP open tag when the PHP ini directiveshort_open_tag
is enabled.If a normal open tag is used, the superfluous semicolon is removed, and a space is left between the open tag and the rest of the code. If a shot open tag is used, no space is left between the open tag and the rest of the code. I'm inclined to think the sniff should behave the same for both types of open tags.
This is probably not a high-priority issue as the resulting code is not a parse error, and short open tags are not very popular.
Related to https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/593
Code sample
To reproduce
Steps to reproduce the behavior:
short_open_tag
ini directive is enabled.test.php
with the code sample above.phpcbf --standard=Generic --sniffs=Generic.CodeAnalysis.EmptyPHPStatement test.php
<?
andmy_function();
.<?my_function(); ?>