Skip to content

Commit

Permalink
more test
Browse files Browse the repository at this point in the history
  • Loading branch information
SpacePossum committed Mar 9, 2022
1 parent 85ee54e commit e01726a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Fixer/Operator/BinaryOperatorSpacesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,8 @@ private function injectAlignmentPlaceholders(Tokens $tokens, int $startAt, int $

for ($index = $startAt; $index < $endAt; ++$index) {
$token = $tokens[$index];

$content = $token->getContent();

if (
strtolower($content) === $tokenContent
&& $this->tokensAnalyzer->isBinaryOperator($index)
Expand Down
76 changes: 68 additions & 8 deletions tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ public function provideConfiguredCases(): array
],
[
'<?php
$var = [];
$var = [1 => 2];
foreach ([
1 => 2,
2 => 3,
] as $k => $v) {
$var[] = [$i => $bar];
}',
'<?php
$var = [];
$var = [1=>2];
foreach ([
1=> 2,
2 =>3,
Expand Down Expand Up @@ -798,7 +798,7 @@ function b(
for ($i = 0; $i < 10; $i++) {
$aa = 2;
$a[$b] = array();
$a[$b] = array(12);
}',
'<?php
$ccc = 1;
Expand Down Expand Up @@ -845,7 +845,7 @@ function b(
for ($i = 0; $i < 10; $i++) {
$aa = 2;
$a[$b] = array();
$a[$b] = array(12);
}',
],
];
Expand Down Expand Up @@ -1344,15 +1344,35 @@ function b(
$abc[$bcd = 1] = 1;
}
while (false) {
while ($i = 1) {
$aa = 2;
$a[$b] = array();
}
for ($i = 0; $i < 10; $i++) {
$aa = 2;
$a[$b] = array();
}',
}
$z = 1;
switch($a = 0) {
case 1:
$b = 1;
$cc = 3;
break;
}
foreach ($a as $b) {
$aa = 2;
$a[$b] = array();
}
do {
$aa = 23;
$a[$b] = array(66);
} while ($i = 1);
$a = 3;
',
'<?php
$ccc = 1;
$bb = 1;
Expand Down Expand Up @@ -1391,15 +1411,35 @@ function b(
$abc[$bcd = 1] = 1;
}
while (false) {
while ($i = 1) {
$aa = 2;
$a[$b] = array();
}
for ($i = 0; $i < 10; $i++) {
$aa = 2;
$a[$b] = array();
}',
}
$z = 1;
switch($a = 0) {
case 1:
$b = 1;
$cc = 3;
break;
}
foreach ($a as $b) {
$aa = 2;
$a[$b] = array();
}
do {
$aa = 23;
$a[$b] = array(66);
} while ($i = 1);
$a = 3;
',
],
[
'<?php
Expand Down Expand Up @@ -1991,6 +2031,26 @@ function foo() {}
self::STATUS_INVALID_7 => [(2+3)=> "III", "description" => "invalid file syntax, file ignored"],
];',
],
[
'<?php
$b = [1 => function() {
foreach([$a => 2] as $b) {
$bv = [
$b => 2,
$cc => 3,
];
}}, 2 => 3];
',
'<?php
$b = [1 => function() {
foreach([$a => 2] as $b) {
$bv = [
$b => 2,
$cc => 3,
];
}}, 2 => 3];
',
],
];
}

Expand Down

0 comments on commit e01726a

Please sign in to comment.