@@ -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 | } |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require __DIR__ . '/../vendor/autoload.php'; |
|
4 | -require __DIR__ . '/vendor/autoload.php'; |
|
3 | +require __DIR__.'/../vendor/autoload.php'; |
|
4 | +require __DIR__.'/vendor/autoload.php'; |
|
5 | 5 | |
6 | 6 | $readmeText = (new \voku\PhpReadmeHelper\GenerateApi())->generate( |
7 | - __DIR__ . '/../src/', |
|
8 | - __DIR__ . '/docs/api.md', |
|
7 | + __DIR__.'/../src/', |
|
8 | + __DIR__.'/docs/api.md', |
|
9 | 9 | [ |
10 | 10 | \voku\helper\DomParserInterface::class, |
11 | 11 | \voku\helper\SimpleHtmlDomNodeInterface::class, |
@@ -13,4 +13,4 @@ discard block |
||
13 | 13 | ] |
14 | 14 | ); |
15 | 15 | |
16 | -file_put_contents(__DIR__ . '/../README_API.md', $readmeText); |
|
16 | +file_put_contents(__DIR__.'/../README_API.md', $readmeText); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | return \call_user_func_array([$this, self::$functionAliases[$name]], $arguments); |
166 | 166 | } |
167 | 167 | |
168 | - throw new \BadMethodCallException('Method does not exist: ' . $name); |
|
168 | + throw new \BadMethodCallException('Method does not exist: '.$name); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | if (\stripos($html, '</html>') !== false) { |
314 | 314 | /** @noinspection NestedPositiveIfStatementsInspection */ |
315 | 315 | if (\preg_match('/<\/html>(.*?)/suiU', $html, $matches_after_html)) { |
316 | - $html = \str_replace($matches_after_html[0], $matches_after_html[1] . '</html>', $html); |
|
316 | + $html = \str_replace($matches_after_html[0], $matches_after_html[1].'</html>', $html); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | || |
358 | 358 | $this->keepBrokenHtml |
359 | 359 | ) { |
360 | - $html = '<' . self::$domHtmlWrapperHelper . '>' . $html . '</' . self::$domHtmlWrapperHelper . '>'; |
|
360 | + $html = '<'.self::$domHtmlWrapperHelper.'>'.$html.'</'.self::$domHtmlWrapperHelper.'>'; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | $html = self::replaceToPreserveHtmlEntities($html); |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | /** @noinspection StringFragmentMisplacedInspection */ |
384 | 384 | if (\stripos('<?xml', $html) !== 0) { |
385 | 385 | $xmlHackUsed = true; |
386 | - $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; |
|
386 | + $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | $this->document->loadHTML($html, $optionsXml); |
@@ -944,11 +944,11 @@ discard block |
||
944 | 944 | |
945 | 945 | $html = (string) \preg_replace_callback( |
946 | 946 | '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui', |
947 | - static function ($matches) { |
|
948 | - return $matches['start'] . |
|
949 | - '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' . |
|
950 | - $matches['value'] . |
|
951 | - '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' . |
|
947 | + static function($matches) { |
|
948 | + return $matches['start']. |
|
949 | + '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'. |
|
950 | + $matches['value']. |
|
951 | + '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'. |
|
952 | 952 | $matches['end']; |
953 | 953 | }, |
954 | 954 | $html |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | |
961 | 961 | $html = (string) \preg_replace_callback( |
962 | 962 | '/(?<start>[^<]*)?(?<broken>(?:(?:<\/\w+(?:\s+\w+=\\"[^\"]+\\")*+)(?:[^<]+)>)+)(?<end>.*)/u', |
963 | - static function ($matches) { |
|
963 | + static function($matches) { |
|
964 | 964 | $matches['broken'] = \str_replace( |
965 | 965 | ['°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'], |
966 | 966 | ['</', '<', '>'], |
@@ -968,9 +968,9 @@ discard block |
||
968 | 968 | ); |
969 | 969 | |
970 | 970 | self::$domBrokenReplaceHelper['orig'][] = $matches['broken']; |
971 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['broken']); |
|
971 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['broken']); |
|
972 | 972 | |
973 | - return $matches['start'] . $matchesHash . $matches['end']; |
|
973 | + return $matches['start'].$matchesHash.$matches['end']; |
|
974 | 974 | }, |
975 | 975 | $html |
976 | 976 | ); |
@@ -992,14 +992,14 @@ discard block |
||
992 | 992 | { |
993 | 993 | // regEx for e.g.: [<script id="elements-image-1" type="text/html">...</script>] |
994 | 994 | $tags = \implode('|', \array_map( |
995 | - static function ($value) { |
|
995 | + static function($value) { |
|
996 | 996 | return \preg_quote($value, '/'); |
997 | 997 | }, |
998 | 998 | $this->specialScriptTags |
999 | 999 | )); |
1000 | 1000 | $html = (string) \preg_replace_callback( |
1001 | - '/(?<start>((?:<script) [^>]*type=(?:["\'])?(?:' . $tags . ')+(?:[^>]*)>))(?<innerContent>.*)(?<end><\/script>)/isU', |
|
1002 | - function ($matches) { |
|
1001 | + '/(?<start>((?:<script) [^>]*type=(?:["\'])?(?:'.$tags.')+(?:[^>]*)>))(?<innerContent>.*)(?<end><\/script>)/isU', |
|
1002 | + function($matches) { |
|
1003 | 1003 | |
1004 | 1004 | // Check for logic in special script tags, like [<% _.each(tierPrices, function(item, key) { %>], |
1005 | 1005 | // because often this looks like non valid html in the template itself. |
@@ -1009,18 +1009,18 @@ discard block |
||
1009 | 1009 | $matches['innerContent'] = \str_replace('<\/', '</', $matches['innerContent']); |
1010 | 1010 | |
1011 | 1011 | self::$domBrokenReplaceHelper['orig'][] = $matches['innerContent']; |
1012 | - self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = '' . self::$domHtmlBrokenHtmlHelper . '' . \crc32($matches['innerContent']); |
|
1012 | + self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = ''.self::$domHtmlBrokenHtmlHelper.''.\crc32($matches['innerContent']); |
|
1013 | 1013 | |
1014 | - return $matches['start'] . $matchesHash . $matches['end']; |
|
1014 | + return $matches['start'].$matchesHash.$matches['end']; |
|
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | // remove the html5 fallback |
1019 | 1019 | $matches[0] = \str_replace('<\/', '</', $matches[0]); |
1020 | 1020 | |
1021 | - $specialNonScript = '<' . self::$domHtmlSpecialScriptHelper . \substr($matches[0], \strlen('<script')); |
|
1021 | + $specialNonScript = '<'.self::$domHtmlSpecialScriptHelper.\substr($matches[0], \strlen('<script')); |
|
1022 | 1022 | |
1023 | - return \substr($specialNonScript, 0, -\strlen('</script>')) . '</' . self::$domHtmlSpecialScriptHelper . '>'; |
|
1023 | + return \substr($specialNonScript, 0, -\strlen('</script>')).'</'.self::$domHtmlSpecialScriptHelper.'>'; |
|
1024 | 1024 | }, |
1025 | 1025 | $html |
1026 | 1026 | ); |