Skip to content

Commit d420d05

Browse files
authored
precise phpdoc for RuleTestCase->analyse() (#1032)
1 parent 2568f5e commit d420d05

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/Testing/RuleTestCase.php

+2-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace PHPStan\Testing;
44

5-
use InvalidArgumentException;
65
use PHPStan\Analyser\Analyser;
76
use PHPStan\Analyser\Error;
87
use PHPStan\Analyser\FileAnalyser;
@@ -88,7 +87,7 @@ private function getAnalyser(): Analyser
8887

8988
/**
9089
* @param string[] $files
91-
* @param mixed[] $expectedErrors
90+
* @param list<array{0: string, 1: int, 2?: string}> $expectedErrors
9291
*/
9392
public function analyse(array $files, array $expectedErrors): void
9493
{
@@ -114,15 +113,7 @@ public function analyse(array $files, array $expectedErrors): void
114113
};
115114

116115
$expectedErrors = array_map(
117-
static function (array $error) use ($strictlyTypedSprintf): string {
118-
if (!isset($error[0])) {
119-
throw new InvalidArgumentException('Missing expected error message.');
120-
}
121-
if (!isset($error[1])) {
122-
throw new InvalidArgumentException('Missing expected file line.');
123-
}
124-
return $strictlyTypedSprintf($error[1], $error[0], $error[2] ?? null);
125-
},
116+
static fn (array $error): string => $strictlyTypedSprintf($error[1], $error[0], $error[2] ?? null),
126117
$expectedErrors,
127118
);
128119

tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public function dataLoopInitialAssignments(): array
346346

347347
/**
348348
* @dataProvider dataLoopInitialAssignments
349-
* @param mixed[][] $expectedErrors
349+
* @param list<array{0: string, 1: int, 2?: string}> $expectedErrors
350350
*/
351351
public function testLoopInitialAssignments(
352352
bool $polluteScopeWithLoopInitialAssignments,

0 commit comments

Comments
 (0)