Completed
Push — master ( e0c79b...030b2b )
by Lars
01:37
created
src/voku/helper/HtmlMin.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1187,7 +1187,7 @@
 block discarded – undo
1187 1187
     /**
1188 1188
      * @param \DOMNode $node
1189 1189
      *
1190
-     * @return \DOMNode|null
1190
+     * @return null|\DOMElement
1191 1191
      */
1192 1192
     protected function getNextSiblingOfTypeDOMElement(\DOMNode $node)
1193 1193
     {
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
                     $attr_val = $attribute->value;
638 638
                 }
639 639
 
640
-                $attr_str .= ($omit_quotes ? '' : $quoteTmp) . $attr_val . ($omit_quotes ? '' : $quoteTmp);
640
+                $attr_str .= ($omit_quotes ? '' : $quoteTmp).$attr_val.($omit_quotes ? '' : $quoteTmp);
641 641
                 $attr_str .= ' ';
642 642
             }
643 643
         }
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
             }
936 936
 
937 937
             if ($child instanceof \DOMElement) {
938
-                $html .= \rtrim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child));
939
-                $html .= '>' . $this->domNodeToString($child);
938
+                $html .= \rtrim('<'.$child->tagName.' '.$this->domNodeAttributesToString($child));
939
+                $html .= '>'.$this->domNodeToString($child);
940 940
 
941 941
                 if (
942 942
                     !(
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
                         $this->domNodeClosingTagOptional($child)
950 950
                     )
951 951
                 ) {
952
-                    $html .= '</' . $child->tagName . '>';
952
+                    $html .= '</'.$child->tagName.'>';
953 953
                 }
954 954
 
955 955
                 if (!$this->doRemoveWhitespaceAroundTags) {
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
                     $html .= $child->wholeText;
1014 1014
                 }
1015 1015
             } elseif ($child instanceof \DOMComment) {
1016
-                $html .= '<!--' . $child->textContent . '-->';
1016
+                $html .= '<!--'.$child->textContent.'-->';
1017 1017
             }
1018 1018
         }
1019 1019
 
@@ -1046,9 +1046,9 @@  discard block
 block discarded – undo
1046 1046
                     $tmpTypePublic = 'PUBLIC';
1047 1047
                 }
1048 1048
 
1049
-                return '<!DOCTYPE ' . $child->name . ''
1050
-                       . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
1051
-                       . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
1049
+                return '<!DOCTYPE '.$child->name.''
1050
+                       . ($child->publicId ? ' '.$tmpTypePublic.' "'.$child->publicId.'"' : '')
1051
+                       . ($child->systemId ? ' '.$tmpTypeSystem.' "'.$child->systemId.'"' : '')
1052 1052
                        . '>';
1053 1053
             }
1054 1054
         }
@@ -1289,8 +1289,8 @@  discard block
 block discarded – undo
1289 1289
         if (\strpos($html, ' ') !== false) {
1290 1290
             $html = (string) \preg_replace_callback(
1291 1291
                 '#<([^/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(/?)>#',
1292
-                static function ($matches) {
1293
-                    return '<' . $matches[1] . \preg_replace('#([^\s=]+)(=([\'"]?)(.*?)\3)?(\s+|$)#su', ' $1$2', $matches[2]) . $matches[3] . '>';
1292
+                static function($matches) {
1293
+                    return '<'.$matches[1].\preg_replace('#([^\s=]+)(=([\'"]?)(.*?)\3)?(\s+|$)#su', ' $1$2', $matches[2]).$matches[3].'>';
1294 1294
                 },
1295 1295
                 $html
1296 1296
             );
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 
1311 1311
         if (\strpos($html, $this->protectedChildNodesHelper) !== false) {
1312 1312
             $html = (string) \preg_replace_callback(
1313
-                '/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/',
1313
+                '/<(?<element>'.$this->protectedChildNodesHelper.')(?<attributes> [^>]*)?>(?<value>.*?)<\/'.$this->protectedChildNodesHelper.'>/',
1314 1314
                 [$this, 'restoreProtectedHtml'],
1315 1315
                 $html
1316 1316
             );
@@ -1330,14 +1330,14 @@  discard block
 block discarded – undo
1330 1330
 
1331 1331
         $html = \str_replace(
1332 1332
             [
1333
-                'html>' . "\n",
1334
-                "\n" . '<html',
1335
-                'html/>' . "\n",
1336
-                "\n" . '</html',
1337
-                'head>' . "\n",
1338
-                "\n" . '<head',
1339
-                'head/>' . "\n",
1340
-                "\n" . '</head',
1333
+                'html>'."\n",
1334
+                "\n".'<html',
1335
+                'html/>'."\n",
1336
+                "\n".'</html',
1337
+                'head>'."\n",
1338
+                "\n".'<head',
1339
+                'head/>'."\n",
1340
+                "\n".'</head',
1341 1341
             ],
1342 1342
             [
1343 1343
                 'html>',
@@ -1356,11 +1356,11 @@  discard block
 block discarded – undo
1356 1356
         $replace = [];
1357 1357
         $replacement = [];
1358 1358
         foreach (self::$selfClosingTags as $selfClosingTag) {
1359
-            $replace[] = '<' . $selfClosingTag . '/>';
1360
-            $replacement[] = '<' . $selfClosingTag . '>';
1361
-            $replace[] = '<' . $selfClosingTag . ' />';
1362
-            $replacement[] = '<' . $selfClosingTag . '>';
1363
-            $replace[] = '></' . $selfClosingTag . '>';
1359
+            $replace[] = '<'.$selfClosingTag.'/>';
1360
+            $replacement[] = '<'.$selfClosingTag.'>';
1361
+            $replace[] = '<'.$selfClosingTag.' />';
1362
+            $replacement[] = '<'.$selfClosingTag.'>';
1363
+            $replace[] = '></'.$selfClosingTag.'>';
1364 1364
             $replacement[] = '>';
1365 1365
         }
1366 1366
         $html = \str_replace(
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
         // -------------------------------------------------------------------------
1516 1516
 
1517 1517
         return $dom->fixHtmlOutput(
1518
-            $doctypeStr . $this->domNodeToString($dom->getDocument()),
1518
+            $doctypeStr.$this->domNodeToString($dom->getDocument()),
1519 1519
             $multiDecodeNewHtmlEntity
1520 1520
         );
1521 1521
     }
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
             $this->protectedChildNodes[$this->protected_tags_counter] = $element->parentNode()->innerHtml();
1561 1561
             $parentNode = $element->getNode()->parentNode;
1562 1562
             if ($parentNode !== null) {
1563
-                $parentNode->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $this->protected_tags_counter . '"></' . $this->protectedChildNodesHelper . '>';
1563
+                $parentNode->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$this->protected_tags_counter.'"></'.$this->protectedChildNodesHelper.'>';
1564 1564
             }
1565 1565
 
1566 1566
             ++$this->protected_tags_counter;
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
             }
1595 1595
 
1596 1596
             $this->protectedChildNodes[$this->protected_tags_counter] = $element->innerhtml;
1597
-            $element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $this->protected_tags_counter . '"></' . $this->protectedChildNodesHelper . '>';
1597
+            $element->getNode()->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$this->protected_tags_counter.'"></'.$this->protectedChildNodesHelper.'>';
1598 1598
 
1599 1599
             ++$this->protected_tags_counter;
1600 1600
         }
@@ -1611,11 +1611,11 @@  discard block
 block discarded – undo
1611 1611
                 continue;
1612 1612
             }
1613 1613
 
1614
-            $this->protectedChildNodes[$this->protected_tags_counter] = '<!--' . $text . '-->';
1614
+            $this->protectedChildNodes[$this->protected_tags_counter] = '<!--'.$text.'-->';
1615 1615
 
1616 1616
             /* @var $node \DOMComment */
1617 1617
             $node = $element->getNode();
1618
-            $child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $this->protected_tags_counter . '"></' . $this->protectedChildNodesHelper . '>');
1618
+            $child = new \DOMText('<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$this->protected_tags_counter.'"></'.$this->protectedChildNodesHelper.'>');
1619 1619
             $parentNode = $element->getNode()->parentNode;
1620 1620
             if ($parentNode !== null) {
1621 1621
                 $parentNode->replaceChild($child, $node);
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -761,230 +761,230 @@  discard block
 block discarded – undo
761 761
         return \in_array($tag_name, self::$optional_end_tags, true)
762 762
                ||
763 763
                (
764
-                   $tag_name === 'li'
764
+                    $tag_name === 'li'
765 765
                    &&
766 766
                    (
767
-                       $nextSibling === null
767
+                        $nextSibling === null
768 768
                        ||
769 769
                        (
770
-                           $nextSibling instanceof \DOMElement
770
+                            $nextSibling instanceof \DOMElement
771 771
                            &&
772 772
                            $nextSibling->tagName === 'li'
773
-                       )
774
-                   )
775
-               )
773
+                        )
774
+                    )
775
+                )
776 776
                ||
777 777
                (
778
-                   $tag_name === 'optgroup'
778
+                    $tag_name === 'optgroup'
779 779
                    &&
780 780
                    (
781
-                       $nextSibling === null
781
+                        $nextSibling === null
782 782
                        ||
783 783
                        (
784
-                           $nextSibling instanceof \DOMElement
784
+                            $nextSibling instanceof \DOMElement
785 785
                            &&
786 786
                            $nextSibling->tagName === 'optgroup'
787
-                       )
788
-                   )
789
-               )
787
+                        )
788
+                    )
789
+                )
790 790
                ||
791 791
                (
792
-                   $tag_name === 'rp'
792
+                    $tag_name === 'rp'
793 793
                    &&
794 794
                    (
795
-                       $nextSibling === null
795
+                        $nextSibling === null
796 796
                        ||
797 797
                        (
798
-                           $nextSibling instanceof \DOMElement
798
+                            $nextSibling instanceof \DOMElement
799 799
                            &&
800 800
                            (
801
-                               $nextSibling->tagName === 'rp'
801
+                                $nextSibling->tagName === 'rp'
802 802
                                ||
803 803
                                $nextSibling->tagName === 'rt'
804
-                           )
805
-                       )
806
-                   )
807
-               )
804
+                            )
805
+                        )
806
+                    )
807
+                )
808 808
                ||
809 809
                (
810
-                   $tag_name === 'tr'
810
+                    $tag_name === 'tr'
811 811
                    &&
812 812
                    (
813
-                       $nextSibling === null
813
+                        $nextSibling === null
814 814
                        ||
815 815
                        (
816
-                           $nextSibling instanceof \DOMElement
816
+                            $nextSibling instanceof \DOMElement
817 817
                            &&
818 818
                            $nextSibling->tagName === 'tr'
819
-                       )
820
-                   )
821
-               )
819
+                        )
820
+                    )
821
+                )
822 822
                ||
823 823
                (
824
-                   $tag_name === 'source'
824
+                    $tag_name === 'source'
825 825
                    &&
826 826
                    (
827
-                       $parent_tag_name === 'audio'
827
+                        $parent_tag_name === 'audio'
828 828
                        ||
829 829
                        $parent_tag_name === 'video'
830 830
                        ||
831 831
                        $parent_tag_name === 'picture'
832 832
                        ||
833 833
                        $parent_tag_name === 'source'
834
-                   )
834
+                    )
835 835
                    &&
836 836
                    (
837
-                       $nextSibling === null
837
+                        $nextSibling === null
838 838
                        ||
839 839
                        (
840
-                           $nextSibling instanceof \DOMElement
840
+                            $nextSibling instanceof \DOMElement
841 841
                            &&
842 842
                            $nextSibling->tagName === 'source'
843
-                       )
844
-                   )
845
-               )
843
+                        )
844
+                    )
845
+                )
846 846
                ||
847 847
                (
848
-                   (
849
-                       $tag_name === 'td'
848
+                    (
849
+                        $tag_name === 'td'
850 850
                        ||
851 851
                        $tag_name === 'th'
852
-                   )
852
+                    )
853 853
                    &&
854 854
                    (
855
-                       $nextSibling === null
855
+                        $nextSibling === null
856 856
                        ||
857 857
                        (
858
-                           $nextSibling instanceof \DOMElement
858
+                            $nextSibling instanceof \DOMElement
859 859
                            &&
860 860
                            (
861
-                               $nextSibling->tagName === 'td'
861
+                                $nextSibling->tagName === 'td'
862 862
                                ||
863 863
                                $nextSibling->tagName === 'th'
864
-                           )
865
-                       )
866
-                   )
867
-               )
864
+                            )
865
+                        )
866
+                    )
867
+                )
868 868
                ||
869 869
                (
870
-                   (
871
-                       $tag_name === 'dd'
870
+                    (
871
+                        $tag_name === 'dd'
872 872
                        ||
873 873
                        $tag_name === 'dt'
874
-                   )
874
+                    )
875 875
                    &&
876 876
                    (
877
-                       (
878
-                           $nextSibling === null
877
+                        (
878
+                            $nextSibling === null
879 879
                            &&
880 880
                            $tag_name === 'dd'
881
-                       )
881
+                        )
882 882
                        ||
883 883
                        (
884
-                           $nextSibling instanceof \DOMElement
884
+                            $nextSibling instanceof \DOMElement
885 885
                            &&
886 886
                            (
887
-                               $nextSibling->tagName === 'dd'
887
+                                $nextSibling->tagName === 'dd'
888 888
                                ||
889 889
                                $nextSibling->tagName === 'dt'
890
-                           )
891
-                       )
892
-                   )
893
-               )
890
+                            )
891
+                        )
892
+                    )
893
+                )
894 894
                ||
895 895
                (
896
-                   $tag_name === 'option'
896
+                    $tag_name === 'option'
897 897
                    &&
898 898
                    (
899
-                       $nextSibling === null
899
+                        $nextSibling === null
900 900
                        ||
901 901
                        (
902
-                           $nextSibling instanceof \DOMElement
902
+                            $nextSibling instanceof \DOMElement
903 903
                            &&
904 904
                            (
905
-                               $nextSibling->tagName === 'option'
905
+                                $nextSibling->tagName === 'option'
906 906
                                ||
907 907
                                $nextSibling->tagName === 'optgroup'
908
-                           )
909
-                       )
910
-                   )
911
-               )
908
+                            )
909
+                        )
910
+                    )
911
+                )
912 912
                ||
913 913
                (
914
-                   $tag_name === 'p'
914
+                    $tag_name === 'p'
915 915
                    &&
916 916
                    (
917
-                       (
918
-                           $nextSibling === null
917
+                        (
918
+                            $nextSibling === null
919 919
                            &&
920 920
                            (
921
-                               $node->parentNode !== null
921
+                                $node->parentNode !== null
922 922
                                &&
923 923
                                (
924
-                                   $node->parentNode->lastChild !== null
924
+                                    $node->parentNode->lastChild !== null
925 925
                                     &&
926 926
                                     (
927 927
                                         $node->parentNode->lastChild === $node
928 928
                                         ||
929 929
                                         \trim($node->parentNode->lastChild->textContent) === ''
930 930
                                     )
931
-                               )
931
+                                )
932 932
                                &&
933 933
                                !\in_array(
934
-                                   $node->parentNode->nodeName,
935
-                                   [
936
-                                       'a',
937
-                                       'audio',
938
-                                       'del',
939
-                                       'ins',
940
-                                       'map',
941
-                                       'noscript',
942
-                                       'video',
943
-                                   ],
944
-                                   true
945
-                               )
946
-                           )
947
-                       )
934
+                                    $node->parentNode->nodeName,
935
+                                    [
936
+                                        'a',
937
+                                        'audio',
938
+                                        'del',
939
+                                        'ins',
940
+                                        'map',
941
+                                        'noscript',
942
+                                        'video',
943
+                                    ],
944
+                                    true
945
+                                )
946
+                            )
947
+                        )
948 948
                        ||
949 949
                        (
950
-                           $nextSibling instanceof \DOMElement
950
+                            $nextSibling instanceof \DOMElement
951 951
                            &&
952 952
                            \in_array(
953
-                               $nextSibling->tagName,
954
-                               [
955
-                                   'address',
956
-                                   'article',
957
-                                   'aside',
958
-                                   'blockquote',
959
-                                   'dir',
960
-                                   'div',
961
-                                   'dl',
962
-                                   'fieldset',
963
-                                   'footer',
964
-                                   'form',
965
-                                   'h1',
966
-                                   'h2',
967
-                                   'h3',
968
-                                   'h4',
969
-                                   'h5',
970
-                                   'h6',
971
-                                   'header',
972
-                                   'hgroup',
973
-                                   'hr',
974
-                                   'menu',
975
-                                   'nav',
976
-                                   'ol',
977
-                                   'p',
978
-                                   'pre',
979
-                                   'section',
980
-                                   'table',
981
-                                   'ul',
982
-                               ],
983
-                               true
984
-                           )
985
-                       )
986
-                   )
987
-               );
953
+                                $nextSibling->tagName,
954
+                                [
955
+                                    'address',
956
+                                    'article',
957
+                                    'aside',
958
+                                    'blockquote',
959
+                                    'dir',
960
+                                    'div',
961
+                                    'dl',
962
+                                    'fieldset',
963
+                                    'footer',
964
+                                    'form',
965
+                                    'h1',
966
+                                    'h2',
967
+                                    'h3',
968
+                                    'h4',
969
+                                    'h5',
970
+                                    'h6',
971
+                                    'header',
972
+                                    'hgroup',
973
+                                    'hr',
974
+                                    'menu',
975
+                                    'nav',
976
+                                    'ol',
977
+                                    'p',
978
+                                    'pre',
979
+                                    'section',
980
+                                    'table',
981
+                                    'ul',
982
+                                ],
983
+                                true
984
+                            )
985
+                        )
986
+                    )
987
+                );
988 988
     }
989 989
 
990 990
     protected function domNodeToString(\DOMNode $node): string
@@ -1113,9 +1113,9 @@  discard block
 block discarded – undo
1113 1113
                 }
1114 1114
 
1115 1115
                 return '<!DOCTYPE ' . $child->name . ''
1116
-                       . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
1117
-                       . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
1118
-                       . '>';
1116
+                        . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
1117
+                        . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
1118
+                        . '>';
1119 1119
             }
1120 1120
         }
1121 1121
 
Please login to merge, or discard this patch.
src/voku/helper/HtmlMinDomObserverOptimizeAttributes.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
                 $attrName === 'action'
265 265
             )
266 266
         ) {
267
-            $attrValue = \str_replace($scheme . '://', '//', $attrValue);
267
+            $attrValue = \str_replace($scheme.'://', '//', $attrValue);
268 268
         }
269 269
 
270 270
         return $attrValue;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
                 continue;
294 294
             }
295 295
 
296
-            $attrValue .= \trim($class) . ' ';
296
+            $attrValue .= \trim($class).' ';
297 297
         }
298 298
 
299 299
         return \trim($attrValue);
Please login to merge, or discard this patch.