diff --git a/src/Testing/TypeInferenceTestCase.php b/src/Testing/TypeInferenceTestCase.php index f3c998d5dc..be3471b02d 100644 --- a/src/Testing/TypeInferenceTestCase.php +++ b/src/Testing/TypeInferenceTestCase.php @@ -220,8 +220,13 @@ public function assertFileAsserts( } /** + * @return array}| + * array{0: 'superType', 1: string, 2: string, 3: string, 4: bool, 5: int, 6?: non-empty-list}| + * array{0: 'variableCertainty', 1: string, 2: TrinaryLogic, 3: TrinaryLogic, 4: string, 5: int, 6?: non-empty-list} + * )> + * * @api - * @return array */ public static function gatherAssertTypes(string $file): array { diff --git a/tests/PHPStan/Analyser/LooseConstComparisonPhp7Test.php b/tests/PHPStan/Analyser/LooseConstComparisonPhp7Test.php index 3b4f48d07a..3139b7a5b9 100644 --- a/tests/PHPStan/Analyser/LooseConstComparisonPhp7Test.php +++ b/tests/PHPStan/Analyser/LooseConstComparisonPhp7Test.php @@ -8,9 +8,6 @@ class LooseConstComparisonPhp7Test extends TypeInferenceTestCase { - /** - * @return iterable> - */ public static function dataFileAsserts(): iterable { // compares constants according to the php-version phpstan configuration, diff --git a/tests/PHPStan/Analyser/LooseConstComparisonPhp8Test.php b/tests/PHPStan/Analyser/LooseConstComparisonPhp8Test.php index fae702cec2..35ade6c0cd 100644 --- a/tests/PHPStan/Analyser/LooseConstComparisonPhp8Test.php +++ b/tests/PHPStan/Analyser/LooseConstComparisonPhp8Test.php @@ -8,9 +8,6 @@ class LooseConstComparisonPhp8Test extends TypeInferenceTestCase { - /** - * @return iterable> - */ public static function dataFileAsserts(): iterable { // compares constants according to the php-version phpstan configuration, diff --git a/tests/PHPStan/Analyser/NodeScopeResolverTest.php b/tests/PHPStan/Analyser/NodeScopeResolverTest.php index c8beac7f17..c08efc1a78 100644 --- a/tests/PHPStan/Analyser/NodeScopeResolverTest.php +++ b/tests/PHPStan/Analyser/NodeScopeResolverTest.php @@ -8,7 +8,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use stdClass; use function array_merge; -use function array_shift; use function define; use function dirname; use function implode; @@ -270,23 +269,24 @@ public function testFile(string $file): void $failures = []; foreach ($asserts as $args) { - $assertType = array_shift($args); - $file = array_shift($args); + if ($args[0] === 'type') { + $file = $args[1]; - if ($assertType === 'type') { - $expected = $args[0]; - $actual = $args[1]; + $expected = $args[2]; + $actual = $args[3]; if ($expected !== $actual) { - $failures[] = sprintf("Line %d:\nExpected: %s\nActual: %s\n", $args[2], $expected, $actual); + $failures[] = sprintf("Line %d:\nExpected: %s\nActual: %s\n", $args[4], $expected, $actual); } - } elseif ($assertType === 'variableCertainty') { - $expectedCertainty = $args[0]; - $actualCertainty = $args[1]; - $variableName = $args[2]; + } elseif ($args[0] === 'variableCertainty') { + $file = $args[1]; + + $expectedCertainty = $args[2]; + $actualCertainty = $args[3]; + $variableName = $args[4]; if ($expectedCertainty->equals($actualCertainty) !== true) { - $failures[] = sprintf("Certainty of %s on line %d:\nExpected: %s\nActual: %s\n", $variableName, $args[3], $expectedCertainty->describe(), $actualCertainty->describe()); + $failures[] = sprintf("Certainty of %s on line %d:\nExpected: %s\nActual: %s\n", $variableName, $args[5], $expectedCertainty->describe(), $actualCertainty->describe()); } } } diff --git a/tests/PHPStan/Analyser/SubstrPhp7Test.php b/tests/PHPStan/Analyser/SubstrPhp7Test.php index 561b33500c..deb4f19717 100644 --- a/tests/PHPStan/Analyser/SubstrPhp7Test.php +++ b/tests/PHPStan/Analyser/SubstrPhp7Test.php @@ -8,9 +8,6 @@ class SubstrPhp7Test extends TypeInferenceTestCase { - /** - * @return iterable> - */ public static function dataFileAsserts(): iterable { yield from self::gatherAssertTypes(__DIR__ . '/data/bug-13129-php7.php'); diff --git a/tests/PHPStan/Analyser/SubstrPhp8Test.php b/tests/PHPStan/Analyser/SubstrPhp8Test.php index 934a7ac78c..a5da5b57c8 100644 --- a/tests/PHPStan/Analyser/SubstrPhp8Test.php +++ b/tests/PHPStan/Analyser/SubstrPhp8Test.php @@ -8,9 +8,6 @@ class SubstrPhp8Test extends TypeInferenceTestCase { - /** - * @return iterable> - */ public static function dataFileAsserts(): iterable { yield from self::gatherAssertTypes(__DIR__ . '/data/bug-13129-php8.php');