@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | 0 == \preg_match('/["\'=<>` \t\r\n\f]+/', $attribute->value); |
| 510 | 510 | |
| 511 | 511 | $attr_val = $attribute->value; |
| 512 | - $attrstr .= ($omitquotes ? '' : '"') . $attr_val . ($omitquotes ? '' : '"'); |
|
| 512 | + $attrstr .= ($omitquotes ? '' : '"').$attr_val.($omitquotes ? '' : '"'); |
|
| 513 | 513 | $attrstr .= ' '; |
| 514 | 514 | } |
| 515 | 515 | } |
@@ -773,23 +773,23 @@ discard block |
||
| 773 | 773 | $tmpTypePublic = 'PUBLIC'; |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - $html .= '<!DOCTYPE ' . $child->name . '' |
|
| 777 | - . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '') |
|
| 778 | - . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '') |
|
| 776 | + $html .= '<!DOCTYPE '.$child->name.'' |
|
| 777 | + . ($child->publicId ? ' '.$tmpTypePublic.' "'.$child->publicId.'"' : '') |
|
| 778 | + . ($child->systemId ? ' '.$tmpTypeSystem.' "'.$child->systemId.'"' : '') |
|
| 779 | 779 | . '>'; |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | } elseif ($child instanceof \DOMElement) { |
| 783 | 783 | |
| 784 | - $html .= \rtrim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child)); |
|
| 785 | - $html .= '>' . $this->domNodeToString($child); |
|
| 784 | + $html .= \rtrim('<'.$child->tagName.' '.$this->domNodeAttributesToString($child)); |
|
| 785 | + $html .= '>'.$this->domNodeToString($child); |
|
| 786 | 786 | |
| 787 | 787 | if ( |
| 788 | 788 | $this->doRemoveOmittedHtmlTags === false |
| 789 | 789 | || |
| 790 | 790 | !$this->domNodeClosingTagOptional($child) |
| 791 | 791 | ) { |
| 792 | - $html .= '</' . $child->tagName . '>'; |
|
| 792 | + $html .= '</'.$child->tagName.'>'; |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | if ($this->doRemoveWhitespaceAroundTags === false) { |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | |
| 836 | 836 | } elseif ($child instanceof \DOMComment) { |
| 837 | 837 | |
| 838 | - $html .= '<!--' . $child->textContent . '-->'; |
|
| 838 | + $html .= '<!--'.$child->textContent.'-->'; |
|
| 839 | 839 | |
| 840 | 840 | } |
| 841 | 841 | } |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | */ |
| 891 | 891 | public function minify($html, $decodeUtf8Specials = false): string |
| 892 | 892 | { |
| 893 | - $html = (string)$html; |
|
| 893 | + $html = (string) $html; |
|
| 894 | 894 | if (!isset($html[0])) { |
| 895 | 895 | return ''; |
| 896 | 896 | } |
@@ -926,25 +926,25 @@ discard block |
||
| 926 | 926 | // ------------------------------------------------------------------------- |
| 927 | 927 | |
| 928 | 928 | // Remove extra white-space(s) between HTML attribute(s) |
| 929 | - $html = (string)\preg_replace_callback( |
|
| 929 | + $html = (string) \preg_replace_callback( |
|
| 930 | 930 | '#<([^/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(/?)>#', |
| 931 | - function ($matches) { |
|
| 932 | - return '<' . $matches[1] . (string)\preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>'; |
|
| 931 | + function($matches) { |
|
| 932 | + return '<'.$matches[1].(string) \preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]).$matches[3].'>'; |
|
| 933 | 933 | }, |
| 934 | 934 | $html |
| 935 | 935 | ); |
| 936 | 936 | |
| 937 | 937 | if ($this->doRemoveSpacesBetweenTags === true) { |
| 938 | 938 | // Remove spaces that are between > and < |
| 939 | - $html = (string)\preg_replace('/(>) (<)/', '>$2', $html); |
|
| 939 | + $html = (string) \preg_replace('/(>) (<)/', '>$2', $html); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | // ------------------------------------------------------------------------- |
| 943 | 943 | // Restore protected HTML-code. |
| 944 | 944 | // ------------------------------------------------------------------------- |
| 945 | 945 | |
| 946 | - $html = (string)\preg_replace_callback( |
|
| 947 | - '/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/', |
|
| 946 | + $html = (string) \preg_replace_callback( |
|
| 947 | + '/<(?<element>'.$this->protectedChildNodesHelper.')(?<attributes> [^>]*)?>(?<value>.*?)<\/'.$this->protectedChildNodesHelper.'>/', |
|
| 948 | 948 | [$this, 'restoreProtectedHtml'], |
| 949 | 949 | $html |
| 950 | 950 | ); |
@@ -963,14 +963,14 @@ discard block |
||
| 963 | 963 | |
| 964 | 964 | $html = \str_replace( |
| 965 | 965 | [ |
| 966 | - 'html>' . "\n", |
|
| 967 | - "\n" . '<html', |
|
| 968 | - 'html/>' . "\n", |
|
| 969 | - "\n" . '</html', |
|
| 970 | - 'head>' . "\n", |
|
| 971 | - "\n" . '<head', |
|
| 972 | - 'head/>' . "\n", |
|
| 973 | - "\n" . '</head', |
|
| 966 | + 'html>'."\n", |
|
| 967 | + "\n".'<html', |
|
| 968 | + 'html/>'."\n", |
|
| 969 | + "\n".'</html', |
|
| 970 | + 'head>'."\n", |
|
| 971 | + "\n".'<head', |
|
| 972 | + 'head/>'."\n", |
|
| 973 | + "\n".'</head', |
|
| 974 | 974 | ], |
| 975 | 975 | [ |
| 976 | 976 | 'html>', |
@@ -989,10 +989,10 @@ discard block |
||
| 989 | 989 | $replace = []; |
| 990 | 990 | $replacement = []; |
| 991 | 991 | foreach (self::$selfClosingTags as $selfClosingTag) { |
| 992 | - $replace[] = '<' . $selfClosingTag . '/>'; |
|
| 993 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
| 994 | - $replace[] = '<' . $selfClosingTag . ' />'; |
|
| 995 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
| 992 | + $replace[] = '<'.$selfClosingTag.'/>'; |
|
| 993 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
| 994 | + $replace[] = '<'.$selfClosingTag.' />'; |
|
| 995 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
| 996 | 996 | } |
| 997 | 997 | $html = \str_replace( |
| 998 | 998 | $replace, |
@@ -1000,7 +1000,7 @@ discard block |
||
| 1000 | 1000 | $html |
| 1001 | 1001 | ); |
| 1002 | 1002 | |
| 1003 | - $html = (string)\preg_replace('#<\b(' . $CACHE_SELF_CLOSING_TAGS . ')([^>]*+)><\/\b\1>#', '<\\1\\2>', $html); |
|
| 1003 | + $html = (string) \preg_replace('#<\b('.$CACHE_SELF_CLOSING_TAGS.')([^>]*+)><\/\b\1>#', '<\\1\\2>', $html); |
|
| 1004 | 1004 | |
| 1005 | 1005 | // ------------------------------------ |
| 1006 | 1006 | // check if compression worked |
@@ -1101,7 +1101,7 @@ discard block |
||
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | $attrs = []; |
| 1104 | - foreach ((array)$attributes as $attrName => $attrValue) { |
|
| 1104 | + foreach ((array) $attributes as $attrName => $attrValue) { |
|
| 1105 | 1105 | |
| 1106 | 1106 | // ------------------------------------------------------------------------- |
| 1107 | 1107 | // Remove optional "http:"-prefix from attributes. |
@@ -1176,7 +1176,7 @@ discard block |
||
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | $this->protectedChildNodes[$counter] = $element->text(); |
| 1179 | - $element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'; |
|
| 1179 | + $element->getNode()->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'; |
|
| 1180 | 1180 | |
| 1181 | 1181 | ++$counter; |
| 1182 | 1182 | } |
@@ -1191,11 +1191,11 @@ discard block |
||
| 1191 | 1191 | continue; |
| 1192 | 1192 | } |
| 1193 | 1193 | |
| 1194 | - $this->protectedChildNodes[$counter] = '<!--' . $text . '-->'; |
|
| 1194 | + $this->protectedChildNodes[$counter] = '<!--'.$text.'-->'; |
|
| 1195 | 1195 | |
| 1196 | 1196 | /* @var $node \DOMComment */ |
| 1197 | 1197 | $node = $element->getNode(); |
| 1198 | - $child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'); |
|
| 1198 | + $child = new \DOMText('<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'); |
|
| 1199 | 1199 | $element->getNode()->parentNode->replaceChild($child, $node); |
| 1200 | 1200 | |
| 1201 | 1201 | ++$counter; |
@@ -1406,7 +1406,7 @@ discard block |
||
| 1406 | 1406 | continue; |
| 1407 | 1407 | } |
| 1408 | 1408 | |
| 1409 | - $attrValue .= \trim($class) . ' '; |
|
| 1409 | + $attrValue .= \trim($class).' '; |
|
| 1410 | 1410 | } |
| 1411 | 1411 | $attrValue = \trim($attrValue); |
| 1412 | 1412 | |