[TOOLS] Fix errors pointed out by PHPStan level 4

This commit is contained in:
2022-10-19 22:38:49 +01:00
parent 4d7742e0e1
commit edeee49af9
37 changed files with 168 additions and 198 deletions

View File

@@ -23,7 +23,6 @@ declare(strict_types = 1);
namespace App\Core;
use App\Core\DB;
use function App\Core\I18n\_m;
use App\Util\Common;
use App\Util\Exception\DuplicateFoundException;
@@ -109,7 +108,7 @@ class GSFile
// The following properly gets the mimetype with `file` or other
// available methods, so should be safe
$mimetype = mb_substr($file->getMimeType(), 0, 64);
$width = $height = null;
$width = $height = null;
$event_map[$mimetype] = [];
$major_mime = self::mimetypeMajor($mimetype);
$event_map[$major_mime] = [];
@@ -120,6 +119,7 @@ class GSFile
}
// Always prefer specific encoders
$encoders = array_merge($event_map[$mimetype], $event_map[$major_mime]);
// @phpstan-ignore-next-line
foreach ($encoders as $encoder) {
if ($encoder($file, $mimetype, $width, $height)) {
break; // One successful sanitizer is enough
@@ -315,7 +315,7 @@ class GSFile
$fallback = function ($title) use ($ext) {
if (!\is_null($ext)) {
return ($title) . ".{$ext}";
return $title . ".{$ext}";
}
};