Completed
Push — master ( d9807c...1be486 )
by Lars
28:06 queued 13:03
created
src/voku/helper/SimpleHtmlDomBlank.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -465,6 +465,6 @@
 block discarded – undo
465 465
      */
466 466
     public function delete()
467 467
     {
468
-        $this->outertext='';
468
+        $this->outertext = '';
469 469
     }
470 470
 }
Please login to merge, or discard this patch.
example/example_add_content.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 // add: "<br>" to "<li>"
10 10
 $htmlTmp = HtmlDomParser::str_get_html($templateHtml);
11 11
 foreach ($htmlTmp->findMulti('ul li') as $li) {
12
-    $li->innerhtml = '<br>' . $li->innerhtml . '<br>';
12
+    $li->innerhtml = '<br>'.$li->innerhtml.'<br>';
13 13
 }
14 14
 foreach ($htmlTmp->findMulti('br') as $br) {
15 15
     // DEBUG:
Please login to merge, or discard this patch.
src/voku/helper/SimpleXmlDom.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 
165 165
             if ($tmpDomString !== $tmpStr) {
166 166
                 throw new \RuntimeException(
167
-                    'Not valid XML fragment!' . "\n" .
168
-                    $tmpDomString . "\n" .
167
+                    'Not valid XML fragment!'."\n".
168
+                    $tmpDomString."\n".
169 169
                     $tmpStr
170 170
                 );
171 171
             }
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 
225 225
         if ($tmpDomOuterTextString !== $tmpStr) {
226 226
             throw new \RuntimeException(
227
-                'Not valid XML fragment!' . "\n"
228
-                . $tmpDomOuterTextString . "\n" .
227
+                'Not valid XML fragment!'."\n"
228
+                . $tmpDomOuterTextString."\n".
229 229
                 $tmpStr
230 230
             );
231 231
         }
Please login to merge, or discard this patch.
src/voku/helper/SimpleHtmlDom.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     public function removeAttributes(): SimpleHtmlDomInterface
173 173
     {
174 174
         if ($this->hasAttributes()) {
175
-            foreach (array_keys((array)$this->getAllAttributes()) as $attribute) {
175
+            foreach (array_keys((array) $this->getAllAttributes()) as $attribute) {
176 176
                 $this->removeAttribute($attribute);
177 177
             }
178 178
         }
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 
198 198
             if ($tmpDomString !== $tmpStr) {
199 199
                 throw new \RuntimeException(
200
-                    'Not valid HTML fragment!' . "\n" .
201
-                    $tmpDomString . "\n" .
200
+                    'Not valid HTML fragment!'."\n".
201
+                    $tmpDomString."\n".
202 202
                     $tmpStr
203 203
                 );
204 204
             }
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 
259 259
         if ($tmpDomOuterTextString !== $tmpStr) {
260 260
             throw new \RuntimeException(
261
-                'Not valid HTML fragment!' . "\n"
262
-                . $tmpDomOuterTextString . "\n" .
261
+                'Not valid HTML fragment!'."\n"
262
+                . $tmpDomOuterTextString."\n".
263 263
                 $tmpStr
264 264
             );
265 265
         }
Please login to merge, or discard this patch.
src/voku/helper/HtmlDomHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         }
24 24
 
25 25
         $dom = \voku\helper\HtmlDomParser::str_get_html($html);
26
-        $domNew = \voku\helper\HtmlDomParser::str_get_html('<textarea ' . $optionStr . '></textarea>');
26
+        $domNew = \voku\helper\HtmlDomParser::str_get_html('<textarea '.$optionStr.'></textarea>');
27 27
 
28 28
         $domElement = $dom->findOneOrFalse($htmlCssSelector);
29 29
         if ($domElement === false) {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                 \strpos($attributeNameNew, 'on') === 0 // e.g. onClick, ...
55 55
             ) {
56 56
                 if (isset($attributes[$attributeNameNew])) {
57
-                    $attributes[$attributeNameNew] .= ' ' . $attributeValueNew;
57
+                    $attributes[$attributeNameNew] .= ' '.$attributeValueNew;
58 58
                 } else {
59 59
                     $attributes[$attributeNameNew] = $attributeValueNew;
60 60
                 }
Please login to merge, or discard this patch.
src/voku/helper/AbstractSimpleHtmlDom.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@
 block discarded – undo
168 168
                 if ($this->node && \property_exists($this->node, $nameOrig)) {
169 169
                     // INFO: Cannot assign null to property DOMNode::* of type string
170 170
                     if ($nameOrig === 'prefix' || $nameOrig === 'textContent') {
171
-                        $value = (string)$value;
171
+                        $value = (string) $value;
172 172
                     }
173 173
 
174 174
                     return $this->node->{$nameOrig} = $value;
Please login to merge, or discard this patch.
src/voku/helper/AbstractDomParser.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             return \call_user_func_array([$this, self::$functionAliases[$name]], $arguments);
91 91
         }
92 92
 
93
-        throw new \BadMethodCallException('Method does not exist: ' . $name);
93
+        throw new \BadMethodCallException('Method does not exist: '.$name);
94 94
     }
95 95
 
96 96
     /**
@@ -413,12 +413,12 @@  discard block
 block discarded – undo
413 413
         $regExSpecialScript = '/<script(?<attr>[^>]*?)>(?<content>.*)<\/script>/isU';
414 414
         $htmlTmp = \preg_replace_callback(
415 415
             $regExSpecialScript,
416
-            static function ($scripts) {
416
+            static function($scripts) {
417 417
                 if (empty($scripts['content'])) {
418 418
                     return $scripts[0];
419 419
                 }
420 420
 
421
-                return '<script' . $scripts['attr'] . '>' . \str_replace('</', '<\/', $scripts['content']) . '</script>';
421
+                return '<script'.$scripts['attr'].'>'.\str_replace('</', '<\/', $scripts['content']).'</script>';
422 422
             },
423 423
             $html
424 424
         );
@@ -447,26 +447,26 @@  discard block
 block discarded – undo
447 447
                 self::$domReplaceHelper['orig']
448 448
             );
449 449
 
450
-            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start'] = '<' . self::$domHtmlWrapperHelper . '>';
451
-            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end'] = '</' . self::$domHtmlWrapperHelper . '>';
450
+            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start'] = '<'.self::$domHtmlWrapperHelper.'>';
451
+            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end'] = '</'.self::$domHtmlWrapperHelper.'>';
452 452
 
453 453
             $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__start'] = '';
454 454
             $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__end'] = '';
455 455
 
456
-            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start_broken'] = self::$domHtmlWrapperHelper . '>';
457
-            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end_broken'] = '</' . self::$domHtmlWrapperHelper;
456
+            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start_broken'] = self::$domHtmlWrapperHelper.'>';
457
+            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end_broken'] = '</'.self::$domHtmlWrapperHelper;
458 458
 
459 459
             $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__start_broken'] = '';
460 460
             $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__end_broken'] = '';
461 461
 
462
-            $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__start'] = '<' . self::$domHtmlSpecialScriptHelper;
463
-            $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__end'] = '</' . self::$domHtmlSpecialScriptHelper . '>';
462
+            $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__start'] = '<'.self::$domHtmlSpecialScriptHelper;
463
+            $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__end'] = '</'.self::$domHtmlSpecialScriptHelper.'>';
464 464
 
465 465
             $DOM_REPLACE__HELPER_CACHE['orig']['html_special_script__start'] = '<script';
466 466
             $DOM_REPLACE__HELPER_CACHE['orig']['html_special_script__end'] = '</script>';
467 467
 
468 468
             $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__start_broken'] = self::$domHtmlSpecialScriptHelper;
469
-            $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__end_broken'] = '</' . self::$domHtmlSpecialScriptHelper;
469
+            $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__end_broken'] = '</'.self::$domHtmlSpecialScriptHelper;
470 470
 
471 471
             $DOM_REPLACE__HELPER_CACHE['orig']['html_special_script__start_broken'] = 'script';
472 472
             $DOM_REPLACE__HELPER_CACHE['orig']['html_special_script__end_broken'] = '</script';
Please login to merge, or discard this patch.
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);
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
             $xmlHackUsed = false;
484 484
             if (\stripos('<?xml', $html) !== 0) {
485 485
                 $xmlHackUsed = true;
486
-                $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html;
486
+                $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html;
487 487
             }
488 488
 
489 489
             if ($html !== '') {
@@ -705,8 +705,8 @@  discard block
 block discarded – undo
705 705
 
706 706
         // https://bugs.php.net/bug.php?id=73175
707 707
         $content = \str_replace(
708
-            \array_map(static function ($e) {
709
-                return '</' . $e . '>';
708
+            \array_map(static function($e) {
709
+                return '</'.$e.'>';
710 710
             }, $this->selfClosingTags),
711 711
             '',
712 712
             $content
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
      */
750 750
     public function getElementByClass(string $class): SimpleHtmlDomNodeInterface
751 751
     {
752
-        return $this->findMulti('.' . $class);
752
+        return $this->findMulti('.'.$class);
753 753
     }
754 754
 
755 755
     /**
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
      */
762 762
     public function getElementById(string $id): SimpleHtmlDomInterface
763 763
     {
764
-        return $this->findOne('#' . $id);
764
+        return $this->findOne('#'.$id);
765 765
     }
766 766
 
767 767
     /**
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
      */
793 793
     public function getElementsById(string $id, $idx = null)
794 794
     {
795
-        return $this->find('#' . $id, $idx);
795
+        return $this->find('#'.$id, $idx);
796 796
     }
797 797
 
798 798
     /**
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
             &&
893 893
             !\file_exists($filePath)
894 894
         ) {
895
-            throw new \RuntimeException('File ' . $filePath . ' not found');
895
+            throw new \RuntimeException('File '.$filePath.' not found');
896 896
         }
897 897
 
898 898
         try {
@@ -902,11 +902,11 @@  discard block
 block discarded – undo
902 902
                 $html = \file_get_contents($filePath);
903 903
             }
904 904
         } catch (\Exception $e) {
905
-            throw new \RuntimeException('Could not load file ' . $filePath);
905
+            throw new \RuntimeException('Could not load file '.$filePath);
906 906
         }
907 907
 
908 908
         if ($html === false) {
909
-            throw new \RuntimeException('Could not load file ' . $filePath);
909
+            throw new \RuntimeException('Could not load file '.$filePath);
910 910
         }
911 911
 
912 912
         return $this->loadHtml($html, $libXMLExtraOptions, $useDefaultLibXMLOptions);
@@ -1035,11 +1035,11 @@  discard block
 block discarded – undo
1035 1035
 
1036 1036
             $html = (string) \preg_replace_callback(
1037 1037
                 '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui',
1038
-                static function ($matches) {
1039
-                    return $matches['start'] .
1040
-                        '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' .
1041
-                        $matches['value'] .
1042
-                        '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' .
1038
+                static function($matches) {
1039
+                    return $matches['start'].
1040
+                        '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'.
1041
+                        $matches['value'].
1042
+                        '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'.
1043 1043
                         $matches['end'];
1044 1044
                 },
1045 1045
                 $html
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 
1052 1052
             $html = (string) \preg_replace_callback(
1053 1053
                 '/(?<start>[^<]*)?(?<broken>(?:<\/\w+(?:\s+\w+=\"[^"]+\")*+[^<]+>)+)(?<end>.*)/u',
1054
-                static function ($matches) {
1054
+                static function($matches) {
1055 1055
                     $matches['broken'] = \str_replace(
1056 1056
                         ['°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'],
1057 1057
                         ['</', '<', '>'],
@@ -1059,9 +1059,9 @@  discard block
 block discarded – undo
1059 1059
                     );
1060 1060
 
1061 1061
                     self::$domBrokenReplaceHelper['orig'][] = $matches['broken'];
1062
-                    self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['broken']);
1062
+                    self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['broken']);
1063 1063
 
1064
-                    return $matches['start'] . $matchesHash . $matches['end'];
1064
+                    return $matches['start'].$matchesHash.$matches['end'];
1065 1065
                 },
1066 1066
                 $html
1067 1067
             );
@@ -1088,16 +1088,16 @@  discard block
 block discarded – undo
1088 1088
         $regExSpecialSvg = '/\((["\'])?(?<start>data:image\/svg.*)<svg(?<attr>[^>]*?)>(?<content>.*)<\/svg>\1\)/isU';
1089 1089
         $htmlTmp = \preg_replace_callback(
1090 1090
             $regExSpecialSvg,
1091
-            static function ($svgs) {
1091
+            static function($svgs) {
1092 1092
                 if (empty($svgs['content'])) {
1093 1093
                     return $svgs[0];
1094 1094
                 }
1095 1095
 
1096
-                $content = '<svg' . $svgs['attr'] . '>' . $svgs['content'] . '</svg>';
1096
+                $content = '<svg'.$svgs['attr'].'>'.$svgs['content'].'</svg>';
1097 1097
                 self::$domBrokenReplaceHelper['orig'][] = $content;
1098
-                self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($content);
1098
+                self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($content);
1099 1099
 
1100
-                return '(' . $svgs[1] . $svgs['start'] . $matchesHash . $svgs[1] . ')';
1100
+                return '('.$svgs[1].$svgs['start'].$matchesHash.$svgs[1].')';
1101 1101
             },
1102 1102
             $html
1103 1103
         );
@@ -1116,14 +1116,14 @@  discard block
 block discarded – undo
1116 1116
     {
1117 1117
         // regEx for e.g.: [<script id="elements-image-1" type="text/html">...</script>]
1118 1118
         $tags = \implode('|', \array_map(
1119
-            static function ($value) {
1119
+            static function($value) {
1120 1120
                 return \preg_quote($value, '/');
1121 1121
             },
1122 1122
             $this->specialScriptTags
1123 1123
         ));
1124 1124
         $html = (string) \preg_replace_callback(
1125
-            '/(?<start>(<script [^>]*type=["\']?(?:' . $tags . ')+[^>]*>))(?<innerContent>.*)(?<end><\/script>)/isU',
1126
-            function ($matches) {
1125
+            '/(?<start>(<script [^>]*type=["\']?(?:'.$tags.')+[^>]*>))(?<innerContent>.*)(?<end><\/script>)/isU',
1126
+            function($matches) {
1127 1127
 
1128 1128
                 // Check for logic in special script tags, like [<% _.each(tierPrices, function(item, key) { %>],
1129 1129
                 // because often this looks like non-valid html in the template itself.
@@ -1133,18 +1133,18 @@  discard block
 block discarded – undo
1133 1133
                         $matches['innerContent'] = \str_replace('<\/', '</', $matches['innerContent']);
1134 1134
 
1135 1135
                         self::$domBrokenReplaceHelper['orig'][] = $matches['innerContent'];
1136
-                        self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['innerContent']);
1136
+                        self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['innerContent']);
1137 1137
 
1138
-                        return $matches['start'] . $matchesHash . $matches['end'];
1138
+                        return $matches['start'].$matchesHash.$matches['end'];
1139 1139
                     }
1140 1140
                 }
1141 1141
 
1142 1142
                 // remove the html5 fallback
1143 1143
                 $matches[0] = \str_replace('<\/', '</', $matches[0]);
1144 1144
 
1145
-                $specialNonScript = '<' . self::$domHtmlSpecialScriptHelper . \substr($matches[0], \strlen('<script'));
1145
+                $specialNonScript = '<'.self::$domHtmlSpecialScriptHelper.\substr($matches[0], \strlen('<script'));
1146 1146
 
1147
-                return \substr($specialNonScript, 0, -\strlen('</script>')) . '</' . self::$domHtmlSpecialScriptHelper . '>';
1147
+                return \substr($specialNonScript, 0, -\strlen('</script>')).'</'.self::$domHtmlSpecialScriptHelper.'>';
1148 1148
             },
1149 1149
             $html
1150 1150
         );
Please login to merge, or discard this patch.