Completed
Push — master ( 7329e0...83359d )
by Ben
30s queued 16s
created
classes/PHPTAL.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -975,10 +975,10 @@  discard block
 block discarded – undo
975 975
      */
976 976
     public function getFunctionName()
977 977
     {
978
-       // function name is used as base for caching, so it must be unique for
979
-       // every combination of settings that changes code in compiled template
978
+        // function name is used as base for caching, so it must be unique for
979
+        // every combination of settings that changes code in compiled template
980 980
 
981
-       if (!$this->_functionName) {
981
+        if (!$this->_functionName) {
982 982
 
983 983
             // just to make tempalte name recognizable
984 984
             $basename = preg_replace('/\.[a-z]{3,5}$/', '', basename($this->_source->getRealPath() ?? ''));
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
             $hash = strtr(rtrim(base64_encode($hash),"="),"+/=","_A_");
999 999
 
1000 1000
             $this->_functionName = $this->getFunctionNamePrefix($this->_source->getLastModifiedTime()) .
1001
-                                   $basename . '__' . $hash;
1001
+                                    $basename . '__' . $hash;
1002 1002
         }
1003 1003
         return $this->_functionName;
1004 1004
     }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
      *
176 176
      * @param string $path Template file path.
177 177
      */
178
-    public function __construct($path=false)
178
+    public function __construct($path = false)
179 179
     {
180 180
         $this->_path = $path;
181 181
         $this->_globalContext = new stdClass();
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      *
204 204
      * @return PHPTAL
205 205
      */
206
-    public static function create($path=false)
206
+    public static function create($path = false)
207 207
     {
208 208
         return new PHPTAL($path);
209 209
     }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
      */
409 409
     public function setPhpCodeDestination($path)
410 410
     {
411
-        $this->_phpCodeDestination = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
411
+        $this->_phpCodeDestination = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
412 412
         $this->resetPrepared();
413 413
         return $this;
414 414
     }
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     private function getPreFiltersCacheId()
549 549
     {
550 550
         $cacheid = '';
551
-        foreach($this->getPreFilters() as $key => $prefilter) {
551
+        foreach ($this->getPreFilters() as $key => $prefilter) {
552 552
             if ($prefilter instanceof PHPTAL_PreFilter) {
553 553
                 $cacheid .= $key.$prefilter->getCacheId();
554 554
             } elseif ($prefilter instanceof PHPTAL_Filter) {
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
     {
570 570
         $prefilters = $this->getPreFilters();
571 571
 
572
-        foreach($prefilters as $prefilter) {
572
+        foreach ($prefilters as $prefilter) {
573 573
             if ($prefilter instanceof PHPTAL_PreFilter) {
574 574
                 $prefilter->setPHPTAL($this);
575 575
             }
@@ -675,12 +675,12 @@  discard block
 block discarded – undo
675 675
 
676 676
             // unshift doctype
677 677
             if ($this->_context->_docType) {
678
-                $res = $this->_context->_docType . $res;
678
+                $res = $this->_context->_docType.$res;
679 679
             }
680 680
 
681 681
             // unshift xml declaration
682 682
             if ($this->_context->_xmlDeclaration) {
683
-                $res = $this->_context->_xmlDeclaration . "\n" . $res;
683
+                $res = $this->_context->_xmlDeclaration."\n".$res;
684 684
             }
685 685
 
686 686
             if ($this->_postfilter) {
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
                 $this->externalMacroTemplatesCache[$file] = $tpl;
769 769
             }
770 770
 
771
-            $fun = $tpl->getFunctionName() . '_' . strtr($macroName, "-", "_");
771
+            $fun = $tpl->getFunctionName().'_'.strtr($macroName, "-", "_");
772 772
             if (!function_exists($fun)) {
773 773
                 throw new PHPTAL_MacroMissingException("Macro '$macroName' is not defined in $file", $this->_source->getRealPath());
774 774
             }
@@ -777,11 +777,11 @@  discard block
 block discarded – undo
777 777
 
778 778
         } else {
779 779
             // call local macro
780
-            $fun = $local_tpl->getFunctionName() . '_' . strtr($path, "-", "_");
780
+            $fun = $local_tpl->getFunctionName().'_'.strtr($path, "-", "_");
781 781
             if (!function_exists($fun)) {
782 782
                 throw new PHPTAL_MacroMissingException("Macro '$path' is not defined", $local_tpl->_source->getRealPath());
783 783
             }
784
-            $fun( $local_tpl, $this);
784
+            $fun($local_tpl, $this);
785 785
         }
786 786
     }
787 787
 
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
     private function setCodeFile()
792 792
     {
793 793
         $this->findTemplate();
794
-        $this->_codeFile = $this->getPhpCodeDestination() . $this->getFunctionName() . '.' . $this->getPhpCodeExtension();
794
+        $this->_codeFile = $this->getPhpCodeDestination().$this->getFunctionName().'.'.$this->getPhpCodeExtension();
795 795
     }
796 796
 
797 797
     protected function resetPrepared()
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 
820 820
                 // i'm not sure where that belongs, but not in normal path of execution
821 821
                 // because some sites have _a lot_ of files in temp
822
-                if ($this->getCachePurgeFrequency() && mt_rand()%$this->getCachePurgeFrequency() == 0) {
822
+                if ($this->getCachePurgeFrequency() && mt_rand() % $this->getCachePurgeFrequency() == 0) {
823 823
                     $this->cleanUpGarbage();
824 824
                 }
825 825
 
@@ -836,16 +836,16 @@  discard block
 block discarded – undo
836 836
                 try {
837 837
                     eval("?>\n".$result);
838 838
                 }
839
-                catch(ParseError $parseError) {
839
+                catch (ParseError $parseError) {
840 840
                     ob_end_clean();
841 841
                     throw new PHPTAL_TemplateException(
842
-                        'Parse error: ' . $parseError->getMessage(),
842
+                        'Parse error: '.$parseError->getMessage(),
843 843
                         $this->getCodePath(),
844 844
                         $parseError->getLine(),
845 845
                         $parseError
846 846
                     );
847 847
                 }
848
-                catch(Exception $e) {
848
+                catch (Exception $e) {
849 849
                     ob_end_clean();
850 850
                     throw $e;
851 851
                 }
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
                     $msg = str_replace('eval()\'d code', $this->getCodePath(), ob_get_clean());
855 855
 
856 856
                     // greedy .* ensures last match
857
-                    if (preg_match('/.*on line (\d+)$/m', $msg, $m)) $line=$m[1]; else $line=0;
857
+                    if (preg_match('/.*on line (\d+)$/m', $msg, $m)) $line = $m[1]; else $line = 0;
858 858
                     throw new PHPTAL_TemplateException(trim($msg), $this->getCodePath(), $line);
859 859
                 }
860 860
                 ob_end_clean();
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
      */
896 896
     public function setCachePurgeFrequency($n)
897 897
     {
898
-        $this->_cachePurgeFrequency = (int)$n;
898
+        $this->_cachePurgeFrequency = (int) $n;
899 899
         return $this;
900 900
     }
901 901
 
@@ -915,14 +915,14 @@  discard block
 block discarded – undo
915 915
      */
916 916
     public function cleanUpGarbage()
917 917
     {
918
-        $cacheFilesExpire = time() - $this->getCacheLifetime() * 3600 * 24;
918
+        $cacheFilesExpire = time()-$this->getCacheLifetime() * 3600 * 24;
919 919
 
920 920
         // relies on templates sorting order being related to their modification dates
921
-        $upperLimit = $this->getPhpCodeDestination() . $this->getFunctionNamePrefix($cacheFilesExpire) . '_';
922
-        $lowerLimit = $this->getPhpCodeDestination() . $this->getFunctionNamePrefix(0);
921
+        $upperLimit = $this->getPhpCodeDestination().$this->getFunctionNamePrefix($cacheFilesExpire).'_';
922
+        $lowerLimit = $this->getPhpCodeDestination().$this->getFunctionNamePrefix(0);
923 923
 
924 924
         // second * gets phptal:cache
925
-        $cacheFiles = glob($this->getPhpCodeDestination() . 'tpl_????????_*.' . $this->getPhpCodeExtension() . '*');
925
+        $cacheFiles = glob($this->getPhpCodeDestination().'tpl_????????_*.'.$this->getPhpCodeExtension().'*');
926 926
 
927 927
         if ($cacheFiles) {
928 928
             foreach ($cacheFiles as $index => $file) {
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
     public function cleanUpCache()
946 946
     {
947 947
         $filename = $this->getCodePath();
948
-        $cacheFiles = glob($filename . '?*');
948
+        $cacheFiles = glob($filename.'?*');
949 949
         if ($cacheFiles) {
950 950
             foreach ($cacheFiles as $file) {
951 951
                 if (substr($file, 0, strlen($filename)) !== $filename) continue; // safety net
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
             $basename = preg_replace('/\.[a-z]{3,5}$/', '', basename($this->_source->getRealPath() ?? ''));
985 985
             $basename = substr(trim(preg_replace('/[^a-zA-Z0-9]+/', '_', $basename), "_"), 0, 20);
986 986
 
987
-            $hash = md5(PHPTAL_VERSION . PHP_VERSION
987
+            $hash = md5(PHPTAL_VERSION.PHP_VERSION
988 988
                     . $this->_source->getRealPath()
989 989
                     . $this->getEncoding()
990 990
                     . $this->getPrefiltersCacheId()
@@ -995,10 +995,10 @@  discard block
 block discarded – undo
995 995
             // uses base64 rather than hex to make filename shorter.
996 996
             // there is loss of some bits due to name constraints and case-insensivity,
997 997
             // but that's still over 110 bits in addition to basename and timestamp.
998
-            $hash = strtr(rtrim(base64_encode($hash),"="),"+/=","_A_");
998
+            $hash = strtr(rtrim(base64_encode($hash), "="), "+/=", "_A_");
999 999
 
1000
-            $this->_functionName = $this->getFunctionNamePrefix($this->_source->getLastModifiedTime()) .
1001
-                                   $basename . '__' . $hash;
1000
+            $this->_functionName = $this->getFunctionNamePrefix($this->_source->getLastModifiedTime()).
1001
+                                   $basename.'__'.$hash;
1002 1002
         }
1003 1003
         return $this->_functionName;
1004 1004
     }
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
     {
1016 1016
         // tpl_ prefix and last modified time must not be changed,
1017 1017
         // because cache cleanup relies on that
1018
-        return 'tpl_' . sprintf("%08x", $timestamp) .'_';
1018
+        return 'tpl_'.sprintf("%08x", $timestamp).'_';
1019 1019
     }
1020 1020
 
1021 1021
     /**
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
      */
1046 1046
     public function addError(Exception $error)
1047 1047
     {
1048
-        $this->_errors[] =  $error;
1048
+        $this->_errors[] = $error;
1049 1049
     }
1050 1050
 
1051 1051
     /**
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
         $data = $this->_source->getData();
1102 1102
 
1103 1103
         $prefilters = $this->getPreFilterInstances();
1104
-        foreach($prefilters as $prefilter) {
1104
+        foreach ($prefilters as $prefilter) {
1105 1105
             $data = $prefilter->filter($data);
1106 1106
         }
1107 1107
 
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
         $builder = new PHPTAL_Dom_PHPTALDocumentBuilder();
1112 1112
         $tree = $parser->parseString($builder, $data, $realpath)->getResult();
1113 1113
 
1114
-        foreach($prefilters as $prefilter) {
1114
+        foreach ($prefilters as $prefilter) {
1115 1115
             if ($prefilter instanceof PHPTAL_PreFilter) {
1116 1116
                 if ($prefilter->filterDOM($tree) !== NULL) {
1117 1117
                     throw new PHPTAL_ConfigurationException("Don't return value from filterDOM()");
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
 
1199 1199
         if (substr($class, 0, 7) !== 'PHPTAL_') return;
1200 1200
 
1201
-        $path = dirname(__FILE__) . strtr("_".$class, "_", DIRECTORY_SEPARATOR) . '.php';
1201
+        $path = dirname(__FILE__).strtr("_".$class, "_", DIRECTORY_SEPARATOR).'.php';
1202 1202
 
1203 1203
         require $path;
1204 1204
     }
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 
1223 1223
         // Prepending PHPTAL's autoloader helps if there are other autoloaders
1224 1224
         // that throw/die when file is not found. Only >5.3 though.
1225
-        @spl_autoload_register(array(__CLASS__,'autoload'), true, true);
1225
+        @spl_autoload_register(array(__CLASS__, 'autoload'), true, true);
1226 1226
 
1227 1227
         if ($uses_autoload) {
1228 1228
             spl_autoload_register('__autoload');
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -76,10 +76,11 @@
 block discarded – undo
76 76
 
77 77
     protected function doEchoAttribute(PHPTAL_Php_CodeWriter $codewriter, $code)
78 78
     {
79
-        if ($this->_echoType === self::ECHO_TEXT)
80
-            $codewriter->doEcho($code);
81
-        else
82
-            $codewriter->doEchoRaw($code);
79
+        if ($this->_echoType === self::ECHO_TEXT) {
80
+                    $codewriter->doEcho($code);
81
+        } else {
82
+                    $codewriter->doEchoRaw($code);
83
+        }
83 84
     }
84 85
 
85 86
     /**
Please login to merge, or discard this patch.
classes/PHPTAL/Php/TalesChainExecutor.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,10 +82,12 @@
 block discarded – undo
82 82
                 $this->reader->talesChainPart($this, $exp, $lastkey === $key);
83 83
             }
84 84
 
85
-            if ($this->state == self::CHAIN_BREAK)
86
-                break;
87
-            if ($this->state == self::CHAIN_CONT)
88
-                continue;
85
+            if ($this->state == self::CHAIN_BREAK) {
86
+                            break;
87
+            }
88
+            if ($this->state == self::CHAIN_CONT) {
89
+                            continue;
90
+            }
89 91
         }
90 92
 
91 93
         $this->codewriter->doEnd('if');
Please login to merge, or discard this patch.
classes/PHPTAL/Php/TalesInternal.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     static public function true($src, $nothrow)
57 57
     {
58
-        return 'phptal_true(' . self::compileToPHPExpression($src, true) . ')';
58
+        return 'phptal_true('.self::compileToPHPExpression($src, true).')';
59 59
     }
60 60
 
61 61
     /**
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     static public function not($expression, $nothrow)
86 86
     {
87
-        return '!phptal_true(' . self::compileToPHPExpression($expression, $nothrow) . ')';
87
+        return '!phptal_true('.self::compileToPHPExpression($expression, $nothrow).')';
88 88
     }
89 89
 
90 90
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      *
122 122
      * @returns string or array
123 123
      */
124
-    static public function path($expression, $nothrow=false)
124
+    static public function path($expression, $nothrow = false)
125 125
     {
126 126
         $expression = trim($expression);
127 127
         if ($expression == 'default') return self::DEFAULT_KEYWORD;
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         if (count($exps) > 1 || isset($string)) {
147 147
             $result = array();
148 148
             foreach ($exps as $i=>$exp) {
149
-                if(isset($string) || $i < count($exps) - 1) {
149
+                if (isset($string) || $i < count($exps)-1) {
150 150
                     $result[] = self::compileToPHPExpressions(trim($exp), true);
151 151
                 }
152 152
                 else {
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         }
181 181
 
182 182
         if ($nothrow) {
183
-            return '$ctx->path($ctx, ' . $next . ($expression === null ? '' : '."/".'.$expression) . ', true)';
183
+            return '$ctx->path($ctx, '.$next.($expression === null ? '' : '."/".'.$expression).', true)';
184 184
         }
185 185
 
186 186
         if (preg_match('/^\'[a-z][a-z0-9_]*\'$/i', $next)) $next = substr($next, 1, -1); else $next = '{'.$next.'}';
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      *      string:hello, ${user/name}
222 222
      *      string:you have $$130 in your bank account
223 223
      */
224
-    static public function string($expression, $nothrow=false)
224
+    static public function string($expression, $nothrow = false)
225 225
     {
226 226
         return self::parseString($expression, $nothrow, '');
227 227
     }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         $lastWasDollar = false;
242 242
         $result = '';
243 243
         $len = strlen($expression);
244
-        for ($i=0; $i<$len; $i++) {
244
+        for ($i = 0; $i < $len; $i++) {
245 245
             $c = $expression[$i];
246 246
             switch ($c) {
247 247
                 case '$':
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
                 case '}':
292 292
                     if ($inAccoladePath) {
293 293
                         $inAccoladePath = false;
294
-                        $subEval = self::compileToPHPExpression($tales_prefix.$subPath,false);
295
-                        $result .= "'.(" . $subEval . ").'";
294
+                        $subEval = self::compileToPHPExpression($tales_prefix.$subPath, false);
295
+                        $result .= "'.(".$subEval.").'";
296 296
                         $subPath = '';
297 297
                         $lastWasDollar = false;
298 298
                         $c = '';
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
                             $c = '';
316 316
                         } else {
317 317
                             $inPath = false;
318
-                            $subEval = self::compileToPHPExpression($tales_prefix.$subPath,false);
319
-                            $result .= "'.(" . $subEval . ").'";
318
+                            $subEval = self::compileToPHPExpression($tales_prefix.$subPath, false);
319
+                            $result .= "'.(".$subEval.").'";
320 320
                             }
321 321
                         }
322 322
                     break;
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         }
326 326
         if ($inPath) {
327 327
             $subEval = self::compileToPHPExpression($tales_prefix.$subPath, false);
328
-            $result .= "'.(" . $subEval . ").'";
328
+            $result .= "'.(".$subEval.").'";
329 329
         }
330 330
 
331 331
         // optimize ''.foo.'' to foo
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
         $src = rawurldecode($src);
366 366
 
367 367
         // Simple echo can be supported via regular method
368
-        if (preg_match('/^\s*echo\s+((?:[^;]+|"[^"\\\\]*"|\'[^\'\\\\]*\'|\/\*.*?\*\/)+);*\s*$/s',$src,$m))
368
+        if (preg_match('/^\s*echo\s+((?:[^;]+|"[^"\\\\]*"|\'[^\'\\\\]*\'|\/\*.*?\*\/)+);*\s*$/s', $src, $m))
369 369
         {
370 370
             return $m[1];
371 371
         }
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
     {
386 386
         $src = trim($src);
387 387
         if (ctype_alnum($src)) return 'isset($ctx->'.$src.')';
388
-        return '(null !== ' . self::compileToPHPExpression($src, true) . ')';
388
+        return '(null !== '.self::compileToPHPExpression($src, true).')';
389 389
     }
390 390
 
391 391
     /**
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
      */
405 405
     static public function json($src, $nothrow)
406 406
     {
407
-        return 'json_encode('.phptal_tale($src,$nothrow).')';
407
+        return 'json_encode('.phptal_tale($src, $nothrow).')';
408 408
     }
409 409
 
410 410
     /**
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
      */
413 413
     static public function urlencode($src, $nothrow)
414 414
     {
415
-        return 'rawurlencode('.phptal_tale($src,$nothrow).')';
415
+        return 'rawurlencode('.phptal_tale($src, $nothrow).')';
416 416
     }
417 417
 
418 418
     /**
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
      * @see PHPTAL_Php_TalesInternal::compileToPHPExpressions()
423 423
      * @return string
424 424
      */
425
-    public static function compileToPHPExpression($expression, $nothrow=false)
425
+    public static function compileToPHPExpression($expression, $nothrow = false)
426 426
     {
427 427
         $r = self::compileToPHPExpressions($expression, $nothrow);
428 428
         if (!is_array($r)) return $r;
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
      */
438 438
     private static function convertExpressionsToExpression(array $array, $nothrow)
439 439
     {
440
-        if (count($array)==1) return '($ctx->noThrow('.($nothrow?'true':'false').')||1?('.
441
-            ($array[0]==self::NOTHING_KEYWORD?'null':$array[0]).
440
+        if (count($array) == 1) return '($ctx->noThrow('.($nothrow ? 'true' : 'false').')||1?('.
441
+            ($array[0] == self::NOTHING_KEYWORD ? 'null' : $array[0]).
442 442
             '):"")';
443 443
 
444 444
         $expr = array_shift($array);
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
      *
458 458
      * @return string or array
459 459
      */
460
-    public static function compileToPHPExpressions($expression, $nothrow=false)
460
+    public static function compileToPHPExpressions($expression, $nothrow = false)
461 461
     {
462 462
         $expression = trim($expression ?? '');
463 463
 
@@ -488,13 +488,13 @@  discard block
 block discarded – undo
488 488
         throw new PHPTAL_UnknownModifierException("Unknown phptal modifier '$typePrefix'. Function '$func' does not exist", $typePrefix);
489 489
     }
490 490
 
491
-    private static function verifyPHPExpressions($typePrefix,$expressions)
491
+    private static function verifyPHPExpressions($typePrefix, $expressions)
492 492
     {
493 493
         if (!is_array($expressions)) {
494 494
             $expressions = array($expressions);
495 495
         }
496 496
 
497
-        foreach($expressions as $expr) {
497
+        foreach ($expressions as $expr) {
498 498
             if (preg_match('/;\s*$/', $expr)) {
499 499
                 throw new PHPTAL_ParserException("Modifier $typePrefix generated PHP statement rather than expression (don't add semicolons)");
500 500
             }
Please login to merge, or discard this patch.
classes/PHPTAL/Tokenizer.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@
 block discarded – undo
42 42
 
43 43
     function skipSpace()
44 44
     {
45
-        while ($this->current_token === 'SPACE') $this->nextToken();
45
+        while ($this->current_token === 'SPACE') {
46
+            $this->nextToken();
47
+        }
46 48
     }
47 49
 
48 50
     function nextToken()
Please login to merge, or discard this patch.
classes/PHPTAL/Dom/Element.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
             $this->generateSurroundFoot($codewriter);
190 190
         }
191
-        catch(PHPTAL_TemplateException $e) {
191
+        catch (PHPTAL_TemplateException $e) {
192 192
             $e->hintSrcPosition($this->getSourceFile(), $this->getSourceLine());
193 193
             throw $e;
194 194
         }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     /** Returns true if the element contains specified PHPTAL attribute. */
218 218
     public function hasAttribute($qname)
219 219
     {
220
-        foreach($this->attribute_nodes as $attr) if ($attr->getQualifiedName() == $qname) return true;
220
+        foreach ($this->attribute_nodes as $attr) if ($attr->getQualifiedName() == $qname) return true;
221 221
         return false;
222 222
     }
223 223
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
     public function getAttributeNode($qname)
248 248
     {
249
-        foreach($this->attribute_nodes as $attr) if ($attr->getQualifiedName() === $qname) return $attr;
249
+        foreach ($this->attribute_nodes as $attr) if ($attr->getQualifiedName() === $qname) return $attr;
250 250
         return null;
251 251
     }
252 252
 
@@ -353,15 +353,15 @@  discard block
 block discarded – undo
353 353
         }
354 354
     }
355 355
 
356
-    public function generateContent(?PHPTAL_Php_CodeWriter $codewriter = null, $realContent=false)
356
+    public function generateContent(?PHPTAL_Php_CodeWriter $codewriter = null, $realContent = false)
357 357
     {
358 358
         if (!$this->isEmptyNode($codewriter->getOutputMode())) {
359 359
             if ($realContent || !count($this->contentAttributes)) {
360
-                foreach($this->childNodes as $child) {
360
+                foreach ($this->childNodes as $child) {
361 361
                     $child->generateCode($codewriter);
362 362
                 }
363 363
             }
364
-            else foreach($this->contentAttributes as $att) {
364
+            else foreach ($this->contentAttributes as $att) {
365 365
                 $att->before($codewriter);
366 366
                 $att->after($codewriter);
367 367
             }
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
     private function isEmptyNode($mode)
440 440
     {
441 441
         return (($mode === PHPTAL::XHTML || $mode === PHPTAL::HTML5) && PHPTAL_Dom_Defs::getInstance()->isEmptyTagNS($this->getNamespaceURI(), $this->getLocalName())) ||
442
-               ( $mode === PHPTAL::XML   && !$this->hasContent());
442
+               ($mode === PHPTAL::XML && !$this->hasContent());
443 443
     }
444 444
 
445 445
     private function hasContent()
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
                 throw new PHPTAL_TemplateException(sprintf("Attribute conflict in < %s > '%s' cannot appear with '%s'",
474 474
                                $this->qualifiedName,
475 475
                                $key,
476
-                               $temp[$nsattr->getPriority()][0]->getNamespace()->getPrefix() . ':' . $temp[$nsattr->getPriority()][0]->getLocalName()
476
+                               $temp[$nsattr->getPriority()][0]->getNamespace()->getPrefix().':'.$temp[$nsattr->getPriority()][0]->getLocalName()
477 477
                                ), $this->getSourceFile(), $this->getSourceLine());
478 478
             }
479 479
             $temp[$nsattr->getPriority()] = array($nsattr, $domattr);
Please login to merge, or discard this patch.
classes/PHPTAL/Dom/PHPTALDocumentBuilder.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class PHPTAL_Dom_PHPTALDocumentBuilder extends PHPTAL_Dom_DocumentBuilder
24 24
 {
25
-    private $_xmlns;   /* PHPTAL_Dom_XmlnsState */
25
+    private $_xmlns; /* PHPTAL_Dom_XmlnsState */
26 26
     private $encoding;
27 27
     private ?PHPTAL_Dom_Element $documentElement = null;
28 28
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
     public function onDocumentEnd()
54 54
     {
55 55
         if (count($this->_stack) > 0) {
56
-            $left='</'.$this->_current->getQualifiedName().'>';
57
-            for ($i = count($this->_stack)-1; $i>0; $i--) $left .= '</'.$this->_stack[$i]->getQualifiedName().'>';
56
+            $left = '</'.$this->_current->getQualifiedName().'>';
57
+            for ($i = count($this->_stack)-1; $i > 0; $i--) $left .= '</'.$this->_stack[$i]->getQualifiedName().'>';
58 58
             throw new PHPTAL_ParserException("Not all elements were closed before end of the document. Missing: ".$left,
59 59
                         $this->file, $this->line);
60 60
         }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
         $node = new PHPTAL_Dom_Element($element_qname, $namespace_uri, $attrnodes, $this->getXmlnsState());
132 132
         $this->pushNode($node);
133
-        $this->_stack[] =  $this->_current;
133
+        $this->_stack[] = $this->_current;
134 134
         $this->_current = $node;
135 135
     }
136 136
 
Please login to merge, or discard this patch.
classes/PHPTAL/Dom/SaxXmlParser.php 3 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
 
61 61
 
62 62
     static $state_names = array(
63
-      self::ST_ROOT => 'root node',
64
-      self::ST_TEXT => 'text',
65
-      self::ST_LT   => 'start of tag',
66
-      self::ST_TAG_NAME => 'tag name',
67
-      self::ST_TAG_CLOSE => 'closing tag',
68
-      self::ST_TAG_SINGLE => 'self-closing tag',
69
-      self::ST_TAG_ATTRIBUTES => 'tag',
70
-      self::ST_TAG_BETWEEN_ATTRIBUTE => 'tag attributes',
71
-      self::ST_CDATA => 'CDATA',
72
-      self::ST_COMMENT => 'comment',
73
-      self::ST_DOCTYPE => 'doctype',
74
-      self::ST_XMLDEC => 'XML declaration',
75
-      self::ST_PREPROC => 'preprocessor directive',
76
-      self::ST_ATTR_KEY => 'attribute name',
77
-      self::ST_ATTR_EQ => 'attribute value',
78
-      self::ST_ATTR_QUOTE => 'quoted attribute value',
79
-      self::ST_ATTR_VALUE => 'unquoted attribute value',
63
+        self::ST_ROOT => 'root node',
64
+        self::ST_TEXT => 'text',
65
+        self::ST_LT   => 'start of tag',
66
+        self::ST_TAG_NAME => 'tag name',
67
+        self::ST_TAG_CLOSE => 'closing tag',
68
+        self::ST_TAG_SINGLE => 'self-closing tag',
69
+        self::ST_TAG_ATTRIBUTES => 'tag',
70
+        self::ST_TAG_BETWEEN_ATTRIBUTE => 'tag attributes',
71
+        self::ST_CDATA => 'CDATA',
72
+        self::ST_COMMENT => 'comment',
73
+        self::ST_DOCTYPE => 'doctype',
74
+        self::ST_XMLDEC => 'XML declaration',
75
+        self::ST_PREPROC => 'preprocessor directive',
76
+        self::ST_ATTR_KEY => 'attribute name',
77
+        self::ST_ATTR_EQ => 'attribute value',
78
+        self::ST_ATTR_QUOTE => 'quoted attribute value',
79
+        self::ST_ATTR_VALUE => 'unquoted attribute value',
80 80
     );
81 81
 
82 82
     private $input_encoding;
@@ -381,15 +381,15 @@  discard block
 block discarded – undo
381 381
 
382 382
             // http://www.w3.org/International/questions/qa-forms-utf-8
383 383
             $match = '[\x09\x0A\x0D\x20-\x7F]'        // ASCII
384
-               . '|[\xC2-\xDF][\x80-\xBF]'            // non-overlong 2-byte
385
-               . '|\xE0[\xA0-\xBF][\x80-\xBF]'        // excluding overlongs
386
-               . '|[\xE1-\xEC\xEE\xEE][\x80-\xBF]{2}' // straight 3-byte (exclude FFFE and FFFF)
387
-               . '|\xEF[\x80-\xBE][\x80-\xBF]'        // straight 3-byte
388
-               . '|\xEF\xBF[\x80-\xBD]'               // straight 3-byte
389
-               . '|\xED[\x80-\x9F][\x80-\xBF]'        // excluding surrogates
390
-               . '|\xF0[\x90-\xBF][\x80-\xBF]{2}'     // planes 1-3
391
-               . '|[\xF1-\xF3][\x80-\xBF]{3}'         // planes 4-15
392
-               . '|\xF4[\x80-\x8F][\x80-\xBF]{2}';    // plane 16
384
+                . '|[\xC2-\xDF][\x80-\xBF]'            // non-overlong 2-byte
385
+                . '|\xE0[\xA0-\xBF][\x80-\xBF]'        // excluding overlongs
386
+                . '|[\xE1-\xEC\xEE\xEE][\x80-\xBF]{2}' // straight 3-byte (exclude FFFE and FFFF)
387
+                . '|\xEF[\x80-\xBE][\x80-\xBF]'        // straight 3-byte
388
+                . '|\xEF\xBF[\x80-\xBD]'               // straight 3-byte
389
+                . '|\xED[\x80-\x9F][\x80-\xBF]'        // excluding surrogates
390
+                . '|\xF0[\x90-\xBF][\x80-\xBF]{2}'     // planes 1-3
391
+                . '|[\xF1-\xF3][\x80-\xBF]{3}'         // planes 4-15
392
+                . '|\xF4[\x80-\x8F][\x80-\xBF]{2}';    // plane 16
393 393
 
394 394
             if (!preg_match('/^(?:(?>'.$match.'))+$/s',$str)) {
395 395
                 $res = preg_split('/((?>'.$match.')+)/s',$str,0,PREG_SPLIT_DELIM_CAPTURE);
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
             $builder->setSource($this->_file, $this->_line);
117 117
             $builder->onDocumentStart();
118 118
 
119
-            $i=0;
119
+            $i = 0;
120 120
             // remove BOM (UTF-8 byte order mark)...
121 121
             if (substr($src, 0, 3) === self::BOM_STR) {
122
-                $i=3;
122
+                $i = 3;
123 123
             }
124
-            for (; $i<$len; $i++) {
124
+            for (; $i < $len; $i++) {
125 125
                 $c = $src[$i]; // Change to substr($src, $i, 1); if you want to use mb_string.func_overload
126 126
 
127 127
                 if ($c === "\n") $builder->setSource($this->_file, ++$this->_line);
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                         if ($c !== '>') {
202 202
                             $this->raiseError("Expected '/>', but found '/$c' inside tag < $tagname >");
203 203
                         }
204
-                        $mark = $i+1;   // mark text start
204
+                        $mark = $i+1; // mark text start
205 205
                         $state = self::ST_TEXT;
206 206
                         $builder->onElementStart($tagname, $attributes);
207 207
                         $builder->onElementClose($tagname);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
                     case self::ST_TAG_BETWEEN_ATTRIBUTE:
211 211
                     case self::ST_TAG_ATTRIBUTES:
212 212
                         if ($c === '>') {
213
-                            $mark = $i+1;   // mark text start
213
+                            $mark = $i+1; // mark text start
214 214
                             $state = self::ST_TEXT;
215 215
                             $builder->onElementStart($tagname, $attributes);
216 216
                         } elseif ($c === '/') {
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
                     case self::ST_COMMENT:
227 227
                         if ($c === '>' && $i > $mark+4 && substr($src, $i-2, 2) === '--') {
228 228
 
229
-                            if (preg_match('/^-|--|-$/', substr($src, $mark +4, $i-$mark+1 -7))) {
229
+                            if (preg_match('/^-|--|-$/', substr($src, $mark+4, $i-$mark+1-7))) {
230 230
                                 $this->raiseError("Ill-formed comment. XML comments are not allowed to contain '--' or start/end with '-': ".substr($src, $mark+4, $i-$mark+1-7));
231 231
                             }
232 232
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
                             if ($c === '=') $state = self::ST_ATTR_VALUE;
291 291
                             else /* white char */ $state = self::ST_ATTR_EQ;
292
-                        } elseif ($c === '/' || $c==='>') {
292
+                        } elseif ($c === '/' || $c === '>') {
293 293
                             $attribute = substr($src, $mark, $i-$mark);
294 294
                             if (!$this->isValidQName($attribute)) {
295 295
                                 $this->raiseError("Invalid attribute name '$attribute'");
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 
324 324
                             // PHPTAL's code generator assumes input is escaped for double-quoted strings. Single-quoted attributes need to be converted.
325 325
                             // FIXME: it should be escaped at later stage.
326
-                            $attributes[$attribute] = str_replace('"',"&quot;", $attributes[$attribute]);
326
+                            $attributes[$attribute] = str_replace('"', "&quot;", $attributes[$attribute]);
327 327
                             $state = self::ST_TAG_BETWEEN_ATTRIBUTE;
328 328
                         }
329 329
                         break;
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
             $builder->onDocumentEnd();
349 349
         }
350
-        catch(PHPTAL_TemplateException $e)
350
+        catch (PHPTAL_TemplateException $e)
351 351
         {
352 352
             $e->hintSrcPosition($this->_file, $this->_line);
353 353
             throw $e;
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
             // $match expression below somehow triggers quite deep recurrency and stack overflow in preg
371 371
             // to avoid this, check string bit by bit, omitting ASCII fragments.
372 372
             if (strlen($str) > 200) {
373
-                $chunks = preg_split('/(?>[\x09\x0A\x0D\x20-\x7F]+)/',$str,0,PREG_SPLIT_NO_EMPTY);
373
+                $chunks = preg_split('/(?>[\x09\x0A\x0D\x20-\x7F]+)/', $str, 0, PREG_SPLIT_NO_EMPTY);
374 374
                 foreach ($chunks as $chunk) {
375 375
                     if (strlen($chunk) < 200) {
376 376
                         $this->checkEncoding($chunk);
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
                . '|\xED[\x80-\x9F][\x80-\xBF]'        // excluding surrogates
390 390
                . '|\xF0[\x90-\xBF][\x80-\xBF]{2}'     // planes 1-3
391 391
                . '|[\xF1-\xF3][\x80-\xBF]{3}'         // planes 4-15
392
-               . '|\xF4[\x80-\x8F][\x80-\xBF]{2}';    // plane 16
392
+               . '|\xF4[\x80-\x8F][\x80-\xBF]{2}'; // plane 16
393 393
 
394
-            if (!preg_match('/^(?:(?>'.$match.'))+$/s',$str)) {
395
-                $res = preg_split('/((?>'.$match.')+)/s',$str,0,PREG_SPLIT_DELIM_CAPTURE);
396
-                for($i=0; $i < count($res); $i+=2)
394
+            if (!preg_match('/^(?:(?>'.$match.'))+$/s', $str)) {
395
+                $res = preg_split('/((?>'.$match.')+)/s', $str, 0, PREG_SPLIT_DELIM_CAPTURE);
396
+                for ($i = 0; $i < count($res); $i += 2)
397 397
                 {
398 398
                     $res[$i] = self::convertBytesToEntities(array(1=>$res[$i]));
399 399
                 }
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
             $forbid = '/((?>[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F]+))/s';
407 407
 
408 408
             if (preg_match($forbid, $str)) {
409
-                $str = preg_replace_callback($forbid, static function (array $m): string {
409
+                $str = preg_replace_callback($forbid, static function(array $m): string {
410 410
                     return self::convertBytesToEntities($m);
411 411
                 }, $str);
412 412
                 $this->raiseError("Invalid ISO-8859-1 characters: ".$str);
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
     {
427 427
         $m = $m[1];
428 428
         $out = "";
429
-        for($i=0; $i < strlen($m); $i++)
429
+        for ($i = 0; $i < strlen($m); $i++)
430 430
         {
431 431
             $out .= '&#X'.strtoupper(dechex(ord($m[$i]))).';';
432 432
         }
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
         /* <?php ?> blocks can't reliably work in attributes (due to escaping impossible in XML)
444 444
            so they have to be converted into special TALES expression
445 445
         */
446
-        $str = preg_replace_callback('/<\?(php|=)(.*?)\?>/', static function ($m) {
446
+        $str = preg_replace_callback('/<\?(php|=)(.*?)\?>/', static function($m) {
447 447
             list(, $type, $code) = $m;
448 448
             if ($type === '=') $code = 'echo '.$code;
449 449
             return '${structure phptal-internal-php-block:'.rawurlencode($code).'}';
Please login to merge, or discard this patch.
Braces   +27 added lines, -11 removed lines patch added patch discarded remove patch
@@ -124,7 +124,9 @@  discard block
 block discarded – undo
124 124
             for (; $i<$len; $i++) {
125 125
                 $c = $src[$i]; // Change to substr($src, $i, 1); if you want to use mb_string.func_overload
126 126
 
127
-                if ($c === "\n") $builder->setSource($this->_file, ++$this->_line);
127
+                if ($c === "\n") {
128
+                    $builder->setSource($this->_file, ++$this->_line);
129
+                }
128 130
 
129 131
                 switch ($state) {
130 132
                     case self::ST_ROOT:
@@ -174,7 +176,9 @@  discard block
 block discarded – undo
174 176
                     case self::ST_TAG_NAME:
175 177
                         if (self::isWhiteChar($c) || $c === '/' || $c === '>') {
176 178
                             $tagname = substr($src, $mark, $i-$mark);
177
-                            if (!$this->isValidQName($tagname)) $this->raiseError("Invalid tag name '$tagname'");
179
+                            if (!$this->isValidQName($tagname)) {
180
+                                $this->raiseError("Invalid tag name '$tagname'");
181
+                            }
178 182
 
179 183
                             if ($c === '/') {
180 184
                                 $state = self::ST_TAG_SINGLE;
@@ -220,7 +224,9 @@  discard block
 block discarded – undo
220 224
                         } elseif ($state === self::ST_TAG_ATTRIBUTES && $this->isValidQName($c)) {
221 225
                             $mark = $i; // mark attribute key start
222 226
                             $state = self::ST_ATTR_KEY;
223
-                        } else $this->raiseError("Unexpected character '$c' between attributes of < $tagname >");
227
+                        } else {
228
+                            $this->raiseError("Unexpected character '$c' between attributes of < $tagname >");
229
+                        }
224 230
                         break;
225 231
 
226 232
                     case self::ST_COMMENT:
@@ -287,8 +293,11 @@  discard block
 block discarded – undo
287 293
                                 $this->raiseError("Attribute $attribute in < $tagname > is defined more than once");
288 294
                             }
289 295
 
290
-                            if ($c === '=') $state = self::ST_ATTR_VALUE;
291
-                            else /* white char */ $state = self::ST_ATTR_EQ;
296
+                            if ($c === '=') {
297
+                                $state = self::ST_ATTR_VALUE;
298
+                            } else {
299
+                                /* white char */ $state = self::ST_ATTR_EQ;
300
+                            }
292 301
                         } elseif ($c === '/' || $c==='>') {
293 302
                             $attribute = substr($src, $mark, $i-$mark);
294 303
                             if (!$this->isValidQName($attribute)) {
@@ -330,11 +339,15 @@  discard block
 block discarded – undo
330 339
                 }
331 340
             }
332 341
 
333
-            if ($state === self::ST_TEXT) // allows text past root node, which is in violation of XML spec
342
+            if ($state === self::ST_TEXT) {
343
+                // allows text past root node, which is in violation of XML spec
334 344
             {
335 345
                 if ($i > $mark) {
336 346
                     $text = substr($src, $mark, $i-$mark);
337
-                    if (!ctype_space($text)) $this->raiseError("Characters found after end of the root element (wrap document in < tal:block > to avoid this error)");
347
+            }
348
+                    if (!ctype_space($text)) {
349
+                        $this->raiseError("Characters found after end of the root element (wrap document in < tal:block > to avoid this error)");
350
+                    }
338 351
                 }
339 352
             } else {
340 353
                 if ($state === self::ST_ROOT) {
@@ -346,8 +359,7 @@  discard block
 block discarded – undo
346 359
             }
347 360
 
348 361
             $builder->onDocumentEnd();
349
-        }
350
-        catch(PHPTAL_TemplateException $e)
362
+        } catch(PHPTAL_TemplateException $e)
351 363
         {
352 364
             $e->hintSrcPosition($this->_file, $this->_line);
353 365
             throw $e;
@@ -363,7 +375,9 @@  discard block
 block discarded – undo
363 375
 
364 376
     private function checkEncoding($str)
365 377
     {
366
-        if ($str === '') return '';
378
+        if ($str === '') {
379
+            return '';
380
+        }
367 381
 
368 382
         if ($this->input_encoding === 'UTF-8') {
369 383
 
@@ -445,7 +459,9 @@  discard block
 block discarded – undo
445 459
         */
446 460
         $str = preg_replace_callback('/<\?(php|=)(.*?)\?>/', static function ($m) {
447 461
             list(, $type, $code) = $m;
448
-            if ($type === '=') $code = 'echo '.$code;
462
+            if ($type === '=') {
463
+                $code = 'echo '.$code;
464
+            }
449 465
             return '${structure phptal-internal-php-block:'.rawurlencode($code).'}';
450 466
         }, $str);
451 467
 
Please login to merge, or discard this patch.