Skip to content
Permalink
Browse files

Merge pull request #171 from phpeek/fix-multiple-switch

Handles multiple switch statements.
  • Loading branch information...
kubawerlos committed Oct 28, 2019
2 parents 3a6ca24 + d80f415 commit 8e3355a440b50341f4813c68fbcb5d096706201a
Showing with 18 additions and 2 deletions.
  1. +1 −1 README.md
  2. +1 −1 src/Fixer/OperatorLinebreakFixer.php
  3. +16 −0 tests/Fixer/OperatorLinebreakFixerTest.php
@@ -8,7 +8,7 @@

[![Build status](https://img.shields.io/travis/kubawerlos/php-cs-fixer-custom-fixers/master.svg)](https://travis-ci.org/kubawerlos/php-cs-fixer-custom-fixers)
[![Code coverage](https://img.shields.io/coveralls/github/kubawerlos/php-cs-fixer-custom-fixers/master.svg)](https://coveralls.io/github/kubawerlos/php-cs-fixer-custom-fixers?branch=master)
![Tests](https://img.shields.io/badge/tests-1358-brightgreen.svg)
![Tests](https://img.shields.io/badge/tests-1359-brightgreen.svg)
[![Mutation testing badge](https://badge.stryker-mutator.io/github.com/kubawerlos/php-cs-fixer-custom-fixers/master)](https://stryker-mutator.github.io)
[![Psalm type coverage](https://shepherd.dev/github/kubawerlos/php-cs-fixer-custom-fixers/coverage.svg)](https://shepherd.dev/github/kubawerlos/php-cs-fixer-custom-fixers)

@@ -135,7 +135,7 @@ private function getExcludedIndices(Tokens $tokens): array
$indices = [];
for ($index = $tokens->count() - 1; $index > 0; $index--) {
if ($tokens[$index]->isGivenKind(T_SWITCH)) {
$indices += $this->getCasesColonsForSwitch($tokens, $index);
$indices = \array_merge($indices, $this->getCasesColonsForSwitch($tokens, $index));
}
}
@@ -189,6 +189,22 @@ function foo(
null,
['position' => 'end'],
];
yield 'multiple switches' => [
'<?php
switch ($foo) {
case 1:
break;
case 2:
break;
}
switch($bar) {
case 1:
break;
case 2:
break;
}',
];
}
private function pairs(): iterable

0 comments on commit 8e3355a

Please sign in to comment.
You can’t perform that action at this time.