@@ -465,6 +465,6 @@ |
||
465 | 465 | */ |
466 | 466 | public function delete() |
467 | 467 | { |
468 | - $this->outertext=''; |
|
468 | + $this->outertext = ''; |
|
469 | 469 | } |
470 | 470 | } |
@@ -9,7 +9,7 @@ |
||
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: |
@@ -164,8 +164,8 @@ discard block |
||
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 |
||
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 | } |
@@ -172,7 +172,7 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -90,7 +90,7 @@ discard block |
||
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 | /** |
@@ -415,12 +415,12 @@ discard block |
||
415 | 415 | $regExSpecialScript = '/<script(?<attr>[^>]*?)>(?<content>.*)<\/script>/isU'; |
416 | 416 | $htmlTmp = \preg_replace_callback( |
417 | 417 | $regExSpecialScript, |
418 | - static function ($scripts) { |
|
418 | + static function($scripts) { |
|
419 | 419 | if (empty($scripts['content'])) { |
420 | 420 | return $scripts[0]; |
421 | 421 | } |
422 | 422 | |
423 | - return '<script' . $scripts['attr'] . '>' . \str_replace('</', '<\/', $scripts['content']) . '</script>'; |
|
423 | + return '<script'.$scripts['attr'].'>'.\str_replace('</', '<\/', $scripts['content']).'</script>'; |
|
424 | 424 | }, |
425 | 425 | $html |
426 | 426 | ); |
@@ -449,14 +449,14 @@ discard block |
||
449 | 449 | self::$domReplaceHelper['orig'] |
450 | 450 | ); |
451 | 451 | |
452 | - $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start'] = '<' . self::$domHtmlWrapperHelper . '>'; |
|
453 | - $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end'] = '</' . self::$domHtmlWrapperHelper . '>'; |
|
452 | + $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start'] = '<'.self::$domHtmlWrapperHelper.'>'; |
|
453 | + $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end'] = '</'.self::$domHtmlWrapperHelper.'>'; |
|
454 | 454 | |
455 | 455 | $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__start'] = ''; |
456 | 456 | $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__end'] = ''; |
457 | 457 | |
458 | - $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__start'] = '<' . self::$domHtmlSpecialScriptHelper; |
|
459 | - $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__end'] = '</' . self::$domHtmlSpecialScriptHelper . '>'; |
|
458 | + $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__start'] = '<'.self::$domHtmlSpecialScriptHelper; |
|
459 | + $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__end'] = '</'.self::$domHtmlSpecialScriptHelper.'>'; |
|
460 | 460 | |
461 | 461 | $DOM_REPLACE__HELPER_CACHE['orig']['html_special_script__start'] = '<script'; |
462 | 462 | $DOM_REPLACE__HELPER_CACHE['orig']['html_special_script__end'] = '</script>'; |
@@ -23,7 +23,7 @@ discard block |
||
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 |
||
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 | } |
@@ -204,7 +204,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | ); |