PHPCSStandards / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
937 stars 56 forks source link

Squiz/EmbeddedPhp: fix false positive when handling short open tags #591

Closed rodrigoprimo closed 2 months ago

rodrigoprimo commented 2 months ago

Description

This PR fixes a bug in Squiz.PHP.EmbeddedPhp that causes a false positive when handling short open tags and was reported in https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/588.

The content of a PHP long open tag token is <?php (note the space after the tag). The content of a PHP short open tag is <? (no space after the tag). The sniff did not account correctly for this difference when checking the expected number of spaces after a short open tag, resulting in false positives and incorrect fixes.

Suggested changelog entry

Squiz.PHP.EmbeddedPhp false positive when checking spaces after a PHP short open tag.

Related issues/external references

Fixes #588

Types of changes

PR checklist

rodrigoprimo commented 2 months ago

Thanks for reviewing this PR, @jrfnl. I applied your suggestions and it is now ready for a final check.

jrfnl commented 2 months ago

Closing as merged manually in 0ed5577b4e3d70ce357d19a36ab5e64587f4327c.