Skip to content

Commit

Permalink
Improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Dec 30, 2024
1 parent 0e08d16 commit 6ddeff5
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 39 deletions.
37 changes: 0 additions & 37 deletions .dev-tools/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ parameters:
bootstrapFiles:
- ../vendor/autoload.php
ignoreErrors:
-
message: '#^Method PhpCsFixerCustomFixers\\Analyzer\\Analysis\\ConstructorAnalysis\:\:getDuplicatesIndices\(\) should return array\<int, int\> but returns array\.$#'
identifier: return.type
count: 1
path: ../src/Analyzer/Analysis/ConstructorAnalysis.php

-
message: '#^Comparison operation "\>\=" between int\<80400, 80499\> and 80000 is always true\.$#'
identifier: greaterOrEqual.alwaysTrue
Expand All @@ -23,37 +17,6 @@ parameters:
identifier: greaterOrEqual.alwaysTrue
count: 1
path: ../src/Fixer/StringableInterfaceFixer.php

-
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertStringContainsString\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: ../tests/AutoReview/ChangelogTest.php

-
message: '#^Method Tests\\AutoReview\\TestsCodeTest\:\:provideTestClassCases\(\) should return iterable\<string, array\{string, string\}\> but returns mixed\.$#'
identifier: return.type
count: 1
path: ../tests/AutoReview/TestsCodeTest.php

-
message: '#^Cannot call method check\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: ../tests/Fixer/AbstractFixerTestCase.php

-
message: '#^Cannot call method lintSource\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: ../tests/Fixer/AbstractFixerTestCase.php

-
message: '#^Method Tests\\FixersTest\:\:fixerNamesFromCollection\(\) should return array\<int, string\> but returns array\<string\>\.$#'
identifier: return.type
count: 1
path: ../tests/FixersTest.php

level: max
paths:
- ../src
Expand Down
2 changes: 2 additions & 0 deletions src/Analyzer/Analysis/ConstructorAnalysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ private function getDuplicatesIndices(array $array): array
$values = [];
foreach ($array as $key => $value) {
if (\array_key_exists($value, $values)) {
\assert(\is_int($values[$value]));
$duplicates[$values[$value]] = $values[$value];

$duplicates[$key] = $key;
}
$values[$value] = $key;
Expand Down
1 change: 1 addition & 0 deletions tests/AutoReview/ChangelogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ private static function assertChangelogContains(string $content): void
$changelog = \file_get_contents(__DIR__ . '/../../CHANGELOG.md');
}

self::assertIsString($changelog);
self::assertStringContainsString($content, $changelog);
}
}
3 changes: 2 additions & 1 deletion tests/AutoReview/TestsCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ public function testDataProvidersValues(string $className): void
}

/**
* @return iterable<string, array{string, string}>
* @return iterable<string, array{string}>
*/
public static function provideTestClassCases(): iterable
{
/** @var \ArrayIterator<string, array{string}> */
static $tests;

if ($tests === null) {
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixer/AbstractFixerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use PhpCsFixer\Fixer\WhitespacesAwareFixerInterface;
use PhpCsFixer\FixerConfiguration\FixerOptionInterface;
use PhpCsFixer\Linter\Linter;
use PhpCsFixer\Linter\LinterInterface;
use PhpCsFixer\Linter\ProcessLinter;
use PhpCsFixer\Tokenizer\Tokens;
use PhpCsFixer\WhitespacesFixerConfig;
Expand Down Expand Up @@ -219,6 +220,7 @@ final protected function getConfigurationOptions(): array

final protected function lintSource(string $source): ?string
{
/** @var null|LinterInterface $linter */
static $linter;

if ($linter === null) {
Expand Down
2 changes: 1 addition & 1 deletion tests/FixersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function provideFixerIsInCollectionCases(): iterable
}

/**
* @return array<int, string>
* @return array<array-key, string>
*/
private function fixerNamesFromCollection(): array
{
Expand Down

0 comments on commit 6ddeff5

Please sign in to comment.