diff --git a/src/block/VanillaBlocks.php b/src/block/VanillaBlocks.php index 3371a7d25..faf49a903 100644 --- a/src/block/VanillaBlocks.php +++ b/src/block/VanillaBlocks.php @@ -685,7 +685,10 @@ final class VanillaBlocks{ * @return Block[] */ public static function getAll() : array{ - return self::_registryGetAll(); + //phpstan doesn't support generic traits yet :( + /** @var Block[] $result */ + $result = self::_registryGetAll(); + return $result; } protected static function setup() : void{ diff --git a/src/entity/effect/VanillaEffects.php b/src/entity/effect/VanillaEffects.php index 9efc7add9..3458fc587 100644 --- a/src/entity/effect/VanillaEffects.php +++ b/src/entity/effect/VanillaEffects.php @@ -112,7 +112,10 @@ final class VanillaEffects{ * @return Effect[] */ public static function getAll() : array{ - return self::_registryGetAll(); + //phpstan doesn't support generic traits yet :( + /** @var Effect[] $result */ + $result = self::_registryGetAll(); + return $result; } public static function fromString(string $name) : Effect{ diff --git a/src/item/VanillaItems.php b/src/item/VanillaItems.php index a95604b8e..e44aa31b7 100644 --- a/src/item/VanillaItems.php +++ b/src/item/VanillaItems.php @@ -312,7 +312,10 @@ final class VanillaItems{ * @return Item[] */ public static function getAll() : array{ - return self::_registryGetAll(); + //phpstan doesn't support generic traits yet :( + /** @var Item[] $result */ + $result = self::_registryGetAll(); + return $result; } protected static function setup() : void{ diff --git a/src/utils/EnumTrait.php b/src/utils/EnumTrait.php index 6f6aa517c..8eb2a1075 100644 --- a/src/utils/EnumTrait.php +++ b/src/utils/EnumTrait.php @@ -51,7 +51,10 @@ trait EnumTrait{ * @return self[] */ public static function getAll() : array{ - return self::_registryGetAll(); + //phpstan doesn't support generic traits yet :( + /** @var self[] $result */ + $result = self::_registryGetAll(); + return $result; } /** @@ -61,7 +64,10 @@ trait EnumTrait{ * @throws \InvalidArgumentException if no member matches. */ public static function fromString(string $name) : self{ - return self::_registryFromString($name); + //phpstan doesn't support generic traits yet :( + /** @var self $result */ + $result = self::_registryFromString($name); + return $result; } /** @var int|null */ diff --git a/tests/phpstan/configs/l7-baseline.neon b/tests/phpstan/configs/l7-baseline.neon index 7225ec793..51bbcd87b 100644 --- a/tests/phpstan/configs/l7-baseline.neon +++ b/tests/phpstan/configs/l7-baseline.neon @@ -420,11 +420,6 @@ parameters: count: 2 path: ../../../src/block/Sugarcane.php - - - message: "#^Method pocketmine\\\\block\\\\VanillaBlocks\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/block/VanillaBlocks.php - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#" count: 1 @@ -555,11 +550,6 @@ parameters: count: 1 path: ../../../src/entity/Skin.php - - - message: "#^Method pocketmine\\\\entity\\\\effect\\\\VanillaEffects\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/entity/effect/VanillaEffects.php - - message: "#^Parameter \\#2 \\$x of method pocketmine\\\\block\\\\Block\\:\\:position\\(\\) expects int, float\\|int given\\.$#" count: 1 @@ -630,11 +620,6 @@ parameters: count: 1 path: ../../../src/item/ItemFactory.php - - - message: "#^Method pocketmine\\\\item\\\\VanillaItems\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/item/VanillaItems.php - - message: "#^Parameter \\#2 \\$input1 of function array_map expects array, array\\|false given\\.$#" count: 1 @@ -795,126 +780,6 @@ parameters: count: 2 path: ../../../src/scheduler/AsyncPool.php - - - message: "#^Method pocketmine\\\\block\\\\utils\\\\DyeColor\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/block/utils/DyeColor.php - - - - message: "#^Method pocketmine\\\\block\\\\utils\\\\DyeColor\\:\\:fromString\\(\\) should return pocketmine\\\\block\\\\utils\\\\DyeColor but returns object\\.$#" - count: 1 - path: ../../../src/block/utils/DyeColor.php - - - - message: "#^Method pocketmine\\\\block\\\\utils\\\\SkullType\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/block/utils/SkullType.php - - - - message: "#^Method pocketmine\\\\block\\\\utils\\\\SkullType\\:\\:fromString\\(\\) should return pocketmine\\\\block\\\\utils\\\\SkullType but returns object\\.$#" - count: 1 - path: ../../../src/block/utils/SkullType.php - - - - message: "#^Method pocketmine\\\\block\\\\utils\\\\SlabType\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/block/utils/SlabType.php - - - - message: "#^Method pocketmine\\\\block\\\\utils\\\\SlabType\\:\\:fromString\\(\\) should return pocketmine\\\\block\\\\utils\\\\SlabType but returns object\\.$#" - count: 1 - path: ../../../src/block/utils/SlabType.php - - - - message: "#^Method pocketmine\\\\block\\\\utils\\\\StairShape\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/block/utils/StairShape.php - - - - message: "#^Method pocketmine\\\\block\\\\utils\\\\StairShape\\:\\:fromString\\(\\) should return pocketmine\\\\block\\\\utils\\\\StairShape but returns object\\.$#" - count: 1 - path: ../../../src/block/utils/StairShape.php - - - - message: "#^Method pocketmine\\\\block\\\\utils\\\\TreeType\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/block/utils/TreeType.php - - - - message: "#^Method pocketmine\\\\block\\\\utils\\\\TreeType\\:\\:fromString\\(\\) should return pocketmine\\\\block\\\\utils\\\\TreeType but returns object\\.$#" - count: 1 - path: ../../../src/block/utils/TreeType.php - - - - message: "#^Method pocketmine\\\\item\\\\ItemUseResult\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/item/ItemUseResult.php - - - - message: "#^Method pocketmine\\\\item\\\\ItemUseResult\\:\\:fromString\\(\\) should return pocketmine\\\\item\\\\ItemUseResult but returns object\\.$#" - count: 1 - path: ../../../src/item/ItemUseResult.php - - - - message: "#^Method pocketmine\\\\item\\\\ToolTier\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/item/ToolTier.php - - - - message: "#^Method pocketmine\\\\item\\\\ToolTier\\:\\:fromString\\(\\) should return pocketmine\\\\item\\\\ToolTier but returns object\\.$#" - count: 1 - path: ../../../src/item/ToolTier.php - - - - message: "#^Method pocketmine\\\\player\\\\GameMode\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/player/GameMode.php - - - - message: "#^Method pocketmine\\\\player\\\\GameMode\\:\\:fromString\\(\\) should return pocketmine\\\\player\\\\GameMode but returns object\\.$#" - count: 1 - path: ../../../src/player/GameMode.php - - - - message: "#^Method pocketmine\\\\player\\\\UsedChunkStatus\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/player/UsedChunkStatus.php - - - - message: "#^Method pocketmine\\\\player\\\\UsedChunkStatus\\:\\:fromString\\(\\) should return pocketmine\\\\player\\\\UsedChunkStatus but returns object\\.$#" - count: 1 - path: ../../../src/player/UsedChunkStatus.php - - - - message: "#^Method pocketmine\\\\plugin\\\\PluginLoadOrder\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/plugin/PluginLoadOrder.php - - - - message: "#^Method pocketmine\\\\plugin\\\\PluginLoadOrder\\:\\:fromString\\(\\) should return pocketmine\\\\plugin\\\\PluginLoadOrder but returns object\\.$#" - count: 1 - path: ../../../src/plugin/PluginLoadOrder.php - - - - message: "#^Method pocketmine\\\\utils\\\\TestEnum\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../phpunit/utils/TestEnum.php - - - - message: "#^Method pocketmine\\\\utils\\\\TestEnum\\:\\:fromString\\(\\) should return pocketmine\\\\utils\\\\TestEnum but returns object\\.$#" - count: 1 - path: ../../phpunit/utils/TestEnum.php - - - - message: "#^Method pocketmine\\\\world\\\\sound\\\\NoteInstrument\\:\\:getAll\\(\\) should return array\\ but returns array\\\\.$#" - count: 1 - path: ../../../src/world/sound/NoteInstrument.php - - - - message: "#^Method pocketmine\\\\world\\\\sound\\\\NoteInstrument\\:\\:fromString\\(\\) should return pocketmine\\\\world\\\\sound\\\\NoteInstrument but returns object\\.$#" - count: 1 - path: ../../../src/world/sound/NoteInstrument.php - - message: "#^Parameter \\#2 \\$subject of function preg_match expects string, string\\|false given\\.$#" count: 1 diff --git a/tests/phpunit/utils/TestCloningRegistry.php b/tests/phpunit/utils/TestCloningRegistry.php index 5683fd11b..edc7a4102 100644 --- a/tests/phpunit/utils/TestCloningRegistry.php +++ b/tests/phpunit/utils/TestCloningRegistry.php @@ -39,11 +39,15 @@ final class TestCloningRegistry{ * @return \stdClass[] */ public static function getAll() : array{ - return self::_registryGetAll(); + /** @var \stdClass[] $result */ + $result = self::_registryGetAll(); + return $result; } public static function fromString(string $s) : \stdClass{ - return self::_registryFromString($s); + /** @var \stdClass $result */ + $result = self::_registryFromString($s); + return $result; } protected static function setup() : void{