From e105578be0728065a14a0cb8f7d438f6114c5711 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 18 Jun 2020 20:08:38 +0100 Subject: [PATCH 1/2] LegacySkinAdapter: an extra check for resourcePatch (fixes 3 phpstan explicitMixed errors) --- .../network/mcpe/protocol/types/LegacySkinAdapter.php | 3 ++- tests/phpstan/configs/check-explicit-mixed-baseline.neon | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php b/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php index e4e7435b6..344203030 100644 --- a/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php +++ b/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php @@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol\types; use pocketmine\entity\InvalidSkinException; use pocketmine\entity\Skin; +use function is_array; use function is_string; use function json_decode; use function json_encode; @@ -58,7 +59,7 @@ class LegacySkinAdapter implements SkinAdapter{ $capeData = $data->isPersonaCapeOnClassic() ? "" : $data->getCapeImage()->getData(); $resourcePatch = json_decode($data->getResourcePatch(), true); - if(isset($resourcePatch["geometry"]["default"]) && is_string($resourcePatch["geometry"]["default"])){ + if(is_array($resourcePatch) && isset($resourcePatch["geometry"]["default"]) && is_string($resourcePatch["geometry"]["default"])){ $geometryName = $resourcePatch["geometry"]["default"]; }else{ throw new InvalidSkinException("Missing geometry name field"); diff --git a/tests/phpstan/configs/check-explicit-mixed-baseline.neon b/tests/phpstan/configs/check-explicit-mixed-baseline.neon index a0389d027..c82bdac38 100644 --- a/tests/phpstan/configs/check-explicit-mixed-baseline.neon +++ b/tests/phpstan/configs/check-explicit-mixed-baseline.neon @@ -455,11 +455,6 @@ parameters: count: 1 path: ../../../src/pocketmine/network/mcpe/protocol/StartGamePacket.php - - - message: "#^Cannot access offset 'geometry' on mixed\\.$#" - count: 3 - path: ../../../src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php - - message: "#^Cannot access offset string on mixed\\.$#" count: 1 From e32180ce93a012369d950f825a4845f763af0cf0 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 19 Jun 2020 10:41:41 +0100 Subject: [PATCH 2/2] phpstan: drop an obsolete phpstan-bugs ignoreError --- tests/phpstan/configs/phpstan-bugs.neon | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index 2c604d354..65c189e43 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -30,11 +30,6 @@ parameters: count: 1 path: ../../../src/pocketmine/network/mcpe/protocol/DataPacket.php - - - message: "#^Strict comparison using \\=\\=\\= between array and false will always evaluate to false\\.$#" - count: 1 - path: ../../../src/pocketmine/utils/Timezone.php - - message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#" count: 1