@@ -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; |
@@ -701,7 +701,7 @@ |
||
701 | 701 | * |
702 | 702 | * @param string $name <p>The name of the html-attribute.</p> |
703 | 703 | * |
704 | - * @return mixed |
|
704 | + * @return SimpleHtmlDom |
|
705 | 705 | */ |
706 | 706 | public function removeAttribute(string $name) |
707 | 707 | { |
@@ -580,7 +580,7 @@ |
||
580 | 580 | $string = \str_replace(['<head>', '</head>'], '', $string); |
581 | 581 | } |
582 | 582 | } else { |
583 | - $string = (string)$input; |
|
583 | + $string = (string) $input; |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | return |
@@ -442,10 +442,10 @@ |
||
442 | 442 | '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui', |
443 | 443 | function ($matches) { |
444 | 444 | return $matches['start'] . |
445 | - '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . |
|
446 | - $matches['value'] . |
|
447 | - '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . |
|
448 | - $matches['end']; |
|
445 | + '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . |
|
446 | + $matches['value'] . |
|
447 | + '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . |
|
448 | + $matches['end']; |
|
449 | 449 | }, |
450 | 450 | $html |
451 | 451 | ); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @var string[][] |
46 | 46 | */ |
47 | 47 | protected static $domLinkReplaceHelper = [ |
48 | - 'orig' => ['[', ']', '{', '}',], |
|
48 | + 'orig' => ['[', ']', '{', '}', ], |
|
49 | 49 | 'tmp' => [ |
50 | 50 | '____SIMPLE_HTML_DOM__VOKU__SQUARE_BRACKET_LEFT____', |
51 | 51 | '____SIMPLE_HTML_DOM__VOKU__SQUARE_BRACKET_RIGHT____', |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | return \call_user_func_array([$this, self::$functionAliases[$name]], $arguments); |
167 | 167 | } |
168 | 168 | |
169 | - throw new \BadMethodCallException('Method does not exist: ' . $name); |
|
169 | + throw new \BadMethodCallException('Method does not exist: '.$name); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | if (!empty($linksOld[1])) { |
283 | 283 | $linksOld = $linksOld[1]; |
284 | - foreach ((array)$linksOld as $linkKey => $linkOld) { |
|
284 | + foreach ((array) $linksOld as $linkKey => $linkOld) { |
|
285 | 285 | $linksNew[$linkKey] = \str_replace( |
286 | 286 | self::$domLinkReplaceHelper['orig'], |
287 | 287 | self::$domLinkReplaceHelper['tmp'], |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | self::$domReplaceHelper['orig'] |
323 | 323 | ); |
324 | 324 | |
325 | - $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start'] = '<' . self::$domHtmlWrapperHelper . '>'; |
|
326 | - $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end'] = '</' . self::$domHtmlWrapperHelper . '>'; |
|
325 | + $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start'] = '<'.self::$domHtmlWrapperHelper.'>'; |
|
326 | + $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end'] = '</'.self::$domHtmlWrapperHelper.'>'; |
|
327 | 327 | |
328 | 328 | $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__start'] = ''; |
329 | 329 | $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__end'] = ''; |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | || |
397 | 397 | $this->keepBrokenHtml === true |
398 | 398 | ) { |
399 | - $html = '<' . self::$domHtmlWrapperHelper . '>' . $html . '</' . self::$domHtmlWrapperHelper . '>'; |
|
399 | + $html = '<'.self::$domHtmlWrapperHelper.'>'.$html.'</'.self::$domHtmlWrapperHelper.'>'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | $html = self::replaceToPreserveHtmlEntities($html); |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | $xmlHackUsed = false; |
413 | 413 | if (\stripos('<?xml', $html) !== 0) { |
414 | 414 | $xmlHackUsed = true; |
415 | - $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; |
|
415 | + $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html; |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | $this->document->loadHTML($html, $optionsXml); |
@@ -449,13 +449,13 @@ discard block |
||
449 | 449 | do { |
450 | 450 | $original = $html; |
451 | 451 | |
452 | - $html = (string)preg_replace_callback( |
|
452 | + $html = (string) preg_replace_callback( |
|
453 | 453 | '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui', |
454 | - function ($matches) { |
|
455 | - return $matches['start'] . |
|
456 | - '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . |
|
457 | - $matches['value'] . |
|
458 | - '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . |
|
454 | + function($matches) { |
|
455 | + return $matches['start']. |
|
456 | + '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'. |
|
457 | + $matches['value']. |
|
458 | + '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'. |
|
459 | 459 | $matches['end']; |
460 | 460 | }, |
461 | 461 | $html |
@@ -466,9 +466,9 @@ discard block |
||
466 | 466 | do { |
467 | 467 | $original = $html; |
468 | 468 | |
469 | - $html = (string)preg_replace_callback( |
|
469 | + $html = (string) preg_replace_callback( |
|
470 | 470 | '/(?<start>[^<]*)?(?<broken>(?:(?:<\/\w+(?:\s+\w+=\\"[^\"]+\\")*+)(?:[^<]+)>)+)(?<end>.*)/u', |
471 | - function ($matches) { |
|
471 | + function($matches) { |
|
472 | 472 | |
473 | 473 | $matches['broken'] = str_replace( |
474 | 474 | ['°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'], |
@@ -477,9 +477,9 @@ discard block |
||
477 | 477 | ); |
478 | 478 | |
479 | 479 | self::$domBrokenReplaceHelper['orig'][] = $matches['broken']; |
480 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = '____simple_html_dom__voku__broken_html____' . crc32($matches['broken']); |
|
480 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = '____simple_html_dom__voku__broken_html____'.crc32($matches['broken']); |
|
481 | 481 | |
482 | - return $matches['start'] . $matchesHash . $matches['end']; |
|
482 | + return $matches['start'].$matchesHash.$matches['end']; |
|
483 | 483 | }, |
484 | 484 | $html |
485 | 485 | ); |
@@ -665,8 +665,8 @@ discard block |
||
665 | 665 | } |
666 | 666 | |
667 | 667 | if ($this->isDOMDocumentCreatedWithoutWrapper === true) { |
668 | - $content = (string)\preg_replace('/^<p>/', '', $content); |
|
669 | - $content = (string)\preg_replace('/<\/p>/', '', $content); |
|
668 | + $content = (string) \preg_replace('/^<p>/', '', $content); |
|
669 | + $content = (string) \preg_replace('/<\/p>/', '', $content); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | if ($this->isDOMDocumentCreatedWithoutHtml === true) { |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | $xml = $this->document->saveXML(null, \LIBXML_NOEMPTYTAG); |
837 | 837 | |
838 | 838 | // remove the XML-header |
839 | - $xml = \ltrim((string)\preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
839 | + $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
840 | 840 | |
841 | 841 | return $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity); |
842 | 842 | } |