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
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
[ ] This change is only breaking for integrators, not for external standards or end-users.
[ ] Documentation improvement
PR checklist
[x] I have checked there is no other PR open for the same change.
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