Completed
Pull Request — master (#107)
by Asmir
03:02
created
src/Html5/Parser/DOMTreeBuilder.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         $this->quirks = $quirks;
250 250
 
251 251
         if ($this->insertMode > static::IM_INITIAL) {
252
-            $this->parseError("Illegal placement of DOCTYPE tag. Ignoring: " . $name);
252
+            $this->parseError("Illegal placement of DOCTYPE tag. Ignoring: ".$name);
253 253
 
254 254
             return;
255 255
         }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         $lname = $this->normalizeTagName($name);
271 271
 
272 272
         // Make sure we have an html element.
273
-        if (! $this->doc->documentElement && $name !== 'html' && ! $this->frag) {
273
+        if (!$this->doc->documentElement && $name !== 'html' && !$this->frag) {
274 274
             $this->startTag('html');
275 275
         }
276 276
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
             array_unshift($this->nsStack, array(
331 331
                 '' => $this->nsRoots[$lname]
332 332
             ) + $this->nsStack[0]);
333
-            $pushes ++;
333
+            $pushes++;
334 334
         }
335 335
         $needsWorkaround = false;
336 336
         if (isset($this->options["xmlNamespaces"]) && $this->options["xmlNamespaces"]) {
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
                     array_unshift($this->nsStack, array(
342 342
                         '' => $aVal
343 343
                     ) + $this->nsStack[0]);
344
-                    $pushes ++;
344
+                    $pushes++;
345 345
                 } elseif ((($pos = strpos($aName, ':')) ? substr($aName, 0, $pos) : '') === 'xmlns') {
346 346
                     array_unshift($this->nsStack, array(
347 347
                         substr($aName, $pos + 1) => $aVal
348 348
                     ) + $this->nsStack[0]);
349
-                    $pushes ++;
349
+                    $pushes++;
350 350
                 }
351 351
             }
352 352
         }
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
             $prefix = ($pos = strpos($lname, ':')) ? substr($lname, 0, $pos) : '';
361 361
 
362 362
 
363
-            if ($needsWorkaround!==false) {
363
+            if ($needsWorkaround !== false) {
364 364
 
365
-                $xml = "<$lname xmlns=\"$needsWorkaround\" ".(strlen($prefix) && isset($this->nsStack[0][$prefix])?("xmlns:$prefix=\"".$this->nsStack[0][$prefix]."\""):"")."/>";
365
+                $xml = "<$lname xmlns=\"$needsWorkaround\" ".(strlen($prefix) && isset($this->nsStack[0][$prefix]) ? ("xmlns:$prefix=\"".$this->nsStack[0][$prefix]."\"") : "")."/>";
366 366
 
367 367
                 $frag = new \DOMDocument('1.0', 'UTF-8');
368 368
                 $frag->loadXML($xml);
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
             try {
416 416
                 $prefix = ($pos = strpos($aName, ':')) ? substr($aName, 0, $pos) : false;
417 417
 
418
-                if ($prefix==='xmlns') {
418
+                if ($prefix === 'xmlns') {
419 419
                     $ele->setAttributeNs(self::NAMESPACE_XMLNS, $aName, $aVal);
420
-                } elseif ($prefix!==false && isset($this->nsStack[0][$prefix])) {
420
+                } elseif ($prefix !== false && isset($this->nsStack[0][$prefix])) {
421 421
                     $ele->setAttributeNs($this->nsStack[0][$prefix], $aName, $aVal);
422 422
                 } else {
423 423
                     $ele->setAttribute($aName, $aVal);
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
             $this->current->appendChild($ele);
442 442
 
443 443
             // XXX: Need to handle self-closing tags and unary tags.
444
-            if (! Elements::isA($name, Elements::VOID_TAG)) {
444
+            if (!Elements::isA($name, Elements::VOID_TAG)) {
445 445
                 $this->current = $ele;
446 446
             }
447 447
         }
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
         // but we have to remove the namespaces pushed to $nsStack.
457 457
         if ($pushes > 0 && Elements::isA($name, Elements::VOID_TAG)) {
458 458
             // remove the namespaced definded by current node
459
-            for ($i = 0; $i < $pushes; $i ++) {
459
+            for ($i = 0; $i < $pushes; $i++) {
460 460
                 array_shift($this->nsStack);
461 461
             }
462 462
         }
@@ -520,14 +520,14 @@  discard block
 block discarded – undo
520 520
 
521 521
         // remove the namespaced definded by current node
522 522
         if (isset($this->pushes[$cid])) {
523
-            for ($i = 0; $i < $this->pushes[$cid][0]; $i ++) {
523
+            for ($i = 0; $i < $this->pushes[$cid][0]; $i++) {
524 524
                 array_shift($this->nsStack);
525 525
             }
526 526
             unset($this->pushes[$cid]);
527 527
         }
528 528
 
529
-        if (! $this->autoclose($lname)) {
530
-            $this->parseError('Could not find closing tag for ' . $lname);
529
+        if (!$this->autoclose($lname)) {
530
+            $this->parseError('Could not find closing tag for '.$lname);
531 531
         }
532 532
 
533 533
         // switch ($this->insertMode) {
@@ -561,9 +561,9 @@  discard block
 block discarded – undo
561 561
             // practical as most documents contain these characters. Other text is not
562 562
             // expected here so recording a parse error is necessary.
563 563
             $dataTmp = trim($data, " \t\n\r\f");
564
-            if (! empty($dataTmp)) {
564
+            if (!empty($dataTmp)) {
565 565
                 $this->logger->debug(sprintf("Unexpected insert mode: %d", $this->insertMode));
566
-                $this->parseError("Unexpected text. Ignoring: " . $dataTmp);
566
+                $this->parseError("Unexpected text. Ignoring: ".$dataTmp);
567 567
             }
568 568
 
569 569
             return;
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
         // it sees fit.
606 606
         if (isset($this->processor)) {
607 607
             $res = $this->processor->process($this->current, $name, $data);
608
-            if (! empty($res)) {
608
+            if (!empty($res)) {
609 609
                 $this->current = $res;
610 610
             }
611 611
 
Please login to merge, or discard this patch.
src/Html5/Parser/Tokenizer.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         if (is_null($this->untilTag)) {
185 185
             return $this->text();
186 186
         }
187
-        $sequence = '</' . $this->untilTag . '>';
187
+        $sequence = '</'.$this->untilTag.'>';
188 188
         $txt = $this->readUntilSequence($sequence);
189 189
         $this->events->text($txt);
190 190
         $this->setTextMode(0);
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
         if (is_null($this->untilTag)) {
200 200
             return $this->text();
201 201
         }
202
-        $sequence = '</' . $this->untilTag;
202
+        $sequence = '</'.$this->untilTag;
203 203
         $txt = '';
204 204
         $tok = $this->scanner->current();
205 205
 
206 206
         $caseSensitive = !Elements::isHtml5Element($this->untilTag);
207
-        while ($tok !== false && ! ($tok == '<' && ($this->sequenceMatches($sequence, $caseSensitive)))) {
207
+        while ($tok !== false && !($tok == '<' && ($this->sequenceMatches($sequence, $caseSensitive)))) {
208 208
             if ($tok == '&') {
209 209
                 $txt .= $this->decodeCharacterReference();
210 210
                 $tok = $this->scanner->current();
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
         // > -> parse error
329 329
         // EOF -> parse error
330 330
         // -> parse error
331
-        if (! ctype_alpha($tok)) {
331
+        if (!ctype_alpha($tok)) {
332 332
             $this->parseError("Expected tag name, got '%s'", $tok);
333 333
             if ($tok == "\0" || $tok === false) {
334 334
                 return false;
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
     protected function tagName()
359 359
     {
360 360
         $tok = $this->scanner->current();
361
-        if (! ctype_alpha($tok)) {
361
+        if (!ctype_alpha($tok)) {
362 362
             return false;
363 363
         }
364 364
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
             do {
374 374
                 $this->scanner->whitespace();
375 375
                 $this->attribute($attributes);
376
-            } while (! $this->isTagEnd($selfClose));
376
+            } while (!$this->isTagEnd($selfClose));
377 377
         } catch (ParseError $e) {
378 378
             $selfClose = false;
379 379
         }
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
      */
532 532
     protected function quotedAttributeValue($quote)
533 533
     {
534
-        $stoplist = "\f" . $quote;
534
+        $stoplist = "\f".$quote;
535 535
         $val = '';
536 536
         $tok = $this->scanner->current();
537 537
         while (strspn($tok, $stoplist) == 0 && $tok !== false) {
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
         } while ($tok !== false && $tok != '>');
598 598
 
599 599
         $this->flushBuffer();
600
-        $this->events->comment($comment . $tok);
600
+        $this->events->comment($comment.$tok);
601 601
         $this->scanner->next();
602 602
 
603 603
         return true;
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
         if ($tok == "\0") {
627 627
             $tok = UTF8Utils::FFFD;
628 628
         }
629
-        while (! $this->isCommentEnd()) {
629
+        while (!$this->isCommentEnd()) {
630 630
             $comment .= $tok;
631 631
             $this->scanner->next();
632 632
             $tok = $this->scanner->current();
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
         $chars = $this->scanner->charsWhile("DOCTYPEdoctype");
683 683
         if (strcasecmp($chars, 'DOCTYPE')) {
684 684
             $this->parseError('Expected DOCTYPE, got %s', $chars);
685
-            return $this->bogusComment('<!' . $chars);
685
+            return $this->bogusComment('<!'.$chars);
686 686
         }
687 687
 
688 688
         $this->scanner->whitespace();
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
         $tok = $this->scanner->current();
795 795
         if ($tok == '"' || $tok == "'") {
796 796
             $this->scanner->next();
797
-            $ret = $this->scanner->charsUntil($tok . $stopchars);
797
+            $ret = $this->scanner->charsUntil($tok.$stopchars);
798 798
             if ($this->scanner->current() == $tok) {
799 799
                 $this->scanner->next();
800 800
             } else {
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
         $chars = $this->scanner->charsWhile('CDAT');
821 821
         if ($chars != 'CDATA' || $this->scanner->current() != '[') {
822 822
             $this->parseError('Expected [CDATA[, got %s', $chars);
823
-            return $this->bogusComment('<![' . $chars);
823
+            return $this->bogusComment('<!['.$chars);
824 824
         }
825 825
 
826 826
         $this->scanner->next();
@@ -828,13 +828,13 @@  discard block
 block discarded – undo
828 828
         do {
829 829
             if ($tok === false) {
830 830
                 $this->parseError('Unexpected EOF inside CDATA.');
831
-                $this->bogusComment('<![CDATA[' . $cdata);
831
+                $this->bogusComment('<![CDATA['.$cdata);
832 832
                 return true;
833 833
             }
834 834
             $cdata .= $tok;
835 835
             $this->scanner->next();
836 836
             $tok = $this->scanner->current();
837
-        } while (! $this->sequenceMatches(']]>'));
837
+        } while (!$this->sequenceMatches(']]>'));
838 838
 
839 839
         // Consume ]]>
840 840
         $this->scanner->consume(3);
@@ -868,13 +868,13 @@  discard block
 block discarded – undo
868 868
         // If not a PI, send to bogusComment.
869 869
         if (strlen($procName) == 0 || $white == 0 || $this->scanner->current() == false) {
870 870
             $this->parseError("Expected processing instruction name, got $tok");
871
-            $this->bogusComment('<?' . $tok . $procName);
871
+            $this->bogusComment('<?'.$tok.$procName);
872 872
             return true;
873 873
         }
874 874
 
875 875
         $data = '';
876 876
         // As long as it's not the case that the next two chars are ? and >.
877
-        while (! ($this->scanner->current() == '?' && $this->scanner->peek() == '>')) {
877
+        while (!($this->scanner->current() == '?' && $this->scanner->peek() == '>')) {
878 878
             $data .= $this->scanner->current();
879 879
 
880 880
             $this->scanner->next();
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 
1032 1032
         // These indicate not an entity. We return just
1033 1033
         // the &.
1034
-        if (strspn($tok, static::WHITE . "&<") == 1) {
1034
+        if (strspn($tok, static::WHITE."&<") == 1) {
1035 1035
             // $this->scanner->next();
1036 1036
             return '&';
1037 1037
         }
@@ -1106,6 +1106,6 @@  discard block
 block discarded – undo
1106 1106
         }
1107 1107
 
1108 1108
         $this->parseError("Expected &ENTITY;, got &ENTITY%s (no trailing ;) ", $tok);
1109
-        return '&' . $entity;
1109
+        return '&'.$entity;
1110 1110
     }
1111 1111
 }
Please login to merge, or discard this patch.