| @@ -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 | ); | 
| @@ -126,7 +126,7 @@ discard block | ||
| 126 | 126 | return \call_user_func_array([$this, self::$functionAliases[$name]], $arguments); | 
| 127 | 127 | } | 
| 128 | 128 | |
| 129 | -        throw new \BadMethodCallException('Method does not exist: ' . $name); | |
| 129 | +        throw new \BadMethodCallException('Method does not exist: '.$name); | |
| 130 | 130 | } | 
| 131 | 131 | |
| 132 | 132 | /** | 
| @@ -294,7 +294,7 @@ discard block | ||
| 294 | 294 | || | 
| 295 | 295 | $this->keepBrokenHtml | 
| 296 | 296 |          ) { | 
| 297 | - $html = '<' . self::$domHtmlWrapperHelper . '>' . $html . '</' . self::$domHtmlWrapperHelper . '>'; | |
| 297 | + $html = '<'.self::$domHtmlWrapperHelper.'>'.$html.'</'.self::$domHtmlWrapperHelper.'>'; | |
| 298 | 298 | } | 
| 299 | 299 | |
| 300 | 300 | $html = self::replaceToPreserveHtmlEntities($html); | 
| @@ -316,7 +316,7 @@ discard block | ||
| 316 | 316 | /** @noinspection StringFragmentMisplacedInspection */ | 
| 317 | 317 |              if (\stripos('<?xml', $html) !== 0) { | 
| 318 | 318 | $xmlHackUsed = true; | 
| 319 | - $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; | |
| 319 | + $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html; | |
| 320 | 320 | } | 
| 321 | 321 | |
| 322 | 322 | $this->document->loadHTML($html, $optionsXml); | 
| @@ -815,11 +815,11 @@ discard block | ||
| 815 | 815 | |
| 816 | 816 | $html = (string) \preg_replace_callback( | 
| 817 | 817 | '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui', | 
| 818 | -                static function ($matches) { | |
| 819 | - return $matches['start'] . | |
| 820 | - '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . | |
| 821 | - $matches['value'] . | |
| 822 | - '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . | |
| 818 | +                static function($matches) { | |
| 819 | + return $matches['start']. | |
| 820 | + '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'. | |
| 821 | + $matches['value']. | |
| 822 | + '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'. | |
| 823 | 823 | $matches['end']; | 
| 824 | 824 | }, | 
| 825 | 825 | $html | 
| @@ -831,7 +831,7 @@ discard block | ||
| 831 | 831 | |
| 832 | 832 | $html = (string) \preg_replace_callback( | 
| 833 | 833 | '/(?<start>[^<]*)?(?<broken>(?:(?:<\/\w+(?:\s+\w+=\\"[^\"]+\\")*+)(?:[^<]+)>)+)(?<end>.*)/u', | 
| 834 | -                static function ($matches) { | |
| 834 | +                static function($matches) { | |
| 835 | 835 | $matches['broken'] = \str_replace( | 
| 836 | 836 | ['°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'], | 
| 837 | 837 | ['</', '<', '>'], | 
| @@ -839,9 +839,9 @@ discard block | ||
| 839 | 839 | ); | 
| 840 | 840 | |
| 841 | 841 | self::$domBrokenReplaceHelper['orig'][] = $matches['broken']; | 
| 842 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['broken']); | |
| 842 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['broken']); | |
| 843 | 843 | |
| 844 | - return $matches['start'] . $matchesHash . $matches['end']; | |
| 844 | + return $matches['start'].$matchesHash.$matches['end']; | |
| 845 | 845 | }, | 
| 846 | 846 | $html | 
| 847 | 847 | ); | 
| @@ -862,7 +862,7 @@ discard block | ||
| 862 | 862 | // regEx for e.g.: [<script id="elements-image-1" type="text/html">...</script>] | 
| 863 | 863 | $html = (string) \preg_replace_callback( | 
| 864 | 864 | '/(?<start>((?:<script) [^>]*type=(?:["\'])?(?:text\/html|text\/x-custom-template)+(?:[^>]*)>))(?<innerContent>.*)(?<end><\/script>)/isU', | 
| 865 | -            static function ($matches) { | |
| 865 | +            static function($matches) { | |
| 866 | 866 | if ( | 
| 867 | 867 | \strpos($matches['innerContent'], '+') === false | 
| 868 | 868 | && | 
| @@ -875,18 +875,18 @@ discard block | ||
| 875 | 875 | // remove the html5 fallback | 
| 876 | 876 |                      $matches[0] = \str_replace('<\/', '</', $matches[0]); | 
| 877 | 877 | |
| 878 | -                    $specialNonScript = '<' . self::$domHtmlSpecialScriptHelper . \substr($matches[0], \strlen('<script')); | |
| 878 | +                    $specialNonScript = '<'.self::$domHtmlSpecialScriptHelper.\substr($matches[0], \strlen('<script')); | |
| 879 | 879 | |
| 880 | -                    return \substr($specialNonScript, 0, -\strlen('</script>')) . '</' . self::$domHtmlSpecialScriptHelper . '>'; | |
| 880 | +                    return \substr($specialNonScript, 0, -\strlen('</script>')).'</'.self::$domHtmlSpecialScriptHelper.'>'; | |
| 881 | 881 | } | 
| 882 | 882 | |
| 883 | 883 | // remove the html5 fallback | 
| 884 | 884 |                  $matches['innerContent'] = \str_replace('<\/', '</', $matches['innerContent']); | 
| 885 | 885 | |
| 886 | 886 | self::$domBrokenReplaceHelper['orig'][] = $matches['innerContent']; | 
| 887 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = '' . self::$domHtmlBrokenHtmlHelper . '' . \crc32($matches['innerContent']); | |
| 887 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = ''.self::$domHtmlBrokenHtmlHelper.''.\crc32($matches['innerContent']); | |
| 888 | 888 | |
| 889 | - return $matches['start'] . $matchesHash . $matches['end']; | |
| 889 | + return $matches['start'].$matchesHash.$matches['end']; | |
| 890 | 890 | }, | 
| 891 | 891 | $html | 
| 892 | 892 | ); | 
| @@ -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 | } | 
| @@ -444,7 +444,7 @@ discard block | ||
| 444 | 444 | /** | 
| 445 | 445 | * Returns the first child of node. | 
| 446 | 446 | * | 
| 447 | - * @return SimpleHtmlDomInterface|null | |
| 447 | + * @return null|SimpleHtmlDom | |
| 448 | 448 | */ | 
| 449 | 449 | public function firstChild() | 
| 450 | 450 |      { | 
| @@ -590,7 +590,7 @@ discard block | ||
| 590 | 590 | /** | 
| 591 | 591 | * Returns the last child of node. | 
| 592 | 592 | * | 
| 593 | - * @return SimpleHtmlDomInterface|null | |
| 593 | + * @return null|SimpleHtmlDom | |
| 594 | 594 | */ | 
| 595 | 595 | public function lastChild() | 
| 596 | 596 |      { | 
| @@ -607,7 +607,7 @@ discard block | ||
| 607 | 607 | /** | 
| 608 | 608 | * Returns the next sibling of node. | 
| 609 | 609 | * | 
| 610 | - * @return SimpleHtmlDomInterface|null | |
| 610 | + * @return null|SimpleHtmlDom | |
| 611 | 611 | */ | 
| 612 | 612 | public function nextSibling() | 
| 613 | 613 |      { | 
| @@ -624,7 +624,7 @@ discard block | ||
| 624 | 624 | /** | 
| 625 | 625 | * Returns the next sibling of node. | 
| 626 | 626 | * | 
| 627 | - * @return SimpleHtmlDomInterface|null | |
| 627 | + * @return null|SimpleHtmlDom | |
| 628 | 628 | */ | 
| 629 | 629 | public function nextNonWhitespaceSibling() | 
| 630 | 630 |      { | 
| @@ -656,7 +656,7 @@ discard block | ||
| 656 | 656 | /** | 
| 657 | 657 | * Returns the previous sibling of node. | 
| 658 | 658 | * | 
| 659 | - * @return SimpleHtmlDomInterface|null | |
| 659 | + * @return null|SimpleHtmlDom | |
| 660 | 660 | */ | 
| 661 | 661 | public function previousSibling() | 
| 662 | 662 |      { | 
| @@ -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 | } | 
| @@ -418,7 +418,7 @@ discard block | ||
| 418 | 418 | /** | 
| 419 | 419 | * Returns the first child of node. | 
| 420 | 420 | * | 
| 421 | - * @return SimpleXmlDomInterface|null | |
| 421 | + * @return null|SimpleXmlDom | |
| 422 | 422 | */ | 
| 423 | 423 | public function firstChild() | 
| 424 | 424 |      { | 
| @@ -576,7 +576,7 @@ discard block | ||
| 576 | 576 | /** | 
| 577 | 577 | * Returns the last child of node. | 
| 578 | 578 | * | 
| 579 | - * @return SimpleXmlDomInterface|null | |
| 579 | + * @return null|SimpleXmlDom | |
| 580 | 580 | */ | 
| 581 | 581 | public function lastChild() | 
| 582 | 582 |      { | 
| @@ -593,7 +593,7 @@ discard block | ||
| 593 | 593 | /** | 
| 594 | 594 | * Returns the next sibling of node. | 
| 595 | 595 | * | 
| 596 | - * @return SimpleXmlDomInterface|null | |
| 596 | + * @return null|SimpleXmlDom | |
| 597 | 597 | */ | 
| 598 | 598 | public function nextSibling() | 
| 599 | 599 |      { | 
| @@ -610,7 +610,7 @@ discard block | ||
| 610 | 610 | /** | 
| 611 | 611 | * Returns the next sibling of node. | 
| 612 | 612 | * | 
| 613 | - * @return SimpleXmlDomInterface|null | |
| 613 | + * @return null|SimpleXmlDom | |
| 614 | 614 | */ | 
| 615 | 615 | public function nextNonWhitespaceSibling() | 
| 616 | 616 |      { | 
| @@ -642,7 +642,7 @@ discard block | ||
| 642 | 642 | /** | 
| 643 | 643 | * Returns the previous sibling of node. | 
| 644 | 644 | * | 
| 645 | - * @return SimpleXmlDomInterface|null | |
| 645 | + * @return null|SimpleXmlDom | |
| 646 | 646 | */ | 
| 647 | 647 | public function previousSibling() | 
| 648 | 648 |      { | 
| @@ -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>'; | 
| @@ -65,7 +65,7 @@ | ||
| 65 | 65 | return (string) $this; | 
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | -        throw new \InvalidArgumentException('Undefined property: $' . $name); | |
| 68 | +        throw new \InvalidArgumentException('Undefined property: $'.$name); | |
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | 71 | /** | 
| @@ -41,5 +41,5 @@ | ||
| 41 | 41 | $document = new \voku\helper\HtmlDomParser($html); | 
| 42 | 42 | |
| 43 | 43 |  foreach (find_contains($document, '.lall', 'foo') as $child_dom) { | 
| 44 | - echo $child_dom->html() . "\n"; | |
| 44 | + echo $child_dom->html()."\n"; | |
| 45 | 45 | } |