Skip to content

Commit 268031a

Browse files
committed
Fix PHPStan errors
1 parent 42c1af9 commit 268031a

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

phpstan.neon

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ parameters:
1313
- '*/tests/**/Fixture/*'
1414

1515
ignoreErrors:
16-
# partial enum
17-
- '#Method Symplify\\CodingStandard\\TokenRunner\\Analyzer\\FixerAnalyzer\\BlockFinder\:\:(getBlockTypeByContent|getBlockTypeByToken)\(\) never returns \d+ so it can be removed from the return type#'
18-
1916
-
2017
path: tests/bootstrap.php
2118
message: '#Instantiated class PHP_CodeSniffer\\Util\\Tokens not found#'
2219

2320
- '#Constant T_OPEN_CURLY_BRACKET|T_START_NOWDOC not found#'
24-
- '#Method Symplify\\CodingStandard\\TokenRunner\\Traverser\\ArrayBlockInfoFinder\:\:reverseTokens\(\) should return array<PhpCsFixer\\Tokenizer\\Token> but returns array<int, PhpCsFixer\\Tokenizer\\Token\|null>#'
2521

2622
# unused generics
2723
- '#Class (.*?) implements generic interface PhpCsFixer\\Fixer\\ConfigurableFixerInterface but does not specify its types\: TFixerInputConfig, TFixerComputedConfig#'
2824

2925
# conditional check to allow various php versions
3026
-
31-
message: '#Comparison operation ">\=" between int<80200, 80499> and (.*?) is always true#'
27+
message: '#Comparison operation ">\=" between int<80200, 80599> and (.*?) is always true#'
3228
path: src/TokenAnalyzer/DocblockRelatedParamNamesResolver.php

src/Fixer/Naming/ClassNameResolver.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ private function resolveFromTokens(Tokens $tokens): ?string
4545
}
4646

4747
$nextNextMeaningfulTokenIndex = $tokens->getNextMeaningfulToken($position + 1);
48+
49+
if (null === $nextNextMeaningfulTokenIndex) {
50+
continue;
51+
}
52+
4853
$nextNextMeaningfulToken = $tokens[$nextNextMeaningfulTokenIndex];
4954

5055
// skip anonymous classes

src/Fixer/Naming/MethodNameResolver.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ public function resolve(Tokens $tokens, int $currentPosition): ?string
2424
}
2525

2626
$nextNextMeaningfulTokenIndex = $tokens->getNextMeaningfulToken($position + 1);
27+
28+
if (null === $nextNextMeaningfulTokenIndex) {
29+
continue;
30+
}
31+
2732
$nextNextMeaningfulToken = $tokens[$nextNextMeaningfulTokenIndex];
2833

2934
// skip anonymous functions

src/TokenRunner/Traverser/TokenReverser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function reverse(Tokens $tokens): array
2424
$reversedTokens = array_reverse($tokens->toArray(), true);
2525

2626
// remove null values
27+
// @phpstan-ignore arrayFilter.same
2728
return array_filter($reversedTokens);
2829
}
2930
}

0 commit comments

Comments
 (0)