Completed
Push — master ( 604db9...9db94b )
by Alexey
07:34
created
system/objects/CodeGenerator.php 1 patch
Braces   +9 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,20 +13,22 @@
 block discarded – undo
13 13
     static function genArray($data, $level = 0)
14 14
     {
15 15
         $return = '';
16
-        if ($level == 0)
17
-            $return = "[";
16
+        if ($level == 0) {
17
+                    $return = "[";
18
+        }
18 19
         foreach ($data as $key => $item) {
19 20
             $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "'{$key}' => ";
20
-            if (!is_array($item))
21
-                $return .= "'{$item}',";
22
-            else {
21
+            if (!is_array($item)) {
22
+                            $return .= "'{$item}',";
23
+            } else {
23 24
                 $return .= "[";
24 25
                 $return .= rtrim(self::genArray($item, $level + 1), ',');
25 26
                 $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "],";
26 27
             }
27 28
         }
28
-        if ($level == 0)
29
-            $return = rtrim($return, ',') . "\n];";
29
+        if ($level == 0) {
30
+                    $return = rtrim($return, ',') . "\n];";
31
+        }
30 32
 
31 33
         return $return;
32 34
     }
Please login to merge, or discard this patch.
system/objects/IdnaConvert.php 1 patch
Braces   +75 added lines, -24 removed lines patch added patch discarded remove patch
@@ -205,7 +205,9 @@  discard block
 block discarded – undo
205 205
             foreach ($arr as $k => $v) {
206 206
                 if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
207 207
                     $conv = $this->_decode($v);
208
-                    if ($conv) $arr[$k] = $conv;
208
+                    if ($conv) {
209
+                        $arr[$k] = $conv;
210
+                    }
209 211
                 }
210 212
             }
211 213
             $input = join('.', $arr);
@@ -213,7 +215,9 @@  discard block
 block discarded – undo
213 215
             foreach ($arr as $k => $v) {
214 216
                 if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
215 217
                     $conv = $this->_decode($v);
216
-                    if ($conv) $arr[$k] = $conv;
218
+                    if ($conv) {
219
+                        $arr[$k] = $conv;
220
+                    }
217 221
                 }
218 222
             }
219 223
             $email_pref = join('.', $arr);
@@ -229,7 +233,9 @@  discard block
 block discarded – undo
229 233
                 $arr = explode('.', $parsed['host']);
230 234
                 foreach ($arr as $k => $v) {
231 235
                     $conv = $this->_decode($v);
232
-                    if ($conv) $arr[$k] = $conv;
236
+                    if ($conv) {
237
+                        $arr[$k] = $conv;
238
+                    }
233 239
                 }
234 240
                 $parsed['host'] = join('.', $arr);
235 241
                 $return =
@@ -250,7 +256,9 @@  discard block
 block discarded – undo
250 256
             }
251 257
         } else { // Otherwise we consider it being a pure domain name string
252 258
             $return = $this->_decode($input);
253
-            if (!$return) $return = $input;
259
+            if (!$return) {
260
+                $return = $input;
261
+            }
254 262
         }
255 263
         // The output is UTF-8 by default, other output formats need conversion here
256 264
         // If one time encoding is given, use this, else the objects property
@@ -294,7 +302,9 @@  discard block
 block discarded – undo
294 302
         }
295 303
 
296 304
         // No input, no output, what else did you expect?
297
-        if (empty($decoded)) return '';
305
+        if (empty($decoded)) {
306
+            return '';
307
+        }
298 308
 
299 309
         // Anchors for iteration
300 310
         $last_begin = 0;
@@ -371,7 +381,9 @@  discard block
 block discarded – undo
371 381
         $arr = explode('.', $parsed['host']);
372 382
         foreach ($arr as $k => $v) {
373 383
             $conv = $this->encode($v, 'utf8');
374
-            if ($conv) $arr[$k] = $conv;
384
+            if ($conv) {
385
+                $arr[$k] = $conv;
386
+            }
375 387
         }
376 388
         $parsed['host'] = join('.', $arr);
377 389
         $return =
@@ -436,7 +448,9 @@  discard block
 block discarded – undo
436 448
                 $idx += $digit * $w;
437 449
                 $t = ($k <= $bias) ? $this->_tmin :
438 450
                         (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
439
-                if ($digit < $t) break;
451
+                if ($digit < $t) {
452
+                    break;
453
+                }
440 454
                 $w = (int) ($w * ($this->_base - $t));
441 455
             }
442 456
             $bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first);
@@ -445,7 +459,9 @@  discard block
 block discarded – undo
445 459
             $idx %= ($deco_len + 1);
446 460
             if ($deco_len > 0) {
447 461
                 // Make room for the decoded char
448
-                for ($i = $deco_len; $i > $idx; $i--) $decoded[$i] = $decoded[($i - 1)];
462
+                for ($i = $deco_len; $i > $idx; $i--) {
463
+                    $decoded[$i] = $decoded[($i - 1)];
464
+                }
449 465
             }
450 466
             $decoded[$idx++] = $char;
451 467
         }
@@ -482,9 +498,15 @@  discard block
 block discarded – undo
482 498
         }
483 499
         // Do NAMEPREP
484 500
         $decoded = $this->_nameprep($decoded);
485
-        if (!$decoded || !is_array($decoded)) return false; // NAMEPREP failed
501
+        if (!$decoded || !is_array($decoded)) {
502
+            return false;
503
+        }
504
+        // NAMEPREP failed
486 505
         $deco_len  = count($decoded);
487
-        if (!$deco_len) return false; // Empty array
506
+        if (!$deco_len) {
507
+            return false;
508
+        }
509
+        // Empty array
488 510
         $codecount = 0; // How many chars have been consumed
489 511
         $encoded = '';
490 512
         // Copy all basic code points to output
@@ -497,12 +519,17 @@  discard block
 block discarded – undo
497 519
                 $codecount++;
498 520
             }
499 521
         }
500
-        if ($codecount == $deco_len) return $encoded; // All codepoints were basic ones
522
+        if ($codecount == $deco_len) {
523
+            return $encoded;
524
+        }
525
+        // All codepoints were basic ones
501 526
 
502 527
         // Start with the prefix; copy it to output
503 528
         $encoded = $this->_punycode_prefix.$encoded;
504 529
         // If we have basic code points in output, add an hyphen to the end
505
-        if ($codecount) $encoded .= '-';
530
+        if ($codecount) {
531
+            $encoded .= '-';
532
+        }
506 533
         // Now find and encode all non-basic code points
507 534
         $is_first = true;
508 535
         $cur_code = $this->_initial_n;
@@ -527,7 +554,9 @@  discard block
 block discarded – undo
527 554
                     for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) {
528 555
                         $t = ($k <= $bias) ? $this->_tmin :
529 556
                                 (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias);
530
-                        if ($q < $t) break;
557
+                        if ($q < $t) {
558
+                            break;
559
+                        }
531 560
                         $encoded .= $this->_encode_digit(intval($t + (($q - $t) % ($this->_base - $t)))); //v0.4.5 Changed from ceil() to intval()
532 561
                         $q = (int) (($q - $t) / ($this->_base - $t));
533 562
                     }
@@ -607,7 +636,9 @@  discard block
 block discarded – undo
607 636
         // While mapping required chars we apply the cannonical ordering
608 637
         foreach ($input as $v) {
609 638
             // Map to nothing == skip that code point
610
-            if (in_array($v, self::$NP['map_nothing'])) continue;
639
+            if (in_array($v, self::$NP['map_nothing'])) {
640
+                continue;
641
+            }
611 642
             // Try to find prohibited input
612 643
             if (in_array($v, self::$NP['prohibit']) || in_array($v, self::$NP['general_prohibited'])) {
613 644
                 $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
@@ -654,7 +685,9 @@  discard block
 block discarded – undo
654 685
                 if ($out) {
655 686
                     $output[$last_starter] = $out;
656 687
                     if (count($out) != $seq_len) {
657
-                        for ($j = $i+1; $j < $out_len; ++$j) $output[$j-1] = $output[$j];
688
+                        for ($j = $i+1; $j < $out_len; ++$j) {
689
+                            $output[$j-1] = $output[$j];
690
+                        }
658 691
                         unset($output[$out_len]);
659 692
                     }
660 693
                     // Rewind the for loop by one, since there can be more possible compositions
@@ -665,7 +698,9 @@  discard block
 block discarded – undo
665 698
                 }
666 699
             }
667 700
             // The current class is 0
668
-            if (!$class) $last_starter = $i;
701
+            if (!$class) {
702
+                $last_starter = $i;
703
+            }
669 704
             $last_class = $class;
670 705
         }
671 706
         return $output;
@@ -680,12 +715,16 @@  discard block
 block discarded – undo
680 715
     protected function _hangul_decompose($char)
681 716
     {
682 717
         $sindex = (int) $char - $this->_sbase;
683
-        if ($sindex < 0 || $sindex >= $this->_scount) return array($char);
718
+        if ($sindex < 0 || $sindex >= $this->_scount) {
719
+            return array($char);
720
+        }
684 721
         $result = array();
685 722
         $result[] = (int) $this->_lbase + $sindex / $this->_ncount;
686 723
         $result[] = (int) $this->_vbase + ($sindex % $this->_ncount) / $this->_tcount;
687 724
         $T = intval($this->_tbase + $sindex % $this->_tcount);
688
-        if ($T != $this->_tbase) $result[] = $T;
725
+        if ($T != $this->_tbase) {
726
+            $result[] = $T;
727
+        }
689 728
         return $result;
690 729
     }
691 730
     /**
@@ -697,7 +736,9 @@  discard block
 block discarded – undo
697 736
     protected function _hangul_compose($input)
698 737
     {
699 738
         $inp_len = count($input);
700
-        if (!$inp_len) return array();
739
+        if (!$inp_len) {
740
+            return array();
741
+        }
701 742
         $result = array();
702 743
         $last = (int) $input[0];
703 744
         $result[] = $last; // copy first char from input to output
@@ -757,7 +798,9 @@  discard block
 block discarded – undo
757 798
                 if ($next != 0 && $last > $next) {
758 799
                     // Move item leftward until it fits
759 800
                     for ($j = $i + 1; $j > 0; --$j) {
760
-                        if ($this->_get_combining_class(intval($input[$j-1])) <= $next) break;
801
+                        if ($this->_get_combining_class(intval($input[$j-1])) <= $next) {
802
+                            break;
803
+                        }
761 804
                         $t = intval($input[$j]);
762 805
                         $input[$j] = intval($input[$j-1]);
763 806
                         $input[$j-1] = $t;
@@ -784,8 +827,12 @@  discard block
 block discarded – undo
784 827
             return false;
785 828
         }
786 829
         foreach (self::$NP['replacemaps'] as $np_src => $np_target) {
787
-            if ($np_target[0] != $input[0]) continue;
788
-            if (count($np_target) != $inp_len) continue;
830
+            if ($np_target[0] != $input[0]) {
831
+                continue;
832
+            }
833
+            if (count($np_target) != $inp_len) {
834
+                continue;
835
+            }
789 836
             $hit = false;
790 837
             foreach ($input as $k2 => $v2) {
791 838
                 if ($v2 == $np_target[$k2]) {
@@ -795,7 +842,9 @@  discard block
 block discarded – undo
795 842
                     break;
796 843
                 }
797 844
             }
798
-            if ($hit) return $np_src;
845
+            if ($hit) {
846
+                return $np_src;
847
+            }
799 848
         }
800 849
         return false;
801 850
     }
@@ -948,7 +997,9 @@  discard block
 block discarded – undo
948 997
             return false;
949 998
         }
950 999
         // Empty input - return empty output
951
-        if (!$inp_len) return $output;
1000
+        if (!$inp_len) {
1001
+            return $output;
1002
+        }
952 1003
         for ($i = 0, $out_len = -1; $i < $inp_len; ++$i) {
953 1004
             // Increment output position every 4 input bytes
954 1005
             if (!($i % 4)) {
Please login to merge, or discard this patch.