LegacySkinAdapter: an extra check for resourcePatch (fixes 3 phpstan explicitMixed errors)

This commit is contained in:
Dylan K. Taylor 2020-06-18 20:08:38 +01:00
parent a9d98bdf73
commit e105578be0
2 changed files with 2 additions and 6 deletions

View File

@ -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");

View File

@ -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