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

FriendsOfPHP / PHP-CS-Fixer / 21370
89%
master: 93%

Build:
Build:
LAST BUILD BRANCH: phpdocAlignFixer
DEFAULT BRANCH: master
Ran 06 Aug 2020 01:05PM UTC
Jobs 1
Files 390
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

pending completion
21370

push

travis-ci

SpacePossum
bug #5065 TernaryOperatorSpacesFixer - fix for discovering ":" correctly (kubawerlos)

This PR was squashed before being merged into the 2.15 branch (closes #5065).

Discussion
----------

TernaryOperatorSpacesFixer - fix for discovering ":" correctly

In the original code for each occurrence of `?` it was assumed that the next `:` is the other part of the operator - which is not always true - see the latter test added to `TernaryOperatorSpacesFixerTest.php`.

Also, when there was no whitespace before `?` the operator was counted twice, because:
 - the loop was iterating by increasing index
 - so at one moment `?` was found at index `n`
 - as it had no whitespace before it, the whitespace was added - at index `n`, so the `?` was moved to position `n + 1`
 - next loop iteration with `n + 1` discovered the very same `?` once again and increased `$ternaryLevel` for the second time.

This scenario is covered by the first test added to `TernaryOperatorSpacesFixerTest.php` - the second `:` (the one from `switch`) was recognized as part of the ternary operator.

THE FIX:
As it might look as overkill it is actually copied from https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4021 - so it will be reused there and I believe is quite clean and - especially - bulletproof solution.

Commits
-------

726f0ae88 TernaryOperatorSpacesFixer - fix for discovering \":\" correctly

15018 of 16391 relevant lines covered (91.62%)

36.44 hits per line

Jobs
ID Job ID Ran Files Coverage
7 21370.7 (DEFAULT_COMPOSER_FLAGS="--optimize-autoloader --no-interaction --no-progress" COMPOSER_FLAGS="") 06 Aug 2020 01:03PM UTC 0
91.62
Travis Job 21370.7
Source Files on build 21370
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #21370
  • 02a63e3f on github
  • Prev Build on 2.15 (#21368)
  • Next Build on 2.15 (#21371)
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