minify_css: minor improvements

", " -> ","
"0." -> "."
This commit is contained in:
Starbeamrainbowlabs 2020-07-28 21:46:00 +01:00
parent 54250e71db
commit 607c9f8529
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
1 changed files with 5 additions and 3 deletions

View File

@ -627,7 +627,7 @@ function render_editor($editorName) {
* @param string $css_str The string of CSS to minify.
* @return string The minified CSS string.
*/
function minify_css($css_str) {
function minify_css(string $css_str) : string {
// Remove comments
$result = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', "", $css_str);
// Cut down whitespace
@ -635,10 +635,12 @@ function minify_css($css_str) {
// Remove whitespace after colons and semicolons
$result = str_replace([
" :", ": ", "; ",
" { ", " } ", "{ ", " {", "} ", " }"
" { ", " } ", "{ ", " {", "} ", " }",
", ", "0."
], [
":", ":", ";",
"{", "}", "{", "{", "}", "}"
"{", "}", "{", "{", "}", "}",
",", "."
], $result);
return $result;
}