• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHPCSStandards / PHP_CodeSniffer / 13438344916 / 2
78%
master: 79%

Build:
Build:
LAST BUILD BRANCH: catch-per-3.0
DEFAULT BRANCH: master
Ran 20 Feb 2025 03:17PM UTC
Files 262
Run time 16s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

20 Feb 2025 03:06PM UTC coverage: 1.901%. Remained the same
13438344916.2

push

github

jrfnl
Squiz/EmbeddedPhp: bug fix - fixer conflict with itself

For multi-line PHP snippets, the `Squiz.PHP.EmbeddedPhp` sniff expects the open and close tag to each be on their own line.
For single-line PHP snippets, it does not.

Now, the sniff already handled a close tag of a previous multi-line snippet and the open tag of a next multi-line snippet being on the same line correctly and prevented a fixer conflict for that, but it did not correctly handle the open tag of a multi-line snippet being on the same line after a single-line PHP snippet.

In that case, it would not recognize that the open tag had to be moved to its own line and it would also calculate the expected indent for both the PHP open tag as well as the first line of the content within the multi-line snippet incorrectly, which in turn would lead to fixer conflicts with the `Generic.WhiteSpace.ScopeIndent` sniff.

I.e. for the new test added:
```php
<?php echo 'Open tag after code'; ?>            <?php
echo $j;
?>
```
... the sniff would previously throw the following error:
```
ERROR | [x] Opening PHP tag indent incorrect; expected no more than 4 spaces but found 48 (Squiz.PHP.EmbeddedPhp.OpenTagIndent)
ERROR | [x] First line of embedded PHP code must be indented 11 spaces; 0 found (Squiz.PHP.EmbeddedPhp.Indent)
```
... and the fixer would conflict and try to add the same indent to the open tag time and time again, but without adding a new line, which meant it was replacing the token content with the existing content, not fixing anything. Hence, the fixer conflict with itself.

Also take note of the incorrect indent expectation for the next line (11 spaces).

This commit fixes both issues by:
1. Improving the "does this line containing a PHP open tag have content on it before" verification for the `ContentBeforeOpen` error and
2. Fixing the "what should the indent be" calculation for both the `ContentBeforeOpen` error (for the indent when the tag is moved to the next line), as well as for th... (continued)

468 of 24617 relevant lines covered (1.9%)

0.03 hits per line

Source Files on job cbf-os-ubuntu-latest-ubuntu-latest-php-8.1-custom-ini-true - 13438344916.2
  • Tree
  • List 262
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 13438344916
  • bbed9064 on github
  • Prev Job for on 4.0 (#13437923291.8)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc