Merge commit '8e1b3ed'

# Conflicts:
#	phpstan.neon.dist
#	resources/vanilla
#	tests/phpstan/configs/phpstan-bugs.neon
#	tests/phpstan/configs/phpunit-wiring-tests.neon
#	tests/phpstan/configs/pthreads-bugs.neon
#	tests/phpstan/configs/runtime-type-checks.neon
This commit is contained in:
Dylan K. Taylor 2020-04-25 12:35:30 +01:00
commit 040fdc2875
10 changed files with 203 additions and 182 deletions

6
composer.lock generated
View File

@ -722,11 +722,11 @@
"packages-dev": [
{
"name": "irstea/phpunit-shim",
"version": "8.5.3",
"version": "8.5.4",
"source": {
"type": "git",
"url": "https://gitlab.irstea.fr/pole-is/tools/phpunit-shim.git",
"reference": "b55d058d7ad3cf516068f22138a5b8fb724605db"
"reference": "25b3ffe1502bfd35d5cd23dc37f2f2e70cdf0b54"
},
"require": {
"ext-dom": "*",
@ -772,7 +772,7 @@
"testing",
"xunit"
],
"time": "2020-04-01T02:21:12+00:00"
"time": "2020-04-24T02:20:21+00:00"
},
{
"name": "phpstan/phpstan",

View File

@ -1,4 +1,5 @@
includes:
- tests/phpstan/configs/actual-problems.neon
- tests/phpstan/configs/com-dotnet-magic.neon
- tests/phpstan/configs/custom-leveldb.neon
- tests/phpstan/configs/ds-bugs.neon
@ -38,105 +39,3 @@ parameters:
reportUnmatchedIgnoredErrors: false #no other way to silence platform-specific non-warnings
staticReflectionClassNamePatterns:
- "#^COM$#"
ignoreErrors:
-
message: "#^Instanceof between pocketmine\\\\plugin\\\\PluginManager and pocketmine\\\\plugin\\\\PluginManager will always evaluate to true\\.$#"
count: 1
path: src/CrashDump.php
-
message: "#^Function parallel\\\\bootstrap not found\\.$#"
count: 1
path: src/PocketMine.php
-
message: "#^Instanceof between pocketmine\\\\plugin\\\\PluginManager and pocketmine\\\\plugin\\\\PluginManager will always evaluate to true\\.$#"
count: 1
path: src/Server.php
-
message: "#^Instanceof between pocketmine\\\\scheduler\\\\AsyncPool and pocketmine\\\\scheduler\\\\AsyncPool will always evaluate to true\\.$#"
count: 1
path: src/Server.php
-
message: "#^Instanceof between pocketmine\\\\command\\\\CommandReader and pocketmine\\\\command\\\\CommandReader will always evaluate to true\\.$#"
count: 1
path: src/Server.php
-
message: "#^Instanceof between pocketmine\\\\network\\\\Network and pocketmine\\\\network\\\\Network will always evaluate to true\\.$#"
count: 2
path: src/Server.php
-
message: "#^Instanceof between pocketmine\\\\world\\\\WorldManager and pocketmine\\\\world\\\\WorldManager will always evaluate to true\\.$#"
count: 1
path: src/Server.php
-
message: "#^Call to an undefined method pocketmine\\\\command\\\\CommandSender\\:\\:teleport\\(\\)\\.$#"
count: 1
path: src/command/defaults/TeleportCommand.php
# comment: "not actually possible, but high cost to fix warning"
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\EntityDeathEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\Living but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: src/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/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/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/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/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/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/event/entity/ProjectileLaunchEvent.php
-
message: "#^pocketmine\\\\block\\\\inventory\\\\DoubleChestInventory\\:\\:__construct\\(\\) does not call parent constructor from pocketmine\\\\block\\\\inventory\\\\ChestInventory\\.$#"
count: 1
path: src/block/inventory/DoubleChestInventory.php
-
message: "#^Cannot instantiate interface pocketmine\\\\world\\\\format\\\\io\\\\WorldProvider\\.$#"
count: 1
path: src/world/WorldManager.php
-
message: "#^Cannot instantiate interface pocketmine\\\\world\\\\format\\\\io\\\\WritableWorldProvider\\.$#"
count: 1
path: src/world/WorldManager.php
-
message: "#^Variable property access on \\$this\\(pocketmine\\\\world\\\\generator\\\\PopulationTask\\)\\.$#"
count: 4
path: src/world/generator/PopulationTask.php
-
message: "#^Cannot instantiate interface pocketmine\\\\world\\\\format\\\\io\\\\WritableWorldProvider\\.$#"
count: 2
path: src/world/format/io/FormatConverter.php

View File

@ -0,0 +1,97 @@
parameters:
ignoreErrors:
-
message: "#^Instanceof between pocketmine\\\\plugin\\\\PluginManager and pocketmine\\\\plugin\\\\PluginManager will always evaluate to true\\.$#"
count: 1
path: ../../../src/CrashDump.php
-
message: "#^Function parallel\\\\bootstrap not found\\.$#"
count: 1
path: ../../../src/PocketMine.php
-
message: "#^Instanceof between pocketmine\\\\plugin\\\\PluginManager and pocketmine\\\\plugin\\\\PluginManager will always evaluate to true\\.$#"
count: 1
path: ../../../src/Server.php
-
message: "#^Instanceof between pocketmine\\\\network\\\\Network and pocketmine\\\\network\\\\Network will always evaluate to true\\.$#"
count: 2
path: ../../../src/Server.php
-
message: "#^Instanceof between pocketmine\\\\world\\\\WorldManager and pocketmine\\\\world\\\\WorldManager will always evaluate to true\\.$#"
count: 1
path: ../../../src/Server.php
-
message: "#^Instanceof between pocketmine\\\\scheduler\\\\AsyncPool and pocketmine\\\\scheduler\\\\AsyncPool will always evaluate to true\\.$#"
count: 1
path: ../../../src/Server.php
-
message: "#^Instanceof between pocketmine\\\\command\\\\CommandReader and pocketmine\\\\command\\\\CommandReader will always evaluate to true\\.$#"
count: 1
path: ../../../src/Server.php
-
message: "#^pocketmine\\\\block\\\\inventory\\\\DoubleChestInventory\\:\\:__construct\\(\\) does not call parent constructor from pocketmine\\\\block\\\\inventory\\\\ChestInventory\\.$#"
count: 1
path: ../../../src/block/inventory/DoubleChestInventory.php
-
message: "#^Call to an undefined method pocketmine\\\\command\\\\CommandSender\\:\\:teleport\\(\\)\\.$#"
count: 1
path: ../../../src/command/defaults/TeleportCommand.php
-
message: "#^Method pocketmine\\\\event\\\\entity\\\\EntityDeathEvent\\:\\:getEntity\\(\\) should return pocketmine\\\\entity\\\\Living but returns pocketmine\\\\entity\\\\Entity\\.$#"
count: 1
path: ../../../src/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/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/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/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/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/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/event/entity/ProjectileLaunchEvent.php
-
message: "#^Cannot instantiate interface pocketmine\\\\world\\\\format\\\\io\\\\WritableWorldProvider\\.$#"
count: 1
path: ../../../src/world/WorldManager.php
-
message: "#^Cannot instantiate interface pocketmine\\\\world\\\\format\\\\io\\\\WritableWorldProvider\\.$#"
count: 2
path: ../../../src/world/format/io/FormatConverter.php
-
message: "#^Variable property access on \\$this\\(pocketmine\\\\world\\\\generator\\\\PopulationTask\\)\\.$#"
count: 4
path: ../../../src/world/generator/PopulationTask.php

View File

@ -1,9 +1,12 @@
parameters:
ignoreErrors:
-
message: "#^Cannot (access an|assign new) offset (on|to) Ds\\\\Deque\\<.+\\>\\.$#"
path: ../../../src
message: "#^Cannot access an offset on Ds\\\\Deque\\<pocketmine\\\\block\\\\utils\\\\BannerPattern\\>\\.$#"
count: 1
path: ../../../src/block/tile/Banner.php
-
message: "#^Cannot (access|assign) offset (int|-?\\d+) (on|to) Ds\\\\Deque\\<.+\\>\\.$#"
path: ../../../src
message: "#^Cannot access offset int on Ds\\\\Deque\\<pocketmine\\\\item\\\\WritableBookPage\\>\\.$#"
count: 2
path: ../../../src/item/WritableBookBase.php

View File

@ -1,6 +1,3 @@
#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:
-
@ -23,21 +20,6 @@ parameters:
count: 1
path: ../../../src/block/tile/Hopper.php
-
message: "#^Property pocketmine\\\\player\\\\Player\\:\\:\\$cursorInventory \\(pocketmine\\\\inventory\\\\PlayerCursorInventory\\) does not accept null\\.$#"
count: 1
path: ../../../src/player/Player.php
-
message: "#^Property pocketmine\\\\player\\\\Player\\:\\:\\$craftingGrid \\(pocketmine\\\\crafting\\\\CraftingGrid\\) does not accept null\\.$#"
count: 1
path: ../../../src/player/Player.php
-
message: "#^Property pocketmine\\\\player\\\\Player\\:\\:\\$perm \\(pocketmine\\\\permission\\\\PermissibleBase\\) does not accept null\\.$#"
count: 1
path: ../../../src/player/Player.php
-
message: "#^Property pocketmine\\\\entity\\\\Human\\:\\:\\$inventory \\(pocketmine\\\\inventory\\\\PlayerInventory\\) does not accept null\\.$#"
count: 1
@ -68,6 +50,21 @@ parameters:
count: 1
path: ../../../src/entity/Living.php
-
message: "#^Property pocketmine\\\\player\\\\Player\\:\\:\\$cursorInventory \\(pocketmine\\\\inventory\\\\PlayerCursorInventory\\) does not accept null\\.$#"
count: 1
path: ../../../src/player/Player.php
-
message: "#^Property pocketmine\\\\player\\\\Player\\:\\:\\$craftingGrid \\(pocketmine\\\\crafting\\\\CraftingGrid\\) does not accept null\\.$#"
count: 1
path: ../../../src/player/Player.php
-
message: "#^Property pocketmine\\\\player\\\\Player\\:\\:\\$perm \\(pocketmine\\\\permission\\\\PermissibleBase\\) does not accept null\\.$#"
count: 1
path: ../../../src/player/Player.php
-
message: "#^Property pocketmine\\\\world\\\\World\\:\\:\\$provider \\(pocketmine\\\\world\\\\format\\\\io\\\\WritableWorldProvider\\) does not accept null\\.$#"
count: 1
@ -77,3 +74,4 @@ parameters:
message: "#^Property pocketmine\\\\world\\\\World\\:\\:\\$temporalPosition \\(pocketmine\\\\world\\\\Position\\) does not accept null\\.$#"
count: 1
path: ../../../src/world/World.php

View File

@ -1,3 +1,12 @@
parameters:
ignoreErrors:
- "#^Method ReflectionMethod\\:\\:getClosure\\(\\) invoked with 0 parameters, 1 required\\.$#"
-
message: "#^Method ReflectionMethod\\:\\:getClosure\\(\\) invoked with 0 parameters, 1 required\\.$#"
count: 2
path: ../../phpunit/event/HandlerListManagerTest.php
-
message: "#^Method ReflectionMethod\\:\\:getClosure\\(\\) invoked with 0 parameters, 1 required\\.$#"
count: 1
path: ../../phpunit/network/mcpe/handler/StupidJsonDecodeTest.php

View File

@ -1,28 +1,11 @@
parameters:
ignoreErrors:
- "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#"
-
message: "#^Default value of the parameter \\#\\d+ \\$[A-Za-z\\d_]+ \\(\\-?\\d+\\) of method .+\\(\\) is incompatible with type float\\.$#"
path: ../../../src
-
message: "#^Offset string does not exist on array\\(\\)\\.$#"
count: 3
path: ../../../src/MemoryManager.php
-
message: "#^Offset \\(int\\|string\\) does not exist on array\\(\\)\\.$#"
count: 1
path: ../../../src/MemoryManager.php
-
#is_a() type narrowing isn't respected yet
message: "#^Parameter \\#1 \\$class of static method pocketmine\\\\world\\\\format\\\\io\\\\WorldProviderManager\\:\\:setDefault\\(\\) expects class\\-string\\<pocketmine\\\\world\\\\format\\\\io\\\\WritableWorldProvider\\>, class\\-string\\<pocketmine\\\\world\\\\format\\\\io\\\\WorldProvider\\> given\\.$#"
count: 1
path: ../../../src/Server.php
-
#dynamic instanceof
message: "#^Instanceof between pocketmine\\\\block\\\\tile\\\\Tile and class\\-string\\<pocketmine\\\\block\\\\tile\\\\Tile\\> will always evaluate to true\\.$#"
count: 1
path: ../../../src/block/Block.php
@ -33,44 +16,49 @@ parameters:
path: ../../../src/block/Liquid.php
-
#adjacentSources comparison FP
message: "#^If condition is always false\\.$#"
count: 1
path: ../../../src/block/Liquid.php
-
#readline() may return false
message: "#^Strict comparison using \\!\\=\\= between string and false will always evaluate to true\\.$#"
count: 1
message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#"
count: 3
path: ../../../src/command/CommandReader.php
-
message: "#^Default value of the parameter \\#4 \\$min \\(\\-30000000\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getRelativeDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/command/defaults/VanillaCommand.php
-
message: "#^Default value of the parameter \\#5 \\$max \\(30000000\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getRelativeDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/command/defaults/VanillaCommand.php
-
message: "#^Default value of the parameter \\#3 \\$min \\(\\-30000000\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/command/defaults/VanillaCommand.php
-
message: "#^Default value of the parameter \\#4 \\$max \\(30000000\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/command/defaults/VanillaCommand.php
-
message: "#^Call to function assert\\(\\) with false and 'unknown hit type' will always evaluate to false\\.$#"
count: 1
path: ../../../src/entity/projectile/Projectile.php
-
#dynamic Entity class access of ::ID constant
message: "#^Strict comparison using \\!\\=\\= between \\-1 and \\-1 will always evaluate to false\\.$#"
count: 1
path: ../../../src/item/ItemFactory.php
-
message: "#^If condition is always false\\.$#"
count: 1
path: ../../../src/item/ItemFactory.php
-
#object to array cast analysis bug
message: "#^Call to function is_object\\(\\) with int will always evaluate to false\\.$#"
message: "#^Strict comparison using \\!\\=\\= between \\-1 and \\-1 will always evaluate to false\\.$#"
count: 1
path: ../../../src/network/mcpe/protocol/DataPacket.php
-
#object to array cast analysis bug
message: "#^Casting to string something that's already string\\.$#"
count: 1
path: ../../../src/network/mcpe/protocol/DataPacket.php
path: ../../../src/item/ItemFactory.php
-
message: "#^If condition is always false\\.$#"
@ -83,13 +71,42 @@ parameters:
path: ../../../src/network/mcpe/protocol/types/entity/EntityMetadataCollection.php
-
#readlink() can return false but phpstan doesn't know this
message: "#^Strict comparison using \\!\\=\\= between string and false will always evaluate to true\\.$#"
count: 1
path: ../../../src/utils/Timezone.php
-
#phpstan doesn't understand that SplFixedArray may contain null
message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#"
count: 2
path: ../../../src/world/format/io/region/RegionLoader.php
-
message: "#^Default value of the parameter \\#1 \\$pitch \\(0\\) of method pocketmine\\\\world\\\\sound\\\\ClickSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/world/sound/ClickSound.php
-
message: "#^Default value of the parameter \\#1 \\$pitch \\(0\\) of method pocketmine\\\\world\\\\sound\\\\DoorSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/world/sound/DoorSound.php
-
message: "#^Default value of the parameter \\#1 \\$pitch \\(0\\) of method pocketmine\\\\world\\\\sound\\\\FizzSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/world/sound/FizzSound.php
-
message: "#^Default value of the parameter \\#1 \\$pitch \\(0\\) of method pocketmine\\\\world\\\\sound\\\\LaunchSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/world/sound/LaunchSound.php
-
message: "#^Default value of the parameter \\#1 \\$pitch \\(0\\) of method pocketmine\\\\world\\\\sound\\\\PopSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/world/sound/PopSound.php
-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotNull\\(\\) with int and string will always evaluate to true\\.$#"
count: 1
path: ../../../tests/phpunit/block/BlockTest.php
path: ../../phpunit/block/BlockTest.php

View File

@ -4,3 +4,4 @@ parameters:
message: "#^Parameter \\#1 \\$class of static method pocketmine\\\\world\\\\format\\\\io\\\\WorldProviderManager\\:\\:addProvider\\(\\) expects class\\-string\\<pocketmine\\\\world\\\\format\\\\io\\\\WorldProvider\\>, string given\\.$#"
count: 2
path: ../../phpunit/world/format/io/LevelProviderManagerTest.php

View File

@ -2,5 +2,6 @@ parameters:
ignoreErrors:
-
message: "#^Variable \\$GLOBALS in isset\\(\\) always exists and is not nullable\\.$#"
count: 1
path: ../../../src/MemoryManager.php

View File

@ -21,19 +21,16 @@ parameters:
path: ../../../src/event/HandlerList.php
-
#jsonDeserialize(), not currently validated
message: "#^Casting to int something that's already int\\.$#"
count: 3
path: ../../../src/item/Item.php
-
#setLore()
message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#"
count: 1
path: ../../../src/item/Item.php
-
#commands plugin.yml not currently validated, can't be sure
message: "#^Casting to int something that's already int\\.$#"
count: 3
path: ../../../src/item/Item.php
-
message: "#^Call to function is_array\\(\\) with array\\<string, mixed\\> will always evaluate to true\\.$#"
count: 1
path: ../../../src/plugin/PluginBase.php
@ -44,7 +41,6 @@ parameters:
path: ../../../src/plugin/PluginManager.php
-
#::add() / ::remove() thread parameter
message: "#^If condition is always true\\.$#"
count: 2
path: ../../../src/thread/ThreadManager.php
@ -54,12 +50,6 @@ parameters:
count: 2
path: ../../../src/thread/ThreadManager.php
-
#->sendBlocks() blocks parameter
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 1
path: ../../../src/world/World.php
-
message: "#^Instanceof between pocketmine\\\\math\\\\Vector3 and pocketmine\\\\math\\\\Vector3 will always evaluate to true\\.$#"
count: 1
@ -70,7 +60,13 @@ parameters:
count: 1
path: ../../../src/world/World.php
-
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 1
path: ../../../src/world/World.php
-
message: "#^Call to function assert\\(\\) with bool will always evaluate to true\\.$#"
count: 1
path: ../../../src/world/World.php