[core] a load more type hints, and fix bugs revealed by type hints

This commit is contained in:
Shish
2024-01-20 14:10:59 +00:00
parent 373be4e05c
commit b60c3fe362
158 changed files with 1532 additions and 616 deletions

View File

@@ -83,6 +83,9 @@ class TranscodeImage extends Extension
$config->set_string(self::get_mapping_name($from_mime), $to_mime);
}
/**
* @return string[]
*/
public static function get_enabled_mimes(): array
{
$output = [];
@@ -320,17 +323,18 @@ class TranscodeImage extends Extension
}
private function can_convert_mime($engine, $mime): bool
private function can_convert_mime(string $engine, string $mime): bool
{
return MediaEngine::is_input_supported($engine, $mime);
}
private function get_supported_output_mimes($engine, ?string $omit_mime = null): array
/**
* @return array<string, string>
*/
private function get_supported_output_mimes(string $engine, ?string $omit_mime = null): array
{
$output = [];
foreach (self::OUTPUT_MIMES as $key => $value) {
if ($value == "") {
$output[$key] = $value;
@@ -409,9 +413,6 @@ class TranscodeImage extends Extension
}
try {
$background_color = Media::hex_color_allocate($new_image, $config->get_string(TranscodeConfig::ALPHA_COLOR));
if ($background_color === false) {
throw new ImageTranscodeException("Could not allocate background color");
}
if (imagefilledrectangle($new_image, 0, 0, $width, $height, $background_color) === false) {
throw new ImageTranscodeException("Could not fill background color");
}