Completed
Push — master ( f2be14...91500e )
by Lars
14:11 queued 13:45
created
src/voku/helper/HtmlDomParser.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
             return \call_user_func_array([$this, self::$functionAliases[$name]], $arguments);
188 188
         }
189 189
 
190
-        throw new \BadMethodCallException('Method does not exist: ' . $name);
190
+        throw new \BadMethodCallException('Method does not exist: '.$name);
191 191
     }
192 192
 
193 193
     /**
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
                 &&
353 353
                 \trim($matches_after_html[1])
354 354
             ) {
355
-                $html = \str_replace($matches_after_html[0], $matches_after_html[1] . '</html>', $html);
355
+                $html = \str_replace($matches_after_html[0], $matches_after_html[1].'</html>', $html);
356 356
             }
357 357
         }
358 358
 
@@ -367,11 +367,11 @@  discard block
 block discarded – undo
367 367
         }
368 368
 
369 369
         $html = \str_replace(
370
-            \array_map(static function ($e) {
371
-                return '<' . $e . '>';
370
+            \array_map(static function($e) {
371
+                return '<'.$e.'>';
372 372
             }, $this->selfClosingTags),
373
-            \array_map(static function ($e) {
374
-                return '<' . $e . '/>';
373
+            \array_map(static function($e) {
374
+                return '<'.$e.'/>';
375 375
             }, $this->selfClosingTags),
376 376
             $html
377 377
         );
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
                 $this->keepBrokenHtml
413 413
             )
414 414
         ) {
415
-            $html = '<' . self::$domHtmlWrapperHelper . '>' . $html . '</' . self::$domHtmlWrapperHelper . '>';
415
+            $html = '<'.self::$domHtmlWrapperHelper.'>'.$html.'</'.self::$domHtmlWrapperHelper.'>';
416 416
         }
417 417
 
418 418
         $html = self::replaceToPreserveHtmlEntities($html);
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             /** @noinspection StringFragmentMisplacedInspection */
439 439
             if (\stripos('<?xml', $html) !== 0) {
440 440
                 $xmlHackUsed = true;
441
-                $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html;
441
+                $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html;
442 442
             }
443 443
 
444 444
             if ($html !== '') {
@@ -653,8 +653,8 @@  discard block
 block discarded – undo
653 653
 
654 654
         // https://bugs.php.net/bug.php?id=73175
655 655
         $content = \str_replace(
656
-            \array_map(static function ($e) {
657
-                return '</' . $e . '>';
656
+            \array_map(static function($e) {
657
+                return '</'.$e.'>';
658 658
             }, $this->selfClosingTags),
659 659
             '',
660 660
             $content
@@ -979,11 +979,11 @@  discard block
 block discarded – undo
979 979
 
980 980
             $html = (string) \preg_replace_callback(
981 981
                 '/(?<start>.*)<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\2)>(?<end>.*)/sui',
982
-                static function ($matches) {
983
-                    return $matches['start'] .
984
-                        '°lt_simple_html_dom__voku_°' . $matches['element_start'] . $matches['element_start_addon'] . '°gt_simple_html_dom__voku_°' .
985
-                        $matches['value'] .
986
-                        '°lt/_simple_html_dom__voku_°' . $matches['element_end'] . '°gt_simple_html_dom__voku_°' .
982
+                static function($matches) {
983
+                    return $matches['start'].
984
+                        '°lt_simple_html_dom__voku_°'.$matches['element_start'].$matches['element_start_addon'].'°gt_simple_html_dom__voku_°'.
985
+                        $matches['value'].
986
+                        '°lt/_simple_html_dom__voku_°'.$matches['element_end'].'°gt_simple_html_dom__voku_°'.
987 987
                         $matches['end'];
988 988
                 },
989 989
                 $html
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 
996 996
             $html = (string) \preg_replace_callback(
997 997
                 '/(?<start>[^<]*)?(?<broken>(?:(?:<\/\w+(?:\s+\w+=\\"[^\"]+\\")*+)(?:[^<]+)>)+)(?<end>.*)/u',
998
-                static function ($matches) {
998
+                static function($matches) {
999 999
                     $matches['broken'] = \str_replace(
1000 1000
                         ['°lt/_simple_html_dom__voku_°', '°lt_simple_html_dom__voku_°', '°gt_simple_html_dom__voku_°'],
1001 1001
                         ['</', '<', '>'],
@@ -1003,9 +1003,9 @@  discard block
 block discarded – undo
1003 1003
                     );
1004 1004
 
1005 1005
                     self::$domBrokenReplaceHelper['orig'][] = $matches['broken'];
1006
-                    self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper . \crc32($matches['broken']);
1006
+                    self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = self::$domHtmlBrokenHtmlHelper.\crc32($matches['broken']);
1007 1007
 
1008
-                    return $matches['start'] . $matchesHash . $matches['end'];
1008
+                    return $matches['start'].$matchesHash.$matches['end'];
1009 1009
                 },
1010 1010
                 $html
1011 1011
             );
@@ -1027,14 +1027,14 @@  discard block
 block discarded – undo
1027 1027
     {
1028 1028
         // regEx for e.g.: [<script id="elements-image-1" type="text/html">...</script>]
1029 1029
         $tags = \implode('|', \array_map(
1030
-            static function ($value) {
1030
+            static function($value) {
1031 1031
                 return \preg_quote($value, '/');
1032 1032
             },
1033 1033
             $this->specialScriptTags
1034 1034
         ));
1035 1035
         $html = (string) \preg_replace_callback(
1036
-            '/(?<start>((?:<script) [^>]*type=(?:["\'])?(?:' . $tags . ')+(?:[^>]*)>))(?<innerContent>.*)(?<end><\/script>)/isU',
1037
-            function ($matches) {
1036
+            '/(?<start>((?:<script) [^>]*type=(?:["\'])?(?:'.$tags.')+(?:[^>]*)>))(?<innerContent>.*)(?<end><\/script>)/isU',
1037
+            function($matches) {
1038 1038
 
1039 1039
                 // Check for logic in special script tags, like [<% _.each(tierPrices, function(item, key) { %>],
1040 1040
                 // because often this looks like non valid html in the template itself.
@@ -1044,18 +1044,18 @@  discard block
 block discarded – undo
1044 1044
                         $matches['innerContent'] = \str_replace('<\/', '</', $matches['innerContent']);
1045 1045
 
1046 1046
                         self::$domBrokenReplaceHelper['orig'][] = $matches['innerContent'];
1047
-                        self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = '' . self::$domHtmlBrokenHtmlHelper . '' . \crc32($matches['innerContent']);
1047
+                        self::$domBrokenReplaceHelper['tmp'][] = $matchesHash = ''.self::$domHtmlBrokenHtmlHelper.''.\crc32($matches['innerContent']);
1048 1048
 
1049
-                        return $matches['start'] . $matchesHash . $matches['end'];
1049
+                        return $matches['start'].$matchesHash.$matches['end'];
1050 1050
                     }
1051 1051
                 }
1052 1052
 
1053 1053
                 // remove the html5 fallback
1054 1054
                 $matches[0] = \str_replace('<\/', '</', $matches[0]);
1055 1055
 
1056
-                $specialNonScript = '<' . self::$domHtmlSpecialScriptHelper . \substr($matches[0], \strlen('<script'));
1056
+                $specialNonScript = '<'.self::$domHtmlSpecialScriptHelper.\substr($matches[0], \strlen('<script'));
1057 1057
 
1058
-                return \substr($specialNonScript, 0, -\strlen('</script>')) . '</' . self::$domHtmlSpecialScriptHelper . '>';
1058
+                return \substr($specialNonScript, 0, -\strlen('</script>')).'</'.self::$domHtmlSpecialScriptHelper.'>';
1059 1059
             },
1060 1060
             $html
1061 1061
         );
Please login to merge, or discard this patch.
src/voku/helper/XmlDomParser.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
             /** @noinspection StringFragmentMisplacedInspection */
211 211
             if (\stripos('<?xml', $xml) !== 0) {
212 212
                 $xmlHackUsed = true;
213
-                $xml = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $xml;
213
+                $xml = '<?xml encoding="'.$this->getEncoding().'" ?>'.$xml;
214 214
             }
215 215
 
216 216
             $documentFound = $this->document->loadXML($xml, $optionsXml);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
             &&
234 234
             \count($xmlErrors) > 0
235 235
         ) {
236
-            $errorStr = 'XML-Errors: ' . \print_r($xmlErrors, true) . ' in ' . \print_r($xml, true);
236
+            $errorStr = 'XML-Errors: '.\print_r($xmlErrors, true).' in '.\print_r($xml, true);
237 237
 
238 238
             if (!$this->reportXmlErrorsAsException) {
239 239
                 \trigger_error($errorStr, \E_USER_WARNING);
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
     private function removeXPathNamespaces(string $xml): string
565 565
     {
566 566
         foreach ($this->xPathNamespaces as $key => $value) {
567
-            $xml = \str_replace($key . ':', '', $xml);
567
+            $xml = \str_replace($key.':', '', $xml);
568 568
         }
569 569
 
570 570
         return (string) \preg_replace('#xmlns:?.*=(["\'])(?:.*)\\1#Ui', '', $xml);
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 attribute 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/SelectorConverter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
             throw new \RuntimeException('Unable to filter with a CSS selector as the Symfony CssSelector 2.8+ is not installed (you can use filterXPath instead).');
51 51
         }
52 52
 
53
-        $converterKey = '-' . $isForHtml . '-' . $ignoreCssSelectorErrors . '-';
53
+        $converterKey = '-'.$isForHtml.'-'.$ignoreCssSelectorErrors.'-';
54 54
         static $converterArray = [];
55 55
         if (!isset($converterArray[$converterKey])) {
56 56
             $converterArray[$converterKey] = new CssSelectorConverter($isForHtml);
Please login to merge, or discard this patch.