@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace voku\helper; |
| 6 | 6 | |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | 0 == \preg_match('/["\'=<>` \t\r\n\f]+/', $attribute->value); |
| 504 | 504 | |
| 505 | 505 | $attr_val = $attribute->value; |
| 506 | - $attrstr .= ($omitquotes ? '' : '"') . $attr_val . ($omitquotes ? '' : '"'); |
|
| 506 | + $attrstr .= ($omitquotes ? '' : '"').$attr_val.($omitquotes ? '' : '"'); |
|
| 507 | 507 | $attrstr .= ' '; |
| 508 | 508 | } |
| 509 | 509 | } |
@@ -755,22 +755,22 @@ discard block |
||
| 755 | 755 | $tmpTypePublic = 'PUBLIC'; |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | - $html .= '<!DOCTYPE ' . $child->name . '' |
|
| 759 | - . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '') |
|
| 760 | - . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '') |
|
| 758 | + $html .= '<!DOCTYPE '.$child->name.'' |
|
| 759 | + . ($child->publicId ? ' '.$tmpTypePublic.' "'.$child->publicId.'"' : '') |
|
| 760 | + . ($child->systemId ? ' '.$tmpTypeSystem.' "'.$child->systemId.'"' : '') |
|
| 761 | 761 | . '>'; |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | } else if ($child instanceof \DOMElement) { |
| 765 | 765 | |
| 766 | - $html .= trim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child)); |
|
| 767 | - $html .= '>' . $this->domNodeToString($child); |
|
| 766 | + $html .= trim('<'.$child->tagName.' '.$this->domNodeAttributesToString($child)); |
|
| 767 | + $html .= '>'.$this->domNodeToString($child); |
|
| 768 | 768 | |
| 769 | 769 | if ( |
| 770 | 770 | $this->doRemoveOmittedHtmlTags === false |
| 771 | 771 | || |
| 772 | 772 | !$this->domNodeClosingTagOptional($child)) { |
| 773 | - $html .= '</' . $child->tagName . '>'; |
|
| 773 | + $html .= '</'.$child->tagName.'>'; |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | } elseif ($child instanceof \DOMText) { |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | */ |
| 845 | 845 | public function minify($html, $decodeUtf8Specials = false): string |
| 846 | 846 | { |
| 847 | - $html = (string)$html; |
|
| 847 | + $html = (string) $html; |
|
| 848 | 848 | if (!isset($html[0])) { |
| 849 | 849 | return ''; |
| 850 | 850 | } |
@@ -880,10 +880,10 @@ discard block |
||
| 880 | 880 | // ------------------------------------------------------------------------- |
| 881 | 881 | |
| 882 | 882 | // Remove extra white-space(s) between HTML attribute(s) |
| 883 | - $html = (string)\preg_replace_callback( |
|
| 883 | + $html = (string) \preg_replace_callback( |
|
| 884 | 884 | '#<([^\/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(\/?)>#', |
| 885 | - function ($matches) { |
|
| 886 | - return '<' . $matches[1] . (string)\preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>'; |
|
| 885 | + function($matches) { |
|
| 886 | + return '<'.$matches[1].(string) \preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]).$matches[3].'>'; |
|
| 887 | 887 | }, |
| 888 | 888 | $html |
| 889 | 889 | ); |
@@ -891,15 +891,15 @@ discard block |
||
| 891 | 891 | |
| 892 | 892 | if ($this->doRemoveSpacesBetweenTags === true) { |
| 893 | 893 | // Remove spaces that are between > and < |
| 894 | - $html = (string)\preg_replace('/(>) (<)/', '>$2', $html); |
|
| 894 | + $html = (string) \preg_replace('/(>) (<)/', '>$2', $html); |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | // ------------------------------------------------------------------------- |
| 898 | 898 | // Restore protected HTML-code. |
| 899 | 899 | // ------------------------------------------------------------------------- |
| 900 | 900 | |
| 901 | - $html = (string)\preg_replace_callback( |
|
| 902 | - '/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/', |
|
| 901 | + $html = (string) \preg_replace_callback( |
|
| 902 | + '/<(?<element>'.$this->protectedChildNodesHelper.')(?<attributes> [^>]*)?>(?<value>.*?)<\/'.$this->protectedChildNodesHelper.'>/', |
|
| 903 | 903 | [$this, 'restoreProtectedHtml'], |
| 904 | 904 | $html |
| 905 | 905 | ); |
@@ -920,14 +920,14 @@ discard block |
||
| 920 | 920 | |
| 921 | 921 | $html = \str_replace( |
| 922 | 922 | [ |
| 923 | - 'html>' . "\n", |
|
| 924 | - "\n" . '<html', |
|
| 925 | - 'html/>' . "\n", |
|
| 926 | - "\n" . '</html', |
|
| 927 | - 'head>' . "\n", |
|
| 928 | - "\n" . '<head', |
|
| 929 | - 'head/>' . "\n", |
|
| 930 | - "\n" . '</head', |
|
| 923 | + 'html>'."\n", |
|
| 924 | + "\n".'<html', |
|
| 925 | + 'html/>'."\n", |
|
| 926 | + "\n".'</html', |
|
| 927 | + 'head>'."\n", |
|
| 928 | + "\n".'<head', |
|
| 929 | + 'head/>'."\n", |
|
| 930 | + "\n".'</head', |
|
| 931 | 931 | ], |
| 932 | 932 | [ |
| 933 | 933 | 'html>', |
@@ -946,10 +946,10 @@ discard block |
||
| 946 | 946 | $replace = []; |
| 947 | 947 | $replacement = []; |
| 948 | 948 | foreach (self::$selfClosingTags as $selfClosingTag) { |
| 949 | - $replace[] = '<' . $selfClosingTag . '/>'; |
|
| 950 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
| 951 | - $replace[] = '<' . $selfClosingTag . ' />'; |
|
| 952 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
| 949 | + $replace[] = '<'.$selfClosingTag.'/>'; |
|
| 950 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
| 951 | + $replace[] = '<'.$selfClosingTag.' />'; |
|
| 952 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
| 953 | 953 | } |
| 954 | 954 | $html = \str_replace( |
| 955 | 955 | $replace, |
@@ -957,7 +957,7 @@ discard block |
||
| 957 | 957 | $html |
| 958 | 958 | ); |
| 959 | 959 | |
| 960 | - $html = (string)\preg_replace('#<\b(' . $CACHE_SELF_CLOSING_TAGS . ')([^>]+)><\/\b\1>#', '<\\1\\2>', $html); |
|
| 960 | + $html = (string) \preg_replace('#<\b('.$CACHE_SELF_CLOSING_TAGS.')([^>]+)><\/\b\1>#', '<\\1\\2>', $html); |
|
| 961 | 961 | |
| 962 | 962 | // ------------------------------------ |
| 963 | 963 | // check if compression worked |
@@ -1056,7 +1056,7 @@ discard block |
||
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | $attrs = []; |
| 1059 | - foreach ((array)$attributes as $attrName => $attrValue) { |
|
| 1059 | + foreach ((array) $attributes as $attrName => $attrValue) { |
|
| 1060 | 1060 | |
| 1061 | 1061 | // ------------------------------------------------------------------------- |
| 1062 | 1062 | // Remove optional "http:"-prefix from attributes. |
@@ -1131,7 +1131,7 @@ discard block |
||
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | 1133 | $this->protectedChildNodes[$counter] = $element->text(); |
| 1134 | - $element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'; |
|
| 1134 | + $element->getNode()->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'; |
|
| 1135 | 1135 | |
| 1136 | 1136 | ++$counter; |
| 1137 | 1137 | } |
@@ -1146,11 +1146,11 @@ discard block |
||
| 1146 | 1146 | continue; |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | - $this->protectedChildNodes[$counter] = '<!--' . $text . '-->'; |
|
| 1149 | + $this->protectedChildNodes[$counter] = '<!--'.$text.'-->'; |
|
| 1150 | 1150 | |
| 1151 | 1151 | /* @var $node \DOMComment */ |
| 1152 | 1152 | $node = $element->getNode(); |
| 1153 | - $child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'); |
|
| 1153 | + $child = new \DOMText('<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'); |
|
| 1154 | 1154 | $element->getNode()->parentNode->replaceChild($child, $node); |
| 1155 | 1155 | |
| 1156 | 1156 | ++$counter; |
@@ -1347,7 +1347,7 @@ discard block |
||
| 1347 | 1347 | continue; |
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | - $attrValue .= \trim($class) . ' '; |
|
| 1350 | + $attrValue .= \trim($class).' '; |
|
| 1351 | 1351 | } |
| 1352 | 1352 | $attrValue = \trim($attrValue); |
| 1353 | 1353 | |