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

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\data\bedrock;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\utils\Utils;
use function file_get_contents;
use function is_array;
use function is_int;
@ -44,7 +45,7 @@ abstract class LegacyToStringBidirectionalIdMap{
private $stringToLegacy = [];
public function __construct(string $file){
$stringToLegacyId = json_decode(file_get_contents($file), true);
$stringToLegacyId = json_decode(Utils::assumeNotFalse(file_get_contents($file), "Missing required resource file"), true);
if(!is_array($stringToLegacyId)){
throw new AssumptionFailedError("Invalid format of ID map");
}