diff --git a/src/Tinyfier/JS/Tool.php b/src/Tinyfier/JS/Tool.php index 9e5ab82..3bceede 100644 --- a/src/Tinyfier/JS/Tool.php +++ b/src/Tinyfier/JS/Tool.php @@ -1,7 +1,5 @@ squeeze($source, true, false, false); } catch (Exception $e) { $errors[] = $e->getMessage(); @@ -53,6 +51,8 @@ public static function process(string $source, array $settings = [], &$errors = } return $result; + } else { + return $source; } } @@ -63,11 +63,11 @@ public static function process(string $source, array $settings = [], &$errors = public static function default_settings(): array { return [ - 'external_services' => true, //Use external compressors (like gclosure) + 'external_services' => true, //Use external compressors (like gclosure) 'external_services_min_length' => 750, //Min source length to use external compressors (to avoid too many calls) - 'gclosure' => true, - 'level' => self::LEVEL_SIMPLE_OPTIMIZATIONS, - 'pretty' => false + 'gclosure' => true, + 'level' => self::LEVEL_SIMPLE_OPTIMIZATIONS, + 'pretty' => false, ]; } @@ -75,9 +75,9 @@ public static function default_settings(): array * Compiles javascript code using the Google Closure Compiler API * @see http://code.google.com/intl/es/closure/compiler/docs/api-ref.html * - * @param string $source + * @param string $source * @param int|string $level One of LEVEL_* constants - * @param bool $pretty + * @param bool $pretty * * @return mixed Code compressed, FALSE if error */ @@ -87,7 +87,7 @@ private static function _compress_google_closure( bool $pretty = false, &$errors = [], &$warnings = null, - $extra_settings = [] + $extra_settings = [], ): mixed { if (!function_exists('curl_exec')) { return false; @@ -95,11 +95,11 @@ private static function _compress_google_closure( //Generate POST data $post = $extra_settings + [ - 'output_info' => 'compiled_code', - 'output_format' => 'json', - 'warning_level' => isset($warnings) ? 'VERBOSE' : 'QUIET', + 'output_info' => 'compiled_code', + 'output_format' => 'json', + 'warning_level' => isset($warnings) ? 'VERBOSE' : 'QUIET', 'compilation_level' => $level, - 'js_code' => $source, + 'js_code' => $source, ]; if ($pretty) { $post['formatting'] = 'pretty_print';