Skip to content

Commit 8e3355a

Browse files
authored
Merge pull request #171 from phpeek/fix-multiple-switch
Handles multiple switch statements.
2 parents 3a6ca24 + d80f415 commit 8e3355a

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
[![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)
1010
[![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)
11-
![Tests](https://img.shields.io/badge/tests-1358-brightgreen.svg)
11+
![Tests](https://img.shields.io/badge/tests-1359-brightgreen.svg)
1212
[![Mutation testing badge](https://badge.stryker-mutator.io/github.com/kubawerlos/php-cs-fixer-custom-fixers/master)](https://stryker-mutator.github.io)
1313
[![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)
1414

src/Fixer/OperatorLinebreakFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private function getExcludedIndices(Tokens $tokens): array
135135
$indices = [];
136136
for ($index = $tokens->count() - 1; $index > 0; $index--) {
137137
if ($tokens[$index]->isGivenKind(T_SWITCH)) {
138-
$indices += $this->getCasesColonsForSwitch($tokens, $index);
138+
$indices = \array_merge($indices, $this->getCasesColonsForSwitch($tokens, $index));
139139
}
140140
}
141141

tests/Fixer/OperatorLinebreakFixerTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,22 @@ function foo(
189189
null,
190190
['position' => 'end'],
191191
];
192+
193+
yield 'multiple switches' => [
194+
'<?php
195+
switch ($foo) {
196+
case 1:
197+
break;
198+
case 2:
199+
break;
200+
}
201+
switch($bar) {
202+
case 1:
203+
break;
204+
case 2:
205+
break;
206+
}',
207+
];
192208
}
193209

194210
private function pairs(): iterable

0 commit comments

Comments
 (0)