Completed
Pull Request — master (#4)
by Helpful
02:37
created
thirdparty/html5lib/HTML5/Data.php 1 patch
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,8 +56,11 @@  discard block
 block discarded – undo
56 56
      * reference.
57 57
      */
58 58
     public static function getRealCodepoint($ref) {
59
-        if (!isset(self::$realCodepointTable[$ref])) return false;
60
-        else return self::$realCodepointTable[$ref];
59
+        if (!isset(self::$realCodepointTable[$ref])) {
60
+            return false;
61
+        } else {
62
+            return self::$realCodepointTable[$ref];
63
+        }
61 64
     }
62 65
 
63 66
     public static function getNamedCharacterReferences() {
@@ -103,9 +106,15 @@  discard block
 block discarded – undo
103 106
         }
104 107
         // set up the actual character
105 108
         $ret = '';
106
-        if($w) $ret .= chr($w);
107
-        if($z) $ret .= chr($z);
108
-        if($y) $ret .= chr($y);
109
+        if($w) {
110
+            $ret .= chr($w);
111
+        }
112
+        if($z) {
113
+            $ret .= chr($z);
114
+        }
115
+        if($y) {
116
+            $ret .= chr($y);
117
+        }
109 118
         $ret .= chr($x);
110 119
 
111 120
         return $ret;
Please login to merge, or discard this patch.
thirdparty/html5lib/HTML5/Tokenizer.php 1 patch
Braces   +26 added lines, -9 removed lines patch added patch discarded remove patch
@@ -86,8 +86,11 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function __construct($data, $builder = null) {
88 88
         $this->stream = new HTML5_InputStream($data);
89
-        if (!$builder) $this->tree = new HTML5_TreeBuilder;
90
-        else $this->tree = $builder;
89
+        if (!$builder) {
90
+            $this->tree = new HTML5_TreeBuilder;
91
+        } else {
92
+            $this->tree = $builder;
93
+        }
91 94
         $this->content_model = self::PCDATA;
92 95
     }
93 96
 
@@ -135,7 +138,9 @@  discard block
 block discarded – undo
135 138
                     /* Consume the next input character */
136 139
                     $char = $this->stream->char();
137 140
                     $lastFourChars .= $char;
138
-                    if (strlen($lastFourChars) > 4) $lastFourChars = substr($lastFourChars, -4);
141
+                    if (strlen($lastFourChars) > 4) {
142
+                        $lastFourChars = substr($lastFourChars, -4);
143
+                    }
139 144
 
140 145
                     // see below for meaning
141 146
                     $hyp_cond = 
@@ -248,7 +253,9 @@  discard block
 block discarded – undo
248 253
                             'data' => $char . $chars
249 254
                         ));
250 255
                         $lastFourChars .= $chars;
251
-                        if (strlen($lastFourChars) > 4) $lastFourChars = substr($lastFourChars, -4);
256
+                        if (strlen($lastFourChars) > 4) {
257
+                            $lastFourChars = substr($lastFourChars, -4);
258
+                        }
252 259
 
253 260
                     } else {
254 261
                         /* Anything else
@@ -257,10 +264,18 @@  discard block
 block discarded – undo
257 264
                         as a single character token. Stay in the data state. */
258 265
                         
259 266
                         $mask = '';
260
-                        if ($hyp_cond) $mask .= '-';
261
-                        if ($amp_cond) $mask .= '&';
262
-                        if ($lt_cond)  $mask .= '<';
263
-                        if ($gt_cond)  $mask .= '>';
267
+                        if ($hyp_cond) {
268
+                            $mask .= '-';
269
+                        }
270
+                        if ($amp_cond) {
271
+                            $mask .= '&';
272
+                        }
273
+                        if ($lt_cond) {
274
+                            $mask .= '<';
275
+                        }
276
+                        if ($gt_cond) {
277
+                            $mask .= '>';
278
+                        }
264 279
 
265 280
                         if ($mask === '') {
266 281
                             $chars = $this->stream->remainingChars();
@@ -274,7 +289,9 @@  discard block
 block discarded – undo
274 289
                         ));
275 290
 
276 291
                         $lastFourChars .= $chars;
277
-                        if (strlen($lastFourChars) > 4) $lastFourChars = substr($lastFourChars, -4);
292
+                        if (strlen($lastFourChars) > 4) {
293
+                            $lastFourChars = substr($lastFourChars, -4);
294
+                        }
278 295
 
279 296
                         $state = 'data';
280 297
                     }
Please login to merge, or discard this patch.
thirdparty/html5lib/HTML5/TreeBuilder.php 1 patch
Braces   +86 added lines, -37 removed lines patch added patch discarded remove patch
@@ -112,7 +112,9 @@  discard block
 block discarded – undo
112 112
             $r = new ReflectionClass('HTML5_TreeBuilder');
113 113
             $consts = $r->getConstants();
114 114
             foreach ($consts as $const => $num) {
115
-                if (!is_int($num)) continue;
115
+                if (!is_int($num)) {
116
+                    continue;
117
+                }
116 118
                 $lookup[$num] = $const;
117 119
             }
118 120
         }
@@ -159,8 +161,12 @@  discard block
 block discarded – undo
159 161
     // Process tag tokens
160 162
     public function emitToken($token, $mode = null) {
161 163
         // XXX: ignore parse errors... why are we emitting them, again?
162
-        if ($token['type'] === HTML5_Tokenizer::PARSEERROR) return;
163
-        if ($mode === null) $mode = $this->mode;
164
+        if ($token['type'] === HTML5_Tokenizer::PARSEERROR) {
165
+            return;
166
+        }
167
+        if ($mode === null) {
168
+            $mode = $this->mode;
169
+        }
164 170
 
165 171
         /*
166 172
         $backtrace = debug_backtrace();
@@ -175,7 +181,9 @@  discard block
 block discarded – undo
175 181
         if ($this->flag_frameset_ok) echo "  -> frameset ok\n";
176 182
         */
177 183
 
178
-        if ($this->ignore_lf_token) $this->ignore_lf_token--;
184
+        if ($this->ignore_lf_token) {
185
+            $this->ignore_lf_token--;
186
+        }
179 187
         $this->ignored = false;
180 188
         // indenting is a little wonky, this can be changed later on
181 189
         switch ($mode) {
@@ -212,8 +220,12 @@  discard block
 block discarded – undo
212 220
              * appropriate. Associate the DocumentType node with the
213 221
              * Document object so that it is returned as the value of the
214 222
              * doctype attribute of the Document object. */
215
-            if (!isset($token['public'])) $token['public'] = null;
216
-            if (!isset($token['system'])) $token['system'] = null;
223
+            if (!isset($token['public'])) {
224
+                $token['public'] = null;
225
+            }
226
+            if (!isset($token['system'])) {
227
+                $token['system'] = null;
228
+            }
217 229
             // XDOM
218 230
             // Yes this is hacky. I'm kind of annoyed that I can't appendChild
219 231
             // a doctype to DOMDocument. Maybe I haven't chanted the right
@@ -318,14 +330,18 @@  discard block
 block discarded – undo
318 330
                                 break;
319 331
                             }
320 332
                         }
321
-                        if (!is_null($this->quirks_mode)) break;
333
+                        if (!is_null($this->quirks_mode)) {
334
+                            break;
335
+                        }
322 336
                         foreach ($publicStartsWithAndSystemForLimitedQuirks as $x) {
323 337
                             if (strncmp($public, $x, strlen($x)) === 0) {
324 338
                                 $this->quirks_mode = self::LIMITED_QUIRKS_MODE;
325 339
                                 break;
326 340
                             }
327 341
                         }
328
-                        if (!is_null($this->quirks_mode)) break;
342
+                        if (!is_null($this->quirks_mode)) {
343
+                            break;
344
+                        }
329 345
                     }
330 346
                     foreach ($publicSetToForQuirks as $x) {
331 347
                         if ($public === $x) {
@@ -333,13 +349,17 @@  discard block
 block discarded – undo
333 349
                             break;
334 350
                         }
335 351
                     }
336
-                    if (!is_null($this->quirks_mode)) break;
352
+                    if (!is_null($this->quirks_mode)) {
353
+                        break;
354
+                    }
337 355
                     foreach ($publicStartsWithForLimitedQuirks as $x) {
338 356
                         if (strncmp($public, $x, strlen($x)) === 0) {
339 357
                             $this->quirks_mode = self::LIMITED_QUIRKS_MODE;
340 358
                         }
341 359
                     }
342
-                    if (!is_null($this->quirks_mode)) break;
360
+                    if (!is_null($this->quirks_mode)) {
361
+                        break;
362
+                    }
343 363
                     if ($system === "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd") {
344 364
                         $this->quirks_mode = self::QUIRKS_MODE;
345 365
                         break;
@@ -1031,11 +1051,15 @@  discard block
 block discarded – undo
1031 1051
                             ));
1032 1052
                             if (in_array($a, $this->a_formatting)) {
1033 1053
                                 $a_i = array_search($a, $this->a_formatting, true);
1034
-                                if($a_i !== false) array_splice($this->a_formatting, $a_i, 1);
1054
+                                if($a_i !== false) {
1055
+                                    array_splice($this->a_formatting, $a_i, 1);
1056
+                                }
1035 1057
                             }
1036 1058
                             if (in_array($a, $this->stack)) {
1037 1059
                                 $a_i = array_search($a, $this->stack, true);
1038
-                                if ($a_i !== false) array_splice($this->stack, $a_i, 1);
1060
+                                if ($a_i !== false) {
1061
+                                    array_splice($this->stack, $a_i, 1);
1062
+                                }
1039 1063
                             }
1040 1064
                             break;
1041 1065
                         }
@@ -1274,7 +1298,9 @@  discard block
 block discarded – undo
1274 1298
                         $attr = array();
1275 1299
                         foreach ($token['attr'] as $keypair) {
1276 1300
                             if ($keypair['name'] === 'name' || $keypair['name'] === 'action' ||
1277
-                                $keypair['name'] === 'prompt') continue;
1301
+                                $keypair['name'] === 'prompt') {
1302
+                                continue;
1303
+                            }
1278 1304
                             $attr[] = $keypair;
1279 1305
                         }
1280 1306
                         $attr[] = array('name' => 'name', 'value' => 'isindex');
@@ -1502,7 +1528,9 @@  discard block
 block discarded – undo
1502 1528
                         'type' => HTML5_Tokenizer::ENDTAG
1503 1529
                     ));
1504 1530
 
1505
-                    if (!$this->ignored) $this->emitToken($token);
1531
+                    if (!$this->ignored) {
1532
+                        $this->emitToken($token);
1533
+                    }
1506 1534
                 break;
1507 1535
 
1508 1536
                 case 'address': case 'article': case 'aside': case 'blockquote':
@@ -2100,7 +2128,9 @@  discard block
 block discarded – undo
2100 2128
                 'type' => HTML5_Tokenizer::ENDTAG
2101 2129
             ));
2102 2130
 
2103
-            if (!$this->ignored) $this->emitToken($token);
2131
+            if (!$this->ignored) {
2132
+                $this->emitToken($token);
2133
+            }
2104 2134
 
2105 2135
         /* An end tag whose tag name is "table" */
2106 2136
         } elseif($token['type'] === HTML5_Tokenizer::ENDTAG &&
@@ -2262,7 +2292,9 @@  discard block
 block discarded – undo
2262 2292
                 'type' => HTML5_Tokenizer::ENDTAG
2263 2293
             ));
2264 2294
 
2265
-            if (!$this->ignored) $this->emitToken($token);
2295
+            if (!$this->ignored) {
2296
+                $this->emitToken($token);
2297
+            }
2266 2298
 
2267 2299
         /* An end tag whose tag name is one of: "body", "col", "colgroup",
2268 2300
         "html", "tbody", "td", "tfoot", "th", "thead", "tr" */
@@ -2342,7 +2374,9 @@  discard block
 block discarded – undo
2342 2374
                 'type' => HTML5_Tokenizer::ENDTAG
2343 2375
             ));
2344 2376
 
2345
-            if (!$this->ignored) $this->emitToken($token);
2377
+            if (!$this->ignored) {
2378
+                $this->emitToken($token);
2379
+            }
2346 2380
         }
2347 2381
     break;
2348 2382
 
@@ -2485,7 +2519,9 @@  discard block
 block discarded – undo
2485 2519
                 'name' => 'tr',
2486 2520
                 'type' => HTML5_Tokenizer::ENDTAG
2487 2521
             ));
2488
-            if (!$this->ignored) $this->emitToken($token);
2522
+            if (!$this->ignored) {
2523
+                $this->emitToken($token);
2524
+            }
2489 2525
 
2490 2526
         /* An end tag whose tag name is one of: "tbody", "tfoot", "thead" */
2491 2527
         } elseif($token['type'] === HTML5_Tokenizer::ENDTAG &&
@@ -3176,11 +3212,15 @@  discard block
 block discarded – undo
3176 3212
     }
3177 3213
 
3178 3214
     private function insertText($data) {
3179
-        if ($data === '') return;
3215
+        if ($data === '') {
3216
+            return;
3217
+        }
3180 3218
         if ($this->ignore_lf_token) {
3181 3219
             if ($data[0] === "\n") {
3182 3220
                 $data = substr($data, 1);
3183
-                if ($data === false) return;
3221
+                if ($data === false) {
3222
+                    return;
3223
+                }
3184 3224
             }
3185 3225
         }
3186 3226
         $text = $this->dom->createTextNode($data);
@@ -3362,19 +3402,19 @@  discard block
 block discarded – undo
3362 3402
     }
3363 3403
 
3364 3404
     private function getElementCategory($node) {
3365
-        if (!is_object($node)) debug_print_backtrace();
3405
+        if (!is_object($node)) {
3406
+            debug_print_backtrace();
3407
+        }
3366 3408
         $name = $node->tagName;
3367
-        if(in_array($name, $this->special))
3368
-            return self::SPECIAL;
3369
-
3370
-        elseif(in_array($name, $this->scoping))
3371
-            return self::SCOPING;
3372
-
3373
-        elseif(in_array($name, $this->formatting))
3374
-            return self::FORMATTING;
3375
-
3376
-        else
3377
-            return self::PHRASING;
3409
+        if(in_array($name, $this->special)) {
3410
+                    return self::SPECIAL;
3411
+        } elseif(in_array($name, $this->scoping)) {
3412
+                    return self::SCOPING;
3413
+        } elseif(in_array($name, $this->formatting)) {
3414
+                    return self::FORMATTING;
3415
+        } else {
3416
+                    return self::PHRASING;
3417
+        }
3378 3418
     }
3379 3419
 
3380 3420
     private function clearStackToTableContext($elements) {
@@ -3540,10 +3580,14 @@  discard block
 block discarded – undo
3540 3580
     }
3541 3581
 
3542 3582
     private function getAttr($token, $key) {
3543
-        if (!isset($token['attr'])) return false;
3583
+        if (!isset($token['attr'])) {
3584
+            return false;
3585
+        }
3544 3586
         $ret = false;
3545 3587
         foreach ($token['attr'] as $keypair) {
3546
-            if ($keypair['name'] === $key) $ret = $keypair['value'];
3588
+            if ($keypair['name'] === $key) {
3589
+                $ret = $keypair['value'];
3590
+            }
3547 3591
         }
3548 3592
         return $ret;
3549 3593
     }
@@ -3624,11 +3668,16 @@  discard block
 block discarded – undo
3624 3668
      * For debugging, prints active formatting elements
3625 3669
      */
3626 3670
     private function printActiveFormattingElements() {
3627
-        if (!$this->a_formatting) return;
3671
+        if (!$this->a_formatting) {
3672
+            return;
3673
+        }
3628 3674
         $names = array();
3629 3675
         foreach ($this->a_formatting as $node) {
3630
-            if ($node === self::MARKER) $names[] = 'MARKER';
3631
-            else $names[] = $node->tagName;
3676
+            if ($node === self::MARKER) {
3677
+                $names[] = 'MARKER';
3678
+            } else {
3679
+                $names[] = $node->tagName;
3680
+            }
3632 3681
         }
3633 3682
         echo "  -> active formatting [" . implode(', ', $names) . "]\n";
3634 3683
     }
Please login to merge, or discard this patch.