Completed
Pull Request — master (#105)
by Lars
44:32 queued 29:26
created
src/voku/helper/HtmlDomParser.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
             return \call_user_func_array([$this, self::$functionAliases[$name]], $arguments);
205 205
         }
206 206
 
207
-        throw new \BadMethodCallException('Method does not exist: ' . $name);
207
+        throw new \BadMethodCallException('Method does not exist: '.$name);
208 208
     }
209 209
 
210 210
     /**
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                 &&
377 377
                 \trim($matches_after_html[1])
378 378
             ) {
379
-                $html = \str_replace($matches_after_html[0], $matches_after_html[1] . '</html>', $html);
379
+                $html = \str_replace($matches_after_html[0], $matches_after_html[1].'</html>', $html);
380 380
             }
381 381
         }
382 382
 
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
         }
413 413
 
414 414
         $html = \str_replace(
415
-            \array_map(static function ($e) {
416
-                return '<' . $e . '>';
415
+            \array_map(static function($e) {
416
+                return '<'.$e.'>';
417 417
             }, $this->selfClosingTags),
418
-            \array_map(static function ($e) {
419
-                return '<' . $e . '/>';
418
+            \array_map(static function($e) {
419
+                return '<'.$e.'/>';
420 420
             }, $this->selfClosingTags),
421 421
             $html
422 422
         );
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
                 $this->keepBrokenHtml
463 463
             )
464 464
         ) {
465
-            $html = '<' . self::$domHtmlWrapperHelper . '>' . $html . '</' . self::$domHtmlWrapperHelper . '>';
465
+            $html = '<'.self::$domHtmlWrapperHelper.'>'.$html.'</'.self::$domHtmlWrapperHelper.'>';
466 466
         }
467 467
 
468 468
         $html = self::replaceToPreserveHtmlEntities($html);
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
             $xmlHackUsed = false;
483 483
             if (\stripos('<?xml', $html) !== 0) {
484 484
                 $xmlHackUsed = true;
485
-                $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html;
485
+                $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html;
486 486
             }
487 487
 
488 488
             if ($html !== '') {
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
 
705 705
         // https://bugs.php.net/bug.php?id=73175
706 706
         $content = \str_replace(
707
-            \array_map(static function ($e) {
708
-                return '</' . $e . '>';
707
+            \array_map(static function($e) {
708
+                return '</'.$e.'>';
709 709
             }, $this->selfClosingTags),
710 710
             '',
711 711
             $content
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
      */
749 749
     public function getElementByClass(string $class): SimpleHtmlDomNodeInterface
750 750
     {
751
-        return $this->findMulti('.' . $class);
751
+        return $this->findMulti('.'.$class);
752 752
     }
753 753
 
754 754
     /**
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
      */
761 761
     public function getElementById(string $id): SimpleHtmlDomInterface
762 762
     {
763
-        return $this->findOne('#' . $id);
763
+        return $this->findOne('#'.$id);
764 764
     }
765 765
 
766 766
     /**
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
      */
792 792
     public function getElementsById(string $id, $idx = null)
793 793
     {
794
-        return $this->find('#' . $id, $idx);
794
+        return $this->find('#'.$id, $idx);
795 795
     }
796 796
 
797 797
     /**
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
             &&
892 892
             !\file_exists($filePath)
893 893
         ) {
894
-            throw new \RuntimeException('File ' . $filePath . ' not found');
894
+            throw new \RuntimeException('File '.$filePath.' not found');
895 895
         }
896 896
 
897 897
         try {
@@ -901,11 +901,11 @@  discard block
 block discarded – undo
901 901
                 $html = \file_get_contents($filePath);
902 902
             }
903 903
         } catch (\Exception $e) {
904
-            throw new \RuntimeException('Could not load file ' . $filePath);
904
+            throw new \RuntimeException('Could not load file '.$filePath);
905 905
         }
906 906
 
907 907
         if ($html === false) {
908
-            throw new \RuntimeException('Could not load file ' . $filePath);
908
+            throw new \RuntimeException('Could not load file '.$filePath);
909 909
         }
910 910
 
911 911
         return $this->loadHtml($html, $libXMLExtraOptions, $useDefaultLibXMLOptions);
@@ -1034,11 +1034,11 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
             $html = (string) \preg_replace_callback(
1036 1036
                 '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui',
1037
-                static function ($matches) {
1038
-                    return $matches['start'] .
1039
-                        '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' .
1040
-                        $matches['value'] .
1041
-                        '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' .
1037
+                static function($matches) {
1038
+                    return $matches['start'].
1039
+                        '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'.
1040
+                        $matches['value'].
1041
+                        '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'.
1042 1042
                         $matches['end'];
1043 1043
                 },
1044 1044
                 $html
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 
1051 1051
             $html = (string) \preg_replace_callback(
1052 1052
                 '/(?<start>[^<]*)?(?<broken>(?:<\/\w+(?:\s+\w+=\"[^"]+\")*+[^<]+>)+)(?<end>.*)/u',
1053
-                static function ($matches) {
1053
+                static function($matches) {
1054 1054
                     $matches['broken'] = \str_replace(
1055 1055
                         ['°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'],
1056 1056
                         ['</', '<', '>'],
@@ -1058,9 +1058,9 @@  discard block
 block discarded – undo
1058 1058
                     );
1059 1059
 
1060 1060
                     self::$domBrokenReplaceHelper['orig'][] = $matches['broken'];
1061
-                    self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['broken']);
1061
+                    self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['broken']);
1062 1062
 
1063
-                    return $matches['start'] . $matchesHash . $matches['end'];
1063
+                    return $matches['start'].$matchesHash.$matches['end'];
1064 1064
                 },
1065 1065
                 $html
1066 1066
             );
@@ -1087,16 +1087,16 @@  discard block
 block discarded – undo
1087 1087
         $regExSpecialSvg = '/\((["\'])?(?<start>data:image\/svg.*)<svg(?<attr>[^>]*?)>(?<content>.*)<\/svg>\1\)/isU';
1088 1088
         $htmlTmp = \preg_replace_callback(
1089 1089
             $regExSpecialSvg,
1090
-            static function ($svgs) {
1090
+            static function($svgs) {
1091 1091
                 if (empty($svgs['content'])) {
1092 1092
                     return $svgs[0];
1093 1093
                 }
1094 1094
 
1095
-                $content = '<svg' . $svgs['attr'] . '>' . $svgs['content'] . '</svg>';
1095
+                $content = '<svg'.$svgs['attr'].'>'.$svgs['content'].'</svg>';
1096 1096
                 self::$domBrokenReplaceHelper['orig'][] = $content;
1097
-                self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($content);
1097
+                self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($content);
1098 1098
 
1099
-                return '(' . $svgs[1] . $svgs['start'] . $matchesHash . $svgs[1] . ')';
1099
+                return '('.$svgs[1].$svgs['start'].$matchesHash.$svgs[1].')';
1100 1100
             },
1101 1101
             $html
1102 1102
         );
@@ -1115,14 +1115,14 @@  discard block
 block discarded – undo
1115 1115
     {
1116 1116
         // regEx for e.g.: [<script id="elements-image-1" type="text/html">...</script>]
1117 1117
         $tags = \implode('|', \array_map(
1118
-            static function ($value) {
1118
+            static function($value) {
1119 1119
                 return \preg_quote($value, '/');
1120 1120
             },
1121 1121
             $this->specialScriptTags
1122 1122
         ));
1123 1123
         $html = (string) \preg_replace_callback(
1124
-            '/(?<start>(<script [^>]*type=["\']?(?:' . $tags . ')+[^>]*>))(?<innerContent>.*)(?<end><\/script>)/isU',
1125
-            function ($matches) {
1124
+            '/(?<start>(<script [^>]*type=["\']?(?:'.$tags.')+[^>]*>))(?<innerContent>.*)(?<end><\/script>)/isU',
1125
+            function($matches) {
1126 1126
                 // Check for logic in special script tags, like [<% _.each(tierPrices, function(item, key) { %>],
1127 1127
                 // because often this looks like non-valid html in the template itself.
1128 1128
                 foreach ($this->templateLogicSyntaxInSpecialScriptTags as $logicSyntaxInSpecialScriptTag) {
@@ -1131,18 +1131,18 @@  discard block
 block discarded – undo
1131 1131
                         $matches['innerContent'] = \str_replace('<\/', '</', $matches['innerContent']);
1132 1132
 
1133 1133
                         self::$domBrokenReplaceHelper['orig'][] = $matches['innerContent'];
1134
-                        self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['innerContent']);
1134
+                        self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['innerContent']);
1135 1135
 
1136
-                        return $matches['start'] . $matchesHash . $matches['end'];
1136
+                        return $matches['start'].$matchesHash.$matches['end'];
1137 1137
                     }
1138 1138
                 }
1139 1139
 
1140 1140
                 // remove the html5 fallback
1141 1141
                 $matches[0] = \str_replace('<\/', '</', $matches[0]);
1142 1142
 
1143
-                $specialNonScript = '<' . self::$domHtmlSpecialScriptHelper . \substr($matches[0], \strlen('<script'));
1143
+                $specialNonScript = '<'.self::$domHtmlSpecialScriptHelper.\substr($matches[0], \strlen('<script'));
1144 1144
 
1145
-                return \substr($specialNonScript, 0, -\strlen('</script>')) . '</' . self::$domHtmlSpecialScriptHelper . '>';
1145
+                return \substr($specialNonScript, 0, -\strlen('</script>')).'</'.self::$domHtmlSpecialScriptHelper.'>';
1146 1146
             },
1147 1147
             $html
1148 1148
         );
Please login to merge, or discard this patch.