Completed
Push — master ( 1fbfdd...ba1ca2 )
by Lars
01:59
created
src/voku/helper/HtmlMin.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -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
     }
@@ -768,23 +768,23 @@  discard block
 block discarded – undo
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) {
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
    */
886 886
   public function minify($html, $decodeUtf8Specials = false): string
887 887
   {
888
-    $html = (string)$html;
888
+    $html = (string) $html;
889 889
     if (!isset($html[0])) {
890 890
       return '';
891 891
     }
@@ -921,25 +921,25 @@  discard block
 block discarded – undo
921 921
     // -------------------------------------------------------------------------
922 922
 
923 923
     // Remove extra white-space(s) between HTML attribute(s)
924
-    $html = (string)\preg_replace_callback(
924
+    $html = (string) \preg_replace_callback(
925 925
         '#<([^/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(/?)>#',
926
-        function ($matches) {
927
-          return '<' . $matches[1] . (string)\preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>';
926
+        function($matches) {
927
+          return '<'.$matches[1].(string) \preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]).$matches[3].'>';
928 928
         },
929 929
         $html
930 930
     );
931 931
 
932 932
     if ($this->doRemoveSpacesBetweenTags === true) {
933 933
       // Remove spaces that are between > and <
934
-      $html = (string)\preg_replace('/(>) (<)/', '>$2', $html);
934
+      $html = (string) \preg_replace('/(>) (<)/', '>$2', $html);
935 935
     }
936 936
 
937 937
     // -------------------------------------------------------------------------
938 938
     // Restore protected HTML-code.
939 939
     // -------------------------------------------------------------------------
940 940
 
941
-    $html = (string)\preg_replace_callback(
942
-        '/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/',
941
+    $html = (string) \preg_replace_callback(
942
+        '/<(?<element>'.$this->protectedChildNodesHelper.')(?<attributes> [^>]*)?>(?<value>.*?)<\/'.$this->protectedChildNodesHelper.'>/',
943 943
         [$this, 'restoreProtectedHtml'],
944 944
         $html
945 945
     );
@@ -958,14 +958,14 @@  discard block
 block discarded – undo
958 958
 
959 959
     $html = \str_replace(
960 960
         [
961
-            'html>' . "\n",
962
-            "\n" . '<html',
963
-            'html/>' . "\n",
964
-            "\n" . '</html',
965
-            'head>' . "\n",
966
-            "\n" . '<head',
967
-            'head/>' . "\n",
968
-            "\n" . '</head',
961
+            'html>'."\n",
962
+            "\n".'<html',
963
+            'html/>'."\n",
964
+            "\n".'</html',
965
+            'head>'."\n",
966
+            "\n".'<head',
967
+            'head/>'."\n",
968
+            "\n".'</head',
969 969
         ],
970 970
         [
971 971
             'html>',
@@ -984,10 +984,10 @@  discard block
 block discarded – undo
984 984
     $replace = [];
985 985
     $replacement = [];
986 986
     foreach (self::$selfClosingTags as $selfClosingTag) {
987
-      $replace[] = '<' . $selfClosingTag . '/>';
988
-      $replacement[] = '<' . $selfClosingTag . '>';
989
-      $replace[] = '<' . $selfClosingTag . ' />';
990
-      $replacement[] = '<' . $selfClosingTag . '>';
987
+      $replace[] = '<'.$selfClosingTag.'/>';
988
+      $replacement[] = '<'.$selfClosingTag.'>';
989
+      $replace[] = '<'.$selfClosingTag.' />';
990
+      $replacement[] = '<'.$selfClosingTag.'>';
991 991
     }
992 992
     $html = \str_replace(
993 993
         $replace,
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
         $html
996 996
     );
997 997
 
998
-    $html = (string)\preg_replace('#<\b(' . $CACHE_SELF_CLOSING_TAGS . ')([^>]*+)><\/\b\1>#', '<\\1\\2>', $html);
998
+    $html = (string) \preg_replace('#<\b('.$CACHE_SELF_CLOSING_TAGS.')([^>]*+)><\/\b\1>#', '<\\1\\2>', $html);
999 999
 
1000 1000
     // ------------------------------------
1001 1001
     // check if compression worked
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
     }
1095 1095
 
1096 1096
     $attrs = [];
1097
-    foreach ((array)$attributes as $attrName => $attrValue) {
1097
+    foreach ((array) $attributes as $attrName => $attrValue) {
1098 1098
 
1099 1099
       // -------------------------------------------------------------------------
1100 1100
       // Remove optional "http:"-prefix from attributes.
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
       }
1170 1170
 
1171 1171
       $this->protectedChildNodes[$counter] = $element->text();
1172
-      $element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>';
1172
+      $element->getNode()->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>';
1173 1173
 
1174 1174
       ++$counter;
1175 1175
     }
@@ -1184,11 +1184,11 @@  discard block
 block discarded – undo
1184 1184
         continue;
1185 1185
       }
1186 1186
 
1187
-      $this->protectedChildNodes[$counter] = '<!--' . $text . '-->';
1187
+      $this->protectedChildNodes[$counter] = '<!--'.$text.'-->';
1188 1188
 
1189 1189
       /* @var $node \DOMComment */
1190 1190
       $node = $element->getNode();
1191
-      $child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>');
1191
+      $child = new \DOMText('<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>');
1192 1192
       $element->getNode()->parentNode->replaceChild($child, $node);
1193 1193
 
1194 1194
       ++$counter;
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
         continue;
1386 1386
       }
1387 1387
 
1388
-      $attrValue .= \trim($class) . ' ';
1388
+      $attrValue .= \trim($class).' ';
1389 1389
     }
1390 1390
     $attrValue = \trim($attrValue);
1391 1391
 
Please login to merge, or discard this patch.