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

PHPCSStandards / PHP_CodeSniffer / 8616469842
78%
master: 79%

Build:
Build:
LAST BUILD BRANCH: 4.x
DEFAULT BRANCH: master
Ran 09 Apr 2024 01:24PM UTC
Jobs 3
Files 259
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

09 Apr 2024 01:20PM UTC coverage: 72.358% (+0.004%) from 72.354%
8616469842

push

github

jrfnl
Squiz/OperatorSpacing: bug fix - prevent fixer conflict

Another one in the fixer conflict series.

When running the `Squiz` standard over all test case files, a fixer conflict in the `Squiz.WhiteSpace.OperatorSpacing` sniff was discovered via the tests in the `./src/Standards/Generic/Tests/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceUnitTest.inc` file for a code sample like this:
```php
$foo = $var // Comment.
    ? false // Comment.
    : true;

```

The conflict essentially comes down to the `Squiz.WhiteSpace.OperatorSpacing` trying to remove the new line before the `?` and the `:` operator, but failing to do so as the new line is included in the comment token on the previous line and the sniff only adjusts/removes whitespace tokens.

Original errors for the code sample added in the test case file:
```
 487 | ERROR | [x] Expected 1 space before "?"; newline found (Squiz.WhiteSpace.OperatorSpacing.SpacingBefore)
 488 | ERROR | [x] Expected 1 space before ":"; newline found (Squiz.WhiteSpace.OperatorSpacing.SpacingBefore)
 493 | ERROR | [x] Expected 1 space before "?"; newline found (Squiz.WhiteSpace.OperatorSpacing.SpacingBefore)
 494 | ERROR | [x] Expected 1 space before ":"; newline found (Squiz.WhiteSpace.OperatorSpacing.SpacingBefore)
 499 | ERROR | [x] Expected 1 space before "?"; newline found (Squiz.WhiteSpace.OperatorSpacing.SpacingBefore)
 504 | ERROR | [x] Expected 1 space before ":"; newline found (Squiz.WhiteSpace.OperatorSpacing.SpacingBefore)
```

The fix proposed in this PR changes the sniff to make the `SpacingBefore` error code non-fixable if the previous non-whitespace token is a comment token - even when the comment token doesn't contain a new line.

While the sniff _could_ auto-fix when the comment token doesn't contain a new line, I have chosen to disable the auto-fixer for those cases anyway as it is not for the sniff to determine whether the comment should be moved, removed or should stay where it is.

With these chan... (continued)

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

17363 of 23996 relevant lines covered (72.36%)

55.28 hits per line

Jobs
ID Job ID Ran Files Coverage
1 php-7.2-custom-ini-false - 8616469842.1 09 Apr 2024 01:25PM UTC 259
68.54
GitHub Action Run
2 php-8.3-custom-ini-false - 8616469842.2 09 Apr 2024 01:24PM UTC 259
70.83
GitHub Action Run
3 php-8.1-custom-ini-true - 8616469842.3 09 Apr 2024 01:24PM UTC 259
70.85
GitHub Action Run
Source Files on build 8616469842
  • Tree
  • List 259
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #8616469842
  • df9d3a2a on github
  • Prev Build on 4.0 (#8604248433)
  • Next Build on 4.0 (#8616918426)
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