Skip to content

Commit 987009a

Browse files
committed
Fix tests
1 parent e2f0c77 commit 987009a

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

tests/PHPStan/Rules/Functions/ExistingClassesInTypehintsRuleTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,18 @@ public function dataTrueTypes(): array
421421
];
422422
}
423423

424-
/**
425-
* @dataProvider dataTrueTypes
426-
* @param list<array{0: string, 1: int, 2?: string}> $errors
427-
*/
428-
public function testTrueTypehint(int $phpVersion, array $errors): void
424+
public function testTrueTypehint(): void
429425
{
430-
$this->phpVersionId = $phpVersion;
426+
if (PHP_VERSION_ID >= 80200) {
427+
$errors = [];
428+
} else {
429+
$errors = [
430+
[
431+
'Function NativeTrueType\alwaysTrue() has invalid return type NativeTrueType\true.',
432+
5,
433+
],
434+
];
435+
}
431436

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

tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -429,20 +429,30 @@ public function testEnums(): void
429429
]);
430430
}
431431

432-
public function dataTrueTypes(): array
432+
public function testTrueTypehint(): void
433433
{
434-
return [
435-
[80200, []],
436-
];
437-
}
438-
439-
/**
440-
* @dataProvider dataTrueTypes
441-
* @param list<array{0: string, 1: int, 2?: string}> $errors
442-
*/
443-
public function testTrueTypehint(int $phpVersion, array $errors): void
444-
{
445-
$this->phpVersionId = $phpVersion;
434+
if (PHP_VERSION_ID >= 80200) {
435+
$errors = [];
436+
} else {
437+
$errors = [
438+
[
439+
'Parameter $v of method NativeTrueType\Truthy::foo() has invalid type NativeTrueType\true.',
440+
10,
441+
],
442+
[
443+
'Method NativeTrueType\Truthy::foo() has invalid return type NativeTrueType\true.',
444+
10,
445+
],
446+
[
447+
'Parameter $trueUnion of method NativeTrueType\Truthy::trueUnion() has invalid type NativeTrueType\true.',
448+
14,
449+
],
450+
[
451+
'Method NativeTrueType\Truthy::trueUnionReturn() has invalid return type NativeTrueType\true.',
452+
31,
453+
],
454+
];
455+
}
446456

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

0 commit comments

Comments
 (0)