@@ -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 | |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | 0 == \preg_match('/["\'=<>` \t\r\n\f]+/', $attribute->value); |
505 | 505 | |
506 | 506 | $attr_val = $attribute->value; |
507 | - $attrstr .= ($omitquotes ? '' : '"') . $attr_val . ($omitquotes ? '' : '"'); |
|
507 | + $attrstr .= ($omitquotes ? '' : '"').$attr_val.($omitquotes ? '' : '"'); |
|
508 | 508 | $attrstr .= ' '; |
509 | 509 | } |
510 | 510 | } |
@@ -768,23 +768,23 @@ discard block |
||
768 | 768 | $tmpTypePublic = 'PUBLIC'; |
769 | 769 | } |
770 | 770 | |
771 | - $html .= '<!DOCTYPE ' . $child->name . '' |
|
772 | - . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '') |
|
773 | - . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '') |
|
771 | + $html .= '<!DOCTYPE '.$child->name.'' |
|
772 | + . ($child->publicId ? ' '.$tmpTypePublic.' "'.$child->publicId.'"' : '') |
|
773 | + . ($child->systemId ? ' '.$tmpTypeSystem.' "'.$child->systemId.'"' : '') |
|
774 | 774 | . '>'; |
775 | 775 | } |
776 | 776 | |
777 | 777 | } elseif ($child instanceof \DOMElement) { |
778 | 778 | |
779 | - $html .= \rtrim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child)); |
|
780 | - $html .= '>' . $this->domNodeToString($child); |
|
779 | + $html .= \rtrim('<'.$child->tagName.' '.$this->domNodeAttributesToString($child)); |
|
780 | + $html .= '>'.$this->domNodeToString($child); |
|
781 | 781 | |
782 | 782 | if ( |
783 | 783 | $this->doRemoveOmittedHtmlTags === false |
784 | 784 | || |
785 | 785 | !$this->domNodeClosingTagOptional($child) |
786 | 786 | ) { |
787 | - $html .= '</' . $child->tagName . '>'; |
|
787 | + $html .= '</'.$child->tagName.'>'; |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | if ($this->doRemoveWhitespaceAroundTags === false) { |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | */ |
878 | 878 | public function minify($html, $decodeUtf8Specials = false): string |
879 | 879 | { |
880 | - $html = (string)$html; |
|
880 | + $html = (string) $html; |
|
881 | 881 | if (!isset($html[0])) { |
882 | 882 | return ''; |
883 | 883 | } |
@@ -913,25 +913,25 @@ discard block |
||
913 | 913 | // ------------------------------------------------------------------------- |
914 | 914 | |
915 | 915 | // Remove extra white-space(s) between HTML attribute(s) |
916 | - $html = (string)\preg_replace_callback( |
|
916 | + $html = (string) \preg_replace_callback( |
|
917 | 917 | '#<([^\/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(\/?)>#', |
918 | - function ($matches) { |
|
919 | - return '<' . $matches[1] . (string)\preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>'; |
|
918 | + function($matches) { |
|
919 | + return '<'.$matches[1].(string) \preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]).$matches[3].'>'; |
|
920 | 920 | }, |
921 | 921 | $html |
922 | 922 | ); |
923 | 923 | |
924 | 924 | if ($this->doRemoveSpacesBetweenTags === true) { |
925 | 925 | // Remove spaces that are between > and < |
926 | - $html = (string)\preg_replace('/(>) (<)/', '>$2', $html); |
|
926 | + $html = (string) \preg_replace('/(>) (<)/', '>$2', $html); |
|
927 | 927 | } |
928 | 928 | |
929 | 929 | // ------------------------------------------------------------------------- |
930 | 930 | // Restore protected HTML-code. |
931 | 931 | // ------------------------------------------------------------------------- |
932 | 932 | |
933 | - $html = (string)\preg_replace_callback( |
|
934 | - '/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/', |
|
933 | + $html = (string) \preg_replace_callback( |
|
934 | + '/<(?<element>'.$this->protectedChildNodesHelper.')(?<attributes> [^>]*)?>(?<value>.*?)<\/'.$this->protectedChildNodesHelper.'>/', |
|
935 | 935 | [$this, 'restoreProtectedHtml'], |
936 | 936 | $html |
937 | 937 | ); |
@@ -952,14 +952,14 @@ discard block |
||
952 | 952 | |
953 | 953 | $html = \str_replace( |
954 | 954 | [ |
955 | - 'html>' . "\n", |
|
956 | - "\n" . '<html', |
|
957 | - 'html/>' . "\n", |
|
958 | - "\n" . '</html', |
|
959 | - 'head>' . "\n", |
|
960 | - "\n" . '<head', |
|
961 | - 'head/>' . "\n", |
|
962 | - "\n" . '</head', |
|
955 | + 'html>'."\n", |
|
956 | + "\n".'<html', |
|
957 | + 'html/>'."\n", |
|
958 | + "\n".'</html', |
|
959 | + 'head>'."\n", |
|
960 | + "\n".'<head', |
|
961 | + 'head/>'."\n", |
|
962 | + "\n".'</head', |
|
963 | 963 | ], |
964 | 964 | [ |
965 | 965 | 'html>', |
@@ -978,10 +978,10 @@ discard block |
||
978 | 978 | $replace = []; |
979 | 979 | $replacement = []; |
980 | 980 | foreach (self::$selfClosingTags as $selfClosingTag) { |
981 | - $replace[] = '<' . $selfClosingTag . '/>'; |
|
982 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
983 | - $replace[] = '<' . $selfClosingTag . ' />'; |
|
984 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
981 | + $replace[] = '<'.$selfClosingTag.'/>'; |
|
982 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
983 | + $replace[] = '<'.$selfClosingTag.' />'; |
|
984 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
985 | 985 | } |
986 | 986 | $html = \str_replace( |
987 | 987 | $replace, |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | $html |
990 | 990 | ); |
991 | 991 | |
992 | - $html = (string)\preg_replace('#<\b(' . $CACHE_SELF_CLOSING_TAGS . ')([^>]+)><\/\b\1>#', '<\\1\\2>', $html); |
|
992 | + $html = (string) \preg_replace('#<\b('.$CACHE_SELF_CLOSING_TAGS.')([^>]+)><\/\b\1>#', '<\\1\\2>', $html); |
|
993 | 993 | |
994 | 994 | // ------------------------------------ |
995 | 995 | // check if compression worked |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | $attrs = []; |
1091 | - foreach ((array)$attributes as $attrName => $attrValue) { |
|
1091 | + foreach ((array) $attributes as $attrName => $attrValue) { |
|
1092 | 1092 | |
1093 | 1093 | // ------------------------------------------------------------------------- |
1094 | 1094 | // Remove optional "http:"-prefix from attributes. |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | $this->protectedChildNodes[$counter] = $element->text(); |
1166 | - $element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'; |
|
1166 | + $element->getNode()->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'; |
|
1167 | 1167 | |
1168 | 1168 | ++$counter; |
1169 | 1169 | } |
@@ -1178,11 +1178,11 @@ discard block |
||
1178 | 1178 | continue; |
1179 | 1179 | } |
1180 | 1180 | |
1181 | - $this->protectedChildNodes[$counter] = '<!--' . $text . '-->'; |
|
1181 | + $this->protectedChildNodes[$counter] = '<!--'.$text.'-->'; |
|
1182 | 1182 | |
1183 | 1183 | /* @var $node \DOMComment */ |
1184 | 1184 | $node = $element->getNode(); |
1185 | - $child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'); |
|
1185 | + $child = new \DOMText('<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'); |
|
1186 | 1186 | $element->getNode()->parentNode->replaceChild($child, $node); |
1187 | 1187 | |
1188 | 1188 | ++$counter; |
@@ -1379,7 +1379,7 @@ discard block |
||
1379 | 1379 | continue; |
1380 | 1380 | } |
1381 | 1381 | |
1382 | - $attrValue .= \trim($class) . ' '; |
|
1382 | + $attrValue .= \trim($class).' '; |
|
1383 | 1383 | } |
1384 | 1384 | $attrValue = \trim($attrValue); |
1385 | 1385 |