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

PHPCSStandards / PHP_CodeSniffer / 13438344916
78%
master: 79%

Build:
Build:
LAST BUILD BRANCH: catch-per-3.0
DEFAULT BRANCH: master
Ran 20 Feb 2025 03:08PM UTC
Jobs 8
Files 262
Run time 1min
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: 77.309% (-0.005%) from 77.314%
13438344916

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)

32 of 32 new or added lines in 1 file covered. (100.0%)

1 existing line in 1 file now uncovered.

19165 of 24790 relevant lines covered (77.31%)

76.7 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
1
99.61
-0.39% src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php
Jobs
ID Job ID Ran Files Coverage
1 os-windows-latest-php-7.2-custom-ini-false - 13438344916.1 20 Feb 2025 03:07PM UTC 262
2.13
GitHub Action Run
2 cbf-os-ubuntu-latest-ubuntu-latest-php-8.1-custom-ini-true - 13438344916.2 20 Feb 2025 03:11PM UTC 262
1.9
GitHub Action Run
3 os-windows-latest-php-8.4-custom-ini-false - 13438344916.3 20 Feb 2025 03:08PM UTC 262
2.68
GitHub Action Run
4 os-ubuntu-latest-php-8.4-custom-ini-false - 13438344916.4 20 Feb 2025 03:10PM UTC 262
75.81
GitHub Action Run
5 cbf-os-ubuntu-latest-ubuntu-latest-php-8.4-custom-ini-false - 13438344916.5 20 Feb 2025 03:10PM UTC 262
1.89
GitHub Action Run
6 os-ubuntu-latest-php-8.1-custom-ini-true - 13438344916.6 20 Feb 2025 03:11PM UTC 262
75.82
GitHub Action Run
7 cbf-os-ubuntu-latest-ubuntu-latest-php-7.2-custom-ini-false - 13438344916.7 20 Feb 2025 03:12PM UTC 262
0.81
GitHub Action Run
8 os-ubuntu-latest-php-7.2-custom-ini-false - 13438344916.8 20 Feb 2025 03:12PM UTC 262
73.64
GitHub Action Run
Source Files on build 13438344916
  • Tree
  • List 262
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #13438344916
  • bbed9064 on github
  • Prev Build on 4.0 (#13437923291)
  • Next Build on 4.0 (#13451299039)
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