@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | HTML; |
16 | 16 | |
17 | 17 | $html = HtmlDomParser::str_get_html($str); |
18 | -echo $html->find('div div div', 0)->innertext . '<br>'; // result: "ok" |
|
18 | +echo $html->find('div div div', 0)->innertext.'<br>'; // result: "ok" |
|
19 | 19 | |
20 | 20 | // ----------------------------------------------------------------------------- |
21 | 21 | // nested selector |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $html = HtmlDomParser::str_get_html($str); |
34 | 34 | foreach ($html->find('ul') as $ul) { |
35 | 35 | foreach ($ul->find('li') as $li) { |
36 | - echo $li->innertext . '<br>'; |
|
36 | + echo $li->innertext.'<br>'; |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | $html = HtmlDomParser::str_get_html($str); |
51 | 51 | foreach ($html->find('input[type=checkbox]') as $checkbox) { |
52 | 52 | if ($checkbox->checked) { |
53 | - echo $checkbox->name . ' is checked<br>'; |
|
53 | + echo $checkbox->name.' is checked<br>'; |
|
54 | 54 | } else { |
55 | - echo $checkbox->name . ' is not checked<br>'; |
|
55 | + echo $checkbox->name.' is not checked<br>'; |
|
56 | 56 | } |
57 | 57 | } |
@@ -9,36 +9,36 @@ |
||
9 | 9 | |
10 | 10 | // find all link |
11 | 11 | foreach ($html->find('a') as $e) { |
12 | - echo $e->href . '<br>'; |
|
12 | + echo $e->href.'<br>'; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | // find all image |
16 | 16 | foreach ($html->find('img') as $e) { |
17 | - echo $e->src . '<br>'; |
|
17 | + echo $e->src.'<br>'; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | // find all image with full tag |
21 | 21 | foreach ($html->find('img') as $e) { |
22 | - echo $e->outertext . '<br>'; |
|
22 | + echo $e->outertext.'<br>'; |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | // find all div tags with id=gbar |
26 | 26 | foreach ($html->find('div#gbar') as $e) { |
27 | - echo $e->innertext . '<br>'; |
|
27 | + echo $e->innertext.'<br>'; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | // find all span tags with class=gb1 |
31 | 31 | foreach ($html->find('span.gb1') as $e) { |
32 | - echo $e->outertext . '<br>'; |
|
32 | + echo $e->outertext.'<br>'; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // find all td tags with attribite align=center |
36 | 36 | foreach ($html->find('td[align=center]') as $e) { |
37 | - echo $e->innertext . '<br>'; |
|
37 | + echo $e->innertext.'<br>'; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // extract text from table |
41 | -echo $html->find('td[align="center"]', 1)->plaintext . '<br><hr>'; |
|
41 | +echo $html->find('td[align="center"]', 1)->plaintext.'<br><hr>'; |
|
42 | 42 | |
43 | 43 | // extract text from HTML |
44 | 44 | echo $html->plaintext; |
@@ -535,10 +535,10 @@ |
||
535 | 535 | '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui', |
536 | 536 | static function ($matches) { |
537 | 537 | return $matches['start'] . |
538 | - '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . |
|
539 | - $matches['value'] . |
|
540 | - '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . |
|
541 | - $matches['end']; |
|
538 | + '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . |
|
539 | + $matches['value'] . |
|
540 | + '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . |
|
541 | + $matches['end']; |
|
542 | 542 | }, |
543 | 543 | $html |
544 | 544 | ); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return \call_user_func_array([$this, self::$functionAliases[$name]], $arguments); |
122 | 122 | } |
123 | 123 | |
124 | - throw new \BadMethodCallException('Method does not exist: ' . $name); |
|
124 | + throw new \BadMethodCallException('Method does not exist: '.$name); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | || |
286 | 286 | $this->keepBrokenHtml |
287 | 287 | ) { |
288 | - $html = '<' . self::$domHtmlWrapperHelper . '>' . $html . '</' . self::$domHtmlWrapperHelper . '>'; |
|
288 | + $html = '<'.self::$domHtmlWrapperHelper.'>'.$html.'</'.self::$domHtmlWrapperHelper.'>'; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | $html = self::replaceToPreserveHtmlEntities($html); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | /** @noinspection StringFragmentMisplacedInspection */ |
308 | 308 | if (\stripos('<?xml', $html) !== 0) { |
309 | 309 | $xmlHackUsed = true; |
310 | - $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; |
|
310 | + $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | $this->document->loadHTML($html, $optionsXml); |
@@ -788,11 +788,11 @@ discard block |
||
788 | 788 | |
789 | 789 | $html = (string) \preg_replace_callback( |
790 | 790 | '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui', |
791 | - static function ($matches) { |
|
792 | - return $matches['start'] . |
|
793 | - '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . |
|
794 | - $matches['value'] . |
|
795 | - '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . |
|
791 | + static function($matches) { |
|
792 | + return $matches['start']. |
|
793 | + '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'. |
|
794 | + $matches['value']. |
|
795 | + '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'. |
|
796 | 796 | $matches['end']; |
797 | 797 | }, |
798 | 798 | $html |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | |
805 | 805 | $html = (string) \preg_replace_callback( |
806 | 806 | '/(?<start>[^<]*)?(?<broken>(?:(?:<\/\w+(?:\s+\w+=\\"[^\"]+\\")*+)(?:[^<]+)>)+)(?<end>.*)/u', |
807 | - static function ($matches) { |
|
807 | + static function($matches) { |
|
808 | 808 | $matches['broken'] = \str_replace( |
809 | 809 | ['°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'], |
810 | 810 | ['</', '<', '>'], |
@@ -812,9 +812,9 @@ discard block |
||
812 | 812 | ); |
813 | 813 | |
814 | 814 | self::$domBrokenReplaceHelper['orig'][] = $matches['broken']; |
815 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['broken']); |
|
815 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['broken']); |
|
816 | 816 | |
817 | - return $matches['start'] . $matchesHash . $matches['end']; |
|
817 | + return $matches['start'].$matchesHash.$matches['end']; |
|
818 | 818 | }, |
819 | 819 | $html |
820 | 820 | ); |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | // regEx for e.g.: [<script id="elements-image-1" type="text/html">...</script>] |
836 | 836 | $html = (string) \preg_replace_callback( |
837 | 837 | '/(?<start>((?:<script) [^>]*type=(?:["\'])?(?:text\/html|text\/x-custom-template)+(?:[^>]*)>))(?<innerContent>.*)(?<end><\/script>)/isU', |
838 | - static function ($matches) { |
|
838 | + static function($matches) { |
|
839 | 839 | |
840 | 840 | if ( |
841 | 841 | strpos($matches['innerContent'], '+') === false |
@@ -849,8 +849,8 @@ discard block |
||
849 | 849 | // remove the html5 fallback |
850 | 850 | $matches[0] = \str_replace('<\/', '</', $matches[0]); |
851 | 851 | |
852 | - $specialNonScript = '<' . self::$domHtmlSpecialScriptHelper . \substr($matches[0], \strlen('<script')); |
|
853 | - $specialNonScript = \substr($specialNonScript, 0, -\strlen('</script>')) . '</' . self::$domHtmlSpecialScriptHelper . '>'; |
|
852 | + $specialNonScript = '<'.self::$domHtmlSpecialScriptHelper.\substr($matches[0], \strlen('<script')); |
|
853 | + $specialNonScript = \substr($specialNonScript, 0, -\strlen('</script>')).'</'.self::$domHtmlSpecialScriptHelper.'>'; |
|
854 | 854 | |
855 | 855 | return $specialNonScript; |
856 | 856 | } |
@@ -859,9 +859,9 @@ discard block |
||
859 | 859 | $matches['innerContent'] = \str_replace('<\/', '</', $matches['innerContent']); |
860 | 860 | |
861 | 861 | self::$domBrokenReplaceHelper['orig'][] = $matches['innerContent']; |
862 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = '' . self::$domHtmlBrokenHtmlHelper . '' . \crc32($matches['innerContent']); |
|
862 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = ''.self::$domHtmlBrokenHtmlHelper.''.\crc32($matches['innerContent']); |
|
863 | 863 | |
864 | - return $matches['start'] . $matchesHash . $matches['end']; |
|
864 | + return $matches['start'].$matchesHash.$matches['end']; |
|
865 | 865 | }, |
866 | 866 | $html |
867 | 867 | ); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * Returns the first child of node. |
99 | 99 | * |
100 | - * @return SimpleHtmlDomInterface|null |
|
100 | + * @return null|SimpleHtmlDom |
|
101 | 101 | */ |
102 | 102 | public function firstChild() |
103 | 103 | { |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | /** |
332 | 332 | * Returns the last child of node. |
333 | 333 | * |
334 | - * @return SimpleHtmlDomInterface|null |
|
334 | + * @return null|SimpleHtmlDom |
|
335 | 335 | */ |
336 | 336 | public function lastChild() |
337 | 337 | { |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | /** |
349 | 349 | * Returns the next sibling of node. |
350 | 350 | * |
351 | - * @return SimpleHtmlDomInterface|null |
|
351 | + * @return null|SimpleHtmlDom |
|
352 | 352 | */ |
353 | 353 | public function nextSibling() |
354 | 354 | { |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | /** |
388 | 388 | * Returns the previous sibling of node. |
389 | 389 | * |
390 | - * @return SimpleHtmlDomInterface|null |
|
390 | + * @return null|SimpleHtmlDom |
|
391 | 391 | */ |
392 | 392 | public function previousSibling() |
393 | 393 | { |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | $tmpStr = $this->normalizeStringForComparision($string); |
418 | 418 | if ($tmpDomString !== $tmpStr) { |
419 | 419 | throw new \RuntimeException( |
420 | - 'Not valid HTML fragment!' . "\n" . |
|
421 | - $tmpDomString . "\n" . |
|
420 | + 'Not valid HTML fragment!'."\n". |
|
421 | + $tmpDomString."\n". |
|
422 | 422 | $tmpStr |
423 | 423 | ); |
424 | 424 | } |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | $tmpStr = $this->normalizeStringForComparision($string); |
491 | 491 | if ($tmpDomOuterTextString !== $tmpStr) { |
492 | 492 | throw new \RuntimeException( |
493 | - 'Not valid HTML fragment!' . "\n" |
|
494 | - . $tmpDomOuterTextString . "\n" . |
|
493 | + 'Not valid HTML fragment!'."\n" |
|
494 | + . $tmpDomOuterTextString."\n". |
|
495 | 495 | $tmpStr |
496 | 496 | ); |
497 | 497 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | /** |
376 | 376 | * Returns the first child of node. |
377 | 377 | * |
378 | - * @return SimpleXmlDomInterface|null |
|
378 | + * @return null|SimpleXmlDom |
|
379 | 379 | */ |
380 | 380 | public function firstChild() |
381 | 381 | { |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | /** |
534 | 534 | * Returns the last child of node. |
535 | 535 | * |
536 | - * @return SimpleXmlDomInterface|null |
|
536 | + * @return null|SimpleXmlDom |
|
537 | 537 | */ |
538 | 538 | public function lastChild() |
539 | 539 | { |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | /** |
551 | 551 | * Returns the next sibling of node. |
552 | 552 | * |
553 | - * @return SimpleXmlDomInterface|null |
|
553 | + * @return null|SimpleXmlDom |
|
554 | 554 | */ |
555 | 555 | public function nextSibling() |
556 | 556 | { |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | /** |
578 | 578 | * Returns the previous sibling of node. |
579 | 579 | * |
580 | - * @return SimpleXmlDomInterface|null |
|
580 | + * @return null|SimpleXmlDom |
|
581 | 581 | */ |
582 | 582 | public function previousSibling() |
583 | 583 | { |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | $tmpStr = $this->normalizeStringForComparision($string); |
418 | 418 | if ($tmpDomString !== $tmpStr) { |
419 | 419 | throw new \RuntimeException( |
420 | - 'Not valid HTML fragment!' . "\n" . |
|
421 | - $tmpDomString . "\n" . |
|
420 | + 'Not valid HTML fragment!'."\n". |
|
421 | + $tmpDomString."\n". |
|
422 | 422 | $tmpStr |
423 | 423 | ); |
424 | 424 | } |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | $tmpStr = $this->normalizeStringForComparision($string); |
491 | 491 | if ($tmpDomOuterTextString !== $tmpStr) { |
492 | 492 | throw new \RuntimeException( |
493 | - 'Not valid HTML fragment!' . "\n" |
|
494 | - . $tmpDomOuterTextString . "\n" . |
|
493 | + 'Not valid HTML fragment!'."\n" |
|
494 | + . $tmpDomOuterTextString."\n". |
|
495 | 495 | $tmpStr |
496 | 496 | ); |
497 | 497 | } |
@@ -151,7 +151,7 @@ |
||
151 | 151 | /** @noinspection StringFragmentMisplacedInspection */ |
152 | 152 | if (\stripos('<?xml', $xml) !== 0) { |
153 | 153 | $xmlHackUsed = true; |
154 | - $xml = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $xml; |
|
154 | + $xml = '<?xml encoding="'.$this->getEncoding().'" ?>'.$xml; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | $this->document->loadXML($xml, $optionsXml); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | return \call_user_func_array([$this, self::$functionAliases[$name]], $arguments); |
84 | 84 | } |
85 | 85 | |
86 | - throw new \BadMethodCallException('Method does not exist: ' . $name); |
|
86 | + throw new \BadMethodCallException('Method does not exist: '.$name); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -389,12 +389,12 @@ discard block |
||
389 | 389 | $regExSpecialScript = '/<(script)(?<attr>[^>]*)>(?<content>.*)<\/\1>/isU'; |
390 | 390 | $htmlTmp = \preg_replace_callback( |
391 | 391 | $regExSpecialScript, |
392 | - static function ($scripts) { |
|
392 | + static function($scripts) { |
|
393 | 393 | if (empty($scripts['content'])) { |
394 | 394 | return $scripts[0]; |
395 | 395 | } |
396 | 396 | |
397 | - return '<script' . $scripts['attr'] . '>' . \str_replace('</', '<\/', $scripts['content']) . '</script>'; |
|
397 | + return '<script'.$scripts['attr'].'>'.\str_replace('</', '<\/', $scripts['content']).'</script>'; |
|
398 | 398 | }, |
399 | 399 | $html |
400 | 400 | ); |
@@ -423,14 +423,14 @@ discard block |
||
423 | 423 | self::$domReplaceHelper['orig'] |
424 | 424 | ); |
425 | 425 | |
426 | - $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start'] = '<' . self::$domHtmlWrapperHelper . '>'; |
|
427 | - $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end'] = '</' . self::$domHtmlWrapperHelper . '>'; |
|
426 | + $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start'] = '<'.self::$domHtmlWrapperHelper.'>'; |
|
427 | + $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end'] = '</'.self::$domHtmlWrapperHelper.'>'; |
|
428 | 428 | |
429 | 429 | $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__start'] = ''; |
430 | 430 | $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__end'] = ''; |
431 | 431 | |
432 | - $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__start'] = '<' . self::$domHtmlSpecialScriptHelper; |
|
433 | - $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__end'] = '</' . self::$domHtmlSpecialScriptHelper . '>'; |
|
432 | + $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__start'] = '<'.self::$domHtmlSpecialScriptHelper; |
|
433 | + $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__end'] = '</'.self::$domHtmlSpecialScriptHelper.'>'; |
|
434 | 434 | |
435 | 435 | $DOM_REPLACE__HELPER_CACHE['orig']['html_special_script__start'] = '<script'; |
436 | 436 | $DOM_REPLACE__HELPER_CACHE['orig']['html_special_script__end'] = '</script>'; |