@@ -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; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | $imageOrFalse = $document->findOneOrFalse('#test'); |
16 | 16 | if ($imageOrFalse !== false) { |
17 | - echo $imageOrFalse->getAttribute('src') . "\n"; |
|
17 | + echo $imageOrFalse->getAttribute('src')."\n"; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | // ----------------------------------------------------------------------------- |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | $imageOrFalse = $document->findOneOrFalse('#non_test'); |
31 | 31 | if ($imageOrFalse !== false) { |
32 | - echo $imageOrFalse->getAttribute('src') . "\n"; |
|
32 | + echo $imageOrFalse->getAttribute('src')."\n"; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // ----------------------------------------------------------------------------- |
@@ -46,6 +46,6 @@ discard block |
||
46 | 46 | $imagesOrFalse = $document->findMultiOrFalse('.image_foo'); |
47 | 47 | if ($imagesOrFalse !== false) { |
48 | 48 | foreach ($imagesOrFalse as $image) { |
49 | - echo $image->getAttribute('src') . "\n"; |
|
49 | + echo $image->getAttribute('src')."\n"; |
|
50 | 50 | } |
51 | 51 | } |
@@ -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 | /** |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | || |
353 | 353 | $this->keepBrokenHtml |
354 | 354 | ) { |
355 | - $html = '<' . self::$domHtmlWrapperHelper . '>' . $html . '</' . self::$domHtmlWrapperHelper . '>'; |
|
355 | + $html = '<'.self::$domHtmlWrapperHelper.'>'.$html.'</'.self::$domHtmlWrapperHelper.'>'; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | $html = self::replaceToPreserveHtmlEntities($html); |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | /** @noinspection StringFragmentMisplacedInspection */ |
375 | 375 | if (\stripos('<?xml', $html) !== 0) { |
376 | 376 | $xmlHackUsed = true; |
377 | - $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; |
|
377 | + $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | $this->document->loadHTML($html, $optionsXml); |
@@ -907,11 +907,11 @@ discard block |
||
907 | 907 | |
908 | 908 | $html = (string) \preg_replace_callback( |
909 | 909 | '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui', |
910 | - static function ($matches) { |
|
911 | - return $matches['start'] . |
|
912 | - '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . |
|
913 | - $matches['value'] . |
|
914 | - '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . |
|
910 | + static function($matches) { |
|
911 | + return $matches['start']. |
|
912 | + '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'. |
|
913 | + $matches['value']. |
|
914 | + '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'. |
|
915 | 915 | $matches['end']; |
916 | 916 | }, |
917 | 917 | $html |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | |
924 | 924 | $html = (string) \preg_replace_callback( |
925 | 925 | '/(?<start>[^<]*)?(?<broken>(?:(?:<\/\w+(?:\s+\w+=\\"[^\"]+\\")*+)(?:[^<]+)>)+)(?<end>.*)/u', |
926 | - static function ($matches) { |
|
926 | + static function($matches) { |
|
927 | 927 | $matches['broken'] = \str_replace( |
928 | 928 | ['°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'], |
929 | 929 | ['</', '<', '>'], |
@@ -931,9 +931,9 @@ discard block |
||
931 | 931 | ); |
932 | 932 | |
933 | 933 | self::$domBrokenReplaceHelper['orig'][] = $matches['broken']; |
934 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['broken']); |
|
934 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['broken']); |
|
935 | 935 | |
936 | - return $matches['start'] . $matchesHash . $matches['end']; |
|
936 | + return $matches['start'].$matchesHash.$matches['end']; |
|
937 | 937 | }, |
938 | 938 | $html |
939 | 939 | ); |
@@ -955,8 +955,8 @@ discard block |
||
955 | 955 | { |
956 | 956 | // regEx for e.g.: [<script id="elements-image-1" type="text/html">...</script>] |
957 | 957 | $html = (string) \preg_replace_callback( |
958 | - '/(?<start>((?:<script) [^>]*type=(?:["\'])?(?:' . implode('|', $this->specialScriptTags) . ')+(?:[^>]*)>))(?<innerContent>.*)(?<end><\/script>)/isU', |
|
959 | - function ($matches) { |
|
958 | + '/(?<start>((?:<script) [^>]*type=(?:["\'])?(?:'.implode('|', $this->specialScriptTags).')+(?:[^>]*)>))(?<innerContent>.*)(?<end><\/script>)/isU', |
|
959 | + function($matches) { |
|
960 | 960 | |
961 | 961 | // Check for logic in special script tags, like [<% _.each(tierPrices, function(item, key) { %>], |
962 | 962 | // because often this looks like non valid html in the template itself. |
@@ -966,18 +966,18 @@ discard block |
||
966 | 966 | $matches['innerContent'] = \str_replace('<\/', '</', $matches['innerContent']); |
967 | 967 | |
968 | 968 | self::$domBrokenReplaceHelper['orig'][] = $matches['innerContent']; |
969 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = '' . self::$domHtmlBrokenHtmlHelper . '' . \crc32($matches['innerContent']); |
|
969 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = ''.self::$domHtmlBrokenHtmlHelper.''.\crc32($matches['innerContent']); |
|
970 | 970 | |
971 | - return $matches['start'] . $matchesHash . $matches['end']; |
|
971 | + return $matches['start'].$matchesHash.$matches['end']; |
|
972 | 972 | } |
973 | 973 | } |
974 | 974 | |
975 | 975 | // remove the html5 fallback |
976 | 976 | $matches[0] = \str_replace('<\/', '</', $matches[0]); |
977 | 977 | |
978 | - $specialNonScript = '<' . self::$domHtmlSpecialScriptHelper . \substr($matches[0], \strlen('<script')); |
|
978 | + $specialNonScript = '<'.self::$domHtmlSpecialScriptHelper.\substr($matches[0], \strlen('<script')); |
|
979 | 979 | |
980 | - return \substr($specialNonScript, 0, -\strlen('</script>')) . '</' . self::$domHtmlSpecialScriptHelper . '>'; |
|
980 | + return \substr($specialNonScript, 0, -\strlen('</script>')).'</'.self::$domHtmlSpecialScriptHelper.'>'; |
|
981 | 981 | }, |
982 | 982 | $html |
983 | 983 | ); |