Skip to content

Commit

Permalink
Simplify Tokens::detectBlockType types (#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Sep 26, 2022
1 parent 553fb81 commit c529b14
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 7 deletions.
1 change: 0 additions & 1 deletion .dev-tools/phpstan.neon
Expand Up @@ -4,7 +4,6 @@ parameters:
excludePaths:
- ./src/Readme
ignoreErrors:
- '~^Parameter #1 \$type of method PhpCsFixer\\Tokenizer\\Tokens::findBlock(Start|End)\(\) expects [\d\|]+, int given\.$~'
- '~^Parameter #1 \$token of class PhpCsFixer\\Tokenizer\\Token constructor expects array\{int, string\}\|string, array\{int\|null, string\} given\.$~'
- message: '#^Call to an undefined method PhpCsFixer\\Fixer\\FixerInterface::[a-zA-Z]+\(\)\.$#'
path: ../tests
Expand Down
1 change: 0 additions & 1 deletion src/Analyzer/FunctionAnalyzer.php
Expand Up @@ -34,7 +34,6 @@ public static function getFunctionArguments(Tokens $tokens, int $index): array
$arguments = [];
$index = $currentArgumentStart = $argumentStartIndex;
while ($index < $argumentsEndIndex) {
/** @var null|array{isStart: bool, type: int} $blockType */
$blockType = Tokens::detectBlockType($tokens[$index]);
if ($blockType !== null && $blockType['isStart']) {
$index = $tokens->findBlockEnd($blockType['type'], $index);
Expand Down
1 change: 0 additions & 1 deletion src/Analyzer/SwitchAnalyzer.php
Expand Up @@ -101,7 +101,6 @@ private function getNextSameLevelToken(Tokens $tokens, int $index): int
return (new self())->getSwitchAnalysis($tokens, $index)->getCasesEnd();
}

/** @var null|array{isStart: bool, type: int} $blockType */
$blockType = Tokens::detectBlockType($tokens[$index]);
if ($blockType !== null && $blockType['isStart']) {
return $tokens->findBlockEnd($blockType['type'], $index) + 1;
Expand Down
1 change: 0 additions & 1 deletion src/Fixer/MultilinePromotedPropertiesFixer.php
Expand Up @@ -131,7 +131,6 @@ private function fixParameters(Tokens $tokens, int $openParenthesis, int $closeP
$index = $tokens->getPrevMeaningfulToken($index);
\assert(\is_int($index));

/** @var null|array{isStart: bool, type: int} $blockType */
$blockType = Tokens::detectBlockType($tokens[$index]);
if ($blockType !== null && !$blockType['isStart']) {
$index = $tokens->findBlockStart($blockType['type'], $index);
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/NoUselessParenthesisFixer.php
Expand Up @@ -54,7 +54,7 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void
continue;
}

/** @var array{isStart: bool, type: int} $blockType */
/** @var array{type: Tokens::BLOCK_TYPE_*, isStart: bool} $blockType */
$blockType = Tokens::detectBlockType($tokens[$index]);
$blockEndIndex = $tokens->findBlockEnd($blockType['type'], $index);

Expand Down
1 change: 0 additions & 1 deletion src/Fixer/PhpdocVarAnnotationToAssertFixer.php
Expand Up @@ -195,7 +195,6 @@ private function getExpressionEnd(Tokens $tokens, int $index): int
$index = $tokens->getNextMeaningfulToken($index);
\assert(\is_int($index));

/** @var null|array{isStart: bool, type: int} $blockType */
$blockType = Tokens::detectBlockType($tokens[$index]);
if ($blockType !== null && $blockType['isStart']) {
$index = $tokens->findBlockEnd($blockType['type'], $index);
Expand Down
1 change: 0 additions & 1 deletion src/Fixer/PromotedConstructorPropertyFixer.php
Expand Up @@ -351,7 +351,6 @@ private function getTokenOfKindSibling(Tokens $tokens, int $direction, int $inde
$index += $direction;

while (!$tokens[$index]->equalsAny($tokenKinds)) {
/** @var null|array{isStart: bool, type: int} $blockType */
$blockType = Tokens::detectBlockType($tokens[$index]);

if ($blockType !== null) {
Expand Down

0 comments on commit c529b14

Please sign in to comment.