From 532dc0fb6f434963c659b01627493a016f599d6a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 6 Feb 2020 13:11:56 +0000 Subject: [PATCH] tests/phpunit: populate iterable types for phpstan --- tests/phpunit/block/BlockTest.php | 3 ++- tests/phpunit/item/ItemTest.php | 4 ++++ tests/phpunit/level/format/io/region/RegionLoaderTest.php | 4 ++++ tests/phpunit/network/mcpe/StupidJsonDecodeTest.php | 4 ++++ tests/phpunit/utils/ConfigTest.php | 7 ++++--- tests/phpunit/utils/UtilsTest.php | 4 ++++ 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/block/BlockTest.php b/tests/phpunit/block/BlockTest.php index 222a4cc6c..6c93e7488 100644 --- a/tests/phpunit/block/BlockTest.php +++ b/tests/phpunit/block/BlockTest.php @@ -95,7 +95,8 @@ class BlockTest extends TestCase{ } /** - * @return array + * @return int[][] + * @phpstan-return list */ public function blockGetProvider() : array{ return [ diff --git a/tests/phpunit/item/ItemTest.php b/tests/phpunit/item/ItemTest.php index b519dcaaa..d84449269 100644 --- a/tests/phpunit/item/ItemTest.php +++ b/tests/phpunit/item/ItemTest.php @@ -61,6 +61,10 @@ class ItemTest extends TestCase{ } } + /** + * @return mixed[][] + * @phpstan-return list + */ public function itemFromStringProvider() : array{ return [ ["dye:4", ItemIds::DYE, 4], diff --git a/tests/phpunit/level/format/io/region/RegionLoaderTest.php b/tests/phpunit/level/format/io/region/RegionLoaderTest.php index b156c2e57..87145144c 100644 --- a/tests/phpunit/level/format/io/region/RegionLoaderTest.php +++ b/tests/phpunit/level/format/io/region/RegionLoaderTest.php @@ -69,6 +69,10 @@ class RegionLoaderTest extends TestCase{ self::assertSame($data, $r->readChunk(0, 0)); } + /** + * @return \Generator|int[][] + * @phpstan-return \Generator + */ public function outOfBoundsCoordsProvider() : \Generator{ yield [-1, -1]; yield [32, 32]; diff --git a/tests/phpunit/network/mcpe/StupidJsonDecodeTest.php b/tests/phpunit/network/mcpe/StupidJsonDecodeTest.php index 0bb6bb940..4e1f3a749 100644 --- a/tests/phpunit/network/mcpe/StupidJsonDecodeTest.php +++ b/tests/phpunit/network/mcpe/StupidJsonDecodeTest.php @@ -33,6 +33,10 @@ class StupidJsonDecodeTest extends TestCase{ $this->stupidJsonDecodeFunc = (new \ReflectionMethod(PlayerNetworkSessionAdapter::class, 'stupid_json_decode'))->getClosure(); } + /** + * @return mixed[][] + * @phpstan-return list + */ public function stupidJsonDecodeProvider() : array{ return [ ["[\n \"a\",\"b,c,d,e\\\" \",,0,1,2, false, 0.001]", ['a', 'b,c,d,e" ', '', 0, 1, 2, false, 0.001]], diff --git a/tests/phpunit/utils/ConfigTest.php b/tests/phpunit/utils/ConfigTest.php index 7c48562ec..3e1487358 100644 --- a/tests/phpunit/utils/ConfigTest.php +++ b/tests/phpunit/utils/ConfigTest.php @@ -28,7 +28,8 @@ use PHPUnit\Framework\TestCase; class ConfigTest extends TestCase{ /** - * @return \Generator + * @return \Generator|mixed[][] + * @phpstan-return \Generator */ public function fixYamlIndexesProvider() : \Generator{ yield ["x: 1\ny: 2\nz: 3\n", [ @@ -60,8 +61,8 @@ class ConfigTest extends TestCase{ /** * @dataProvider fixYamlIndexesProvider * - * @param string $test - * @param array $expected + * @param string $test + * @param mixed[] $expected */ public function testFixYamlIndexes(string $test, array $expected) : void{ $fixed = Config::fixYAMLIndexes($test); diff --git a/tests/phpunit/utils/UtilsTest.php b/tests/phpunit/utils/UtilsTest.php index be0cc7255..b020c682d 100644 --- a/tests/phpunit/utils/UtilsTest.php +++ b/tests/phpunit/utils/UtilsTest.php @@ -38,6 +38,10 @@ class UtilsTest extends TestCase{ } } + /** + * @return string[][] + * @phpstan-return list + */ public function parseDocCommentNewlineProvider() : array{ return [ ["\t/**\r\n\t * @param PlayerJoinEvent \$event\r\n\t * @priority HIGHEST\r\n\t * @notHandler\r\n\t */"],