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

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\lang;
use pocketmine\utils\Utils;
use Webmozart\PathUtil\Path;
use function array_filter;
use function array_map;
@ -123,7 +124,7 @@ class Language{
protected static function loadLang(string $path, string $languageCode) : array{
$file = Path::join($path, $languageCode . ".ini");
if(file_exists($file)){
return array_map('\stripcslashes', parse_ini_file($file, false, INI_SCANNER_RAW));
return array_map('\stripcslashes', Utils::assumeNotFalse(parse_ini_file($file, false, INI_SCANNER_RAW), "Missing or inaccessible required resource files"));
}
throw new LanguageNotFoundException("Language \"$languageCode\" not found");