Completed
Push — master ( 39d888...a9db4b )
by Lars
01:42
created
src/voku/helper/HtmlMin.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
@@ -756,23 +756,23 @@  discard block
 block discarded – undo
756 756
             $tmpTypePublic = 'PUBLIC';
757 757
           }
758 758
 
759
-          $html .= '<!DOCTYPE ' . $child->name . ''
760
-                   . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
761
-                   . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
759
+          $html .= '<!DOCTYPE '.$child->name.''
760
+                   . ($child->publicId ? ' '.$tmpTypePublic.' "'.$child->publicId.'"' : '')
761
+                   . ($child->systemId ? ' '.$tmpTypeSystem.' "'.$child->systemId.'"' : '')
762 762
                    . '>';
763 763
         }
764 764
 
765 765
       } elseif ($child instanceof \DOMElement) {
766 766
 
767
-        $html .= trim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child));
768
-        $html .= '>' . $this->domNodeToString($child);
767
+        $html .= trim('<'.$child->tagName.' '.$this->domNodeAttributesToString($child));
768
+        $html .= '>'.$this->domNodeToString($child);
769 769
 
770 770
         if (
771 771
             $this->doRemoveOmittedHtmlTags === false
772 772
             ||
773 773
             !$this->domNodeClosingTagOptional($child)
774 774
         ) {
775
-          $html .= '</' . $child->tagName . '>';
775
+          $html .= '</'.$child->tagName.'>';
776 776
 
777 777
           if ($this->doRemoveWhitespaceAroundTags === false) {
778 778
             if (!$child->nextSibling instanceof \DOMText) {
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
    */
853 853
   public function minify($html, $decodeUtf8Specials = false): string
854 854
   {
855
-    $html = (string)$html;
855
+    $html = (string) $html;
856 856
     if (!isset($html[0])) {
857 857
       return '';
858 858
     }
@@ -888,10 +888,10 @@  discard block
 block discarded – undo
888 888
     // -------------------------------------------------------------------------
889 889
 
890 890
     // Remove extra white-space(s) between HTML attribute(s)
891
-    $html = (string)\preg_replace_callback(
891
+    $html = (string) \preg_replace_callback(
892 892
         '#<([^\/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(\/?)>#',
893
-        function ($matches) {
894
-          return '<' . $matches[1] . (string)\preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>';
893
+        function($matches) {
894
+          return '<'.$matches[1].(string) \preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]).$matches[3].'>';
895 895
         },
896 896
         $html
897 897
     );
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
 
900 900
     if ($this->doRemoveSpacesBetweenTags === true) {
901 901
       // Remove spaces that are between > and <
902
-      $html = (string)\preg_replace('/(>) (<)/', '>$2', $html);
902
+      $html = (string) \preg_replace('/(>) (<)/', '>$2', $html);
903 903
     }
904 904
 
905 905
     // -------------------------------------------------------------------------
906 906
     // Restore protected HTML-code.
907 907
     // -------------------------------------------------------------------------
908 908
 
909
-    $html = (string)\preg_replace_callback(
910
-        '/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/',
909
+    $html = (string) \preg_replace_callback(
910
+        '/<(?<element>'.$this->protectedChildNodesHelper.')(?<attributes> [^>]*)?>(?<value>.*?)<\/'.$this->protectedChildNodesHelper.'>/',
911 911
         [$this, 'restoreProtectedHtml'],
912 912
         $html
913 913
     );
@@ -928,14 +928,14 @@  discard block
 block discarded – undo
928 928
 
929 929
     $html = \str_replace(
930 930
         [
931
-            'html>' . "\n",
932
-            "\n" . '<html',
933
-            'html/>' . "\n",
934
-            "\n" . '</html',
935
-            'head>' . "\n",
936
-            "\n" . '<head',
937
-            'head/>' . "\n",
938
-            "\n" . '</head',
931
+            'html>'."\n",
932
+            "\n".'<html',
933
+            'html/>'."\n",
934
+            "\n".'</html',
935
+            'head>'."\n",
936
+            "\n".'<head',
937
+            'head/>'."\n",
938
+            "\n".'</head',
939 939
         ],
940 940
         [
941 941
             'html>',
@@ -954,10 +954,10 @@  discard block
 block discarded – undo
954 954
     $replace = [];
955 955
     $replacement = [];
956 956
     foreach (self::$selfClosingTags as $selfClosingTag) {
957
-      $replace[] = '<' . $selfClosingTag . '/>';
958
-      $replacement[] = '<' . $selfClosingTag . '>';
959
-      $replace[] = '<' . $selfClosingTag . ' />';
960
-      $replacement[] = '<' . $selfClosingTag . '>';
957
+      $replace[] = '<'.$selfClosingTag.'/>';
958
+      $replacement[] = '<'.$selfClosingTag.'>';
959
+      $replace[] = '<'.$selfClosingTag.' />';
960
+      $replacement[] = '<'.$selfClosingTag.'>';
961 961
     }
962 962
     $html = \str_replace(
963 963
         $replace,
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
         $html
966 966
     );
967 967
 
968
-    $html = (string)\preg_replace('#<\b(' . $CACHE_SELF_CLOSING_TAGS . ')([^>]+)><\/\b\1>#', '<\\1\\2>', $html);
968
+    $html = (string) \preg_replace('#<\b('.$CACHE_SELF_CLOSING_TAGS.')([^>]+)><\/\b\1>#', '<\\1\\2>', $html);
969 969
 
970 970
     // ------------------------------------
971 971
     // check if compression worked
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
     }
1065 1065
 
1066 1066
     $attrs = [];
1067
-    foreach ((array)$attributes as $attrName => $attrValue) {
1067
+    foreach ((array) $attributes as $attrName => $attrValue) {
1068 1068
 
1069 1069
       // -------------------------------------------------------------------------
1070 1070
       // Remove optional "http:"-prefix from attributes.
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
       }
1140 1140
 
1141 1141
       $this->protectedChildNodes[$counter] = $element->text();
1142
-      $element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>';
1142
+      $element->getNode()->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>';
1143 1143
 
1144 1144
       ++$counter;
1145 1145
     }
@@ -1154,11 +1154,11 @@  discard block
 block discarded – undo
1154 1154
         continue;
1155 1155
       }
1156 1156
 
1157
-      $this->protectedChildNodes[$counter] = '<!--' . $text . '-->';
1157
+      $this->protectedChildNodes[$counter] = '<!--'.$text.'-->';
1158 1158
 
1159 1159
       /* @var $node \DOMComment */
1160 1160
       $node = $element->getNode();
1161
-      $child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>');
1161
+      $child = new \DOMText('<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>');
1162 1162
       $element->getNode()->parentNode->replaceChild($child, $node);
1163 1163
 
1164 1164
       ++$counter;
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
         continue;
1356 1356
       }
1357 1357
 
1358
-      $attrValue .= \trim($class) . ' ';
1358
+      $attrValue .= \trim($class).' ';
1359 1359
     }
1360 1360
     $attrValue = \trim($attrValue);
1361 1361
 
Please login to merge, or discard this patch.