Completed
Push — master ( dfdd9c...823879 )
by Lars
01:46
created
example/example_advanced_selector.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
example/example_basic_selector.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,36 +9,36 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/voku/helper/HtmlDomParser.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -535,10 +535,10 @@
 block discarded – undo
535 535
                 '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui',
536 536
                 static function ($matches) {
537 537
                     return $matches['start'] .
538
-                           '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' .
539
-                           $matches['value'] .
540
-                           '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' .
541
-                           $matches['end'];
538
+                            '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' .
539
+                            $matches['value'] .
540
+                            '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' .
541
+                            $matches['end'];
542 542
                 },
543 543
                 $html
544 544
             );
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
             return \call_user_func_array([$this, self::$functionAliases[$name]], $arguments);
180 180
         }
181 181
 
182
-        throw new \BadMethodCallException('Method does not exist: ' . $name);
182
+        throw new \BadMethodCallException('Method does not exist: '.$name);
183 183
     }
184 184
 
185 185
     /**
@@ -330,14 +330,14 @@  discard block
 block discarded – undo
330 330
                 self::$domReplaceHelper['orig']
331 331
             );
332 332
 
333
-            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start'] = '<' . self::$domHtmlWrapperHelper . '>';
334
-            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end'] = '</' . self::$domHtmlWrapperHelper . '>';
333
+            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__start'] = '<'.self::$domHtmlWrapperHelper.'>';
334
+            $DOM_REPLACE__HELPER_CACHE['tmp']['html_wrapper__end'] = '</'.self::$domHtmlWrapperHelper.'>';
335 335
 
336 336
             $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__start'] = '';
337 337
             $DOM_REPLACE__HELPER_CACHE['orig']['html_wrapper__end'] = '';
338 338
 
339
-            $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__start'] = '<' . self::$domHtmlSpecialScriptHelper;
340
-            $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__end'] = '</' . self::$domHtmlSpecialScriptHelper . '>';
339
+            $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__start'] = '<'.self::$domHtmlSpecialScriptHelper;
340
+            $DOM_REPLACE__HELPER_CACHE['tmp']['html_special_script__end'] = '</'.self::$domHtmlSpecialScriptHelper.'>';
341 341
 
342 342
             $DOM_REPLACE__HELPER_CACHE['orig']['html_special_script__start'] = '<script';
343 343
             $DOM_REPLACE__HELPER_CACHE['orig']['html_special_script__end'] = '</script>';
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             ||
434 434
             $this->keepBrokenHtml
435 435
         ) {
436
-            $html = '<' . self::$domHtmlWrapperHelper . '>' . $html . '</' . self::$domHtmlWrapperHelper . '>';
436
+            $html = '<'.self::$domHtmlWrapperHelper.'>'.$html.'</'.self::$domHtmlWrapperHelper.'>';
437 437
         }
438 438
 
439 439
         $html = self::replaceToPreserveHtmlEntities($html);
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
             $xmlHackUsed = false;
455 455
             if (\stripos('<?xml', $html) !== 0) {
456 456
                 $xmlHackUsed = true;
457
-                $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html;
457
+                $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html;
458 458
             }
459 459
 
460 460
             $this->document->loadHTML($html, $optionsXml);
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
         // regEx for e.g.: [<script id="elements-image-2">...<script>]
494 494
         /** @noinspection HtmlDeprecatedTag */
495 495
         $regExSpecialScript = '/<(script)(?<attr>[^>]*)>(?<content>.*)<\/\1>/isU';
496
-        $html = \preg_replace_callback($regExSpecialScript, static function ($scripts) {
497
-            return '<script' . $scripts['attr'] . '>' . \str_replace('</', '<\/', $scripts['content']) . '</script>';
496
+        $html = \preg_replace_callback($regExSpecialScript, static function($scripts) {
497
+            return '<script'.$scripts['attr'].'>'.\str_replace('</', '<\/', $scripts['content']).'</script>';
498 498
         }, $html);
499 499
     }
500 500
 
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
         if (isset($specialScripts[0])) {
512 512
             foreach ($specialScripts[0] as $specialScript) {
513 513
 
514
-                $specialNonScript = '<' . self::$domHtmlSpecialScriptHelper . \substr($specialScript, \strlen('<script'));
515
-                $specialNonScript = \substr($specialNonScript, 0, -\strlen('</script>')) . '</' . self::$domHtmlSpecialScriptHelper . '>';
514
+                $specialNonScript = '<'.self::$domHtmlSpecialScriptHelper.\substr($specialScript, \strlen('<script'));
515
+                $specialNonScript = \substr($specialNonScript, 0, -\strlen('</script>')).'</'.self::$domHtmlSpecialScriptHelper.'>';
516 516
                 // remove the html5 fallback
517 517
                 $specialNonScript = \str_replace('<\/', '</', $specialNonScript);
518 518
 
@@ -533,11 +533,11 @@  discard block
 block discarded – undo
533 533
 
534 534
             $html = (string) \preg_replace_callback(
535 535
                 '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui',
536
-                static function ($matches) {
537
-                    return $matches['start'] .
538
-                           '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' .
539
-                           $matches['value'] .
540
-                           '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' .
536
+                static function($matches) {
537
+                    return $matches['start'].
538
+                           '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'.
539
+                           $matches['value'].
540
+                           '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'.
541 541
                            $matches['end'];
542 542
                 },
543 543
                 $html
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 
550 550
             $html = (string) \preg_replace_callback(
551 551
                 '/(?<start>[^<]*)?(?<broken>(?:(?:<\/\w+(?:\s+\w+=\\"[^\"]+\\")*+)(?:[^<]+)>)+)(?<end>.*)/u',
552
-                static function ($matches) {
552
+                static function($matches) {
553 553
                     $matches['broken'] = \str_replace(
554 554
                         ['°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'],
555 555
                         ['</', '<', '>'],
@@ -557,9 +557,9 @@  discard block
 block discarded – undo
557 557
                     );
558 558
 
559 559
                     self::$domBrokenReplaceHelper['orig'][] = $matches['broken'];
560
-                    self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = '____simple_html_dom__voku__broken_html____' . \crc32($matches['broken']);
560
+                    self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = '____simple_html_dom__voku__broken_html____'.\crc32($matches['broken']);
561 561
 
562
-                    return $matches['start'] . $matchesHash . $matches['end'];
562
+                    return $matches['start'].$matchesHash.$matches['end'];
563 563
                 },
564 564
                 $html
565 565
             );
Please login to merge, or discard this patch.
src/voku/helper/SimpleHtmlDom.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     /**
98 98
      * Returns the first child of node.
99 99
      *
100
-     * @return SimpleHtmlDomInterface|null
100
+     * @return null|SimpleHtmlDom
101 101
      */
102 102
     public function firstChild()
103 103
     {
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
     /**
332 332
      * Returns the last child of node.
333 333
      *
334
-     * @return SimpleHtmlDomInterface|null
334
+     * @return null|SimpleHtmlDom
335 335
      */
336 336
     public function lastChild()
337 337
     {
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
     /**
349 349
      * Returns the next sibling of node.
350 350
      *
351
-     * @return SimpleHtmlDomInterface|null
351
+     * @return null|SimpleHtmlDom
352 352
      */
353 353
     public function nextSibling()
354 354
     {
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
     /**
388 388
      * Returns the previous sibling of node.
389 389
      *
390
-     * @return SimpleHtmlDomInterface|null
390
+     * @return null|SimpleHtmlDom
391 391
      */
392 392
     public function previousSibling()
393 393
     {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
             $tmpStr = $this->normalizeStringForComparision($string);
418 418
             if ($tmpDomString !== $tmpStr) {
419 419
                 throw new \RuntimeException(
420
-                    'Not valid HTML fragment!' . "\n" .
421
-                    $tmpDomString . "\n" .
420
+                    'Not valid HTML fragment!'."\n".
421
+                    $tmpDomString."\n".
422 422
                     $tmpStr
423 423
                 );
424 424
             }
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
         $tmpStr = $this->normalizeStringForComparision($string);
491 491
         if ($tmpDomOuterTextString !== $tmpStr) {
492 492
             throw new \RuntimeException(
493
-                'Not valid HTML fragment!' . "\n"
494
-                . $tmpDomOuterTextString . "\n" .
493
+                'Not valid HTML fragment!'."\n"
494
+                . $tmpDomOuterTextString."\n".
495 495
                 $tmpStr
496 496
             );
497 497
         }
Please login to merge, or discard this patch.