Completed
Push — master ( fa912e...9a88a5 )
by Lars
02:35
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.
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -705,220 +705,220 @@  discard block
 block discarded – undo
705 705
         return \in_array($tag_name, self::$optional_end_tags, true)
706 706
                ||
707 707
                (
708
-                   $tag_name === 'li'
708
+                    $tag_name === 'li'
709 709
                    &&
710 710
                    (
711
-                       $nextSibling === null
711
+                        $nextSibling === null
712 712
                        ||
713 713
                        (
714
-                           $nextSibling instanceof \DOMElement
714
+                            $nextSibling instanceof \DOMElement
715 715
                            &&
716 716
                            $nextSibling->tagName === 'li'
717
-                       )
718
-                   )
719
-               )
717
+                        )
718
+                    )
719
+                )
720 720
                ||
721 721
                (
722
-                   $tag_name === 'optgroup'
722
+                    $tag_name === 'optgroup'
723 723
                    &&
724 724
                    (
725
-                       $nextSibling === null
725
+                        $nextSibling === null
726 726
                        ||
727 727
                        (
728
-                           $nextSibling instanceof \DOMElement
728
+                            $nextSibling instanceof \DOMElement
729 729
                            &&
730 730
                            $nextSibling->tagName === 'optgroup'
731
-                       )
732
-                   )
733
-               )
731
+                        )
732
+                    )
733
+                )
734 734
                ||
735 735
                (
736
-                   $tag_name === 'rp'
736
+                    $tag_name === 'rp'
737 737
                    &&
738 738
                    (
739
-                       $nextSibling === null
739
+                        $nextSibling === null
740 740
                        ||
741 741
                        (
742
-                           $nextSibling instanceof \DOMElement
742
+                            $nextSibling instanceof \DOMElement
743 743
                            &&
744 744
                            (
745
-                               $nextSibling->tagName === 'rp'
745
+                                $nextSibling->tagName === 'rp'
746 746
                                ||
747 747
                                $nextSibling->tagName === 'rt'
748
-                           )
749
-                       )
750
-                   )
751
-               )
748
+                            )
749
+                        )
750
+                    )
751
+                )
752 752
                ||
753 753
                (
754
-                   $tag_name === 'tr'
754
+                    $tag_name === 'tr'
755 755
                    &&
756 756
                    (
757
-                       $nextSibling === null
757
+                        $nextSibling === null
758 758
                        ||
759 759
                        (
760
-                           $nextSibling instanceof \DOMElement
760
+                            $nextSibling instanceof \DOMElement
761 761
                            &&
762 762
                            $nextSibling->tagName === 'tr'
763
-                       )
764
-                   )
765
-               )
763
+                        )
764
+                    )
765
+                )
766 766
                ||
767 767
                (
768
-                   $tag_name === 'source'
768
+                    $tag_name === 'source'
769 769
                    &&
770 770
                    (
771
-                       $parent_tag_name === 'audio'
771
+                        $parent_tag_name === 'audio'
772 772
                        ||
773 773
                        $parent_tag_name === 'video'
774 774
                        ||
775 775
                        $parent_tag_name === 'picture'
776 776
                        ||
777 777
                        $parent_tag_name === 'source'
778
-                   )
778
+                    )
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 === 'source'
787
-                       )
788
-                   )
789
-               )
787
+                        )
788
+                    )
789
+                )
790 790
                ||
791 791
                (
792
-                   (
793
-                       $tag_name === 'td'
792
+                    (
793
+                        $tag_name === 'td'
794 794
                        ||
795 795
                        $tag_name === 'th'
796
-                   )
796
+                    )
797 797
                    &&
798 798
                    (
799
-                       $nextSibling === null
799
+                        $nextSibling === null
800 800
                        ||
801 801
                        (
802
-                           $nextSibling instanceof \DOMElement
802
+                            $nextSibling instanceof \DOMElement
803 803
                            &&
804 804
                            (
805
-                               $nextSibling->tagName === 'td'
805
+                                $nextSibling->tagName === 'td'
806 806
                                ||
807 807
                                $nextSibling->tagName === 'th'
808
-                           )
809
-                       )
810
-                   )
811
-               )
808
+                            )
809
+                        )
810
+                    )
811
+                )
812 812
                ||
813 813
                (
814
-                   (
815
-                       $tag_name === 'dd'
814
+                    (
815
+                        $tag_name === 'dd'
816 816
                        ||
817 817
                        $tag_name === 'dt'
818
-                   )
818
+                    )
819 819
                    &&
820 820
                    (
821
-                       (
822
-                           $nextSibling === null
821
+                        (
822
+                            $nextSibling === null
823 823
                            &&
824 824
                            $tag_name === 'dd'
825
-                       )
825
+                        )
826 826
                        ||
827 827
                        (
828
-                           $nextSibling instanceof \DOMElement
828
+                            $nextSibling instanceof \DOMElement
829 829
                            &&
830 830
                            (
831
-                               $nextSibling->tagName === 'dd'
831
+                                $nextSibling->tagName === 'dd'
832 832
                                ||
833 833
                                $nextSibling->tagName === 'dt'
834
-                           )
835
-                       )
836
-                   )
837
-               )
834
+                            )
835
+                        )
836
+                    )
837
+                )
838 838
                ||
839 839
                (
840
-                   $tag_name === 'option'
840
+                    $tag_name === 'option'
841 841
                    &&
842 842
                    (
843
-                       $nextSibling === null
843
+                        $nextSibling === null
844 844
                        ||
845 845
                        (
846
-                           $nextSibling instanceof \DOMElement
846
+                            $nextSibling instanceof \DOMElement
847 847
                            &&
848 848
                            (
849
-                               $nextSibling->tagName === 'option'
849
+                                $nextSibling->tagName === 'option'
850 850
                                ||
851 851
                                $nextSibling->tagName === 'optgroup'
852
-                           )
853
-                       )
854
-                   )
855
-               )
852
+                            )
853
+                        )
854
+                    )
855
+                )
856 856
                ||
857 857
                (
858
-                   $tag_name === 'p'
858
+                    $tag_name === 'p'
859 859
                    &&
860 860
                    (
861
-                       (
862
-                           $nextSibling === null
861
+                        (
862
+                            $nextSibling === null
863 863
                            &&
864 864
                            (
865
-                               $node->parentNode !== null
865
+                                $node->parentNode !== null
866 866
                                &&
867 867
                                !\in_array(
868
-                                   $node->parentNode->nodeName,
869
-                                   [
870
-                                       'a',
871
-                                       'audio',
872
-                                       'del',
873
-                                       'ins',
874
-                                       'map',
875
-                                       'noscript',
876
-                                       'video',
877
-                                   ],
878
-                                   true
879
-                               )
880
-                           )
881
-                       )
868
+                                    $node->parentNode->nodeName,
869
+                                    [
870
+                                        'a',
871
+                                        'audio',
872
+                                        'del',
873
+                                        'ins',
874
+                                        'map',
875
+                                        'noscript',
876
+                                        'video',
877
+                                    ],
878
+                                    true
879
+                                )
880
+                            )
881
+                        )
882 882
                        ||
883 883
                        (
884
-                           $nextSibling instanceof \DOMElement
884
+                            $nextSibling instanceof \DOMElement
885 885
                            &&
886 886
                            \in_array(
887
-                               $nextSibling->tagName,
888
-                               [
889
-                                   'address',
890
-                                   'article',
891
-                                   'aside',
892
-                                   'blockquote',
893
-                                   'dir',
894
-                                   'div',
895
-                                   'dl',
896
-                                   'fieldset',
897
-                                   'footer',
898
-                                   'form',
899
-                                   'h1',
900
-                                   'h2',
901
-                                   'h3',
902
-                                   'h4',
903
-                                   'h5',
904
-                                   'h6',
905
-                                   'header',
906
-                                   'hgroup',
907
-                                   'hr',
908
-                                   'menu',
909
-                                   'nav',
910
-                                   'ol',
911
-                                   'p',
912
-                                   'pre',
913
-                                   'section',
914
-                                   'table',
915
-                                   'ul',
916
-                               ],
917
-                               true
918
-                           )
919
-                       )
920
-                   )
921
-               );
887
+                                $nextSibling->tagName,
888
+                                [
889
+                                    'address',
890
+                                    'article',
891
+                                    'aside',
892
+                                    'blockquote',
893
+                                    'dir',
894
+                                    'div',
895
+                                    'dl',
896
+                                    'fieldset',
897
+                                    'footer',
898
+                                    'form',
899
+                                    'h1',
900
+                                    'h2',
901
+                                    'h3',
902
+                                    'h4',
903
+                                    'h5',
904
+                                    'h6',
905
+                                    'header',
906
+                                    'hgroup',
907
+                                    'hr',
908
+                                    'menu',
909
+                                    'nav',
910
+                                    'ol',
911
+                                    'p',
912
+                                    'pre',
913
+                                    'section',
914
+                                    'table',
915
+                                    'ul',
916
+                                ],
917
+                                true
918
+                            )
919
+                        )
920
+                    )
921
+                );
922 922
     }
923 923
 
924 924
     protected function domNodeToString(\DOMNode $node): string
@@ -1047,9 +1047,9 @@  discard block
 block discarded – undo
1047 1047
                 }
1048 1048
 
1049 1049
                 return '<!DOCTYPE ' . $child->name . ''
1050
-                       . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
1051
-                       . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
1052
-                       . '>';
1050
+                        . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
1051
+                        . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
1052
+                        . '>';
1053 1053
             }
1054 1054
         }
1055 1055
 
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.
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.