Completed
Push — master ( 9a5449...ad2f53 )
by Lars
14:03
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
     /**
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
                 &&
376 376
                 \trim($matches_after_html[1])
377 377
             ) {
378
-                $html = \str_replace($matches_after_html[0], $matches_after_html[1] . '</html>', $html);
378
+                $html = \str_replace($matches_after_html[0], $matches_after_html[1].'</html>', $html);
379 379
             }
380 380
         }
381 381
 
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
         }
412 412
 
413 413
         $html = \str_replace(
414
-            \array_map(static function ($e) {
415
-                return '<' . $e . '>';
414
+            \array_map(static function($e) {
415
+                return '<'.$e.'>';
416 416
             }, $this->selfClosingTags),
417
-            \array_map(static function ($e) {
418
-                return '<' . $e . '/>';
417
+            \array_map(static function($e) {
418
+                return '<'.$e.'/>';
419 419
             }, $this->selfClosingTags),
420 420
             $html
421 421
         );
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
                 $this->keepBrokenHtml
459 459
             )
460 460
         ) {
461
-            $html = '<' . self::$domHtmlWrapperHelper . '>' . $html . '</' . self::$domHtmlWrapperHelper . '>';
461
+            $html = '<'.self::$domHtmlWrapperHelper.'>'.$html.'</'.self::$domHtmlWrapperHelper.'>';
462 462
         }
463 463
 
464 464
         $html = self::replaceToPreserveHtmlEntities($html);
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
             $xmlHackUsed = false;
480 480
             if (\stripos('<?xml', $html) !== 0) {
481 481
                 $xmlHackUsed = true;
482
-                $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html;
482
+                $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html;
483 483
             }
484 484
 
485 485
             if ($html !== '') {
@@ -701,8 +701,8 @@  discard block
 block discarded – undo
701 701
 
702 702
         // https://bugs.php.net/bug.php?id=73175
703 703
         $content = \str_replace(
704
-            \array_map(static function ($e) {
705
-                return '</' . $e . '>';
704
+            \array_map(static function($e) {
705
+                return '</'.$e.'>';
706 706
             }, $this->selfClosingTags),
707 707
             '',
708 708
             $content
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
      */
746 746
     public function getElementByClass(string $class): SimpleHtmlDomNodeInterface
747 747
     {
748
-        return $this->findMulti('.' . $class);
748
+        return $this->findMulti('.'.$class);
749 749
     }
750 750
 
751 751
     /**
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
      */
758 758
     public function getElementById(string $id): SimpleHtmlDomInterface
759 759
     {
760
-        return $this->findOne('#' . $id);
760
+        return $this->findOne('#'.$id);
761 761
     }
762 762
 
763 763
     /**
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
      */
789 789
     public function getElementsById(string $id, $idx = null)
790 790
     {
791
-        return $this->find('#' . $id, $idx);
791
+        return $this->find('#'.$id, $idx);
792 792
     }
793 793
 
794 794
     /**
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
             &&
887 887
             !\file_exists($filePath)
888 888
         ) {
889
-            throw new \RuntimeException("File " . $filePath . " not found");
889
+            throw new \RuntimeException("File ".$filePath." not found");
890 890
         }
891 891
 
892 892
         try {
@@ -896,11 +896,11 @@  discard block
 block discarded – undo
896 896
                 $html = \file_get_contents($filePath);
897 897
             }
898 898
         } catch (\Exception $e) {
899
-            throw new \RuntimeException("Could not load file " . $filePath);
899
+            throw new \RuntimeException("Could not load file ".$filePath);
900 900
         }
901 901
 
902 902
         if ($html === false) {
903
-            throw new \RuntimeException("Could not load file " . $filePath);
903
+            throw new \RuntimeException("Could not load file ".$filePath);
904 904
         }
905 905
 
906 906
         return $this->loadHtml($html, $libXMLExtraOptions);
@@ -1029,11 +1029,11 @@  discard block
 block discarded – undo
1029 1029
 
1030 1030
             $html = (string) \preg_replace_callback(
1031 1031
                 '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui',
1032
-                static function ($matches) {
1033
-                    return $matches['start'] .
1034
-                        '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' .
1035
-                        $matches['value'] .
1036
-                        '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' .
1032
+                static function($matches) {
1033
+                    return $matches['start'].
1034
+                        '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'.
1035
+                        $matches['value'].
1036
+                        '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'.
1037 1037
                         $matches['end'];
1038 1038
                 },
1039 1039
                 $html
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 
1046 1046
             $html = (string) \preg_replace_callback(
1047 1047
                 '/(?<start>[^<]*)?(?<broken>(?:<\/\w+(?:\s+\w+=\"[^"]+\")*+[^<]+>)+)(?<end>.*)/u',
1048
-                static function ($matches) {
1048
+                static function($matches) {
1049 1049
                     $matches['broken'] = \str_replace(
1050 1050
                         ['°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'],
1051 1051
                         ['</', '<', '>'],
@@ -1053,9 +1053,9 @@  discard block
 block discarded – undo
1053 1053
                     );
1054 1054
 
1055 1055
                     self::$domBrokenReplaceHelper['orig'][] = $matches['broken'];
1056
-                    self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['broken']);
1056
+                    self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['broken']);
1057 1057
 
1058
-                    return $matches['start'] . $matchesHash . $matches['end'];
1058
+                    return $matches['start'].$matchesHash.$matches['end'];
1059 1059
                 },
1060 1060
                 $html
1061 1061
             );
@@ -1082,16 +1082,16 @@  discard block
 block discarded – undo
1082 1082
         $regExSpecialSvg = '/\((["\'])?(?<start>data:image\/svg.*)<svg(?<attr>[^>]*?)>(?<content>.*)<\/svg>\1\)/isU';
1083 1083
         $htmlTmp = \preg_replace_callback(
1084 1084
             $regExSpecialSvg,
1085
-            static function ($svgs) {
1085
+            static function($svgs) {
1086 1086
                 if (empty($svgs['content'])) {
1087 1087
                     return $svgs[0];
1088 1088
                 }
1089 1089
 
1090
-                $content = '<svg' . $svgs['attr'] . '>' . $svgs['content'] . '</svg>';
1090
+                $content = '<svg'.$svgs['attr'].'>'.$svgs['content'].'</svg>';
1091 1091
                 self::$domBrokenReplaceHelper['orig'][] = $content;
1092
-                self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($content);
1092
+                self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($content);
1093 1093
 
1094
-                return '(' . $svgs[1] . $svgs['start'] . $matchesHash . $svgs[1] . ')';
1094
+                return '('.$svgs[1].$svgs['start'].$matchesHash.$svgs[1].')';
1095 1095
             },
1096 1096
             $html
1097 1097
         );
@@ -1110,14 +1110,14 @@  discard block
 block discarded – undo
1110 1110
     {
1111 1111
         // regEx for e.g.: [<script id="elements-image-1" type="text/html">...</script>]
1112 1112
         $tags = \implode('|', \array_map(
1113
-            static function ($value) {
1113
+            static function($value) {
1114 1114
                 return \preg_quote($value, '/');
1115 1115
             },
1116 1116
             $this->specialScriptTags
1117 1117
         ));
1118 1118
         $html = (string) \preg_replace_callback(
1119
-            '/(?<start>(<script [^>]*type=["\']?(?:' . $tags . ')+[^>]*>))(?<innerContent>.*)(?<end><\/script>)/isU',
1120
-            function ($matches) {
1119
+            '/(?<start>(<script [^>]*type=["\']?(?:'.$tags.')+[^>]*>))(?<innerContent>.*)(?<end><\/script>)/isU',
1120
+            function($matches) {
1121 1121
 
1122 1122
                 // Check for logic in special script tags, like [<% _.each(tierPrices, function(item, key) { %>],
1123 1123
                 // because often this looks like non-valid html in the template itself.
@@ -1127,18 +1127,18 @@  discard block
 block discarded – undo
1127 1127
                         $matches['innerContent'] = \str_replace('<\/', '</', $matches['innerContent']);
1128 1128
 
1129 1129
                         self::$domBrokenReplaceHelper['orig'][] = $matches['innerContent'];
1130
-                        self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['innerContent']);
1130
+                        self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['innerContent']);
1131 1131
 
1132
-                        return $matches['start'] . $matchesHash . $matches['end'];
1132
+                        return $matches['start'].$matchesHash.$matches['end'];
1133 1133
                     }
1134 1134
                 }
1135 1135
 
1136 1136
                 // remove the html5 fallback
1137 1137
                 $matches[0] = \str_replace('<\/', '</', $matches[0]);
1138 1138
 
1139
-                $specialNonScript = '<' . self::$domHtmlSpecialScriptHelper . \substr($matches[0], \strlen('<script'));
1139
+                $specialNonScript = '<'.self::$domHtmlSpecialScriptHelper.\substr($matches[0], \strlen('<script'));
1140 1140
 
1141
-                return \substr($specialNonScript, 0, -\strlen('</script>')) . '</' . self::$domHtmlSpecialScriptHelper . '>';
1141
+                return \substr($specialNonScript, 0, -\strlen('</script>')).'</'.self::$domHtmlSpecialScriptHelper.'>';
1142 1142
             },
1143 1143
             $html
1144 1144
         );
Please login to merge, or discard this patch.