Deal with a whole lot of PHPStan suppressed key casting errors

closes #6534
This commit is contained in:
Dylan K. Taylor
2024-11-25 14:30:58 +00:00
parent aef4fa7174
commit 5325ecee37
66 changed files with 338 additions and 124 deletions

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\tools\compact_regions;
use pocketmine\utils\Utils;
use pocketmine\world\format\io\exception\CorruptedChunkException;
use pocketmine\world\format\io\region\CorruptedRegionException;
use pocketmine\world\format\io\region\RegionLoader;
@ -59,6 +60,7 @@ const SUPPORTED_EXTENSIONS = [
/**
* @param int[] $files
* @phpstan-param array<string, int> $files
* @phpstan-param-out array<string, int> $files
*/
function find_regions_recursive(string $dir, array &$files) : void{
$dirFiles = scandir($dir, SCANDIR_SORT_NONE);
@ -112,7 +114,7 @@ function main(array $argv) : int{
$corruptedFiles = [];
$doneCount = 0;
$totalCount = count($files);
foreach($files as $file => $size){
foreach(Utils::stringifyKeys($files) as $file => $size){
try{
$oldRegion = RegionLoader::loadExisting($file);
}catch(CorruptedRegionException $e){
@ -162,7 +164,7 @@ function main(array $argv) : int{
clearstatcache();
$newSize = 0;
foreach($files as $file => $oldSize){
foreach(Utils::stringifyKeys($files) as $file => $oldSize){
$newSize += file_exists($file) ? filesize($file) : 0;
}
$diff = $currentSize - $newSize;