diff --git a/src/Api.php b/src/Api.php index 3f467c1..ad6b005 100644 --- a/src/Api.php +++ b/src/Api.php @@ -6,6 +6,7 @@ use Baraja\AssetsLoader\Minifier\Minifier; +use Nette\Utils\FileSystem; final class Api { @@ -113,7 +114,7 @@ public function run(string $path): void echo '/* Path "' . htmlspecialchars($parser[1]) . '" was automatically generated ' . date('Y-m-d H:i:s', $topModTime) . ' */' . "\n\n"; // 4. foreach ($filePaths as $file => $filePath) { echo '/* ' . $file . ' */' . "\n"; - echo $this->minifier->minify(file_get_contents($filePath), $format); + echo $this->minifier->minify(FileSystem::read($filePath), $format); echo "\n\n"; } die; diff --git a/src/Helpers.php b/src/Helpers.php index f53d34d..ad57c00 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -48,7 +48,7 @@ public static function formatRoute(string $module, string $presenter = 'Homepage } - public static function formatRouteToPath(string $route): ?string + public static function formatRouteToPath(string $route): string { if ($route === 'Error4xx:default') { return 'error4xx-default'; @@ -57,7 +57,7 @@ public static function formatRouteToPath(string $route): ?string return self::firstLower($parser['module']) . '-' . self::firstLower($parser['presenter']) . '-' . self::firstLower($parser['action']); } - return null; + throw new \InvalidArgumentException('Can not parse route format, because haystack "' . $route . '" given.'); } diff --git a/src/Minifier/DefaultCssMinifier.php b/src/Minifier/DefaultCssMinifier.php index d0947e6..8b9ef91 100644 --- a/src/Minifier/DefaultCssMinifier.php +++ b/src/Minifier/DefaultCssMinifier.php @@ -9,7 +9,7 @@ final class DefaultCssMinifier implements AssetMinifier { public function minify(string $haystack): string { - return preg_replace_callback( + return (string) preg_replace_callback( '#[ \t\r\n]+|<(/)?(textarea|pre|script)(?=\W)#si', static function ($m): string { if (empty($m[2])) { diff --git a/src/Minifier/DefaultJsMinifier.php b/src/Minifier/DefaultJsMinifier.php index 864f43e..493a1de 100644 --- a/src/Minifier/DefaultJsMinifier.php +++ b/src/Minifier/DefaultJsMinifier.php @@ -11,6 +11,6 @@ final class DefaultJsMinifier implements AssetMinifier { public function minify(string $haystack): string { - return JShrinkMinifier::minify($haystack); + return (string) JShrinkMinifier::minify($haystack); } }