Make use of Utils::assumeNotFalse() in a bunch of places

I've stuck to only doing this in the places where I'm sure we should never get false back. Other places I'm less sure of (and I found more bugs along the way).
This commit is contained in:
Dylan K. Taylor
2021-12-08 19:33:45 +00:00
parent 8b73549355
commit 889d048ca3
26 changed files with 67 additions and 171 deletions

View File

@ -1,10 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, string\\|false given\\.$#"
count: 1
path: ../../../build/make-release.php
-
message: "#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, string\\|null given\\.$#"
count: 2
@ -20,16 +15,6 @@ parameters:
count: 1
path: ../../../build/server-phar.php
-
message: "#^Parameter \\#1 \\$stream of function fclose expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/MemoryManager.php
-
message: "#^Parameter \\#1 \\$stream of function fwrite expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/MemoryManager.php
-
message: "#^Binary operation \"\\.\" between array\\<int, mixed\\>\\|string\\|false and '/'\\|'\\\\\\\\' results in an error\\.$#"
count: 2
@ -40,11 +25,6 @@ parameters:
count: 1
path: ../../../src/PocketMine.php
-
message: "#^Parameter \\#1 \\$path of function realpath expects string, string\\|false given\\.$#"
count: 2
path: ../../../src/PocketMine.php
-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
@ -60,11 +40,6 @@ parameters:
count: 1
path: ../../../src/Server.php
-
message: "#^Parameter \\#3 \\$subject of function str_replace expects array\\|string, string\\|false given\\.$#"
count: 1
path: ../../../src/Server.php
-
message: "#^Cannot cast array\\<int, mixed\\>\\|string\\|false to string\\.$#"
count: 1
@ -495,21 +470,11 @@ parameters:
count: 2
path: ../../../src/console/ConsoleReader.php
-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/crafting/CraftingManagerFromDataHelper.php
-
message: "#^Parameter \\#1 \\$path of static method pocketmine\\\\utils\\\\Filesystem\\:\\:cleanPath\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/crash/CrashDump.php
-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/data/bedrock/LegacyToStringBidirectionalIdMap.php
-
message: "#^Parameter \\#1 \\$index of method pocketmine\\\\inventory\\\\BaseInventory\\:\\:setItem\\(\\) expects int, int\\|string given\\.$#"
count: 1
@ -615,11 +580,6 @@ parameters:
count: 1
path: ../../../src/item/Item.php
-
message: "#^Parameter \\#2 \\$array of function array_map expects array, array\\|false given\\.$#"
count: 1
path: ../../../src/lang/Language.php
-
message: "#^Parameter \\#1 \\$result of method pocketmine\\\\network\\\\mcpe\\\\compression\\\\CompressBatchPromise\\:\\:resolve\\(\\) expects string, mixed given\\.$#"
count: 1
@ -735,16 +695,6 @@ parameters:
count: 1
path: ../../../src/network/mcpe/compression/CompressBatchTask.php
-
message: "#^Parameter \\#1 \\$buffer of static method pocketmine\\\\network\\\\mcpe\\\\protocol\\\\serializer\\\\PacketSerializer\\:\\:decoder\\(\\) expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/network/mcpe/convert/RuntimeBlockMapping.php
-
message: "#^Method pocketmine\\\\network\\\\mcpe\\\\encryption\\\\EncryptionUtils\\:\\:generateKey\\(\\) should return string but returns string\\|false\\.$#"
count: 1
path: ../../../src/network/mcpe/encryption/EncryptionUtils.php
-
message: "#^Property pocketmine\\\\network\\\\mcpe\\\\encryption\\\\PrepareEncryptionTask\\:\\:\\$serverPrivateKey \\(string\\) does not accept string\\|null\\.$#"
count: 1
@ -865,11 +815,6 @@ parameters:
count: 4
path: ../../../src/plugin/PluginManager.php
-
message: "#^Method pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:getPackChunk\\(\\) should return string but returns string\\|false\\.$#"
count: 1
path: ../../../src/resourcepacks/ZippedResourcePack.php
-
message: "#^Method pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:getPackSize\\(\\) should return int but returns int\\<0, max\\>\\|false\\.$#"
count: 1
@ -880,11 +825,6 @@ parameters:
count: 1
path: ../../../src/resourcepacks/ZippedResourcePack.php
-
message: "#^Parameter \\#1 \\$string of function strlen expects string, string\\|false given\\.$#"
count: 2
path: ../../../src/resourcepacks/ZippedResourcePack.php
-
message: "#^Parameter \\#2 \\$code of class pocketmine\\\\resourcepacks\\\\ResourcePackException constructor expects int, mixed given\\.$#"
count: 1
@ -895,11 +835,6 @@ parameters:
count: 1
path: ../../../src/resourcepacks/ZippedResourcePack.php
-
message: "#^Parameter \\#2 \\$subject of function preg_match expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/resourcepacks/ZippedResourcePack.php
-
message: "#^Property pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:\\$fileResource \\(resource\\) does not accept resource\\|false\\.$#"
count: 1
@ -980,11 +915,6 @@ parameters:
count: 1
path: ../../../src/utils/Config.php
-
message: "#^Parameter \\#2 \\$subject of function preg_match expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/utils/Filesystem.php
-
message: "#^Parameter \\#2 \\$offset of function substr expects int, mixed given\\.$#"
count: 1
@ -995,26 +925,11 @@ parameters:
count: 1
path: ../../../src/utils/Internet.php
-
message: "#^Parameter \\#1 \\$abbr of function timezone_name_from_abbr expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/utils/Timezone.php
-
message: "#^Parameter \\#1 \\$haystack of function strpos expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/utils/Timezone.php
-
message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/utils/Timezone.php
-
message: "#^Parameter \\#1 \\$timezoneId of function date_default_timezone_set expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/utils/Timezone.php
-
message: "#^Cannot cast mixed to string\\.$#"
count: 1