diff --git a/phpstan.neon.dist b/phpstan.neon.dist index d078a7acf..170897410 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,11 +1,12 @@ includes: + - tests/phpstan/configs/gc-hacks.neon - tests/phpstan/configs/optional-com-dotnet.neon - tests/phpstan/configs/optional-leveldb.neon - tests/phpstan/configs/phpstan-bugs.neon - tests/phpstan/configs/pthreads-bugs.neon parameters: - level: 2 + level: 3 autoload_files: - tests/phpstan/bootstrap.php - src/pocketmine/PocketMine.php @@ -24,6 +25,51 @@ parameters: path: src/pocketmine/command/defaults/TeleportCommand.php # comment: "not actually possible, but high cost to fix warning" + - + message: "#^Array \\(array\\\\) does not accept pocketmine\\\\entity\\\\Entity\\.$#" + count: 2 + path: src/pocketmine/entity/Entity.php + + - + message: "#^Invalid array key type pocketmine\\\\entity\\\\Entity\\.$#" + count: 1 + path: src/pocketmine/entity/Entity.php + + - + message: "#^Method pocketmine\\\\event\\\\entity\\\\EntityDeathEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\Living but returns pocketmine\\\\entity\\\\Entity\\.$#" + count: 1 + path: src/pocketmine/event/entity/EntityDeathEvent.php + + - + message: "#^Method pocketmine\\\\event\\\\entity\\\\EntityShootBowEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\Living but returns pocketmine\\\\entity\\\\Entity\\.$#" + count: 1 + path: src/pocketmine/event/entity/EntityShootBowEvent.php + + - + message: "#^Property pocketmine\\\\event\\\\entity\\\\EntityShootBowEvent\\:\\:\\$projectile \\(pocketmine\\\\entity\\\\projectile\\\\Projectile\\) does not accept pocketmine\\\\entity\\\\Entity\\.$#" + count: 1 + path: src/pocketmine/event/entity/EntityShootBowEvent.php + + - + message: "#^Method pocketmine\\\\event\\\\entity\\\\ItemDespawnEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\object\\\\ItemEntity but returns pocketmine\\\\entity\\\\Entity\\.$#" + count: 1 + path: src/pocketmine/event/entity/ItemDespawnEvent.php + + - + message: "#^Method pocketmine\\\\event\\\\entity\\\\ItemSpawnEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\object\\\\ItemEntity but returns pocketmine\\\\entity\\\\Entity\\.$#" + count: 1 + path: src/pocketmine/event/entity/ItemSpawnEvent.php + + - + message: "#^Method pocketmine\\\\event\\\\entity\\\\ProjectileHitEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\projectile\\\\Projectile but returns pocketmine\\\\entity\\\\Entity\\.$#" + count: 1 + path: src/pocketmine/event/entity/ProjectileHitEvent.php + + - + message: "#^Method pocketmine\\\\event\\\\entity\\\\ProjectileLaunchEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\projectile\\\\Projectile but returns pocketmine\\\\entity\\\\Entity\\.$#" + count: 1 + path: src/pocketmine/event/entity/ProjectileLaunchEvent.php + - message: "#^Constructor of class pocketmine\\\\level\\\\generator\\\\hell\\\\Nether has an unused parameter \\$options\\.$#" count: 1 diff --git a/tests/phpstan/configs/gc-hacks.neon b/tests/phpstan/configs/gc-hacks.neon new file mode 100644 index 000000000..14267631d --- /dev/null +++ b/tests/phpstan/configs/gc-hacks.neon @@ -0,0 +1,80 @@ +#cyclic refs in lots of objects prevent GC, causing increased memory pressure +#the proper fix is to not have cycles, but in the meantime we have these hacks + +parameters: + ignoreErrors: + - + message: "#^Property pocketmine\\\\Player\\:\\:\\$sessionAdapter \\(pocketmine\\\\network\\\\mcpe\\\\PlayerNetworkSessionAdapter\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Property pocketmine\\\\Player\\:\\:\\$cursorInventory \\(pocketmine\\\\inventory\\\\PlayerCursorInventory\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Property pocketmine\\\\Player\\:\\:\\$craftingGrid \\(pocketmine\\\\inventory\\\\CraftingGrid\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Property pocketmine\\\\Player\\:\\:\\$perm \\(pocketmine\\\\permission\\\\PermissibleBase\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Property pocketmine\\\\entity\\\\Entity\\:\\:\\$namedtag \\(pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/entity/Entity.php + + - + message: "#^Property pocketmine\\\\entity\\\\Human\\:\\:\\$inventory \\(pocketmine\\\\inventory\\\\PlayerInventory\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/entity/Human.php + + - + message: "#^Property pocketmine\\\\entity\\\\Human\\:\\:\\$enderChestInventory \\(pocketmine\\\\inventory\\\\EnderChestInventory\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/entity/Human.php + + - + message: "#^Property pocketmine\\\\entity\\\\Living\\:\\:\\$armorInventory \\(pocketmine\\\\inventory\\\\ArmorInventory\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/entity/Living.php + + - + message: "#^Property pocketmine\\\\inventory\\\\DoubleChestInventory\\:\\:\\$left \\(pocketmine\\\\inventory\\\\ChestInventory\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/inventory/DoubleChestInventory.php + + - + message: "#^Property pocketmine\\\\inventory\\\\DoubleChestInventory\\:\\:\\$right \\(pocketmine\\\\inventory\\\\ChestInventory\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/inventory/DoubleChestInventory.php + + - + message: "#^Property pocketmine\\\\level\\\\Level\\:\\:\\$provider \\(pocketmine\\\\level\\\\format\\\\io\\\\LevelProvider\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/level/Level.php + + - + message: "#^Property pocketmine\\\\level\\\\Level\\:\\:\\$blockMetadata \\(pocketmine\\\\metadata\\\\BlockMetadataStore\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/level/Level.php + + - + message: "#^Property pocketmine\\\\level\\\\Level\\:\\:\\$temporalPosition \\(pocketmine\\\\level\\\\Position\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/level/Level.php + + - + message: "#^Property pocketmine\\\\tile\\\\Chest\\:\\:\\$inventory \\(pocketmine\\\\inventory\\\\ChestInventory\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/tile/Chest.php + + - + message: "#^Property pocketmine\\\\tile\\\\Furnace\\:\\:\\$inventory \\(pocketmine\\\\inventory\\\\FurnaceInventory\\) does not accept null\\.$#" + count: 1 + path: ../../../src/pocketmine/tile/Furnace.php + diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index 1f7c01b9c..696fcc8ab 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -16,3 +16,18 @@ parameters: message: "#^Cannot assign new offset to Threaded\\.$#" path: ../../../src + - + message: "#^Offset string does not exist on array\\(\\)\\.$#" + count: 3 + path: ../../../src/pocketmine/MemoryManager.php + + - + message: "#^Offset \\(int\\|string\\) does not exist on array\\(\\)\\.$#" + count: 1 + path: ../../../src/pocketmine/MemoryManager.php + + - + message: "#^Array \\(array\\) does not accept key int\\.$#" + count: 1 + path: ../../../src/pocketmine/plugin/PluginDescription.php +