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

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

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

06 Aug 2020 12:16PM UTC coverage: 91.623% (+0.03%) from 91.591%
DEFAULT_COMPOSER_FLAGS="--optimize-autoloader --no-interaction --no-progress" COMPOSER_FLAGS=""

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

Source Files on job 21370.7 (DEFAULT_COMPOSER_FLAGS="--optimize-autoloader --no-interaction --no-progress" COMPOSER_FLAGS="")
  • Tree
  • List 0
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 16430
  • Travis Job 21370.7
  • 02a63e3f on github
  • Prev Job for DEFAULT_COMPOSER_FLAGS="--optimize-autoloader --no-interaction --no-progress" COMPOSER_FLAGS="" on 2.15 (#21368.7)
  • Next Job for DEFAULT_COMPOSER_FLAGS="--optimize-autoloader --no-interaction --no-progress" COMPOSER_FLAGS="" on 2.15 (#21371.7)
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