@@ -528,7 +528,7 @@ |
||
528 | 528 | */ |
529 | 529 | protected function changeElementName(\DOMNode $node, $name) { |
530 | 530 | $newnode = $node->ownerDocument->createElement($name); |
531 | - foreach ($node->childNodes as $child){ |
|
531 | + foreach ($node->childNodes as $child) { |
|
532 | 532 | $child = $node->ownerDocument->importNode($child, true); |
533 | 533 | $newnode->appendChild($child); |
534 | 534 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * @return mixed |
|
36 | + * @return string |
|
37 | 37 | */ |
38 | 38 | public function __toString() |
39 | 39 | { |
@@ -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; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | return call_user_func_array(array($this, self::$functionAliases[$name]), $arguments); |
103 | 103 | } |
104 | 104 | |
105 | - throw new BadMethodCallException('Method does not exist: ' . $name); |
|
105 | + throw new BadMethodCallException('Method does not exist: '.$name); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | if (count(libxml_get_errors()) === 0) { |
202 | 202 | $this->document = dom_import_simplexml($sxe)->ownerDocument; |
203 | 203 | } else { |
204 | - $this->document->loadHTML('<?xml encoding="' . $this->getEncoding() . '">' . $html); |
|
204 | + $this->document->loadHTML('<?xml encoding="'.$this->getEncoding().'">'.$html); |
|
205 | 205 | |
206 | 206 | // remove the "xml-encoding" hack |
207 | 207 | foreach ($this->document->childNodes as $child) { |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | array( |
335 | 335 | "\n", |
336 | 336 | '<p>', '</p>', |
337 | - "\n" . '<simpleHtmlDomP>', '<simpleHtmlDomP>', '</simpleHtmlDomP>', |
|
337 | + "\n".'<simpleHtmlDomP>', '<simpleHtmlDomP>', '</simpleHtmlDomP>', |
|
338 | 338 | '<body>', '</body>', |
339 | 339 | '<html>', '</html>' |
340 | 340 | ), |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $content = str_replace( |
347 | 347 | array( |
348 | 348 | "\n", |
349 | - "\n" . '<simpleHtmlDomP>', '<simpleHtmlDomP>', '</simpleHtmlDomP>', |
|
349 | + "\n".'<simpleHtmlDomP>', '<simpleHtmlDomP>', '</simpleHtmlDomP>', |
|
350 | 350 | '<body>', '</body>', |
351 | 351 | '<html>', '</html>' |
352 | 352 | ), |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | public function loadHtml($html) |
444 | 444 | { |
445 | 445 | if (!is_string($html)) { |
446 | - throw new InvalidArgumentException(__METHOD__ . ' expects parameter 1 to be string.'); |
|
446 | + throw new InvalidArgumentException(__METHOD__.' expects parameter 1 to be string.'); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | $this->document = $this->createDOMDocument($html); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | public function loadHtmlFile($filePath) |
462 | 462 | { |
463 | 463 | if (!is_string($filePath)) { |
464 | - throw new InvalidArgumentException(__METHOD__ . ' expects parameter 1 to be string.'); |
|
464 | + throw new InvalidArgumentException(__METHOD__.' expects parameter 1 to be string.'); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | if (!preg_match("/^https?:\/\//i", $filePath) && !file_exists($filePath)) { |