From 3edbea85457d03aef144e3fc952fa1cdb4e1181e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 7 Feb 2020 19:37:22 +0000 Subject: [PATCH 1/4] PluginManager: fix spacing of phpdoc comment for registerEvent() --- src/pocketmine/plugin/PluginManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index c25eaccf3..2523f4d24 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -732,7 +732,7 @@ class PluginManager{ } /** - * @param string $event Class name that extends Event + * @param string $event Class name that extends Event * * @throws PluginException */ From 681dd469a2af6ca4b0b86e87ec170c6b5976afde Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 7 Feb 2020 20:05:41 +0000 Subject: [PATCH 2/4] PluginManager: add class-string phpstan param to registerEvent() --- src/pocketmine/plugin/PluginManager.php | 1 + tests/phpstan/configs/runtime-type-checks.neon | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index 2523f4d24..78cbdc66e 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -733,6 +733,7 @@ class PluginManager{ /** * @param string $event Class name that extends Event + * @phpstan-param class-string $event * * @throws PluginException */ diff --git a/tests/phpstan/configs/runtime-type-checks.neon b/tests/phpstan/configs/runtime-type-checks.neon index 59776a047..0474cff39 100644 --- a/tests/phpstan/configs/runtime-type-checks.neon +++ b/tests/phpstan/configs/runtime-type-checks.neon @@ -80,3 +80,8 @@ parameters: message: "#^Call to function is_array\\(\\) with array\\ will always evaluate to true\\.$#" count: 1 path: ../../../src/pocketmine/plugin/PluginManager.php + + - + message: "#^Call to function is_subclass_of\\(\\) with class\\-string\\ and 'pocketmine\\\\\\\\event…' will always evaluate to true\\.$#" + count: 1 + path: ../../../src/pocketmine/plugin/PluginManager.php From bfce478e720c39d57320642e7767cf2799f70fb2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 7 Feb 2020 20:10:40 +0000 Subject: [PATCH 3/4] BlockFactory: keep the generic types for PHPStan, which actually understands it --- src/pocketmine/block/BlockFactory.php | 40 +++++++++++++++++++++------ 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/pocketmine/block/BlockFactory.php b/src/pocketmine/block/BlockFactory.php index 6e99fcf6d..3bc389c8a 100644 --- a/src/pocketmine/block/BlockFactory.php +++ b/src/pocketmine/block/BlockFactory.php @@ -32,22 +32,46 @@ use function min; * Manages block registration and instance creation */ class BlockFactory{ - /** @var \SplFixedArray */ + /** + * @var \SplFixedArray|Block[] + * @phpstan-var \SplFixedArray + */ private static $fullList; - /** @var \SplFixedArray */ + /** + * @var \SplFixedArray|bool[] + * @phpstan-var \SplFixedArray + */ public static $solid; - /** @var \SplFixedArray */ + /** + * @var \SplFixedArray|bool[] + * @phpstan-var \SplFixedArray + */ public static $transparent; - /** @var \SplFixedArray */ + /** + * @var \SplFixedArray|float[] + * @phpstan-var \SplFixedArray + */ public static $hardness; - /** @var \SplFixedArray */ + /** + * @var \SplFixedArray|int[] + * @phpstan-var \SplFixedArray + */ public static $light; - /** @var \SplFixedArray */ + /** + * @var \SplFixedArray|int[] + * @phpstan-var \SplFixedArray + */ public static $lightFilter; - /** @var \SplFixedArray */ + /** + * @var \SplFixedArray|bool[] + * @phpstan-var \SplFixedArray + */ public static $diffusesSkyLight; - /** @var \SplFixedArray */ + /** + * @var \SplFixedArray|float[] + * @phpstan-var \SplFixedArray + */ public static $blastResistance; /** From 758a68aa2c848165488889922755ba495b67f209 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 7 Feb 2020 20:11:31 +0000 Subject: [PATCH 4/4] ItemFactory: add Item[] as type for list field (for auto complete) --- src/pocketmine/item/ItemFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/item/ItemFactory.php b/src/pocketmine/item/ItemFactory.php index 0f933fd9c..cf1c63774 100644 --- a/src/pocketmine/item/ItemFactory.php +++ b/src/pocketmine/item/ItemFactory.php @@ -44,7 +44,7 @@ use function trim; class ItemFactory{ /** - * @var \SplFixedArray + * @var \SplFixedArray|Item[] * @phpstan-var \SplFixedArray */ private static $list;