Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 4, 2024
1 parent 6b0e1e6 commit 9501e8a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,18 @@ public function dataTrueTypes(): array
];
}

/**
* @dataProvider dataTrueTypes
* @param list<array{0: string, 1: int, 2?: string}> $errors
*/
public function testTrueTypehint(int $phpVersion, array $errors): void
public function testTrueTypehint(): void
{
$this->phpVersionId = $phpVersion;
if (PHP_VERSION_ID >= 80200) {
$errors = [];
} else {
$errors = [
[
'Function NativeTrueType\alwaysTrue() has invalid return type NativeTrueType\true.',
5,
],
];
}

$this->analyse([__DIR__ . '/data/true-typehint.php'], $errors);
}
Expand Down
36 changes: 23 additions & 13 deletions tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,20 +429,30 @@ public function testEnums(): void
]);
}

public function dataTrueTypes(): array
public function testTrueTypehint(): void
{
return [
[80200, []],
];
}

/**
* @dataProvider dataTrueTypes
* @param list<array{0: string, 1: int, 2?: string}> $errors
*/
public function testTrueTypehint(int $phpVersion, array $errors): void
{
$this->phpVersionId = $phpVersion;
if (PHP_VERSION_ID >= 80200) {
$errors = [];
} else {
$errors = [
[
'Parameter $v of method NativeTrueType\Truthy::foo() has invalid type NativeTrueType\true.',
10,
],
[
'Method NativeTrueType\Truthy::foo() has invalid return type NativeTrueType\true.',
10,
],
[
'Parameter $trueUnion of method NativeTrueType\Truthy::trueUnion() has invalid type NativeTrueType\true.',
14,
],
[
'Method NativeTrueType\Truthy::trueUnionReturn() has invalid return type NativeTrueType\true.',
31,
],
];
}

$this->analyse([__DIR__ . '/data/true-typehint.php'], $errors);
}
Expand Down

0 comments on commit 9501e8a

Please sign in to comment.