Skip to content

Commit

Permalink
Use new constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Wirone committed Sep 27, 2023
1 parent 033149d commit 8146bf7
Show file tree
Hide file tree
Showing 105 changed files with 247 additions and 247 deletions.
2 changes: 1 addition & 1 deletion src/AbstractFunctionReferenceFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ protected function find(string $functionNameToSearch, Tokens $tokens, int $start
return $this->find($functionNameToSearch, $tokens, $openParenthesis, $end);
}

return [$functionName, $openParenthesis, $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openParenthesis)];
return [$functionName, $openParenthesis, $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $openParenthesis)];
}
}
6 changes: 3 additions & 3 deletions src/AbstractNoUselessElseFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private function getPreviousBlock(Tokens $tokens, int $index): array
$close = $previous = $tokens->getPrevMeaningfulToken($index);
// short 'if' detection
if ($tokens[$close]->equals('}')) {
$previous = $tokens->findBlockStart(Tokens::BLOCK_TYPE_CURLY_BRACE, $close);
$previous = $tokens->findBlockStart(Tokens::BLOCK_TYPE_BRACE, $close);
}

$open = $tokens->getPrevTokenOfKind($previous, [[T_IF], [T_ELSE], [T_ELSEIF]]);
Expand Down Expand Up @@ -132,7 +132,7 @@ private function isInConditional(Tokens $tokens, int $index, int $lowerLimitInde
// token is always ')' here.
// If it is part of the condition the token is always in, return false.
// If it is not it is a nested condition so return true
$open = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $candidateIndex);
$open = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS, $candidateIndex);

return $tokens->getPrevMeaningfulToken($open) > $lowerLimitIndex;
}
Expand Down Expand Up @@ -178,7 +178,7 @@ private function isInConditionWithoutBraces(Tokens $tokens, int $index, int $low
}

$index = $tokens->findBlockStart(
Tokens::BLOCK_TYPE_PARENTHESIS_BRACE,
Tokens::BLOCK_TYPE_PARENTHESIS,
$index
);

Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/Alias/ArrayPushFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
$openBraceIndex = $tokens->getNextMeaningfulToken($callIndex);
$blockType = Tokens::detectBlockType($tokens[$openBraceIndex]);

if (null === $blockType || Tokens::BLOCK_TYPE_PARENTHESIS_BRACE !== $blockType['type']) {
if (null === $blockType || Tokens::BLOCK_TYPE_PARENTHESIS !== $blockType['type']) {
continue;
}

// figure out where the arguments list closes

$closeBraceIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openBraceIndex);
$closeBraceIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $openBraceIndex);

// meaningful after `)` must be `;`, `? >` or nothing

Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Alias/ModernizeStrposFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void

// assert called with 2 arguments
$openIndex = $tokens->getNextMeaningfulToken($index);
$closeIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openIndex);
$closeIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $openIndex);
$arguments = $argumentsAnalyzer->getArguments($tokens, $openIndex, $closeIndex);

if (2 !== \count($arguments)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Alias/NoAliasFunctionsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
if (\is_array($this->aliases[$tokenContent])) {
[$alias, $numberOfArguments] = $this->aliases[$tokenContent];

$count = $argumentsAnalyzer->countArguments($tokens, $openParenthesis, $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openParenthesis));
$count = $argumentsAnalyzer->countArguments($tokens, $openParenthesis, $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $openParenthesis));

if ($numberOfArguments !== $count) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/ArrayNotation/ArraySyntaxFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn

private function fixToLongArraySyntax(Tokens $tokens, int $index): void
{
$closeIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_SQUARE_BRACE, $index);
$closeIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_BRACKET, $index);

$tokens[$index] = new Token('(');
$tokens[$closeIndex] = new Token(')');
Expand All @@ -116,7 +116,7 @@ private function fixToLongArraySyntax(Tokens $tokens, int $index): void
private function fixToShortArraySyntax(Tokens $tokens, int $index): void
{
$openIndex = $tokens->getNextTokenOfKind($index, ['(']);
$closeIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openIndex);
$closeIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $openIndex);

$tokens[$openIndex] = new Token([CT::T_ARRAY_SQUARE_BRACE_OPEN, '[']);
$tokens[$closeIndex] = new Token([CT::T_ARRAY_SQUARE_BRACE_CLOSE, ']']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ private function fixSpacing(int $index, Tokens $tokens): void
{
if ($tokens[$index]->isGivenKind(CT::T_ARRAY_SQUARE_BRACE_OPEN)) {
$startIndex = $index;
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_SQUARE_BRACE, $startIndex);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_BRACKET, $startIndex);
} else {
$startIndex = $tokens->getNextTokenOfKind($index, ['(']);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $startIndex);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $startIndex);
}

for ($i = $endIndex - 1; $i > $startIndex; --$i) {
Expand All @@ -109,11 +109,11 @@ private function fixSpacing(int $index, Tokens $tokens): void
private function skipNonArrayElements(int $index, Tokens $tokens): int
{
if ($tokens[$index]->equals('}')) {
return $tokens->findBlockStart(Tokens::BLOCK_TYPE_CURLY_BRACE, $index);
return $tokens->findBlockStart(Tokens::BLOCK_TYPE_BRACE, $index);
}

if ($tokens[$index]->equals(')')) {
$startIndex = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $index);
$startIndex = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS, $index);
$startIndex = $tokens->getPrevMeaningfulToken($startIndex);
if (!$tokens[$startIndex]->isGivenKind([T_ARRAY, CT::T_ARRAY_SQUARE_BRACE_OPEN])) {
return $startIndex;
Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/ArrayNotation/ReturnToYieldFromFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ private function shouldBeFixed(Tokens $tokens, int $returnIndex): bool
}

if ($tokens[$arrayStartIndex]->isGivenKind(CT::T_ARRAY_SQUARE_BRACE_OPEN)) {
$arrayEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_SQUARE_BRACE, $arrayStartIndex);
$arrayEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_BRACKET, $arrayStartIndex);
} else {
$arrayOpenParenthesisIndex = $tokens->getNextTokenOfKind($arrayStartIndex, ['(']);
$arrayEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $arrayOpenParenthesisIndex);
$arrayEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $arrayOpenParenthesisIndex);
}

$functionEndIndex = $arrayEndIndex;
Expand All @@ -87,7 +87,7 @@ private function shouldBeFixed(Tokens $tokens, int $returnIndex): bool
return false;
}

$functionStartIndex = $tokens->findBlockStart(Tokens::BLOCK_TYPE_CURLY_BRACE, $functionEndIndex);
$functionStartIndex = $tokens->findBlockStart(Tokens::BLOCK_TYPE_BRACE, $functionEndIndex);

$returnTypeIndex = $tokens->getPrevMeaningfulToken($functionStartIndex);
if (!$tokens[$returnTypeIndex]->isGivenKind(T_STRING)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/ArrayNotation/TrimArraySpacesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ private static function fixArray(Tokens $tokens, int $index): void

if ($tokens[$startIndex]->isGivenKind(T_ARRAY)) {
$startIndex = $tokens->getNextMeaningfulToken($startIndex);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $startIndex);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $startIndex);
} elseif ($tokens[$startIndex]->isGivenKind(CT::T_DESTRUCTURING_SQUARE_BRACE_OPEN)) {
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_DESTRUCTURING_SQUARE_BRACE, $startIndex);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_DESTRUCTURING_BRACKET, $startIndex);
} else {
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_SQUARE_BRACE, $startIndex);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_BRACKET, $startIndex);
}

$nextIndex = $startIndex + 1;
Expand Down
8 changes: 4 additions & 4 deletions src/Fixer/ArrayNotation/WhitespaceAfterCommaInArrayFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void

if ($tokens[$index]->isGivenKind(CT::T_ARRAY_SQUARE_BRACE_OPEN)) {
$startIndex = $index;
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_SQUARE_BRACE, $startIndex);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_BRACKET, $startIndex);
} else {
$startIndex = $tokens->getNextTokenOfKind($index, ['(']);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $startIndex);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $startIndex);
}

for ($i = $endIndex - 1; $i > $startIndex; --$i) {
Expand Down Expand Up @@ -106,11 +106,11 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
private function skipNonArrayElements(int $index, Tokens $tokens): int
{
if ($tokens[$index]->equals('}')) {
return $tokens->findBlockStart(Tokens::BLOCK_TYPE_CURLY_BRACE, $index);
return $tokens->findBlockStart(Tokens::BLOCK_TYPE_BRACE, $index);
}

if ($tokens[$index]->equals(')')) {
$startIndex = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $index);
$startIndex = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS, $index);
$startIndex = $tokens->getPrevMeaningfulToken($startIndex);
if (!$tokens[$startIndex]->isGivenKind([T_ARRAY, CT::T_ARRAY_SQUARE_BRACE_OPEN])) {
return $startIndex;
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/ArrayNotation/YieldFromArrayToYieldsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ private function getYieldsFromToUnpack(Tokens $tokens): iterable

if ($tokens[$arrayStartIndex]->isGivenKind(T_ARRAY)) {
$startIndex = $tokens->getNextTokenOfKind($arrayStartIndex, ['(']);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $startIndex);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $startIndex);
} else {
$startIndex = $arrayStartIndex;
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_SQUARE_BRACE, $startIndex);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_BRACKET, $startIndex);
}

// is there empty "yield from []" ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void

// Find closing parentheses, we need to do this in case there's a comma inside the parentheses
if ($tokens[$nextIndex]->equals('(')) {
$nextIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $nextIndex);
$nextIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $nextIndex);
$nextIndex = $tokens->getNextTokenOfKind($nextIndex, [',', [CT::T_ATTRIBUTE_CLOSE]]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/Basic/CurlyBracesPositionFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
continue;
}

$closeBraceIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $openBraceIndex);
$closeBraceIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_BRACE, $openBraceIndex);

$addNewlinesInsideBraces = true;
if ($allowSingleLine || $allowSingleLineIfEmpty || $index < $allowSingleLineUntil) {
Expand Down Expand Up @@ -382,7 +382,7 @@ private function findParenthesisEnd(Tokens $tokens, int $structureTokenIndex): i
return $structureTokenIndex;
}

return $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $nextIndex);
return $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS, $nextIndex);
}

private function isFollowedByNewLine(Tokens $tokens, int $index): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Basic/NoMultipleStatementsPerLineFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
for ($index = 1, $max = \count($tokens) - 1; $index < $max; ++$index) {
if ($tokens[$index]->isGivenKind(T_FOR)) {
$index = $tokens->findBlockEnd(
Tokens::BLOCK_TYPE_PARENTHESIS_BRACE,
Tokens::BLOCK_TYPE_PARENTHESIS,
$tokens->getNextTokenOfKind($index, ['('])
);

Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/Basic/NoTrailingCommaInSinglelineFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ private function shouldBeCleared(Tokens $tokens, int $openIndex): bool
(
Tokens::BLOCK_TYPE_ARRAY_INDEX_CURLY_BRACE === $block['type']
|| Tokens::BLOCK_TYPE_DYNAMIC_VAR_BRACE === $block['type']
|| Tokens::BLOCK_TYPE_INDEX_SQUARE_BRACE === $block['type']
|| Tokens::BLOCK_TYPE_PARENTHESIS_BRACE === $block['type']
|| Tokens::BLOCK_TYPE_INDEX_BRACKET === $block['type']
|| Tokens::BLOCK_TYPE_PARENTHESIS === $block['type']
) && \in_array('arguments', $elements, true);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/ClassNotation/ClassAttributesSeparationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ private function getElementsByClass(Tokens $tokens): \Generator

$classIndex = $element['classIndex'];
$classOpen = $tokens->getNextTokenOfKind($classIndex, ['{']);
$classEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $classOpen);
$classEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_BRACE, $classOpen);
$class = [
'index' => $classIndex,
'open' => $classOpen,
Expand Down Expand Up @@ -542,7 +542,7 @@ private function getLastTokenIndexOfClassElement(Tokens $tokens, array $class, a
if (true === $attributes['abstract']) {
$elementEndIndex = $tokens->getNextTokenOfKind($element['index'], [';']);
} else {
$elementEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $tokens->getNextTokenOfKind($element['index'], ['{']));
$elementEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_BRACE, $tokens->getNextTokenOfKind($element['index'], ['{']));
}
} elseif ('trait_import' === $element['type']) {
$elementEndIndex = $element['index'];
Expand All @@ -552,7 +552,7 @@ private function getLastTokenIndexOfClassElement(Tokens $tokens, array $class, a
} while ($tokens[$elementEndIndex]->isGivenKind([T_STRING, T_NS_SEPARATOR]) || $tokens[$elementEndIndex]->equals(','));

if (!$tokens[$elementEndIndex]->equals(';')) {
$elementEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $tokens->getNextTokenOfKind($element['index'], ['{']));
$elementEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_BRACE, $tokens->getNextTokenOfKind($element['index'], ['{']));
}
} else { // 'const', 'property', enum-'case', or 'method' of an interface
$elementEndIndex = $tokens->getNextTokenOfKind($element['index'], [';']);
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/ClassNotation/ClassDefinitionFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private function fixClassyDefinition(Tokens $tokens, int $classyIndex): void
}

if ($tokens[$end]->equals(')')) { // skip constructor arguments of anonymous class
$end = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $end);
$end = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS, $end);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
}

$classOpen = $tokens->getNextTokenOfKind($classIndex, ['{']);
$classClose = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $classOpen);
$classClose = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_BRACE, $classOpen);

$this->fixClass($tokens, $classOpen, $classClose);
}
Expand All @@ -101,7 +101,7 @@ private function fixClass(Tokens $tokens, int $classOpenIndex, int $classCloseIn
for ($index = $classCloseIndex - 1; $index > $classOpenIndex; --$index) {
// skip method contents
if ($tokens[$index]->equals('}')) {
$index = $tokens->findBlockStart(Tokens::BLOCK_TYPE_CURLY_BRACE, $index);
$index = $tokens->findBlockStart(Tokens::BLOCK_TYPE_BRACE, $index);

continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
}

// the index points to the { of a block-namespace
$nspEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $nspIndex);
$nspEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_BRACE, $nspIndex);

if ($index < $nspEnd) {
// the class is inside a block namespace, skip other classes that might be in it
Expand All @@ -116,7 +116,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
$classNameIndex = $tokens->getNextMeaningfulToken($index);
$className = $tokens[$classNameIndex]->getContent();
$classStart = $tokens->getNextTokenOfKind($classNameIndex, ['{']);
$classEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $classStart);
$classEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_BRACE, $classStart);

$this->fixConstructor($tokens, $className, $classStart, $classEnd);
$this->fixParent($tokens, $classStart, $classEnd);
Expand Down Expand Up @@ -394,7 +394,7 @@ private function findFunction(Tokens $tokens, string $name, int $startIndex, int
} else {
// find method body start and the end of the function definition
$bodyStart = $tokens->getNextTokenOfKind($function[2], ['{']);
$funcEnd = null !== $bodyStart ? $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $bodyStart) : null;
$funcEnd = null !== $bodyStart ? $tokens->findBlockEnd(Tokens::BLOCK_TYPE_BRACE, $bodyStart) : null;
}

return [
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/ClassNotation/OrderedClassElementsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ private function findElementEnd(Tokens $tokens, int $index): int
$index = $tokens->getNextTokenOfKind($index, ['{', ';']);

if ($tokens[$index]->equals('{')) {
$index = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $index);
$index = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_BRACE, $index);
}

for (++$index; $tokens[$index]->isWhitespace(" \t") || $tokens[$index]->isComment(); ++$index);
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/ClassNotation/OrderedTraitsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private function findUseStatementsGroups(Tokens $tokens): iterable
$endIndex = $tokens->getNextTokenOfKind($index, [';', '{']);

if ($tokens[$endIndex]->equals('{')) {
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $endIndex);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_BRACE, $endIndex);
}

$use = [];
Expand Down Expand Up @@ -154,7 +154,7 @@ private function sortMultipleTraitsInStatement(Tokens $use): void
}

if ($token->equals('{')) {
$index = $use->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $index);
$index = $use->findBlockEnd(Tokens::BLOCK_TYPE_BRACE, $index);
}
}

Expand Down
Loading

0 comments on commit 8146bf7

Please sign in to comment.