From b9643c250b01ca9f950581fad72618669e421cfb Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Thu, 29 Feb 2024 21:36:57 +0100 Subject: [PATCH] Address phpstan ImageProxy complaints Re. https://github.com/FreshRSS/Extensions/pull/208#issuecomment-1971845385 --- xExtension-ImageProxy/extension.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xExtension-ImageProxy/extension.php b/xExtension-ImageProxy/extension.php index b5f1b4c..59c2458 100644 --- a/xExtension-ImageProxy/extension.php +++ b/xExtension-ImageProxy/extension.php @@ -109,11 +109,11 @@ final class ImageProxyExtension extends Minz_Extension { /** * @param array $matches - * @return array + * @return string */ - public static function getSrcSetUris(array $matches): array { - $result = str_replace($matches[1], self::getProxyImageUri($matches[1]), $matches[0]); - return is_array($result) ? $result : [$result]; + public static function getSrcSetUris(array $matches): string { + $result = str_replace($matches[1], self::getProxyImageUri($matches[1]), $matches[0]) ?: ''; + return $result; } public static function swapUris(string $content): string { @@ -131,7 +131,7 @@ final class ImageProxyExtension extends Minz_Extension { $img->setAttribute('src', $newSrc); } if ($img->hasAttribute('srcset')) { - $newSrcSet = preg_replace_callback('/(?:([^\s,]+)(\s*(?:\s+\d+[wx])(?:,\s*)?))/', fn($matches) => self::getSrcSetUris($matches), $img->getAttribute('srcset')); + $newSrcSet = preg_replace_callback('/(?:([^\s,]+)(\s*(?:\s+\d+[wx])(?:,\s*)?))/', fn($matches) => self::getSrcSetUris($matches), $img->getAttribute('srcset')) ?: ''; $img->setAttribute('srcset', $newSrcSet); } }