@@ -14,8 +14,8 @@  | 
                                                    ||
| 14 | 14 | |
| 15 | 15 | $document = new HtmlDomParser($html);  | 
                                                        
| 16 | 16 | |
| 17 | -$tags = $document->find( 'style' );  | 
                                                        |
| 18 | -foreach ( $tags as $tag ) { | 
                                                        |
| 17 | +$tags = $document->find('style'); | 
                                                        |
| 18 | +foreach ($tags as $tag) { | 
                                                        |
| 19 | 19 | // INFO: here we need to use "innerhtmlKeep" instead of "innerhtml", so that we keep the svg-hack  | 
                                                        
| 20 | 20 |      $tag->innerhtmlKeep .= ' .test{color: red;} '; | 
                                                        
| 21 | 21 | }  | 
                                                        
@@ -199,7 +199,7 @@ discard block  | 
                                                    ||
| 199 | 199 | return \call_user_func_array([$this, self::$functionAliases[$name]], $arguments);  | 
                                                        
| 200 | 200 | }  | 
                                                        
| 201 | 201 | |
| 202 | -        throw new \BadMethodCallException('Method does not exist: ' . $name); | 
                                                        |
| 202 | +        throw new \BadMethodCallException('Method does not exist: '.$name); | 
                                                        |
| 203 | 203 | }  | 
                                                        
| 204 | 204 | |
| 205 | 205 | /**  | 
                                                        
@@ -370,7 +370,7 @@ discard block  | 
                                                    ||
| 370 | 370 | &&  | 
                                                        
| 371 | 371 | \trim($matches_after_html[1])  | 
                                                        
| 372 | 372 |              ) { | 
                                                        
| 373 | - $html = \str_replace($matches_after_html[0], $matches_after_html[1] . '</html>', $html);  | 
                                                        |
| 373 | + $html = \str_replace($matches_after_html[0], $matches_after_html[1].'</html>', $html);  | 
                                                        |
| 374 | 374 | }  | 
                                                        
| 375 | 375 | }  | 
                                                        
| 376 | 376 | |
@@ -389,11 +389,11 @@ discard block  | 
                                                    ||
| 389 | 389 | }  | 
                                                        
| 390 | 390 | |
| 391 | 391 | $html = \str_replace(  | 
                                                        
| 392 | -            \array_map(static function ($e) { | 
                                                        |
| 393 | - return '<' . $e . '>';  | 
                                                        |
| 392 | +            \array_map(static function($e) { | 
                                                        |
| 393 | + return '<'.$e.'>';  | 
                                                        |
| 394 | 394 | }, $this->selfClosingTags),  | 
                                                        
| 395 | -            \array_map(static function ($e) { | 
                                                        |
| 396 | - return '<' . $e . '/>';  | 
                                                        |
| 395 | +            \array_map(static function($e) { | 
                                                        |
| 396 | + return '<'.$e.'/>';  | 
                                                        |
| 397 | 397 | }, $this->selfClosingTags),  | 
                                                        
| 398 | 398 | $html  | 
                                                        
| 399 | 399 | );  | 
                                                        
@@ -434,7 +434,7 @@ discard block  | 
                                                    ||
| 434 | 434 | $this->keepBrokenHtml  | 
                                                        
| 435 | 435 | )  | 
                                                        
| 436 | 436 |          ) { | 
                                                        
| 437 | - $html = '<' . self::$domHtmlWrapperHelper . '>' . $html . '</' . self::$domHtmlWrapperHelper . '>';  | 
                                                        |
| 437 | + $html = '<'.self::$domHtmlWrapperHelper.'>'.$html.'</'.self::$domHtmlWrapperHelper.'>';  | 
                                                        |
| 438 | 438 | }  | 
                                                        
| 439 | 439 | |
| 440 | 440 | $html = self::replaceToPreserveHtmlEntities($html);  | 
                                                        
@@ -456,7 +456,7 @@ discard block  | 
                                                    ||
| 456 | 456 | /** @noinspection StringFragmentMisplacedInspection */  | 
                                                        
| 457 | 457 |              if (\stripos('<?xml', $html) !== 0) { | 
                                                        
| 458 | 458 | $xmlHackUsed = true;  | 
                                                        
| 459 | - $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html;  | 
                                                        |
| 459 | + $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html;  | 
                                                        |
| 460 | 460 | }  | 
                                                        
| 461 | 461 | |
| 462 | 462 |              if ($html !== '') { | 
                                                        
@@ -679,8 +679,8 @@ discard block  | 
                                                    ||
| 679 | 679 | |
| 680 | 680 | // https://bugs.php.net/bug.php?id=73175  | 
                                                        
| 681 | 681 | $content = \str_replace(  | 
                                                        
| 682 | -            \array_map(static function ($e) { | 
                                                        |
| 683 | - return '</' . $e . '>';  | 
                                                        |
| 682 | +            \array_map(static function($e) { | 
                                                        |
| 683 | + return '</'.$e.'>';  | 
                                                        |
| 684 | 684 | }, $this->selfClosingTags),  | 
                                                        
| 685 | 685 | '',  | 
                                                        
| 686 | 686 | $content  | 
                                                        
@@ -999,11 +999,11 @@ discard block  | 
                                                    ||
| 999 | 999 | |
| 1000 | 1000 | $html = (string) \preg_replace_callback(  | 
                                                        
| 1001 | 1001 | '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui',  | 
                                                        
| 1002 | -                static function ($matches) { | 
                                                        |
| 1003 | - return $matches['start'] .  | 
                                                        |
| 1004 | - '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' .  | 
                                                        |
| 1005 | - $matches['value'] .  | 
                                                        |
| 1006 | - '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' .  | 
                                                        |
| 1002 | +                static function($matches) { | 
                                                        |
| 1003 | + return $matches['start'].  | 
                                                        |
| 1004 | + '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'.  | 
                                                        |
| 1005 | + $matches['value'].  | 
                                                        |
| 1006 | + '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'.  | 
                                                        |
| 1007 | 1007 | $matches['end'];  | 
                                                        
| 1008 | 1008 | },  | 
                                                        
| 1009 | 1009 | $html  | 
                                                        
@@ -1015,7 +1015,7 @@ discard block  | 
                                                    ||
| 1015 | 1015 | |
| 1016 | 1016 | $html = (string) \preg_replace_callback(  | 
                                                        
| 1017 | 1017 | '/(?<start>[^<]*)?(?<broken>(?:<\/\w+(?:\s+\w+=\"[^"]+\")*+[^<]+>)+)(?<end>.*)/u',  | 
                                                        
| 1018 | -                static function ($matches) { | 
                                                        |
| 1018 | +                static function($matches) { | 
                                                        |
| 1019 | 1019 | $matches['broken'] = \str_replace(  | 
                                                        
| 1020 | 1020 | ['°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'],  | 
                                                        
| 1021 | 1021 | ['</', '<', '>'],  | 
                                                        
@@ -1023,9 +1023,9 @@ discard block  | 
                                                    ||
| 1023 | 1023 | );  | 
                                                        
| 1024 | 1024 | |
| 1025 | 1025 | self::$domBrokenReplaceHelper['orig'][] = $matches['broken'];  | 
                                                        
| 1026 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['broken']);  | 
                                                        |
| 1026 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['broken']);  | 
                                                        |
| 1027 | 1027 | |
| 1028 | - return $matches['start'] . $matchesHash . $matches['end'];  | 
                                                        |
| 1028 | + return $matches['start'].$matchesHash.$matches['end'];  | 
                                                        |
| 1029 | 1029 | },  | 
                                                        
| 1030 | 1030 | $html  | 
                                                        
| 1031 | 1031 | );  | 
                                                        
@@ -1052,16 +1052,16 @@ discard block  | 
                                                    ||
| 1052 | 1052 | $regExSpecialSvg = '/\((["\'])?(?<start>data:image\/svg.*)<svg(?<attr>[^>]*?)>(?<content>.*)<\/svg>\1\)/isU';  | 
                                                        
| 1053 | 1053 | $htmlTmp = \preg_replace_callback(  | 
                                                        
| 1054 | 1054 | $regExSpecialSvg,  | 
                                                        
| 1055 | -            static function ($svgs) { | 
                                                        |
| 1055 | +            static function($svgs) { | 
                                                        |
| 1056 | 1056 |                  if (empty($svgs['content'])) { | 
                                                        
| 1057 | 1057 | return $svgs[0];  | 
                                                        
| 1058 | 1058 | }  | 
                                                        
| 1059 | 1059 | |
| 1060 | - $content = '<svg' . $svgs['attr'] . '>' . $svgs['content'] . '</svg>';  | 
                                                        |
| 1060 | + $content = '<svg'.$svgs['attr'].'>'.$svgs['content'].'</svg>';  | 
                                                        |
| 1061 | 1061 | self::$domBrokenReplaceHelper['orig'][] = $content;  | 
                                                        
| 1062 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($content);  | 
                                                        |
| 1062 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($content);  | 
                                                        |
| 1063 | 1063 | |
| 1064 | -                return '(' . $svgs[1] . $svgs['start'] . $matchesHash . $svgs[1] . ')'; | 
                                                        |
| 1064 | +                return '('.$svgs[1].$svgs['start'].$matchesHash.$svgs[1].')'; | 
                                                        |
| 1065 | 1065 | },  | 
                                                        
| 1066 | 1066 | $html  | 
                                                        
| 1067 | 1067 | );  | 
                                                        
@@ -1080,14 +1080,14 @@ discard block  | 
                                                    ||
| 1080 | 1080 |      { | 
                                                        
| 1081 | 1081 | // regEx for e.g.: [<script id="elements-image-1" type="text/html">...</script>]  | 
                                                        
| 1082 | 1082 |          $tags = \implode('|', \array_map( | 
                                                        
| 1083 | -            static function ($value) { | 
                                                        |
| 1083 | +            static function($value) { | 
                                                        |
| 1084 | 1084 | return \preg_quote($value, '/');  | 
                                                        
| 1085 | 1085 | },  | 
                                                        
| 1086 | 1086 | $this->specialScriptTags  | 
                                                        
| 1087 | 1087 | ));  | 
                                                        
| 1088 | 1088 | $html = (string) \preg_replace_callback(  | 
                                                        
| 1089 | - '/(?<start>(<script [^>]*type=["\']?(?:' . $tags . ')+[^>]*>))(?<innerContent>.*)(?<end><\/script>)/isU',  | 
                                                        |
| 1090 | -            function ($matches) { | 
                                                        |
| 1089 | + '/(?<start>(<script [^>]*type=["\']?(?:'.$tags.')+[^>]*>))(?<innerContent>.*)(?<end><\/script>)/isU',  | 
                                                        |
| 1090 | +            function($matches) { | 
                                                        |
| 1091 | 1091 | |
| 1092 | 1092 |                  // Check for logic in special script tags, like [<% _.each(tierPrices, function(item, key) { %>], | 
                                                        
| 1093 | 1093 | // because often this looks like non-valid html in the template itself.  | 
                                                        
@@ -1097,18 +1097,18 @@ discard block  | 
                                                    ||
| 1097 | 1097 |                          $matches['innerContent'] = \str_replace('<\/', '</', $matches['innerContent']); | 
                                                        
| 1098 | 1098 | |
| 1099 | 1099 | self::$domBrokenReplaceHelper['orig'][] = $matches['innerContent'];  | 
                                                        
| 1100 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['innerContent']);  | 
                                                        |
| 1100 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['innerContent']);  | 
                                                        |
| 1101 | 1101 | |
| 1102 | - return $matches['start'] . $matchesHash . $matches['end'];  | 
                                                        |
| 1102 | + return $matches['start'].$matchesHash.$matches['end'];  | 
                                                        |
| 1103 | 1103 | }  | 
                                                        
| 1104 | 1104 | }  | 
                                                        
| 1105 | 1105 | |
| 1106 | 1106 | // remove the html5 fallback  | 
                                                        
| 1107 | 1107 |                  $matches[0] = \str_replace('<\/', '</', $matches[0]); | 
                                                        
| 1108 | 1108 | |
| 1109 | -                $specialNonScript = '<' . self::$domHtmlSpecialScriptHelper . \substr($matches[0], \strlen('<script')); | 
                                                        |
| 1109 | +                $specialNonScript = '<'.self::$domHtmlSpecialScriptHelper.\substr($matches[0], \strlen('<script')); | 
                                                        |
| 1110 | 1110 | |
| 1111 | -                return \substr($specialNonScript, 0, -\strlen('</script>')) . '</' . self::$domHtmlSpecialScriptHelper . '>'; | 
                                                        |
| 1111 | +                return \substr($specialNonScript, 0, -\strlen('</script>')).'</'.self::$domHtmlSpecialScriptHelper.'>'; | 
                                                        |
| 1112 | 1112 | },  | 
                                                        
| 1113 | 1113 | $html  | 
                                                        
| 1114 | 1114 | );  | 
                                                        
@@ -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>';  |