Completed
Push — master ( d27882...fd8f2b )
by Lars
14s queued 13s
created
src/voku/helper/HtmlMin.php 3 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
                     $attr_val = $attribute->value;
573 573
                 }
574 574
 
575
-                $attr_str .= ($omit_quotes ? '' : $quoteTmp) . $attr_val . ($omit_quotes ? '' : $quoteTmp);
575
+                $attr_str .= ($omit_quotes ? '' : $quoteTmp).$attr_val.($omit_quotes ? '' : $quoteTmp);
576 576
                 $attr_str .= ' ';
577 577
             }
578 578
         }
@@ -869,21 +869,21 @@  discard block
 block discarded – undo
869 869
                         $tmpTypePublic = 'PUBLIC';
870 870
                     }
871 871
 
872
-                    $html .= '<!DOCTYPE ' . $child->name . ''
873
-                             . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
874
-                             . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
872
+                    $html .= '<!DOCTYPE '.$child->name.''
873
+                             . ($child->publicId ? ' '.$tmpTypePublic.' "'.$child->publicId.'"' : '')
874
+                             . ($child->systemId ? ' '.$tmpTypeSystem.' "'.$child->systemId.'"' : '')
875 875
                              . '>';
876 876
                 }
877 877
             } elseif ($child instanceof \DOMElement) {
878
-                $html .= \rtrim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child));
879
-                $html .= '>' . $this->domNodeToString($child);
878
+                $html .= \rtrim('<'.$child->tagName.' '.$this->domNodeAttributesToString($child));
879
+                $html .= '>'.$this->domNodeToString($child);
880 880
 
881 881
                 if (
882 882
                     !$this->doRemoveOmittedHtmlTags
883 883
                     ||
884 884
                     !$this->domNodeClosingTagOptional($child)
885 885
                 ) {
886
-                    $html .= '</' . $child->tagName . '>';
886
+                    $html .= '</'.$child->tagName.'>';
887 887
                 }
888 888
 
889 889
                 if (!$this->doRemoveWhitespaceAroundTags) {
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
                     $html .= $child->wholeText;
948 948
                 }
949 949
             } elseif ($child instanceof \DOMComment) {
950
-                $html .= '<!--' . $child->textContent . '-->';
950
+                $html .= '<!--'.$child->textContent.'-->';
951 951
             }
952 952
         }
953 953
 
@@ -1155,8 +1155,8 @@  discard block
 block discarded – undo
1155 1155
         if (\strpos($html, ' ') !== false) {
1156 1156
             $html = (string) \preg_replace_callback(
1157 1157
                 '#<([^/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(/?)>#',
1158
-                static function ($matches) {
1159
-                    return '<' . $matches[1] . \preg_replace('#([^\s=]+)(=([\'"]?)(.*?)\3)?(\s+|$)#su', ' $1$2', $matches[2]) . $matches[3] . '>';
1158
+                static function($matches) {
1159
+                    return '<'.$matches[1].\preg_replace('#([^\s=]+)(=([\'"]?)(.*?)\3)?(\s+|$)#su', ' $1$2', $matches[2]).$matches[3].'>';
1160 1160
                 },
1161 1161
                 $html
1162 1162
             );
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 
1177 1177
         if (\strpos($html, $this->protectedChildNodesHelper) !== false) {
1178 1178
             $html = (string) \preg_replace_callback(
1179
-                '/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/',
1179
+                '/<(?<element>'.$this->protectedChildNodesHelper.')(?<attributes> [^>]*)?>(?<value>.*?)<\/'.$this->protectedChildNodesHelper.'>/',
1180 1180
                 [$this, 'restoreProtectedHtml'],
1181 1181
                 $html
1182 1182
             );
@@ -1196,14 +1196,14 @@  discard block
 block discarded – undo
1196 1196
 
1197 1197
         $html = \str_replace(
1198 1198
             [
1199
-                'html>' . "\n",
1200
-                "\n" . '<html',
1201
-                'html/>' . "\n",
1202
-                "\n" . '</html',
1203
-                'head>' . "\n",
1204
-                "\n" . '<head',
1205
-                'head/>' . "\n",
1206
-                "\n" . '</head',
1199
+                'html>'."\n",
1200
+                "\n".'<html',
1201
+                'html/>'."\n",
1202
+                "\n".'</html',
1203
+                'head>'."\n",
1204
+                "\n".'<head',
1205
+                'head/>'."\n",
1206
+                "\n".'</head',
1207 1207
             ],
1208 1208
             [
1209 1209
                 'html>',
@@ -1222,11 +1222,11 @@  discard block
 block discarded – undo
1222 1222
         $replace = [];
1223 1223
         $replacement = [];
1224 1224
         foreach (self::$selfClosingTags as $selfClosingTag) {
1225
-            $replace[] = '<' . $selfClosingTag . '/>';
1226
-            $replacement[] = '<' . $selfClosingTag . '>';
1227
-            $replace[] = '<' . $selfClosingTag . ' />';
1228
-            $replacement[] = '<' . $selfClosingTag . '>';
1229
-            $replace[] = '></' . $selfClosingTag . '>';
1225
+            $replace[] = '<'.$selfClosingTag.'/>';
1226
+            $replacement[] = '<'.$selfClosingTag.'>';
1227
+            $replace[] = '<'.$selfClosingTag.' />';
1228
+            $replacement[] = '<'.$selfClosingTag.'>';
1229
+            $replace[] = '></'.$selfClosingTag.'>';
1230 1230
             $replacement[] = '>';
1231 1231
         }
1232 1232
         $html = \str_replace(
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
             $this->protectedChildNodes[$this->protected_tags_counter] = $element->parentNode()->innerHtml();
1418 1418
             $parentNode = $element->getNode()->parentNode;
1419 1419
             if ($parentNode !== null) {
1420
-                $parentNode->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $this->protected_tags_counter . '"></' . $this->protectedChildNodesHelper . '>';
1420
+                $parentNode->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$this->protected_tags_counter.'"></'.$this->protectedChildNodesHelper.'>';
1421 1421
             }
1422 1422
 
1423 1423
             ++$this->protected_tags_counter;
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
             }
1452 1452
 
1453 1453
             $this->protectedChildNodes[$this->protected_tags_counter] = $element->innerhtml;
1454
-            $element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $this->protected_tags_counter . '"></' . $this->protectedChildNodesHelper . '>';
1454
+            $element->getNode()->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$this->protected_tags_counter.'"></'.$this->protectedChildNodesHelper.'>';
1455 1455
 
1456 1456
             ++$this->protected_tags_counter;
1457 1457
         }
@@ -1468,11 +1468,11 @@  discard block
 block discarded – undo
1468 1468
                 continue;
1469 1469
             }
1470 1470
 
1471
-            $this->protectedChildNodes[$this->protected_tags_counter] = '<!--' . $text . '-->';
1471
+            $this->protectedChildNodes[$this->protected_tags_counter] = '<!--'.$text.'-->';
1472 1472
 
1473 1473
             /* @var $node \DOMComment */
1474 1474
             $node = $element->getNode();
1475
-            $child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $this->protected_tags_counter . '"></' . $this->protectedChildNodesHelper . '>');
1475
+            $child = new \DOMText('<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$this->protected_tags_counter.'"></'.$this->protectedChildNodesHelper.'>');
1476 1476
             $parentNode = $element->getNode()->parentNode;
1477 1477
             if ($parentNode !== null) {
1478 1478
                 $parentNode->replaceChild($child, $node);
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -450,7 +450,6 @@  discard block
 block discarded – undo
450 450
     }
451 451
 
452 452
     /**
453
-     * @param bool $doMakeSameDomainLinksRelative
454 453
      *
455 454
      * @return $this
456 455
      */
@@ -1315,7 +1314,7 @@  discard block
 block discarded – undo
1315 1314
     /**
1316 1315
      * @param \DOMNode $node
1317 1316
      *
1318
-     * @return \DOMNode|null
1317
+     * @return null|\DOMElement
1319 1318
      */
1320 1319
     protected function getNextSiblingOfTypeDOMElement(\DOMNode $node)
1321 1320
     {
Please login to merge, or discard this patch.
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -456,9 +456,9 @@  discard block
 block discarded – undo
456 456
      */
457 457
     public function doMakeSameDomainLinksRelative(string $localDomain = ''): self
458 458
     {
459
-		$this->localDomain = \rtrim((string) \preg_replace('/(?:https?:)?\/\//i', '', $localDomain), '/');
459
+    $this->localDomain = \rtrim((string) \preg_replace('/(?:https?:)?\/\//i', '', $localDomain), '/');
460 460
 
461
-		$this->doMakeSameDomainLinksRelative = ($this->localDomain !== '');
461
+    $this->doMakeSameDomainLinksRelative = ($this->localDomain !== '');
462 462
 
463 463
         return $this;
464 464
     }
@@ -689,206 +689,206 @@  discard block
 block discarded – undo
689 689
         return \in_array($tag_name, self::$optional_end_tags, true)
690 690
                ||
691 691
                (
692
-                   $tag_name === 'li'
692
+                    $tag_name === 'li'
693 693
                    &&
694 694
                    (
695
-                       $nextSibling === null
695
+                        $nextSibling === null
696 696
                        ||
697 697
                        (
698
-                           $nextSibling instanceof \DOMElement
698
+                            $nextSibling instanceof \DOMElement
699 699
                            &&
700 700
                            $nextSibling->tagName === 'li'
701
-                       )
702
-                   )
703
-               )
701
+                        )
702
+                    )
703
+                )
704 704
                ||
705 705
                (
706
-                   $tag_name === 'rp'
706
+                    $tag_name === 'rp'
707 707
                    &&
708 708
                    (
709
-                       $nextSibling === null
709
+                        $nextSibling === null
710 710
                        ||
711 711
                        (
712
-                           $nextSibling instanceof \DOMElement
712
+                            $nextSibling instanceof \DOMElement
713 713
                            &&
714 714
                            (
715
-                               $nextSibling->tagName === 'rp'
715
+                                $nextSibling->tagName === 'rp'
716 716
                                ||
717 717
                                $nextSibling->tagName === 'rt'
718
-                           )
719
-                       )
720
-                   )
721
-               )
718
+                            )
719
+                        )
720
+                    )
721
+                )
722 722
                ||
723 723
                (
724
-                   $tag_name === 'tr'
724
+                    $tag_name === 'tr'
725 725
                    &&
726 726
                    (
727
-                       $nextSibling === null
727
+                        $nextSibling === null
728 728
                        ||
729 729
                        (
730
-                           $nextSibling instanceof \DOMElement
730
+                            $nextSibling instanceof \DOMElement
731 731
                            &&
732 732
                            $nextSibling->tagName === 'tr'
733
-                       )
734
-                   )
735
-               )
733
+                        )
734
+                    )
735
+                )
736 736
                ||
737 737
                (
738
-                   $tag_name === 'source'
738
+                    $tag_name === 'source'
739 739
                    &&
740 740
                    (
741
-                       $parent_tag_name === 'audio'
741
+                        $parent_tag_name === 'audio'
742 742
                        ||
743 743
                        $parent_tag_name === 'video'
744 744
                        ||
745 745
                        $parent_tag_name === 'picture'
746 746
                        ||
747 747
                        $parent_tag_name === 'source'
748
-                   )
748
+                    )
749 749
                    &&
750 750
                    (
751
-                       $nextSibling === null
751
+                        $nextSibling === null
752 752
                        ||
753 753
                        (
754
-                           $nextSibling instanceof \DOMElement
754
+                            $nextSibling instanceof \DOMElement
755 755
                            &&
756 756
                            $nextSibling->tagName === 'source'
757
-                       )
758
-                   )
759
-               )
757
+                        )
758
+                    )
759
+                )
760 760
                ||
761 761
                (
762
-                   (
763
-                       $tag_name === 'td'
762
+                    (
763
+                        $tag_name === 'td'
764 764
                        ||
765 765
                        $tag_name === 'th'
766
-                   )
766
+                    )
767 767
                    &&
768 768
                    (
769
-                       $nextSibling === null
769
+                        $nextSibling === null
770 770
                        ||
771 771
                        (
772
-                           $nextSibling instanceof \DOMElement
772
+                            $nextSibling instanceof \DOMElement
773 773
                            &&
774 774
                            (
775
-                               $nextSibling->tagName === 'td'
775
+                                $nextSibling->tagName === 'td'
776 776
                                ||
777 777
                                $nextSibling->tagName === 'th'
778
-                           )
779
-                       )
780
-                   )
781
-               )
778
+                            )
779
+                        )
780
+                    )
781
+                )
782 782
                ||
783 783
                (
784
-                   (
785
-                       $tag_name === 'dd'
784
+                    (
785
+                        $tag_name === 'dd'
786 786
                        ||
787 787
                        $tag_name === 'dt'
788
-                   )
788
+                    )
789 789
                    &&
790 790
                    (
791
-                       (
792
-                           $nextSibling === null
791
+                        (
792
+                            $nextSibling === null
793 793
                            &&
794 794
                            $tag_name === 'dd'
795
-                       )
795
+                        )
796 796
                        ||
797 797
                        (
798
-                           $nextSibling instanceof \DOMElement
798
+                            $nextSibling instanceof \DOMElement
799 799
                            &&
800 800
                            (
801
-                               $nextSibling->tagName === 'dd'
801
+                                $nextSibling->tagName === 'dd'
802 802
                                ||
803 803
                                $nextSibling->tagName === 'dt'
804
-                           )
805
-                       )
806
-                   )
807
-               )
804
+                            )
805
+                        )
806
+                    )
807
+                )
808 808
                ||
809 809
                (
810
-                   $tag_name === 'option'
810
+                    $tag_name === 'option'
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
                            (
819
-                               $nextSibling->tagName === 'option'
819
+                                $nextSibling->tagName === 'option'
820 820
                                ||
821 821
                                $nextSibling->tagName === 'optgroup'
822
-                           )
823
-                       )
824
-                   )
825
-               )
822
+                            )
823
+                        )
824
+                    )
825
+                )
826 826
                ||
827 827
                (
828
-                   $tag_name === 'p'
828
+                    $tag_name === 'p'
829 829
                    &&
830 830
                    (
831
-                       (
832
-                           $nextSibling === null
831
+                        (
832
+                            $nextSibling === null
833 833
                            &&
834 834
                            (
835
-                               $node->parentNode !== null
835
+                                $node->parentNode !== null
836 836
                                &&
837 837
                                !\in_array(
838
-                                   $node->parentNode->nodeName,
839
-                                   [
840
-                                       'a',
841
-                                       'audio',
842
-                                       'del',
843
-                                       'ins',
844
-                                       'map',
845
-                                       'noscript',
846
-                                       'video',
847
-                                   ],
848
-                                   true
849
-                               )
850
-                           )
851
-                       )
838
+                                    $node->parentNode->nodeName,
839
+                                    [
840
+                                        'a',
841
+                                        'audio',
842
+                                        'del',
843
+                                        'ins',
844
+                                        'map',
845
+                                        'noscript',
846
+                                        'video',
847
+                                    ],
848
+                                    true
849
+                                )
850
+                            )
851
+                        )
852 852
                        ||
853 853
                        (
854
-                           $nextSibling instanceof \DOMElement
854
+                            $nextSibling instanceof \DOMElement
855 855
                            &&
856 856
                            \in_array(
857
-                               $nextSibling->tagName,
858
-                               [
859
-                                   'address',
860
-                                   'article',
861
-                                   'aside',
862
-                                   'blockquote',
863
-                                   'dir',
864
-                                   'div',
865
-                                   'dl',
866
-                                   'fieldset',
867
-                                   'footer',
868
-                                   'form',
869
-                                   'h1',
870
-                                   'h2',
871
-                                   'h3',
872
-                                   'h4',
873
-                                   'h5',
874
-                                   'h6',
875
-                                   'header',
876
-                                   'hgroup',
877
-                                   'hr',
878
-                                   'menu',
879
-                                   'nav',
880
-                                   'ol',
881
-                                   'p',
882
-                                   'pre',
883
-                                   'section',
884
-                                   'table',
885
-                                   'ul',
886
-                               ],
887
-                               true
888
-                           )
889
-                       )
890
-                   )
891
-               );
857
+                                $nextSibling->tagName,
858
+                                [
859
+                                    'address',
860
+                                    'article',
861
+                                    'aside',
862
+                                    'blockquote',
863
+                                    'dir',
864
+                                    'div',
865
+                                    'dl',
866
+                                    'fieldset',
867
+                                    'footer',
868
+                                    'form',
869
+                                    'h1',
870
+                                    'h2',
871
+                                    'h3',
872
+                                    'h4',
873
+                                    'h5',
874
+                                    'h6',
875
+                                    'header',
876
+                                    'hgroup',
877
+                                    'hr',
878
+                                    'menu',
879
+                                    'nav',
880
+                                    'ol',
881
+                                    'p',
882
+                                    'pre',
883
+                                    'section',
884
+                                    'table',
885
+                                    'ul',
886
+                                ],
887
+                                true
888
+                            )
889
+                        )
890
+                    )
891
+                );
892 892
     }
893 893
 
894 894
     protected function domNodeToString(\DOMNode $node): string
@@ -920,9 +920,9 @@  discard block
 block discarded – undo
920 920
                     }
921 921
 
922 922
                     $html .= '<!DOCTYPE ' . $child->name . ''
923
-                             . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
924
-                             . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
925
-                             . '>';
923
+                              . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
924
+                              . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
925
+                              . '>';
926 926
                 }
927 927
             } elseif ($child instanceof \DOMElement) {
928 928
                 $html .= \rtrim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child));
Please login to merge, or discard this patch.
src/voku/helper/HtmlMinDomObserverOptimizeAttributes.php 2 patches
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.
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function domElementAfterMinification(SimpleHtmlDomInterface $element, HtmlMinInterface $htmlMin)
52 52
     {
53
-		$tag_name = $element->getNode()->nodeName;
53
+    $tag_name = $element->getNode()->nodeName;
54 54
         $attributes = $element->getAllAttributes();
55 55
         if ($attributes === null) {
56 56
             return;
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
                     $attrValue,
69 69
                     $attrName,
70 70
                     'http',
71
-					$attributes,
72
-					$tag_name,
71
+          $attributes,
72
+          $tag_name,
73 73
                     $htmlMin
74 74
                 );
75 75
             }
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
                     $attrValue,
80 80
                     $attrName,
81 81
                     'https',
82
-					$attributes,
83
-					$tag_name,
82
+          $attributes,
83
+          $tag_name,
84 84
                     $htmlMin
85 85
                 );
86 86
             }
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
         string $attrValue,
248 248
         string $attrName,
249 249
         string $scheme,
250
-		array $attributes,
251
-		string $tag_name,
250
+    array $attributes,
251
+    string $tag_name,
252 252
         HtmlMinInterface $htmlMin
253 253
     ): string {
254 254
         /** @noinspection InArrayCanBeUsedInspection */
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
                 (
262 262
                     $attrName === 'href'
263 263
                     &&
264
-					(
265
-						!$htmlMin->isKeepPrefixOnExternalAttributes()
266
-						||
267
-						$tag_name === 'link'
268
-					)
269
-				)
264
+          (
265
+            !$htmlMin->isKeepPrefixOnExternalAttributes()
266
+            ||
267
+            $tag_name === 'link'
268
+          )
269
+        )
270 270
                 ||
271 271
                 $attrName === 'src'
272 272
                 ||
Please login to merge, or discard this patch.