Skip to content

precise phpdoc for RuleTestCase->analyse() #1032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/Testing/RuleTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace PHPStan\Testing;

use InvalidArgumentException;
use PHPStan\Analyser\Analyser;
use PHPStan\Analyser\Error;
use PHPStan\Analyser\FileAnalyser;
Expand Down Expand Up @@ -88,7 +87,7 @@ private function getAnalyser(): Analyser

/**
* @param string[] $files
* @param mixed[] $expectedErrors
* @param list<array{0: string, 1: int, 2?: string}> $expectedErrors
*/
public function analyse(array $files, array $expectedErrors): void
{
Expand All @@ -114,15 +113,7 @@ public function analyse(array $files, array $expectedErrors): void
};

$expectedErrors = array_map(
static function (array $error) use ($strictlyTypedSprintf): string {
if (!isset($error[0])) {
throw new InvalidArgumentException('Missing expected error message.');
}
if (!isset($error[1])) {
throw new InvalidArgumentException('Missing expected file line.');
}
return $strictlyTypedSprintf($error[1], $error[0], $error[2] ?? null);
},
static fn (array $error): string => $strictlyTypedSprintf($error[1], $error[0], $error[2] ?? null),
$expectedErrors,
);

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public function dataLoopInitialAssignments(): array

/**
* @dataProvider dataLoopInitialAssignments
* @param mixed[][] $expectedErrors
* @param list<array{0: string, 1: int, 2?: string}> $expectedErrors
*/
public function testLoopInitialAssignments(
bool $polluteScopeWithLoopInitialAssignments,
Expand Down