Skip to content

Commit 9700f5a

Browse files
authored
Improve types (#997)
1 parent 0e08d16 commit 9700f5a

File tree

6 files changed

+8
-39
lines changed

6 files changed

+8
-39
lines changed

.dev-tools/phpstan.neon

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ parameters:
66
bootstrapFiles:
77
- ../vendor/autoload.php
88
ignoreErrors:
9-
-
10-
message: '#^Method PhpCsFixerCustomFixers\\Analyzer\\Analysis\\ConstructorAnalysis\:\:getDuplicatesIndices\(\) should return array\<int, int\> but returns array\.$#'
11-
identifier: return.type
12-
count: 1
13-
path: ../src/Analyzer/Analysis/ConstructorAnalysis.php
14-
159
-
1610
message: '#^Comparison operation "\>\=" between int\<80400, 80499\> and 80000 is always true\.$#'
1711
identifier: greaterOrEqual.alwaysTrue
@@ -23,37 +17,6 @@ parameters:
2317
identifier: greaterOrEqual.alwaysTrue
2418
count: 1
2519
path: ../src/Fixer/StringableInterfaceFixer.php
26-
27-
-
28-
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertStringContainsString\(\) expects string, mixed given\.$#'
29-
identifier: argument.type
30-
count: 1
31-
path: ../tests/AutoReview/ChangelogTest.php
32-
33-
-
34-
message: '#^Method Tests\\AutoReview\\TestsCodeTest\:\:provideTestClassCases\(\) should return iterable\<string, array\{string, string\}\> but returns mixed\.$#'
35-
identifier: return.type
36-
count: 1
37-
path: ../tests/AutoReview/TestsCodeTest.php
38-
39-
-
40-
message: '#^Cannot call method check\(\) on mixed\.$#'
41-
identifier: method.nonObject
42-
count: 1
43-
path: ../tests/Fixer/AbstractFixerTestCase.php
44-
45-
-
46-
message: '#^Cannot call method lintSource\(\) on mixed\.$#'
47-
identifier: method.nonObject
48-
count: 1
49-
path: ../tests/Fixer/AbstractFixerTestCase.php
50-
51-
-
52-
message: '#^Method Tests\\FixersTest\:\:fixerNamesFromCollection\(\) should return array\<int, string\> but returns array\<string\>\.$#'
53-
identifier: return.type
54-
count: 1
55-
path: ../tests/FixersTest.php
56-
5720
level: max
5821
paths:
5922
- ../src

src/Analyzer/Analysis/ConstructorAnalysis.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ private function getDuplicatesIndices(array $array): array
188188
$values = [];
189189
foreach ($array as $key => $value) {
190190
if (\array_key_exists($value, $values)) {
191+
\assert(\is_int($values[$value]));
191192
$duplicates[$values[$value]] = $values[$value];
193+
192194
$duplicates[$key] = $key;
193195
}
194196
$values[$value] = $key;

tests/AutoReview/ChangelogTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ private static function assertChangelogContains(string $content): void
5252
$changelog = \file_get_contents(__DIR__ . '/../../CHANGELOG.md');
5353
}
5454

55+
self::assertIsString($changelog);
5556
self::assertStringContainsString($content, $changelog);
5657
}
5758
}

tests/AutoReview/TestsCodeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,11 @@ public function testDataProvidersValues(string $className): void
156156
}
157157

158158
/**
159-
* @return iterable<string, array{string, string}>
159+
* @return iterable<string, array{string}>
160160
*/
161161
public static function provideTestClassCases(): iterable
162162
{
163+
/** @var \ArrayIterator<string, array{string}> */
163164
static $tests;
164165

165166
if ($tests === null) {

tests/Fixer/AbstractFixerTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PhpCsFixer\Fixer\WhitespacesAwareFixerInterface;
1919
use PhpCsFixer\FixerConfiguration\FixerOptionInterface;
2020
use PhpCsFixer\Linter\Linter;
21+
use PhpCsFixer\Linter\LinterInterface;
2122
use PhpCsFixer\Linter\ProcessLinter;
2223
use PhpCsFixer\Tokenizer\Tokens;
2324
use PhpCsFixer\WhitespacesFixerConfig;
@@ -219,6 +220,7 @@ final protected function getConfigurationOptions(): array
219220

220221
final protected function lintSource(string $source): ?string
221222
{
223+
/** @var null|LinterInterface $linter */
222224
static $linter;
223225

224226
if ($linter === null) {

tests/FixersTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static function provideFixerIsInCollectionCases(): iterable
6262
}
6363

6464
/**
65-
* @return array<int, string>
65+
* @return array<array-key, string>
6666
*/
6767
private function fixerNamesFromCollection(): array
6868
{

0 commit comments

Comments
 (0)