@@ -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 |
@@ -430,10 +430,10 @@ |
||
430 | 430 | '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui', |
431 | 431 | function ($matches) { |
432 | 432 | return $matches['start'] . |
433 | - '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . |
|
434 | - $matches['value'] . |
|
435 | - '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . |
|
436 | - $matches['end']; |
|
433 | + '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . |
|
434 | + $matches['value'] . |
|
435 | + '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . |
|
436 | + $matches['end']; |
|
437 | 437 | }, |
438 | 438 | $html |
439 | 439 | ); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @var string[][] |
45 | 45 | */ |
46 | 46 | protected static $domLinkReplaceHelper = [ |
47 | - 'orig' => ['[', ']', '{', '}',], |
|
47 | + 'orig' => ['[', ']', '{', '}', ], |
|
48 | 48 | 'tmp' => [ |
49 | 49 | '____SIMPLE_HTML_DOM__VOKU__SQUARE_BRACKET_LEFT____', |
50 | 50 | '____SIMPLE_HTML_DOM__VOKU__SQUARE_BRACKET_RIGHT____', |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | return \call_user_func_array([$this, self::$functionAliases[$name]], $arguments); |
162 | 162 | } |
163 | 163 | |
164 | - throw new \BadMethodCallException('Method does not exist: ' . $name); |
|
164 | + throw new \BadMethodCallException('Method does not exist: '.$name); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | |
271 | 271 | if (!empty($linksOld[1])) { |
272 | 272 | $linksOld = $linksOld[1]; |
273 | - foreach ((array)$linksOld as $linkKey => $linkOld) { |
|
273 | + foreach ((array) $linksOld as $linkKey => $linkOld) { |
|
274 | 274 | $linksNew[$linkKey] = \str_replace( |
275 | 275 | self::$domLinkReplaceHelper['orig'], |
276 | 276 | self::$domLinkReplaceHelper['tmp'], |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | $xmlHackUsed = false; |
386 | 386 | if (\stripos('<?xml', $html) !== 0) { |
387 | 387 | $xmlHackUsed = true; |
388 | - $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; |
|
388 | + $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | $html = self::replaceToPreserveHtmlEntities($html); |
@@ -426,13 +426,13 @@ discard block |
||
426 | 426 | do { |
427 | 427 | $original = $html; |
428 | 428 | |
429 | - $html = (string)preg_replace_callback( |
|
429 | + $html = (string) preg_replace_callback( |
|
430 | 430 | '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui', |
431 | - function ($matches) { |
|
432 | - return $matches['start'] . |
|
433 | - '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . |
|
434 | - $matches['value'] . |
|
435 | - '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . |
|
431 | + function($matches) { |
|
432 | + return $matches['start']. |
|
433 | + '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'. |
|
434 | + $matches['value']. |
|
435 | + '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'. |
|
436 | 436 | $matches['end']; |
437 | 437 | }, |
438 | 438 | $html |
@@ -446,9 +446,9 @@ discard block |
||
446 | 446 | do { |
447 | 447 | $original = $html; |
448 | 448 | |
449 | - $html = (string)preg_replace_callback( |
|
449 | + $html = (string) preg_replace_callback( |
|
450 | 450 | '/(?<start>[^<]*)?(?<broken>(?:(?:<\/\w+(?:\s+\w+=\\"[^\"]+\\")*+)(?:[^<]+)>)+)(?<end>.*)/u', |
451 | - function ($matches) { |
|
451 | + function($matches) { |
|
452 | 452 | |
453 | 453 | $matches['broken'] = str_replace( |
454 | 454 | array('°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'), |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | //var_dump($matches['broken']); |
460 | 460 | |
461 | 461 | self::$domBrokenReplaceHelper['orig'][] = $matches['broken']; |
462 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = '____simple_html_dom__voku__broken_html____' . crc32($matches['broken']); |
|
462 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = '____simple_html_dom__voku__broken_html____'.crc32($matches['broken']); |
|
463 | 463 | |
464 | - return $matches['start'] . $matchesHash . $matches['end']; |
|
464 | + return $matches['start'].$matchesHash.$matches['end']; |
|
465 | 465 | }, |
466 | 466 | $html |
467 | 467 | ); |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | ); |
479 | 479 | |
480 | 480 | if ($backup !== $html) { |
481 | - $html = '<____simple_html_dom__voku__broken_html_wrapper____>' . $html . '</____simple_html_dom__voku__broken_html_wrapper____>'; |
|
481 | + $html = '<____simple_html_dom__voku__broken_html_wrapper____>'.$html.'</____simple_html_dom__voku__broken_html_wrapper____>'; |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | return $html; |
@@ -647,8 +647,8 @@ discard block |
||
647 | 647 | } |
648 | 648 | |
649 | 649 | if ($this->isDOMDocumentCreatedWithoutWrapper === true) { |
650 | - $content = (string)\preg_replace('/^<p>/', '', $content); |
|
651 | - $content = (string)\preg_replace('/<\/p>/', '', $content); |
|
650 | + $content = (string) \preg_replace('/^<p>/', '', $content); |
|
651 | + $content = (string) \preg_replace('/<\/p>/', '', $content); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | if ($this->isDOMDocumentCreatedWithoutHtml === true) { |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | $xml = $this->document->saveXML(null, \LIBXML_NOEMPTYTAG); |
810 | 810 | |
811 | 811 | // remove the XML-header |
812 | - $xml = \ltrim((string)\preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
812 | + $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
813 | 813 | |
814 | 814 | return $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity); |
815 | 815 | } |