Skip to content

Commit

Permalink
Merge 5a33afc into 56d8399
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Dec 12, 2021
2 parents 56d8399 + 5a33afc commit 5e23b42
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Fixer/LanguageConstruct/DeclareEqualNormalizeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,14 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
continue;
}

while (!$tokens[++$index]->equals('='));
$openParenthesisIndex = $tokens->getNextMeaningfulToken($index);
$closeParenthesisIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openParenthesisIndex);

$this->{$callback}($tokens, $index);
for ($i = $closeParenthesisIndex; $i > $openParenthesisIndex; --$i) {
if ($tokens[$i]->equals('=')) {
$this->{$callback}($tokens, $i);
}
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions tests/Fixer/LanguageConstruct/DeclareEqualNormalizeFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ public function provideFixCases(): array
null,
['space' => 'none'],
],
'declare having multiple directives, single' => [
'<?php declare(strict_types=1, ticks=1);',
'<?php declare(strict_types = 1, ticks = 1);',
[],
],
'declare having multiple directives, none' => [
'<?php declare(strict_types = 1, ticks = 1);',
'<?php declare(strict_types=1, ticks=1);',
['space' => 'single'],
],
];
}

Expand Down

0 comments on commit 5e23b42

Please sign in to comment.