Passed
Push — 1.3 ( 6f1a67...b00944 )
by David
05:24
created
lib/Dwoo/Compiler.php 1 patch
Spacing   +384 added lines, -386 removed lines patch added patch discarded remove patch
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
      */
295 295
     public function setNestedCommentsHandling($allow = true)
296 296
     {
297
-        $this->allowNestedComments = (bool)$allow;
297
+        $this->allowNestedComments = (bool) $allow;
298 298
     }
299 299
 
300 300
     /**
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
      */
320 320
     public function setLooseOpeningHandling($allow = false)
321 321
     {
322
-        $this->allowLooseOpenings = (bool)$allow;
322
+        $this->allowLooseOpenings = (bool) $allow;
323 323
     }
324 324
 
325 325
     /**
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
      */
345 345
     public function setAutoEscape($enabled)
346 346
     {
347
-        $this->autoEscape = (bool)$enabled;
347
+        $this->autoEscape = (bool) $enabled;
348 348
     }
349 349
 
350 350
     /**
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     {
372 372
         if ($autoload) {
373 373
             $name  = str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', Core::toCamelCase($callback));
374
-            $class = Core::NAMESPACE_PLUGINS_PROCESSORS . $name;
374
+            $class = Core::NAMESPACE_PLUGINS_PROCESSORS.$name;
375 375
 
376 376
             if (class_exists($class)) {
377 377
                 $callback = array(new $class($this), 'process');
@@ -396,12 +396,12 @@  discard block
 block discarded – undo
396 396
     {
397 397
         if (($index = array_search($callback, $this->processors['pre'], true)) !== false) {
398 398
             unset($this->processors['pre'][$index]);
399
-        } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '',
399
+        } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS.str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '',
400 400
                     $callback),
401 401
                 $this->processors['pre'], true)) !== false) {
402 402
             unset($this->processors['pre'][$index]);
403 403
         } else {
404
-            $class = Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback);
404
+            $class = Core::NAMESPACE_PLUGINS_PROCESSORS.str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback);
405 405
             foreach ($this->processors['pre'] as $index => $proc) {
406 406
                 if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) {
407 407
                     unset($this->processors['pre'][$index]);
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
     {
425 425
         if ($autoload) {
426 426
             $name  = str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback);
427
-            $class = Core::NAMESPACE_PLUGINS_PROCESSORS . Core::toCamelCase($name);
427
+            $class = Core::NAMESPACE_PLUGINS_PROCESSORS.Core::toCamelCase($name);
428 428
 
429 429
             if (class_exists($class)) {
430 430
                 $callback = array(new $class($this), 'process');
@@ -449,12 +449,12 @@  discard block
 block discarded – undo
449 449
     {
450 450
         if (($index = array_search($callback, $this->processors['post'], true)) !== false) {
451 451
             unset($this->processors['post'][$index]);
452
-        } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '',
452
+        } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS.str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '',
453 453
                     $callback),
454 454
                 $this->processors['post'], true)) !== false) {
455 455
             unset($this->processors['post'][$index]);
456 456
         } else {
457
-            $class = Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback);
457
+            $class = Core::NAMESPACE_PLUGINS_PROCESSORS.str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback);
458 458
             foreach ($this->processors['post'] as $index => $proc) {
459 459
                 if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) {
460 460
                     unset($this->processors['post'][$index]);
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
                 $this->getCore()->getLoader()->loadPlugin($name);
481 481
             }
482 482
             catch (Exception $e) {
483
-                throw new Exception('Processor ' . $name . ' could not be found in your plugin directories, please ensure it is in a file named ' . $name . '.php in the plugin directory');
483
+                throw new Exception('Processor '.$name.' could not be found in your plugin directories, please ensure it is in a file named '.$name.'.php in the plugin directory');
484 484
             }
485 485
         }
486 486
 
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
     public function setTemplateSource($newSource, $fromPointer = false)
667 667
     {
668 668
         if ($fromPointer === true) {
669
-            $this->templateSource = substr($this->templateSource, 0, $this->pointer) . $newSource;
669
+            $this->templateSource = substr($this->templateSource, 0, $this->pointer).$newSource;
670 670
         } else {
671 671
             $this->templateSource = $newSource;
672 672
         }
@@ -737,11 +737,11 @@  discard block
 block discarded – undo
737 737
 
738 738
                 if ($this->debug) {
739 739
                     echo "\n";
740
-                    echo 'COMPILER INIT' . "\n";
740
+                    echo 'COMPILER INIT'."\n";
741 741
                 }
742 742
 
743 743
                 if ($this->debug) {
744
-                    echo 'PROCESSING PREPROCESSORS (' . count($this->processors['pre']) . ')' . "\n";
744
+                    echo 'PROCESSING PREPROCESSORS ('.count($this->processors['pre']).')'."\n";
745 745
                 }
746 746
 
747 747
                 // runs preprocessors
@@ -785,23 +785,23 @@  discard block
 block discarded – undo
785 785
             if ($pos === false) {
786 786
                 $this->push(substr($tpl, $ptr), 0);
787 787
                 break;
788
-            } elseif (substr($tpl, $pos - 1, 1) === '\\' && substr($tpl, $pos - 2, 1) !== '\\') {
789
-                $this->push(substr($tpl, $ptr, $pos - $ptr - 1) . $this->ld);
790
-                $ptr = $pos + strlen($this->ld);
791
-            } elseif (preg_match('/^' . $this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . 'literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr . '/s', substr($tpl, $pos), $litOpen)) {
792
-                if (!preg_match('/' . $this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . '\/literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr . '/s', $tpl, $litClose, PREG_OFFSET_CAPTURE, $pos)) {
788
+            } elseif (substr($tpl, $pos-1, 1) === '\\' && substr($tpl, $pos-2, 1) !== '\\') {
789
+                $this->push(substr($tpl, $ptr, $pos-$ptr-1).$this->ld);
790
+                $ptr = $pos+strlen($this->ld);
791
+            } elseif (preg_match('/^'.$this->ldr.($this->allowLooseOpenings ? '\s*' : '').'literal'.($this->allowLooseOpenings ? '\s*' : '').$this->rdr.'/s', substr($tpl, $pos), $litOpen)) {
792
+                if (!preg_match('/'.$this->ldr.($this->allowLooseOpenings ? '\s*' : '').'\/literal'.($this->allowLooseOpenings ? '\s*' : '').$this->rdr.'/s', $tpl, $litClose, PREG_OFFSET_CAPTURE, $pos)) {
793 793
                     throw new CompilationException($this, 'The {literal} blocks must be closed explicitly with {/literal}');
794 794
                 }
795 795
                 $endpos = $litClose[0][1];
796
-                $this->push(substr($tpl, $ptr, $pos - $ptr) . substr($tpl, $pos + strlen($litOpen[0]), $endpos - $pos - strlen($litOpen[0])));
797
-                $ptr = $endpos + strlen($litClose[0][0]);
796
+                $this->push(substr($tpl, $ptr, $pos-$ptr).substr($tpl, $pos+strlen($litOpen[0]), $endpos-$pos-strlen($litOpen[0])));
797
+                $ptr = $endpos+strlen($litClose[0][0]);
798 798
             } else {
799
-                if (substr($tpl, $pos - 2, 1) === '\\' && substr($tpl, $pos - 1, 1) === '\\') {
800
-                    $this->push(substr($tpl, $ptr, $pos - $ptr - 1));
799
+                if (substr($tpl, $pos-2, 1) === '\\' && substr($tpl, $pos-1, 1) === '\\') {
800
+                    $this->push(substr($tpl, $ptr, $pos-$ptr-1));
801 801
                     $ptr = $pos;
802 802
                 }
803 803
 
804
-                $this->push(substr($tpl, $ptr, $pos - $ptr));
804
+                $this->push(substr($tpl, $ptr, $pos-$ptr));
805 805
                 $ptr = $pos;
806 806
 
807 807
                 $pos += strlen($this->ld);
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 
820 820
                 // check that there is an end tag present
821 821
                 if (strpos($tpl, $this->rd, $pos) === false) {
822
-                    throw new CompilationException($this, 'A template tag was not closed, started with "' . substr($tpl, $ptr, 30) . '"');
822
+                    throw new CompilationException($this, 'A template tag was not closed, started with "'.substr($tpl, $ptr, 30).'"');
823 823
                 }
824 824
 
825 825
                 $ptr += strlen($this->ld);
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
                         continue 2;
834 834
                     }
835 835
 
836
-                    $len = $subptr - $ptr;
836
+                    $len = $subptr-$ptr;
837 837
                     $this->push($parsed, substr_count(substr($tpl, $ptr, $len), "\n"));
838 838
                     $ptr += $len;
839 839
 
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
         $compiled .= $this->removeBlock('TopLevelBlock');
848 848
 
849 849
         if ($this->debug) {
850
-            echo 'PROCESSING POSTPROCESSORS' . "\n";
850
+            echo 'PROCESSING POSTPROCESSORS'."\n";
851 851
         }
852 852
 
853 853
         foreach ($this->processors['post'] as $postProc) {
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
         unset($postProc);
864 864
 
865 865
         if ($this->debug) {
866
-            echo 'COMPILATION COMPLETE : MEM USAGE : ' . memory_get_usage() . "\n";
866
+            echo 'COMPILATION COMPLETE : MEM USAGE : '.memory_get_usage()."\n";
867 867
         }
868 868
 
869 869
         $output = "<?php\n/* template head */\n";
@@ -876,30 +876,30 @@  discard block
 block discarded – undo
876 876
 
877 877
             switch ($type) {
878 878
                 case Core::CLASS_PLUGIN:
879
-                case Core::CLASS_PLUGIN + Core::BLOCK_PLUGIN:
880
-                    if (class_exists('Plugin' . $plugin) !== false) {
881
-                        $output .= "if (class_exists('" . "Plugin" . $plugin . "')===false)".
879
+                case Core::CLASS_PLUGIN+Core::BLOCK_PLUGIN:
880
+                    if (class_exists('Plugin'.$plugin) !== false) {
881
+                        $output .= "if (class_exists('"."Plugin".$plugin."')===false)".
882 882
                         "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
883 883
                     } else {
884
-                        $output .= "if (class_exists('" . Core::NAMESPACE_PLUGINS_BLOCKS . "Plugin" . $plugin . "')===false)".
884
+                        $output .= "if (class_exists('".Core::NAMESPACE_PLUGINS_BLOCKS."Plugin".$plugin."')===false)".
885 885
                         "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
886 886
                     }
887 887
                     break;
888
-                case Core::CLASS_PLUGIN + Core::FUNC_PLUGIN:
889
-                    if (class_exists('Plugin' . $plugin) !== false) {
890
-                        $output .= "if (class_exists('" . "Plugin" . $plugin . "')===false)".
888
+                case Core::CLASS_PLUGIN+Core::FUNC_PLUGIN:
889
+                    if (class_exists('Plugin'.$plugin) !== false) {
890
+                        $output .= "if (class_exists('"."Plugin".$plugin."')===false)".
891 891
                             "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
892 892
                     } else {
893
-                        $output .= "if (class_exists('" . Core::NAMESPACE_PLUGINS_FUNCTIONS . "Plugin" . $plugin . "')===false)".
893
+                        $output .= "if (class_exists('".Core::NAMESPACE_PLUGINS_FUNCTIONS."Plugin".$plugin."')===false)".
894 894
                             "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
895 895
                     }
896 896
                     break;
897 897
                 case Core::FUNC_PLUGIN:
898
-                    if (function_exists('Plugin' . $plugin) !== false) {
899
-                        $output .= "if (function_exists('" . "Plugin" . $plugin . "')===false)".
898
+                    if (function_exists('Plugin'.$plugin) !== false) {
899
+                        $output .= "if (function_exists('"."Plugin".$plugin."')===false)".
900 900
                         "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
901 901
                     } else {
902
-                        $output .= "if (function_exists('" . Core::NAMESPACE_PLUGINS_FUNCTIONS . "Plugin" . $plugin . "')===false)".
902
+                        $output .= "if (function_exists('".Core::NAMESPACE_PLUGINS_FUNCTIONS."Plugin".$plugin."')===false)".
903 903
                         "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
904 904
                     }
905 905
                     break;
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
                     $output .= $this->getCore()->getPluginProxy()->getLoader($plugin);
920 920
                     break;
921 921
                 default:
922
-                    throw new CompilationException($this, 'Type error for ' . $plugin . ' with type' . $type);
922
+                    throw new CompilationException($this, 'Type error for '.$plugin.' with type'.$type);
923 923
             }
924 924
         }
925 925
 
@@ -930,30 +930,30 @@  discard block
 block discarded – undo
930 930
         }
931 931
         foreach ($this->templatePlugins as $function) {
932 932
             if (isset($function['called']) && $function['called'] === true) {
933
-                $output .= $function['body'] . PHP_EOL;
933
+                $output .= $function['body'].PHP_EOL;
934 934
             }
935 935
         }
936 936
 
937
-        $output .= $compiled . "\n?>";
937
+        $output .= $compiled."\n?>";
938 938
 
939
-        $output = preg_replace('/(?<!;|\}|\*\/|\n|\{)(\s*' . preg_quote(self::PHP_CLOSE, '/') . preg_quote(self::PHP_OPEN, '/') . ')/', ";\n", $output);
940
-        $output = str_replace(self::PHP_CLOSE . self::PHP_OPEN, "\n", $output);
939
+        $output = preg_replace('/(?<!;|\}|\*\/|\n|\{)(\s*'.preg_quote(self::PHP_CLOSE, '/').preg_quote(self::PHP_OPEN, '/').')/', ";\n", $output);
940
+        $output = str_replace(self::PHP_CLOSE.self::PHP_OPEN, "\n", $output);
941 941
 
942 942
         // handle <?xml tag at the beginning
943 943
         $output = preg_replace('#(/\* template body \*/ \?>\s*)<\?xml#is', '$1<?php echo \'<?xml\'; ?>', $output);
944 944
 
945 945
         // add another line break after PHP closing tags that have a line break following,
946 946
         // as we do not know whether it's intended, and PHP will strip it otherwise
947
-        $output = preg_replace('/(?<!"|<\?xml)\s*\?>\n/', '$0' . "\n", $output);
947
+        $output = preg_replace('/(?<!"|<\?xml)\s*\?>\n/', '$0'."\n", $output);
948 948
 
949 949
         if ($this->debug) {
950
-            echo '=============================================================================================' . "\n";
950
+            echo '============================================================================================='."\n";
951 951
             $lines = preg_split('{\r\n|\n|<br />}', $output);
952 952
             array_shift($lines);
953 953
             foreach ($lines as $i => $line) {
954
-                echo ($i + 1) . '. ' . $line . "\r\n";
954
+                echo ($i+1).'. '.$line."\r\n";
955 955
             }
956
-            echo '=============================================================================================' . "\n";
956
+            echo '============================================================================================='."\n";
957 957
         }
958 958
 
959 959
         $this->template = $this->dwoo = null;
@@ -970,13 +970,13 @@  discard block
 block discarded – undo
970 970
     protected function resolveSubTemplateDependencies($function)
971 971
     {
972 972
         if ($this->debug) {
973
-            echo 'Compiler::' . __FUNCTION__ . "\n";
973
+            echo 'Compiler::'.__FUNCTION__."\n";
974 974
         }
975 975
 
976 976
         $body = $this->templatePlugins[$function]['body'];
977 977
         foreach ($this->templatePlugins as $func => $attr) {
978
-            if ($func !== $function && !isset($attr['called']) && strpos($body, Core::NAMESPACE_PLUGINS_FUNCTIONS .
979
-            'Plugin' . Core::toCamelCase($func)) !== false) {
978
+            if ($func !== $function && !isset($attr['called']) && strpos($body, Core::NAMESPACE_PLUGINS_FUNCTIONS.
979
+            'Plugin'.Core::toCamelCase($func)) !== false) {
980 980
                 $this->templatePlugins[$func]['called'] = true;
981 981
                 $this->resolveSubTemplateDependencies($func);
982 982
             }
@@ -1000,14 +1000,14 @@  discard block
 block discarded – undo
1000 1000
 
1001 1001
         if ($this->curBlock['buffer'] === null && count($this->stack) > 1) {
1002 1002
             // buffer is not initialized yet (the block has just been created)
1003
-            $this->stack[count($this->stack) - 2]['buffer'] .= (string)$content;
1003
+            $this->stack[count($this->stack)-2]['buffer'] .= (string) $content;
1004 1004
             $this->curBlock['buffer'] = '';
1005 1005
         } else {
1006 1006
             if (!isset($this->curBlock['buffer'])) {
1007 1007
                 throw new CompilationException($this, 'The template has been closed too early, you probably have an extra block-closing tag somewhere');
1008 1008
             }
1009 1009
             // append current content to current block's buffer
1010
-            $this->curBlock['buffer'] .= (string)$content;
1010
+            $this->curBlock['buffer'] .= (string) $content;
1011 1011
         }
1012 1012
         $this->line += $lineCount;
1013 1013
     }
@@ -1077,26 +1077,26 @@  discard block
 block discarded – undo
1077 1077
     public function addBlock($type, array $params, $paramtype)
1078 1078
     {
1079 1079
         if ($this->debug) {
1080
-            echo 'Compiler::' . __FUNCTION__ . "\n";
1080
+            echo 'Compiler::'.__FUNCTION__."\n";
1081 1081
         }
1082 1082
 
1083 1083
         $class = current(array_filter([
1084
-            'Plugin' . Core::toCamelCase($type),
1085
-            Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($type)
1084
+            'Plugin'.Core::toCamelCase($type),
1085
+            Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($type)
1086 1086
         ], 'class_exists'));
1087 1087
         if (false === $class) {
1088 1088
             $this->getCore()->getLoader()->loadPlugin($type);
1089 1089
         }
1090 1090
         $params = $this->mapParams($params, array($class, 'init'), $paramtype);
1091 1091
 
1092
-        $this->stack[]  = array(
1092
+        $this->stack[] = array(
1093 1093
             'type'   => $type,
1094 1094
             'params' => $params,
1095 1095
             'custom' => false,
1096 1096
             'class'  => $class,
1097 1097
             'buffer' => null
1098 1098
         );
1099
-        $this->curBlock = &$this->stack[count($this->stack) - 1];
1099
+        $this->curBlock = &$this->stack[count($this->stack)-1];
1100 1100
 
1101 1101
         return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type);
1102 1102
     }
@@ -1121,14 +1121,14 @@  discard block
 block discarded – undo
1121 1121
 
1122 1122
         $params = $this->mapParams($params, array($class, 'init'), $paramtype);
1123 1123
 
1124
-        $this->stack[]  = array(
1124
+        $this->stack[] = array(
1125 1125
             'type'   => $type,
1126 1126
             'params' => $params,
1127 1127
             'custom' => true,
1128 1128
             'class'  => $class,
1129 1129
             'buffer' => null
1130 1130
         );
1131
-        $this->curBlock = &$this->stack[count($this->stack) - 1];
1131
+        $this->curBlock = &$this->stack[count($this->stack)-1];
1132 1132
 
1133 1133
         return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type);
1134 1134
     }
@@ -1143,21 +1143,21 @@  discard block
 block discarded – undo
1143 1143
     public function injectBlock($type, array $params)
1144 1144
     {
1145 1145
         if ($this->debug) {
1146
-            echo 'Compiler::' . __FUNCTION__ . "\n";
1146
+            echo 'Compiler::'.__FUNCTION__."\n";
1147 1147
         }
1148 1148
 
1149
-        $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($type);
1149
+        $class = Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($type);
1150 1150
         if (class_exists($class) === false) {
1151 1151
             $this->getCore()->getLoader()->loadPlugin($type);
1152 1152
         }
1153
-        $this->stack[]  = array(
1153
+        $this->stack[] = array(
1154 1154
             'type'   => $type,
1155 1155
             'params' => $params,
1156 1156
             'custom' => false,
1157 1157
             'class'  => $class,
1158 1158
             'buffer' => null
1159 1159
         );
1160
-        $this->curBlock = &$this->stack[count($this->stack) - 1];
1160
+        $this->curBlock = &$this->stack[count($this->stack)-1];
1161 1161
     }
1162 1162
 
1163 1163
     /**
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
     public function removeBlock($type)
1173 1173
     {
1174 1174
         if ($this->debug) {
1175
-            echo 'Compiler::' . __FUNCTION__ . "\n";
1175
+            echo 'Compiler::'.__FUNCTION__."\n";
1176 1176
         }
1177 1177
 
1178 1178
         $output = '';
@@ -1187,12 +1187,12 @@  discard block
 block discarded – undo
1187 1187
                     $class = $top['class'];
1188 1188
                 } else {
1189 1189
                     $class = current(array_filter([
1190
-                        'Plugin' . Core::toCamelCase($top['type']),
1191
-                        Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($top['type'])
1190
+                        'Plugin'.Core::toCamelCase($top['type']),
1191
+                        Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($top['type'])
1192 1192
                     ], 'class_exists'));
1193 1193
                 }
1194 1194
                 if (count($this->stack)) {
1195
-                    $this->curBlock = &$this->stack[count($this->stack) - 1];
1195
+                    $this->curBlock = &$this->stack[count($this->stack)-1];
1196 1196
                     $this->push(call_user_func(array(
1197 1197
                         $class,
1198 1198
                         'postProcessing'
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
                 }
1214 1214
             }
1215 1215
 
1216
-            throw new CompilationException($this, 'Syntax malformation, a block of type "' . $type . '" was closed but was not opened');
1216
+            throw new CompilationException($this, 'Syntax malformation, a block of type "'.$type.'" was closed but was not opened');
1217 1217
         }
1218 1218
 
1219 1219
         return $output;
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
             }
1252 1252
         }
1253 1253
 
1254
-        throw new CompilationException($this, 'A parent block of type "' . $type . '" is required and can not be found');
1254
+        throw new CompilationException($this, 'A parent block of type "'.$type.'" is required and can not be found');
1255 1255
     }
1256 1256
 
1257 1257
     /**
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
     public function removeTopBlock()
1275 1275
     {
1276 1276
         if ($this->debug) {
1277
-            echo 'Compiler::' . __FUNCTION__ . "\n";
1277
+            echo 'Compiler::'.__FUNCTION__."\n";
1278 1278
         }
1279 1279
 
1280 1280
         $o = array_pop($this->stack);
@@ -1284,10 +1284,10 @@  discard block
 block discarded – undo
1284 1284
         if ($o['custom']) {
1285 1285
             $class = $o['class'];
1286 1286
         } else {
1287
-            $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($o['type']);
1287
+            $class = Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($o['type']);
1288 1288
         }
1289 1289
 
1290
-        $this->curBlock = &$this->stack[count($this->stack) - 1];
1290
+        $this->curBlock = &$this->stack[count($this->stack)-1];
1291 1291
 
1292 1292
         return call_user_func(array($class, 'postProcessing'), $this, $o['params'], '', '', $o['buffer']);
1293 1293
     }
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
     protected function parse($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
1367 1367
     {
1368 1368
         if ($this->debug) {
1369
-            echo 'Compiler::' . __FUNCTION__ . "\n";
1369
+            echo 'Compiler::'.__FUNCTION__."\n";
1370 1370
         }
1371 1371
 
1372 1372
         if ($to === null) {
@@ -1383,14 +1383,14 @@  discard block
 block discarded – undo
1383 1383
                 // end template tag
1384 1384
                 $pointer += strlen($this->rd);
1385 1385
                 if ($this->debug) {
1386
-                    echo 'TEMPLATE PARSING ENDED' . "\n";
1386
+                    echo 'TEMPLATE PARSING ENDED'."\n";
1387 1387
                 }
1388 1388
 
1389 1389
                 return false;
1390 1390
             }
1391
-            ++ $from;
1391
+            ++$from;
1392 1392
             if ($pointer !== null) {
1393
-                ++ $pointer;
1393
+                ++$pointer;
1394 1394
             }
1395 1395
             if ($from >= $to) {
1396 1396
                 if (is_array($parsingParams)) {
@@ -1402,22 +1402,22 @@  discard block
 block discarded – undo
1402 1402
             $first = $in[$from];
1403 1403
         }
1404 1404
 
1405
-        $substr = substr($in, $from, $to - $from);
1405
+        $substr = substr($in, $from, $to-$from);
1406 1406
 
1407 1407
         if ($this->debug) {
1408
-            echo 'PARSE CALL : PARSING "' . htmlentities(substr($in, $from, min($to - $from, 50))) . (($to - $from) > 50 ? '...' : '') . '" @ ' . $from . ':' . $to . ' in ' . $curBlock . ' : pointer=' . $pointer . "\n";
1408
+            echo 'PARSE CALL : PARSING "'.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...' : '').'" @ '.$from.':'.$to.' in '.$curBlock.' : pointer='.$pointer."\n";
1409 1409
         }
1410 1410
         $parsed = '';
1411 1411
 
1412 1412
         if ($curBlock === 'root' && $first === '*') {
1413 1413
             $src      = $this->getTemplateSource();
1414
-            $startpos = $this->getPointer() - strlen($this->ld);
1414
+            $startpos = $this->getPointer()-strlen($this->ld);
1415 1415
             if (substr($src, $startpos, strlen($this->ld)) === $this->ld) {
1416 1416
                 if ($startpos > 0) {
1417 1417
                     do {
1418 1418
                         $char = substr($src, -- $startpos, 1);
1419 1419
                         if ($char == "\n") {
1420
-                            ++ $startpos;
1420
+                            ++$startpos;
1421 1421
                             $whitespaceStart = true;
1422 1422
                             break;
1423 1423
                         }
@@ -1428,12 +1428,12 @@  discard block
 block discarded – undo
1428 1428
                 if (!isset($whitespaceStart)) {
1429 1429
                     $startpos = $this->getPointer();
1430 1430
                 } else {
1431
-                    $pointer -= $this->getPointer() - $startpos;
1431
+                    $pointer -= $this->getPointer()-$startpos;
1432 1432
                 }
1433 1433
 
1434
-                if ($this->allowNestedComments && strpos($src, $this->ld . '*', $this->getPointer()) !== false) {
1435
-                    $comOpen  = $this->ld . '*';
1436
-                    $comClose = '*' . $this->rd;
1434
+                if ($this->allowNestedComments && strpos($src, $this->ld.'*', $this->getPointer()) !== false) {
1435
+                    $comOpen  = $this->ld.'*';
1436
+                    $comClose = '*'.$this->rd;
1437 1437
                     $level    = 1;
1438 1438
                     $ptr      = $this->getPointer();
1439 1439
 
@@ -1443,33 +1443,33 @@  discard block
 block discarded – undo
1443 1443
 
1444 1444
                         if ($open !== false && $close !== false) {
1445 1445
                             if ($open < $close) {
1446
-                                $ptr = $open + strlen($comOpen);
1447
-                                ++ $level;
1446
+                                $ptr = $open+strlen($comOpen);
1447
+                                ++$level;
1448 1448
                             } else {
1449
-                                $ptr = $close + strlen($comClose);
1450
-                                -- $level;
1449
+                                $ptr = $close+strlen($comClose);
1450
+                                --$level;
1451 1451
                             }
1452 1452
                         } elseif ($open !== false) {
1453
-                            $ptr = $open + strlen($comOpen);
1454
-                            ++ $level;
1453
+                            $ptr = $open+strlen($comOpen);
1454
+                            ++$level;
1455 1455
                         } elseif ($close !== false) {
1456
-                            $ptr = $close + strlen($comClose);
1457
-                            -- $level;
1456
+                            $ptr = $close+strlen($comClose);
1457
+                            --$level;
1458 1458
                         } else {
1459 1459
                             $ptr = strlen($src);
1460 1460
                         }
1461 1461
                     }
1462
-                    $endpos = $ptr - strlen('*' . $this->rd);
1462
+                    $endpos = $ptr-strlen('*'.$this->rd);
1463 1463
                 } else {
1464
-                    $endpos = strpos($src, '*' . $this->rd, $startpos);
1464
+                    $endpos = strpos($src, '*'.$this->rd, $startpos);
1465 1465
                     if ($endpos == false) {
1466 1466
                         throw new CompilationException($this, 'Un-ended comment');
1467 1467
                     }
1468 1468
                 }
1469
-                $pointer += $endpos - $startpos + strlen('*' . $this->rd);
1470
-                if (isset($whitespaceStart) && preg_match('#^[\t ]*\r?\n#', substr($src, $endpos + strlen('*' . $this->rd)), $m)) {
1469
+                $pointer += $endpos-$startpos+strlen('*'.$this->rd);
1470
+                if (isset($whitespaceStart) && preg_match('#^[\t ]*\r?\n#', substr($src, $endpos+strlen('*'.$this->rd)), $m)) {
1471 1471
                     $pointer += strlen($m[0]);
1472
-                    $this->curBlock['buffer'] = substr($this->curBlock['buffer'], 0, strlen($this->curBlock['buffer']) - ($this->getPointer() - $startpos - strlen($this->ld)));
1472
+                    $this->curBlock['buffer'] = substr($this->curBlock['buffer'], 0, strlen($this->curBlock['buffer'])-($this->getPointer()-$startpos-strlen($this->ld)));
1473 1473
                 }
1474 1474
 
1475 1475
                 return false;
@@ -1486,20 +1486,20 @@  discard block
 block discarded – undo
1486 1486
         } elseif (($first === '"' || $first === "'") && !(is_array($parsingParams) && preg_match('#^([\'"])[a-z0-9_]+\1\s*=>?(?:\s+|[^=])#i', $substr))) {
1487 1487
             // string
1488 1488
             $out = $this->parseString($in, $from, $to, $parsingParams, $curBlock, $pointer);
1489
-        } elseif (preg_match('/^\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?(' . (is_array($parsingParams) || $curBlock != 'root' ? '' : '\s+[^(]|') . '\s*\(|\s*' . $this->rdr . '|\s*;)/i', $substr)) {
1489
+        } elseif (preg_match('/^\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?('.(is_array($parsingParams) || $curBlock != 'root' ? '' : '\s+[^(]|').'\s*\(|\s*'.$this->rdr.'|\s*;)/i', $substr)) {
1490 1490
             // func
1491 1491
             $out    = $this->parseFunction($in, $from, $to, $parsingParams, $curBlock, $pointer);
1492 1492
             $parsed = 'func';
1493 1493
         } elseif ($first === ';') {
1494 1494
             // instruction end
1495 1495
             if ($this->debug) {
1496
-                echo 'END OF INSTRUCTION' . "\n";
1496
+                echo 'END OF INSTRUCTION'."\n";
1497 1497
             }
1498 1498
             if ($pointer !== null) {
1499
-                ++ $pointer;
1499
+                ++$pointer;
1500 1500
             }
1501 1501
 
1502
-            return $this->parse($in, $from + 1, $to, false, 'root', $pointer);
1502
+            return $this->parse($in, $from+1, $to, false, 'root', $pointer);
1503 1503
         } elseif ($curBlock === 'root' && preg_match('#^/([a-z_][a-z0-9_]*)?#i', $substr, $match)) {
1504 1504
             // close block
1505 1505
             if (!empty($match[1]) && $match[1] == 'else') {
@@ -1516,13 +1516,13 @@  discard block
 block discarded – undo
1516 1516
                     $pointer -= strlen($match[0]);
1517 1517
                 }
1518 1518
                 if ($this->debug) {
1519
-                    echo 'TOP BLOCK CLOSED' . "\n";
1519
+                    echo 'TOP BLOCK CLOSED'."\n";
1520 1520
                 }
1521 1521
 
1522 1522
                 return $this->removeTopBlock();
1523 1523
             } else {
1524 1524
                 if ($this->debug) {
1525
-                    echo 'BLOCK OF TYPE ' . $match[1] . ' CLOSED' . "\n";
1525
+                    echo 'BLOCK OF TYPE '.$match[1].' CLOSED'."\n";
1526 1526
                 }
1527 1527
 
1528 1528
                 return $this->removeBlock($match[1]);
@@ -1530,19 +1530,19 @@  discard block
 block discarded – undo
1530 1530
         } elseif ($curBlock === 'root' && substr($substr, 0, strlen($this->rd)) === $this->rd) {
1531 1531
             // end template tag
1532 1532
             if ($this->debug) {
1533
-                echo 'TAG PARSING ENDED' . "\n";
1533
+                echo 'TAG PARSING ENDED'."\n";
1534 1534
             }
1535 1535
             $pointer += strlen($this->rd);
1536 1536
 
1537 1537
             return false;
1538
-        } elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*=' . ($curBlock === 'array' ? '>?' : '') . ')(?:\s+|[^=]).*#i', $substr, $match)) {
1538
+        } elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*='.($curBlock === 'array' ? '>?' : '').')(?:\s+|[^=]).*#i', $substr, $match)) {
1539 1539
             // named parameter
1540 1540
             if ($this->debug) {
1541
-                echo 'NAMED PARAM FOUND' . "\n";
1541
+                echo 'NAMED PARAM FOUND'."\n";
1542 1542
             }
1543 1543
             $len = strlen($match[1]);
1544
-            while (substr($in, $from + $len, 1) === ' ') {
1545
-                ++ $len;
1544
+            while (substr($in, $from+$len, 1) === ' ') {
1545
+                ++$len;
1546 1546
             }
1547 1547
             if ($pointer !== null) {
1548 1548
                 $pointer += $len;
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
 
1551 1551
             $output = array(
1552 1552
                 trim($match[1], " \t\r\n=>'\""),
1553
-                $this->parse($in, $from + $len, $to, false, 'namedparam', $pointer)
1553
+                $this->parse($in, $from+$len, $to, false, 'namedparam', $pointer)
1554 1554
             );
1555 1555
 
1556 1556
             $parsingParams[] = $output;
@@ -1571,31 +1571,31 @@  discard block
 block discarded – undo
1571 1571
             $out = $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer);
1572 1572
         } else {
1573 1573
             // parse error
1574
-            throw new CompilationException($this, 'Parse error in "' . substr($in, $from, $to - $from) . '"');
1574
+            throw new CompilationException($this, 'Parse error in "'.substr($in, $from, $to-$from).'"');
1575 1575
         }
1576 1576
 
1577 1577
         if (empty($out)) {
1578 1578
             return '';
1579 1579
         }
1580 1580
 
1581
-        $substr = substr($in, $pointer, $to - $pointer);
1581
+        $substr = substr($in, $pointer, $to-$pointer);
1582 1582
 
1583 1583
         // var parsed, check if any var-extension applies
1584 1584
         if ($parsed === 'var') {
1585 1585
             if (preg_match('#^\s*([/%+*-])\s*([a-z0-9]|\$)#i', $substr, $match)) {
1586 1586
                 if ($this->debug) {
1587
-                    echo 'PARSING POST-VAR EXPRESSION ' . $substr . "\n";
1587
+                    echo 'PARSING POST-VAR EXPRESSION '.$substr."\n";
1588 1588
                 }
1589 1589
                 // parse expressions
1590
-                $pointer += strlen($match[0]) - 1;
1590
+                $pointer += strlen($match[0])-1;
1591 1591
                 if (is_array($parsingParams)) {
1592 1592
                     if ($match[2] == '$') {
1593 1593
                         $expr = $this->parseVar($in, $pointer, $to, array(), $curBlock, $pointer);
1594 1594
                     } else {
1595 1595
                         $expr = $this->parse($in, $pointer, $to, array(), 'expression', $pointer);
1596 1596
                     }
1597
-                    $out[count($out) - 1][0] .= $match[1] . $expr[0][0];
1598
-                    $out[count($out) - 1][1] .= $match[1] . $expr[0][1];
1597
+                    $out[count($out)-1][0] .= $match[1].$expr[0][0];
1598
+                    $out[count($out)-1][1] .= $match[1].$expr[0][1];
1599 1599
                 } else {
1600 1600
                     if ($match[2] == '$') {
1601 1601
                         $expr = $this->parseVar($in, $pointer, $to, false, $curBlock, $pointer);
@@ -1603,26 +1603,26 @@  discard block
 block discarded – undo
1603 1603
                         $expr = $this->parse($in, $pointer, $to, false, 'expression', $pointer);
1604 1604
                     }
1605 1605
                     if (is_array($out) && is_array($expr)) {
1606
-                        $out[0] .= $match[1] . $expr[0];
1607
-                        $out[1] .= $match[1] . $expr[1];
1606
+                        $out[0] .= $match[1].$expr[0];
1607
+                        $out[1] .= $match[1].$expr[1];
1608 1608
                     } elseif (is_array($out)) {
1609
-                        $out[0] .= $match[1] . $expr;
1610
-                        $out[1] .= $match[1] . $expr;
1609
+                        $out[0] .= $match[1].$expr;
1610
+                        $out[1] .= $match[1].$expr;
1611 1611
                     } elseif (is_array($expr)) {
1612
-                        $out .= $match[1] . $expr[0];
1612
+                        $out .= $match[1].$expr[0];
1613 1613
                     } else {
1614
-                        $out .= $match[1] . $expr;
1614
+                        $out .= $match[1].$expr;
1615 1615
                     }
1616 1616
                 }
1617 1617
             } elseif ($curBlock === 'root' && preg_match('#^(\s*(?:[+/*%-.]=|=|\+\+|--)\s*)(.*)#s', $substr, $match)) {
1618 1618
                 if ($this->debug) {
1619
-                    echo 'PARSING POST-VAR ASSIGNMENT ' . $substr . "\n";
1619
+                    echo 'PARSING POST-VAR ASSIGNMENT '.$substr."\n";
1620 1620
                 }
1621 1621
                 // parse assignment
1622 1622
                 $value    = $match[2];
1623 1623
                 $operator = trim($match[1]);
1624 1624
                 if (substr($value, 0, 1) == '=') {
1625
-                    throw new CompilationException($this, 'Unexpected "=" in <em>' . $substr . '</em>');
1625
+                    throw new CompilationException($this, 'Unexpected "=" in <em>'.$substr.'</em>');
1626 1626
                 }
1627 1627
 
1628 1628
                 if ($pointer !== null) {
@@ -1643,7 +1643,7 @@  discard block
 block discarded – undo
1643 1643
                         throw new CompilationException($this, 'Assignments require the "if" plugin to be accessible');
1644 1644
                     }
1645 1645
 
1646
-                    $parts  = $this->mapParams($parts, array(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf', 'init'), 1);
1646
+                    $parts  = $this->mapParams($parts, array(Core::NAMESPACE_PLUGINS_BLOCKS.'PluginIf', 'init'), 1);
1647 1647
                     $tokens = $this->getParamTokens($parts);
1648 1648
                     $parts  = $this->getCompiledParams($parts);
1649 1649
 
@@ -1657,14 +1657,14 @@  discard block
 block discarded – undo
1657 1657
                 if ($this->autoEscape) {
1658 1658
                     $out = preg_replace('#\(is_string\(\$tmp=(.+?)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $out);
1659 1659
                 }
1660
-                $out = self::PHP_OPEN . $echo . $out . $operator . implode(' ', $value) . self::PHP_CLOSE;
1660
+                $out = self::PHP_OPEN.$echo.$out.$operator.implode(' ', $value).self::PHP_CLOSE;
1661 1661
             } elseif ($curBlock === 'array' && is_array($parsingParams) && preg_match('#^(\s*=>?\s*)#', $substr, $match)) {
1662 1662
                 // parse namedparam with var as name (only for array)
1663 1663
                 if ($this->debug) {
1664
-                    echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND' . "\n";
1664
+                    echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND'."\n";
1665 1665
                 }
1666 1666
                 $len = strlen($match[1]);
1667
-                $var = $out[count($out) - 1];
1667
+                $var = $out[count($out)-1];
1668 1668
                 $pointer += $len;
1669 1669
 
1670 1670
                 $output = array($var[0], $this->parse($substr, $len, null, false, 'namedparam', $pointer));
@@ -1679,16 +1679,16 @@  discard block
 block discarded – undo
1679 1679
             // parse modifier on funcs or vars
1680 1680
             $srcPointer = $pointer;
1681 1681
             if (is_array($parsingParams)) {
1682
-                $tmp                     = $this->replaceModifiers(
1682
+                $tmp = $this->replaceModifiers(
1683 1683
                     array(
1684 1684
                     null,
1685 1685
                     null,
1686
-                    $out[count($out) - 1][0],
1686
+                    $out[count($out)-1][0],
1687 1687
                     $match[0]
1688 1688
                     ), $curBlock, $pointer
1689 1689
                 );
1690
-                $out[count($out) - 1][0] = $tmp;
1691
-                $out[count($out) - 1][1] .= substr($substr, $srcPointer, $srcPointer - $pointer);
1690
+                $out[count($out)-1][0] = $tmp;
1691
+                $out[count($out)-1][1] .= substr($substr, $srcPointer, $srcPointer-$pointer);
1692 1692
             } else {
1693 1693
                 $out = $this->replaceModifiers(array(null, null, $out, $match[0]), $curBlock, $pointer);
1694 1694
             }
@@ -1700,10 +1700,10 @@  discard block
 block discarded – undo
1700 1700
             $ptr = 0;
1701 1701
 
1702 1702
             if (is_array($parsingParams)) {
1703
-                $output = $this->parseMethodCall($out[count($out) - 1][1], $match[0], $curBlock, $ptr);
1703
+                $output = $this->parseMethodCall($out[count($out)-1][1], $match[0], $curBlock, $ptr);
1704 1704
 
1705
-                $out[count($out) - 1][0] = $output;
1706
-                $out[count($out) - 1][1] .= substr($match[0], 0, $ptr);
1705
+                $out[count($out)-1][0] = $output;
1706
+                $out[count($out)-1][1] .= substr($match[0], 0, $ptr);
1707 1707
             } else {
1708 1708
                 $out = $this->parseMethodCall($out, $match[0], $curBlock, $ptr);
1709 1709
             }
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
         }
1713 1713
 
1714 1714
         if ($curBlock === 'root' && substr($out, 0, strlen(self::PHP_OPEN)) !== self::PHP_OPEN) {
1715
-            return self::PHP_OPEN . 'echo ' . $out . ';' . self::PHP_CLOSE;
1715
+            return self::PHP_OPEN.'echo '.$out.';'.self::PHP_CLOSE;
1716 1716
         }
1717 1717
 
1718 1718
         return $out;
@@ -1738,11 +1738,11 @@  discard block
 block discarded – undo
1738 1738
     protected function parseFunction($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
1739 1739
     {
1740 1740
         $output = '';
1741
-        $cmdstr = substr($in, $from, $to - $from);
1742
-        preg_match('/^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?)(\s*' . $this->rdr . '|\s*;)?/i', $cmdstr, $match);
1741
+        $cmdstr = substr($in, $from, $to-$from);
1742
+        preg_match('/^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?)(\s*'.$this->rdr.'|\s*;)?/i', $cmdstr, $match);
1743 1743
 
1744 1744
         if (empty($match[1])) {
1745
-            throw new CompilationException($this, 'Parse error, invalid function name : ' . substr($cmdstr, 0, 15));
1745
+            throw new CompilationException($this, 'Parse error, invalid function name : '.substr($cmdstr, 0, 15));
1746 1746
         }
1747 1747
 
1748 1748
         $func = $match[1];
@@ -1752,7 +1752,7 @@  discard block
 block discarded – undo
1752 1752
         }
1753 1753
 
1754 1754
         if ($this->debug) {
1755
-            echo 'FUNC FOUND (' . $func . ')' . "\n";
1755
+            echo 'FUNC FOUND ('.$func.')'."\n";
1756 1756
         }
1757 1757
 
1758 1758
         $paramsep = '';
@@ -1764,11 +1764,11 @@  discard block
 block discarded – undo
1764 1764
             $paramspos = $match[1][0][1];
1765 1765
             $paramsep  = substr($match[1][0][0], - 1) === '(' ? ')' : '';
1766 1766
             if ($paramsep === ')') {
1767
-                $paramspos += strlen($match[1][0][0]) - 1;
1767
+                $paramspos += strlen($match[1][0][0])-1;
1768 1768
                 if (substr($cmdstr, 0, 2) === 'if' || substr($cmdstr, 0, 6) === 'elseif') {
1769 1769
                     $paramsep = '';
1770 1770
                     if (strlen($match[1][0][0]) > 1) {
1771
-                        -- $paramspos;
1771
+                        --$paramspos;
1772 1772
                     }
1773 1773
                 }
1774 1774
             }
@@ -1793,8 +1793,8 @@  discard block
 block discarded – undo
1793 1793
                     return $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer);
1794 1794
                 }
1795 1795
             }
1796
-            $whitespace = strlen(substr($cmdstr, strlen($func), $paramspos - strlen($func)));
1797
-            $paramstr   = substr($cmdstr, $paramspos + 1);
1796
+            $whitespace = strlen(substr($cmdstr, strlen($func), $paramspos-strlen($func)));
1797
+            $paramstr   = substr($cmdstr, $paramspos+1);
1798 1798
             if (substr($paramstr, - 1, 1) === $paramsep) {
1799 1799
                 $paramstr = substr($paramstr, 0, - 1);
1800 1800
             }
@@ -1816,36 +1816,36 @@  discard block
 block discarded – undo
1816 1816
 
1817 1817
                             if ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === ')') {
1818 1818
                                 if ($this->debug) {
1819
-                                    echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT ' . $ptr . "\n";
1819
+                                    echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT '.$ptr."\n";
1820 1820
                                 }
1821 1821
                                 break 2;
1822 1822
                             } elseif ($paramstr[$ptr] === ';') {
1823
-                                ++ $ptr;
1823
+                                ++$ptr;
1824 1824
                                 if ($this->debug) {
1825
-                                    echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT ' . $ptr . "\n";
1825
+                                    echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT '.$ptr."\n";
1826 1826
                                 }
1827 1827
                                 break 2;
1828 1828
                             } elseif ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === '/') {
1829 1829
                                 if ($this->debug) {
1830
-                                    echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT ' . $ptr . "\n";
1830
+                                    echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT '.$ptr."\n";
1831 1831
                                 }
1832 1832
                                 break 2;
1833 1833
                             } elseif (substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) {
1834 1834
                                 if ($this->debug) {
1835
-                                    echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT ' . $ptr . "\n";
1835
+                                    echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT '.$ptr."\n";
1836 1836
                                 }
1837 1837
                                 break 2;
1838 1838
                             }
1839 1839
 
1840 1840
                             if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === ',' || $paramstr[$ptr] === "\r" || $paramstr[$ptr] === "\n" || $paramstr[$ptr] === "\t") {
1841
-                                ++ $ptr;
1841
+                                ++$ptr;
1842 1842
                             } else {
1843 1843
                                 break;
1844 1844
                             }
1845 1845
                         }
1846 1846
 
1847 1847
                         if ($this->debug) {
1848
-                            echo 'FUNC START PARAM PARSING WITH POINTER AT ' . $ptr . "\n";
1848
+                            echo 'FUNC START PARAM PARSING WITH POINTER AT '.$ptr."\n";
1849 1849
                         }
1850 1850
 
1851 1851
                         if ($func === 'if' || $func === 'elseif' || $func === 'tif') {
@@ -1857,7 +1857,7 @@  discard block
 block discarded – undo
1857 1857
                         }
1858 1858
 
1859 1859
                         if ($this->debug) {
1860
-                            echo 'PARAM PARSED, POINTER AT ' . $ptr . ' (' . substr($paramstr, $ptr - 1, 3) . ')' . "\n";
1860
+                            echo 'PARAM PARSED, POINTER AT '.$ptr.' ('.substr($paramstr, $ptr-1, 3).')'."\n";
1861 1861
                         }
1862 1862
                     }
1863 1863
                 }
@@ -1881,16 +1881,16 @@  discard block
 block discarded – undo
1881 1881
         }
1882 1882
 
1883 1883
         if ($pointer !== null) {
1884
-            $pointer += (isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func) + (isset($whitespace) ? $whitespace : 0);
1884
+            $pointer += (isset($paramstr) ? strlen($paramstr) : 0)+(')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1))+strlen($func)+(isset($whitespace) ? $whitespace : 0);
1885 1885
             if ($this->debug) {
1886
-                echo 'FUNC ADDS ' . ((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func)) . ' TO POINTER' . "\n";
1886
+                echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0)+(')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1))+strlen($func)).' TO POINTER'."\n";
1887 1887
             }
1888 1888
         }
1889 1889
 
1890 1890
         if ($curBlock === 'method' || $func === 'do' || strstr($func, '::') !== false) {
1891 1891
             // handle static method calls with security policy
1892 1892
             if (strstr($func, '::') !== false && $this->securityPolicy !== null && $this->securityPolicy->isMethodAllowed(explode('::', strtolower($func))) !== true) {
1893
-                throw new SecurityException('Call to a disallowed php function : ' . $func);
1893
+                throw new SecurityException('Call to a disallowed php function : '.$func);
1894 1894
             }
1895 1895
             $pluginType = Core::NATIVE_PLUGIN;
1896 1896
         } else {
@@ -1935,19 +1935,19 @@  discard block
 block discarded – undo
1935 1935
                     $this->customPlugins[$func]['function']
1936 1936
                 ), $state);
1937 1937
             } else {
1938
-                if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) {
1938
+                if (class_exists('Plugin'.Core::toCamelCase($func)) !== false) {
1939 1939
                     $params = $this->mapParams($params, array(
1940
-                        'Plugin' . Core::toCamelCase($func),
1940
+                        'Plugin'.Core::toCamelCase($func),
1941 1941
                         ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'
1942 1942
                     ), $state);
1943
-                } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !== false) {
1943
+                } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func)) !== false) {
1944 1944
                     $params = $this->mapParams($params, array(
1945
-                        Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func),
1945
+                        Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func),
1946 1946
                         ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'
1947 1947
                     ), $state);
1948 1948
                 } else {
1949 1949
                     $params = $this->mapParams($params, array(
1950
-                        Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func),
1950
+                        Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func),
1951 1951
                         ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'
1952 1952
                     ), $state);
1953 1953
                 }
@@ -1958,24 +1958,22 @@  discard block
 block discarded – undo
1958 1958
                 $params = $this->mapParams($params, $this->customPlugins[$func]['callback'], $state);
1959 1959
             } else {
1960 1960
                 // Custom plugin
1961
-                if (function_exists('Plugin' . Core::toCamelCase($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ?
1961
+                if (function_exists('Plugin'.Core::toCamelCase($func).(($pluginType & Core::COMPILABLE_PLUGIN) ?
1962 1962
                         'Compile' : '')) !== false) {
1963
-                    $params = $this->mapParams($params, 'Plugin' . Core::toCamelCase($func) . (($pluginType &
1963
+                    $params = $this->mapParams($params, 'Plugin'.Core::toCamelCase($func).(($pluginType &
1964 1964
                             Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state);
1965 1965
                 } // Builtin helper plugin
1966
-                elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . (
1966
+                elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func).(
1967 1967
                     ($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : '')) !== false) {
1968
-                    $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase
1969
-                        ($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state);
1968
+                    $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func).(($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state);
1970 1969
                 } // Builtin function plugin
1971 1970
                 else {
1972
-                    $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase
1973
-                        ($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state);
1971
+                    $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func).(($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state);
1974 1972
                 }
1975 1973
             }
1976 1974
         } // Smarty modifier
1977 1975
         elseif ($pluginType & Core::SMARTY_MODIFIER) {
1978
-            $output = 'smarty_modifier_' . $func . '(' . implode(', ', $params) . ')';
1976
+            $output = 'smarty_modifier_'.$func.'('.implode(', ', $params).')';
1979 1977
         } // Proxy plugin
1980 1978
         elseif ($pluginType & Core::PROXY_PLUGIN) {
1981 1979
             $params = $this->mapParams($params, $this->getCore()->getPluginProxy()->getCallback($func), $state);
@@ -2015,19 +2013,19 @@  discard block
 block discarded – undo
2015 2013
             if ($func === 'do') {
2016 2014
                 $output = '';
2017 2015
                 if (isset($params['*'])) {
2018
-                    $output = implode(';', $params['*']) . ';';
2016
+                    $output = implode(';', $params['*']).';';
2019 2017
                 }
2020 2018
 
2021 2019
                 if (is_array($parsingParams) || $curBlock !== 'root') {
2022 2020
                     throw new CompilationException($this, 'Do can not be used inside another function or block');
2023 2021
                 }
2024 2022
 
2025
-                return self::PHP_OPEN . $output . self::PHP_CLOSE;
2023
+                return self::PHP_OPEN.$output.self::PHP_CLOSE;
2026 2024
             } else {
2027 2025
                 if (isset($params['*'])) {
2028
-                    $output = $func . '(' . implode(', ', $params['*']) . ')';
2026
+                    $output = $func.'('.implode(', ', $params['*']).')';
2029 2027
                 } else {
2030
-                    $output = $func . '()';
2028
+                    $output = $func.'()';
2031 2029
                 }
2032 2030
             }
2033 2031
         } // Block class OR Function class
@@ -2037,7 +2035,7 @@  discard block
 block discarded – undo
2037 2035
                     $callback = $this->customPlugins[$func]['callback'];
2038 2036
                     if (!is_array($callback)) {
2039 2037
                         if (!method_exists($callback, 'compile')) {
2040
-                            throw new Exception('Custom plugin ' . $func . ' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use');
2038
+                            throw new Exception('Custom plugin '.$func.' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use');
2041 2039
                         }
2042 2040
                         if (($ref = new ReflectionMethod($callback, 'compile')) && $ref->isStatic()) {
2043 2041
                             $funcCompiler = array($callback, 'compile');
@@ -2048,13 +2046,13 @@  discard block
 block discarded – undo
2048 2046
                         $funcCompiler = $callback;
2049 2047
                     }
2050 2048
                 } else {
2051
-                    if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) {
2052
-                        $funcCompiler = array('Plugin' . Core::toCamelCase($func), 'compile');
2053
-                    } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !== false) {
2054
-                        $funcCompiler = array(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func), 'compile');
2049
+                    if (class_exists('Plugin'.Core::toCamelCase($func)) !== false) {
2050
+                        $funcCompiler = array('Plugin'.Core::toCamelCase($func), 'compile');
2051
+                    } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func)) !== false) {
2052
+                        $funcCompiler = array(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func), 'compile');
2055 2053
                     } else {
2056 2054
                         $funcCompiler = array(
2057
-                            Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func),
2055
+                            Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func),
2058 2056
                             'compile'
2059 2057
                         );
2060 2058
                     }
@@ -2071,34 +2069,34 @@  discard block
 block discarded – undo
2071 2069
                     $callback = $this->customPlugins[$func]['callback'];
2072 2070
                     if (!is_array($callback)) {
2073 2071
                         if (!method_exists($callback, 'process')) {
2074
-                            throw new Exception('Custom plugin ' . $func . ' must implement the "process" method to be usable, or you should provide a full callback to the method to use');
2072
+                            throw new Exception('Custom plugin '.$func.' must implement the "process" method to be usable, or you should provide a full callback to the method to use');
2075 2073
                         }
2076 2074
                         if (is_object($callback)) {
2077 2075
                             $callback = get_class($callback);
2078 2076
                         }
2079 2077
                         if (($ref = new ReflectionMethod($callback, 'process')) && $ref->isStatic()) {
2080
-                            $output = 'call_user_func(array(\'' . $callback . '\', \'process\'), ' . $params . ')';
2078
+                            $output = 'call_user_func(array(\''.$callback.'\', \'process\'), '.$params.')';
2081 2079
                         } else {
2082
-                            $output = 'call_user_func(array($this->getObjectPlugin(\'' . $callback . '\'), \'process\'), ' . $params . ')';
2080
+                            $output = 'call_user_func(array($this->getObjectPlugin(\''.$callback.'\'), \'process\'), '.$params.')';
2083 2081
                         }
2084 2082
                     } elseif (is_object($callback[0])) {
2085
-                        $output = 'call_user_func(array($this->plugins[\'' . $func . '\'][\'callback\'][0], \'' . $callback[1] . '\'), ' . $params . ')';
2083
+                        $output = 'call_user_func(array($this->plugins[\''.$func.'\'][\'callback\'][0], \''.$callback[1].'\'), '.$params.')';
2086 2084
                     } elseif (($ref = new ReflectionMethod($callback[0], $callback[1])) && $ref->isStatic()) {
2087
-                        $output = 'call_user_func(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), ' . $params . ')';
2085
+                        $output = 'call_user_func(array(\''.$callback[0].'\', \''.$callback[1].'\'), '.$params.')';
2088 2086
                     } else {
2089
-                        $output = 'call_user_func(array($this->getObjectPlugin(\'' . $callback[0] . '\'), \'' . $callback[1] . '\'), ' . $params . ')';
2087
+                        $output = 'call_user_func(array($this->getObjectPlugin(\''.$callback[0].'\'), \''.$callback[1].'\'), '.$params.')';
2090 2088
                     }
2091 2089
                     if (empty($params)) {
2092
-                        $output = substr($output, 0, - 3) . ')';
2090
+                        $output = substr($output, 0, - 3).')';
2093 2091
                     }
2094 2092
                 } else {
2095
-                    if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) {
2096
-                        $output = '$this->classCall(\'Plugin' . $func . '\', array(' . $params . '))';
2097
-                    } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func)) !== false) {
2098
-                        $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . $func . '\',
2099
-                        array(' . $params . '))';
2093
+                    if (class_exists('Plugin'.Core::toCamelCase($func)) !== false) {
2094
+                        $output = '$this->classCall(\'Plugin'.$func.'\', array('.$params.'))';
2095
+                    } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func)) !== false) {
2096
+                        $output = '$this->classCall(\''.Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.$func.'\',
2097
+                        array(' . $params.'))';
2100 2098
                     } else {
2101
-                        $output = '$this->classCall(\'' . $func . '\', array(' . $params . '))';
2099
+                        $output = '$this->classCall(\''.$func.'\', array('.$params.'))';
2102 2100
                     }
2103 2101
                 }
2104 2102
             }
@@ -2109,15 +2107,15 @@  discard block
 block discarded – undo
2109 2107
                     $funcCompiler = $this->customPlugins[$func]['callback'];
2110 2108
                 } else {
2111 2109
                     // Custom plugin
2112
-                    if (function_exists('Plugin' . Core::toCamelCase($func) . 'Compile') !== false) {
2113
-                        $funcCompiler = 'Plugin' . Core::toCamelCase($func) . 'Compile';
2110
+                    if (function_exists('Plugin'.Core::toCamelCase($func).'Compile') !== false) {
2111
+                        $funcCompiler = 'Plugin'.Core::toCamelCase($func).'Compile';
2114 2112
                     } // Builtin helper plugin
2115
-                    elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . 'Compile') !== false) {
2116
-                        $funcCompiler = Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) .
2113
+                    elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func).'Compile') !== false) {
2114
+                        $funcCompiler = Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func).
2117 2115
                             'Compile';
2118 2116
                     } // Builtin function plugin
2119 2117
                     else {
2120
-                        $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) .
2118
+                        $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func).
2121 2119
                             'Compile';
2122 2120
                     }
2123 2121
                 }
@@ -2133,24 +2131,24 @@  discard block
 block discarded – undo
2133 2131
                 if ($pluginType & Core::CUSTOM_PLUGIN) {
2134 2132
                     $callback = $this->customPlugins[$func]['callback'];
2135 2133
                     if ($callback instanceof Closure) {
2136
-                        $output = 'call_user_func($this->getCustomPlugin(\'' . $func . '\'), ' . $params . ')';
2134
+                        $output = 'call_user_func($this->getCustomPlugin(\''.$func.'\'), '.$params.')';
2137 2135
                     } else {
2138
-                        $output = 'call_user_func(\'' . $callback . '\', ' . $params . ')';
2136
+                        $output = 'call_user_func(\''.$callback.'\', '.$params.')';
2139 2137
                     }
2140 2138
                 } else {
2141 2139
                     // Custom plugin
2142
-                    if (function_exists('Plugin' . Core::toCamelCase($func)) !== false) {
2143
-                        $output = 'Plugin' . Core::toCamelCase($func) . '(' . $params .
2140
+                    if (function_exists('Plugin'.Core::toCamelCase($func)) !== false) {
2141
+                        $output = 'Plugin'.Core::toCamelCase($func).'('.$params.
2144 2142
                             ')';
2145 2143
                     } // Builtin helper plugin
2146
-                    elseif(function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !==
2144
+                    elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func)) !==
2147 2145
                         false) {
2148
-                        $output = Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . '(' .
2149
-                            $params . ')';
2146
+                        $output = Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($func).'('.
2147
+                            $params.')';
2150 2148
                     } // Builtin function plugin
2151 2149
                     else {
2152
-                        $output = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . '(' .
2153
-                            $params . ')';
2150
+                        $output = Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func).'('.
2151
+                            $params.')';
2154 2152
                     }
2155 2153
                 }
2156 2154
             }
@@ -2168,22 +2166,22 @@  discard block
 block discarded – undo
2168 2166
                 $callback = $this->customPlugins[$func]['callback'];
2169 2167
                 if (is_array($callback)) {
2170 2168
                     if (is_object($callback[0])) {
2171
-                        $output = 'call_user_func_array(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(array(' . $params . '), $this))';
2169
+                        $output = 'call_user_func_array(array($this->getCustomPlugin(\''.$func.'\'), \''.$callback[1].'\'), array(array('.$params.'), $this))';
2172 2170
                     } else {
2173
-                        $output = 'call_user_func_array(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(array(' . $params . '), $this))';
2171
+                        $output = 'call_user_func_array(array(\''.$callback[0].'\', \''.$callback[1].'\'), array(array('.$params.'), $this))';
2174 2172
                     }
2175 2173
                 } else {
2176
-                    $output = $callback . '(array(' . $params . '), $this)';
2174
+                    $output = $callback.'(array('.$params.'), $this)';
2177 2175
                 }
2178 2176
             } else {
2179
-                $output = 'smarty_function_' . $func . '(array(' . $params . '), $this)';
2177
+                $output = 'smarty_function_'.$func.'(array('.$params.'), $this)';
2180 2178
             }
2181 2179
         } // Template plugin
2182 2180
         elseif ($pluginType & Core::TEMPLATE_PLUGIN) {
2183 2181
             array_unshift($params, '$this');
2184 2182
             $params                                 = self::implode_r($params);
2185
-            $output                                 = 'Plugin' . Core::toCamelCase($func) .
2186
-                $this->templatePlugins[$func]['uuid'] . '(' . $params . ')';
2183
+            $output                                 = 'Plugin'.Core::toCamelCase($func).
2184
+                $this->templatePlugins[$func]['uuid'].'('.$params.')';
2187 2185
             $this->templatePlugins[$func]['called'] = true;
2188 2186
         }
2189 2187
 
@@ -2215,29 +2213,29 @@  discard block
 block discarded – undo
2215 2213
      */
2216 2214
     protected function parseString($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
2217 2215
     {
2218
-        $substr = substr($in, $from, $to - $from);
2216
+        $substr = substr($in, $from, $to-$from);
2219 2217
         $first  = $substr[0];
2220 2218
 
2221 2219
         if ($this->debug) {
2222
-            echo 'STRING FOUND (in ' . htmlentities(substr($in, $from, min($to - $from, 50))) . (($to - $from) > 50 ? '...' : '') . ')' . "\n";
2220
+            echo 'STRING FOUND (in '.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...' : '').')'."\n";
2223 2221
         }
2224 2222
         $strend = false;
2225
-        $o      = $from + 1;
2223
+        $o      = $from+1;
2226 2224
         while ($strend === false) {
2227 2225
             $strend = strpos($in, $first, $o);
2228 2226
             if ($strend === false) {
2229
-                throw new CompilationException($this, 'Unfinished string, started with ' . substr($in, $from, $to - $from));
2227
+                throw new CompilationException($this, 'Unfinished string, started with '.substr($in, $from, $to-$from));
2230 2228
             }
2231
-            if (substr($in, $strend - 1, 1) === '\\') {
2232
-                $o      = $strend + 1;
2229
+            if (substr($in, $strend-1, 1) === '\\') {
2230
+                $o      = $strend+1;
2233 2231
                 $strend = false;
2234 2232
             }
2235 2233
         }
2236 2234
         if ($this->debug) {
2237
-            echo 'STRING DELIMITED: ' . substr($in, $from, $strend + 1 - $from) . "\n";
2235
+            echo 'STRING DELIMITED: '.substr($in, $from, $strend+1-$from)."\n";
2238 2236
         }
2239 2237
 
2240
-        $srcOutput = substr($in, $from, $strend + 1 - $from);
2238
+        $srcOutput = substr($in, $from, $strend+1-$from);
2241 2239
 
2242 2240
         if ($pointer !== null) {
2243 2241
             $pointer += strlen($srcOutput);
@@ -2246,13 +2244,13 @@  discard block
 block discarded – undo
2246 2244
         $output = $this->replaceStringVars($srcOutput, $first);
2247 2245
 
2248 2246
         // handle modifiers
2249
-        if ($curBlock !== 'modifier' && preg_match('#^((?:\|(?:@?[a-z0-9_]+(?::.*)*))+)#i', substr($substr, $strend + 1 - $from), $match)) {
2247
+        if ($curBlock !== 'modifier' && preg_match('#^((?:\|(?:@?[a-z0-9_]+(?::.*)*))+)#i', substr($substr, $strend+1-$from), $match)) {
2250 2248
             $modstr = $match[1];
2251 2249
 
2252 2250
             if ($curBlock === 'root' && substr($modstr, - 1) === '}') {
2253 2251
                 $modstr = substr($modstr, 0, - 1);
2254 2252
             }
2255
-            $modstr = str_replace('\\' . $first, $first, $modstr);
2253
+            $modstr = str_replace('\\'.$first, $first, $modstr);
2256 2254
             $ptr    = 0;
2257 2255
             $output = $this->replaceModifiers(array(null, null, $output, $modstr), 'string', $ptr);
2258 2256
 
@@ -2260,7 +2258,7 @@  discard block
 block discarded – undo
2260 2258
             if ($pointer !== null) {
2261 2259
                 $pointer += $ptr;
2262 2260
             }
2263
-            $srcOutput .= substr($substr, $strend + 1 - $from, $ptr);
2261
+            $srcOutput .= substr($substr, $strend+1-$from, $ptr);
2264 2262
         }
2265 2263
 
2266 2264
         if (is_array($parsingParams)) {
@@ -2291,10 +2289,10 @@  discard block
 block discarded – undo
2291 2289
      */
2292 2290
     protected function parseConst($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
2293 2291
     {
2294
-        $substr = substr($in, $from, $to - $from);
2292
+        $substr = substr($in, $from, $to-$from);
2295 2293
 
2296 2294
         if ($this->debug) {
2297
-            echo 'CONST FOUND : ' . $substr . "\n";
2295
+            echo 'CONST FOUND : '.$substr."\n";
2298 2296
         }
2299 2297
 
2300 2298
         if (!preg_match('#^%([\\\\a-z0-9_:]+)#i', $substr, $m)) {
@@ -2335,7 +2333,7 @@  discard block
 block discarded – undo
2335 2333
         }
2336 2334
 
2337 2335
         if ($curBlock !== 'root') {
2338
-            return '(defined("' . $key . '") ? ' . $key . ' : null)';
2336
+            return '(defined("'.$key.'") ? '.$key.' : null)';
2339 2337
         }
2340 2338
 
2341 2339
         return $key;
@@ -2358,7 +2356,7 @@  discard block
 block discarded – undo
2358 2356
      */
2359 2357
     protected function parseVar($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
2360 2358
     {
2361
-        $substr = substr($in, $from, $to - $from);
2359
+        $substr = substr($in, $from, $to-$from);
2362 2360
 
2363 2361
         // var key
2364 2362
         $varRegex = '(\\$?\\.?[a-z0-9\\\\_:]*(?:(?:(?:\\.|->)(?:[a-z0-9\\\\_:]+|(?R))|\\[(?:[a-z0-9\\\\_:]+|(?R)|(["\'])[^\\2]*?\\2)\\]))*)';
@@ -2386,13 +2384,13 @@  discard block
 block discarded – undo
2386 2384
 
2387 2385
             if (substr($key, - 1) == '.') {
2388 2386
                 $key = substr($key, 0, - 1);
2389
-                -- $matchedLength;
2387
+                --$matchedLength;
2390 2388
             }
2391 2389
 
2392 2390
             if ($hasMethodCall) {
2393
-                $matchedLength -= strlen($match[3]) + strlen(substr($match[1], strrpos($match[1], '->')));
2394
-                $key        = substr($match[1], 1, strrpos($match[1], '->') - 1);
2395
-                $methodCall = substr($match[1], strrpos($match[1], '->')) . $match[3];
2391
+                $matchedLength -= strlen($match[3])+strlen(substr($match[1], strrpos($match[1], '->')));
2392
+                $key        = substr($match[1], 1, strrpos($match[1], '->')-1);
2393
+                $methodCall = substr($match[1], strrpos($match[1], '->')).$match[3];
2396 2394
             }
2397 2395
 
2398 2396
             if ($hasModifiers) {
@@ -2408,9 +2406,9 @@  discard block
 block discarded – undo
2408 2406
 
2409 2407
             if ($this->debug) {
2410 2408
                 if ($hasMethodCall) {
2411
-                    echo 'METHOD CALL FOUND : $' . $key . substr($methodCall, 0, 30) . "\n";
2409
+                    echo 'METHOD CALL FOUND : $'.$key.substr($methodCall, 0, 30)."\n";
2412 2410
                 } else {
2413
-                    echo 'VAR FOUND : $' . $key . "\n";
2411
+                    echo 'VAR FOUND : $'.$key."\n";
2414 2412
                 }
2415 2413
             }
2416 2414
 
@@ -2421,7 +2419,7 @@  discard block
 block discarded – undo
2421 2419
                 $uid           = 0;
2422 2420
                 $parsed        = array($uid => '');
2423 2421
                 $current       = &$parsed;
2424
-                $curTxt        = &$parsed[$uid ++];
2422
+                $curTxt        = &$parsed[$uid++];
2425 2423
                 $tree          = array();
2426 2424
                 $chars         = str_split($key, 1);
2427 2425
                 $inSplittedVar = false;
@@ -2430,33 +2428,33 @@  discard block
 block discarded – undo
2430 2428
                 while (($char = array_shift($chars)) !== null) {
2431 2429
                     if ($char === '[') {
2432 2430
                         if (count($tree) > 0) {
2433
-                            ++ $bracketCount;
2431
+                            ++$bracketCount;
2434 2432
                         } else {
2435 2433
                             $tree[]        = &$current;
2436
-                            $current[$uid] = array($uid + 1 => '');
2437
-                            $current       = &$current[$uid ++];
2438
-                            $curTxt        = &$current[$uid ++];
2434
+                            $current[$uid] = array($uid+1 => '');
2435
+                            $current       = &$current[$uid++];
2436
+                            $curTxt        = &$current[$uid++];
2439 2437
                             continue;
2440 2438
                         }
2441 2439
                     } elseif ($char === ']') {
2442 2440
                         if ($bracketCount > 0) {
2443
-                            -- $bracketCount;
2441
+                            --$bracketCount;
2444 2442
                         } else {
2445
-                            $current = &$tree[count($tree) - 1];
2443
+                            $current = &$tree[count($tree)-1];
2446 2444
                             array_pop($tree);
2447 2445
                             if (current($chars) !== '[' && current($chars) !== false && current($chars) !== ']') {
2448 2446
                                 $current[$uid] = '';
2449
-                                $curTxt        = &$current[$uid ++];
2447
+                                $curTxt        = &$current[$uid++];
2450 2448
                             }
2451 2449
                             continue;
2452 2450
                         }
2453 2451
                     } elseif ($char === '$') {
2454 2452
                         if (count($tree) == 0) {
2455
-                            $curTxt        = &$current[$uid ++];
2453
+                            $curTxt        = &$current[$uid++];
2456 2454
                             $inSplittedVar = true;
2457 2455
                         }
2458 2456
                     } elseif (($char === '.' || $char === '-') && count($tree) == 0 && $inSplittedVar) {
2459
-                        $curTxt        = &$current[$uid ++];
2457
+                        $curTxt        = &$current[$uid++];
2460 2458
                         $inSplittedVar = false;
2461 2459
                     }
2462 2460
 
@@ -2465,16 +2463,16 @@  discard block
 block discarded – undo
2465 2463
                 unset($uid, $current, $curTxt, $tree, $chars);
2466 2464
 
2467 2465
                 if ($this->debug) {
2468
-                    echo 'RECURSIVE VAR REPLACEMENT : ' . $key . "\n";
2466
+                    echo 'RECURSIVE VAR REPLACEMENT : '.$key."\n";
2469 2467
                 }
2470 2468
 
2471 2469
                 $key = $this->flattenVarTree($parsed);
2472 2470
 
2473 2471
                 if ($this->debug) {
2474
-                    echo 'RECURSIVE VAR REPLACEMENT DONE : ' . $key . "\n";
2472
+                    echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key."\n";
2475 2473
                 }
2476 2474
 
2477
-                $output = preg_replace('#(^""\.|""\.|\.""$|(\()""\.|\.""(\)))#', '$2$3', '$this->readVar("' . $key . '")');
2475
+                $output = preg_replace('#(^""\.|""\.|\.""$|(\()""\.|\.""(\)))#', '$2$3', '$this->readVar("'.$key.'")');
2478 2476
             } else {
2479 2477
                 $output = $this->parseVarKey($key, $hasModifiers ? 'modifier' : $curBlock);
2480 2478
             }
@@ -2499,10 +2497,10 @@  discard block
 block discarded – undo
2499 2497
                     if (substr($expMatch[2][$k], 0, 1) === '=') {
2500 2498
                         $assign = true;
2501 2499
                         if ($operator === '=') {
2502
-                            throw new CompilationException($this, 'Invalid expression <em>' . $substr . '</em>, can not use "==" in expressions');
2500
+                            throw new CompilationException($this, 'Invalid expression <em>'.$substr.'</em>, can not use "==" in expressions');
2503 2501
                         }
2504 2502
                         if ($curBlock !== 'root') {
2505
-                            throw new CompilationException($this, 'Invalid expression <em>' . $substr . '</em>, assignments can only be used in top level expressions like {$foo+=3} or {$foo="bar"}');
2503
+                            throw new CompilationException($this, 'Invalid expression <em>'.$substr.'</em>, assignments can only be used in top level expressions like {$foo+=3} or {$foo="bar"}');
2506 2504
                         }
2507 2505
                         $operator .= '=';
2508 2506
                         $expMatch[2][$k] = substr($expMatch[2][$k], 1);
@@ -2513,22 +2511,22 @@  discard block
 block discarded – undo
2513 2511
                         $expMatch[2][$k] = substr($expMatch[2][$k], 1);
2514 2512
                     }
2515 2513
                     if (($operator === '+' || $operator === '-') && $expMatch[2][$k] === $operator) {
2516
-                        $output = '(' . $output . $operator . $operator . ')';
2514
+                        $output = '('.$output.$operator.$operator.')';
2517 2515
                         break;
2518 2516
                     } elseif (substr($expMatch[2][$k], 0, 1) === '$') {
2519
-                        $output = '(' . $output . ' ' . $operator . ' ' . $this->parseVar($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression') . ')';
2517
+                        $output = '('.$output.' '.$operator.' '.$this->parseVar($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression').')';
2520 2518
                     } elseif (substr($expMatch[2][$k], 0, 1) === '%') {
2521
-                        $output = '(' . $output . ' ' . $operator . ' ' . $this->parseConst($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression') . ')';
2519
+                        $output = '('.$output.' '.$operator.' '.$this->parseConst($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression').')';
2522 2520
                     } elseif (!empty($expMatch[2][$k])) {
2523
-                        $output = '(' . $output . ' ' . $operator . ' ' . str_replace(',', '.', $expMatch[2][$k]) . ')';
2521
+                        $output = '('.$output.' '.$operator.' '.str_replace(',', '.', $expMatch[2][$k]).')';
2524 2522
                     } else {
2525
-                        throw new CompilationException($this, 'Unfinished expression <em>' . $substr . '</em>, missing var or number after math operator');
2523
+                        throw new CompilationException($this, 'Unfinished expression <em>'.$substr.'</em>, missing var or number after math operator');
2526 2524
                     }
2527 2525
                 }
2528 2526
             }
2529 2527
 
2530 2528
             if ($this->autoEscape === true && $curBlock !== 'condition') {
2531
-                $output = '(is_string($tmp=' . $output . ') ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)';
2529
+                $output = '(is_string($tmp='.$output.') ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)';
2532 2530
             }
2533 2531
 
2534 2532
             // handle modifiers
@@ -2552,7 +2550,7 @@  discard block
 block discarded – undo
2552 2550
             } elseif ($curBlock === 'expression' || $curBlock === 'variable') {
2553 2551
                 return $output;
2554 2552
             } elseif (isset($assign)) {
2555
-                return self::PHP_OPEN . $output . ';' . self::PHP_CLOSE;
2553
+                return self::PHP_OPEN.$output.';'.self::PHP_CLOSE;
2556 2554
             }
2557 2555
 
2558 2556
             return $output;
@@ -2560,7 +2558,7 @@  discard block
 block discarded – undo
2560 2558
             if ($curBlock === 'string' || $curBlock === 'delimited_string') {
2561 2559
                 return array(0, '');
2562 2560
             }
2563
-            throw new CompilationException($this, 'Invalid variable name <em>' . $substr . '</em>');
2561
+            throw new CompilationException($this, 'Invalid variable name <em>'.$substr.'</em>');
2564 2562
         }
2565 2563
     }
2566 2564
 
@@ -2614,16 +2612,16 @@  discard block
 block discarded – undo
2614 2612
             if (empty($methMatch[2])) {
2615 2613
                 // property
2616 2614
                 if ($curBlock === 'root') {
2617
-                    $output .= '->' . $methMatch[1];
2615
+                    $output .= '->'.$methMatch[1];
2618 2616
                 } else {
2619
-                    $output = '(($tmp = ' . $output . ') ? $tmp->' . $methMatch[1] . ' : null)';
2617
+                    $output = '(($tmp = '.$output.') ? $tmp->'.$methMatch[1].' : null)';
2620 2618
                 }
2621 2619
                 $ptr += strlen($methMatch[1]);
2622 2620
             } else {
2623 2621
                 // method
2624 2622
                 if (substr($methMatch[2], 0, 2) === '()') {
2625
-                    $parsedCall = $methMatch[1] . '()';
2626
-                    $ptr += strlen($methMatch[1]) + 2;
2623
+                    $parsedCall = $methMatch[1].'()';
2624
+                    $ptr += strlen($methMatch[1])+2;
2627 2625
                 } else {
2628 2626
                     $parsedCall = $this->parseFunction($methodCall, $ptr, strlen($methodCall), false, 'method', $ptr);
2629 2627
                 }
@@ -2632,15 +2630,15 @@  discard block
 block discarded – undo
2632 2630
                     $method = strtolower(substr($parsedCall, 0, $argPos));
2633 2631
                     $args   = substr($parsedCall, $argPos);
2634 2632
                     if ($curBlock === 'root') {
2635
-                        $output = '$this->getSecurityPolicy()->callMethod($this, ' . $output . ', ' . var_export($method, true) . ', array' . $args . ')';
2633
+                        $output = '$this->getSecurityPolicy()->callMethod($this, '.$output.', '.var_export($method, true).', array'.$args.')';
2636 2634
                     } else {
2637
-                        $output = '(($tmp = ' . $output . ') ? $this->getSecurityPolicy()->callMethod($this, $tmp, ' . var_export($method, true) . ', array' . $args . ') : null)';
2635
+                        $output = '(($tmp = '.$output.') ? $this->getSecurityPolicy()->callMethod($this, $tmp, '.var_export($method, true).', array'.$args.') : null)';
2638 2636
                     }
2639 2637
                 } else {
2640 2638
                     if ($curBlock === 'root') {
2641
-                        $output .= '->' . $parsedCall;
2639
+                        $output .= '->'.$parsedCall;
2642 2640
                     } else {
2643
-                        $output = '(($tmp = ' . $output . ') ? $tmp->' . $parsedCall . ' : null)';
2641
+                        $output = '(($tmp = '.$output.') ? $tmp->'.$parsedCall.' : null)';
2644 2642
                     }
2645 2643
                 }
2646 2644
             }
@@ -2666,21 +2664,21 @@  discard block
 block discarded – undo
2666 2664
             return '$this->scope';
2667 2665
         }
2668 2666
         if (substr($key, 0, 1) === '.') {
2669
-            $key = 'dwoo' . $key;
2667
+            $key = 'dwoo'.$key;
2670 2668
         }
2671 2669
         if (preg_match('#dwoo\.(get|post|server|cookies|session|env|request)((?:\.[a-z0-9_-]+)+)#i', $key, $m)) {
2672 2670
             $global = strtoupper($m[1]);
2673 2671
             if ($global === 'COOKIES') {
2674 2672
                 $global = 'COOKIE';
2675 2673
             }
2676
-            $key = '$_' . $global;
2674
+            $key = '$_'.$global;
2677 2675
             foreach (explode('.', ltrim($m[2], '.')) as $part) {
2678
-                $key .= '[' . var_export($part, true) . ']';
2676
+                $key .= '['.var_export($part, true).']';
2679 2677
             }
2680 2678
             if ($curBlock === 'root') {
2681 2679
                 $output = $key;
2682 2680
             } else {
2683
-                $output = '(isset(' . $key . ')?' . $key . ':null)';
2681
+                $output = '(isset('.$key.')?'.$key.':null)';
2684 2682
             }
2685 2683
         } elseif (preg_match('#dwoo\\.const\\.([a-z0-9\\\\_:]+)#i', $key, $m)) {
2686 2684
             return $this->parseConstKey($m[1], $curBlock);
@@ -2696,9 +2694,9 @@  discard block
 block discarded – undo
2696 2694
                     $output = '$tmp_key';
2697 2695
                 } else {
2698 2696
                     if ($curBlock === 'root') {
2699
-                        $output = '$this->scope["' . $key . '"]';
2697
+                        $output = '$this->scope["'.$key.'"]';
2700 2698
                     } else {
2701
-                        $output = '(isset($this->scope["' . $key . '"]) ? $this->scope["' . $key . '"] : null)';
2699
+                        $output = '(isset($this->scope["'.$key.'"]) ? $this->scope["'.$key.'"] : null)';
2702 2700
                     }
2703 2701
                 }
2704 2702
             } else {
@@ -2709,7 +2707,7 @@  discard block
 block discarded – undo
2709 2707
                     $parentCnt = 0;
2710 2708
 
2711 2709
                     while (true) {
2712
-                        ++ $parentCnt;
2710
+                        ++$parentCnt;
2713 2711
                         array_shift($m[2]);
2714 2712
                         array_shift($m[1]);
2715 2713
                         if (current($m[2]) === '_parent') {
@@ -2718,7 +2716,7 @@  discard block
 block discarded – undo
2718 2716
                         break;
2719 2717
                     }
2720 2718
 
2721
-                    $output = '$this->readParentVar(' . $parentCnt . ')';
2719
+                    $output = '$this->readParentVar('.$parentCnt.')';
2722 2720
                 } else {
2723 2721
                     if ($i === 'dwoo') {
2724 2722
                         $output = '$this->globals';
@@ -2737,28 +2735,28 @@  discard block
 block discarded – undo
2737 2735
                     while (count($m[1]) && $m[1][0] !== '->') {
2738 2736
                         $m[2][0] = preg_replace('/(^\\\([\'"])|\\\([\'"])$)/x', '$2$3', $m[2][0]);
2739 2737
                         if (substr($m[2][0], 0, 1) == '"' || substr($m[2][0], 0, 1) == "'") {
2740
-                            $output .= '[' . $m[2][0] . ']';
2738
+                            $output .= '['.$m[2][0].']';
2741 2739
                         } else {
2742
-                            $output .= '["' . $m[2][0] . '"]';
2740
+                            $output .= '["'.$m[2][0].'"]';
2743 2741
                         }
2744 2742
                         array_shift($m[2]);
2745 2743
                         array_shift($m[1]);
2746 2744
                     }
2747 2745
 
2748 2746
                     if ($curBlock !== 'root') {
2749
-                        $output = '(isset(' . $output . ') ? ' . $output . ':null)';
2747
+                        $output = '(isset('.$output.') ? '.$output.':null)';
2750 2748
                     }
2751 2749
                 }
2752 2750
 
2753 2751
                 if (count($m[2])) {
2754 2752
                     unset($m[0]);
2755
-                    $output = '$this->readVarInto(' . str_replace("\n", '', var_export($m, true)) . ', ' . $output . ', ' . ($curBlock == 'root' ? 'false' : 'true') . ')';
2753
+                    $output = '$this->readVarInto('.str_replace("\n", '', var_export($m, true)).', '.$output.', '.($curBlock == 'root' ? 'false' : 'true').')';
2756 2754
                 }
2757 2755
             }
2758 2756
         } else {
2759 2757
             preg_match_all('#(\[|->|\.)?((?:[a-z0-9_]|-(?!>))+)\]?#i', $key, $m);
2760 2758
             unset($m[0]);
2761
-            $output = '$this->readVar(' . str_replace("\n", '', var_export($m, true)) . ')';
2759
+            $output = '$this->readVar('.str_replace("\n", '', var_export($m, true)).')';
2762 2760
         }
2763 2761
 
2764 2762
         return $output;
@@ -2778,38 +2776,38 @@  discard block
 block discarded – undo
2778 2776
         $out = $recursed ? '".$this->readVarInto(' : '';
2779 2777
         foreach ($tree as $bit) {
2780 2778
             if (is_array($bit)) {
2781
-                $out .= '.' . $this->flattenVarTree($bit, false);
2779
+                $out .= '.'.$this->flattenVarTree($bit, false);
2782 2780
             } else {
2783 2781
                 $key = str_replace('"', '\\"', $bit);
2784 2782
 
2785 2783
                 if (substr($key, 0, 1) === '$') {
2786
-                    $out .= '".' . $this->parseVar($key, 0, strlen($key), false, 'variable') . '."';
2784
+                    $out .= '".'.$this->parseVar($key, 0, strlen($key), false, 'variable').'."';
2787 2785
                 } else {
2788 2786
                     $cnt = substr_count($key, '$');
2789 2787
 
2790 2788
                     if ($this->debug) {
2791
-                        echo 'PARSING SUBVARS IN : ' . $key . "\n";
2789
+                        echo 'PARSING SUBVARS IN : '.$key."\n";
2792 2790
                     }
2793 2791
                     if ($cnt > 0) {
2794
-                        while (-- $cnt >= 0) {
2792
+                        while (--$cnt >= 0) {
2795 2793
                             if (isset($last)) {
2796
-                                $last = strrpos($key, '$', - (strlen($key) - $last + 1));
2794
+                                $last = strrpos($key, '$', - (strlen($key)-$last+1));
2797 2795
                             } else {
2798 2796
                                 $last = strrpos($key, '$');
2799 2797
                             }
2800
-                            preg_match('#\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*' . '((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', substr($key, $last), $submatch);
2798
+                            preg_match('#\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*'.'((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', substr($key, $last), $submatch);
2801 2799
 
2802 2800
                             $len = strlen($submatch[0]);
2803 2801
                             $key = substr_replace(
2804 2802
                                 $key, preg_replace_callback(
2805
-                                    '#(\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*)' . '((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', array(
2803
+                                    '#(\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*)'.'((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', array(
2806 2804
                                         $this,
2807 2805
                                         'replaceVarKeyHelper'
2808 2806
                                     ), substr($key, $last, $len)
2809 2807
                                 ), $last, $len
2810 2808
                             );
2811 2809
                             if ($this->debug) {
2812
-                                echo 'RECURSIVE VAR REPLACEMENT DONE : ' . $key . "\n";
2810
+                                echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key."\n";
2813 2811
                             }
2814 2812
                         }
2815 2813
                         unset($last);
@@ -2835,7 +2833,7 @@  discard block
 block discarded – undo
2835 2833
      */
2836 2834
     protected function replaceVarKeyHelper($match)
2837 2835
     {
2838
-        return '".' . $this->parseVar($match[0], 0, strlen($match[0]), false, 'variable') . '."';
2836
+        return '".'.$this->parseVar($match[0], 0, strlen($match[0]), false, 'variable').'."';
2839 2837
     }
2840 2838
 
2841 2839
     /**
@@ -2855,7 +2853,7 @@  discard block
 block discarded – undo
2855 2853
      */
2856 2854
     protected function parseOthers($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
2857 2855
     {
2858
-        $substr = substr($in, $from, $to - $from);
2856
+        $substr = substr($in, $from, $to-$from);
2859 2857
 
2860 2858
         $end = strlen($substr);
2861 2859
 
@@ -2929,48 +2927,48 @@  discard block
 block discarded – undo
2929 2927
 
2930 2928
         if (strtolower($substr) === 'false' || strtolower($substr) === 'no' || strtolower($substr) === 'off') {
2931 2929
             if ($this->debug) {
2932
-                echo 'BOOLEAN(FALSE) PARSED' . "\n";
2930
+                echo 'BOOLEAN(FALSE) PARSED'."\n";
2933 2931
             }
2934 2932
             $substr = 'false';
2935 2933
             $type   = self::T_BOOL;
2936 2934
         } elseif (strtolower($substr) === 'true' || strtolower($substr) === 'yes' || strtolower($substr) === 'on') {
2937 2935
             if ($this->debug) {
2938
-                echo 'BOOLEAN(TRUE) PARSED' . "\n";
2936
+                echo 'BOOLEAN(TRUE) PARSED'."\n";
2939 2937
             }
2940 2938
             $substr = 'true';
2941 2939
             $type   = self::T_BOOL;
2942 2940
         } elseif ($substr === 'null' || $substr === 'NULL') {
2943 2941
             if ($this->debug) {
2944
-                echo 'NULL PARSED' . "\n";
2942
+                echo 'NULL PARSED'."\n";
2945 2943
             }
2946 2944
             $substr = 'null';
2947 2945
             $type   = self::T_NULL;
2948 2946
         } elseif (is_numeric($substr)) {
2949
-            $substr = (float)$substr;
2950
-            if ((int)$substr == $substr) {
2951
-                $substr = (int)$substr;
2947
+            $substr = (float) $substr;
2948
+            if ((int) $substr == $substr) {
2949
+                $substr = (int) $substr;
2952 2950
             }
2953 2951
             $type = self::T_NUMERIC;
2954 2952
             if ($this->debug) {
2955
-                echo 'NUMBER (' . $substr . ') PARSED' . "\n";
2953
+                echo 'NUMBER ('.$substr.') PARSED'."\n";
2956 2954
             }
2957 2955
         } elseif (preg_match('{^-?(\d+|\d*(\.\d+))\s*([/*%+-]\s*-?(\d+|\d*(\.\d+)))+$}', $substr)) {
2958 2956
             if ($this->debug) {
2959 2957
                 echo 'SIMPLE MATH PARSED . "\n"';
2960 2958
             }
2961 2959
             $type   = self::T_MATH;
2962
-            $substr = '(' . $substr . ')';
2960
+            $substr = '('.$substr.')';
2963 2961
         } elseif ($curBlock === 'condition' && array_search($substr, $breakChars, true) !== false) {
2964 2962
             if ($this->debug) {
2965
-                echo 'BREAKCHAR (' . $substr . ') PARSED' . "\n";
2963
+                echo 'BREAKCHAR ('.$substr.') PARSED'."\n";
2966 2964
             }
2967 2965
             $type = self::T_BREAKCHAR;
2968 2966
             //$substr = '"'.$substr.'"';
2969 2967
         } else {
2970
-            $substr = $this->replaceStringVars('\'' . str_replace('\'', '\\\'', $substr) . '\'', '\'', $curBlock);
2968
+            $substr = $this->replaceStringVars('\''.str_replace('\'', '\\\'', $substr).'\'', '\'', $curBlock);
2971 2969
             $type   = self::T_UNQUOTED_STRING;
2972 2970
             if ($this->debug) {
2973
-                echo 'BLABBER (' . $substr . ') CASTED AS STRING' . "\n";
2971
+                echo 'BLABBER ('.$substr.') CASTED AS STRING'."\n";
2974 2972
             }
2975 2973
         }
2976 2974
 
@@ -3000,28 +2998,28 @@  discard block
 block discarded – undo
3000 2998
     {
3001 2999
         $pos = 0;
3002 3000
         if ($this->debug) {
3003
-            echo 'STRING VAR REPLACEMENT : ' . $string . "\n";
3001
+            echo 'STRING VAR REPLACEMENT : '.$string."\n";
3004 3002
         }
3005 3003
         // replace vars
3006 3004
         while (($pos = strpos($string, '$', $pos)) !== false) {
3007
-            $prev = substr($string, $pos - 1, 1);
3005
+            $prev = substr($string, $pos-1, 1);
3008 3006
             if ($prev === '\\') {
3009
-                ++ $pos;
3007
+                ++$pos;
3010 3008
                 continue;
3011 3009
             }
3012 3010
 
3013 3011
             $var = $this->parse($string, $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string')));
3014 3012
             $len = $var[0];
3015
-            $var = $this->parse(str_replace('\\' . $first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string')));
3013
+            $var = $this->parse(str_replace('\\'.$first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string')));
3016 3014
 
3017
-            if ($prev === '`' && substr($string, $pos + $len, 1) === '`') {
3018
-                $string = substr_replace($string, $first . '.' . $var[1] . '.' . $first, $pos - 1, $len + 2);
3015
+            if ($prev === '`' && substr($string, $pos+$len, 1) === '`') {
3016
+                $string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos-1, $len+2);
3019 3017
             } else {
3020
-                $string = substr_replace($string, $first . '.' . $var[1] . '.' . $first, $pos, $len);
3018
+                $string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos, $len);
3021 3019
             }
3022
-            $pos += strlen($var[1]) + 2;
3020
+            $pos += strlen($var[1])+2;
3023 3021
             if ($this->debug) {
3024
-                echo 'STRING VAR REPLACEMENT DONE : ' . $string . "\n";
3022
+                echo 'STRING VAR REPLACEMENT DONE : '.$string."\n";
3025 3023
             }
3026 3024
         }
3027 3025
 
@@ -3057,7 +3055,7 @@  discard block
 block discarded – undo
3057 3055
     protected function replaceModifiers(array $m, $curBlock = null, &$pointer = null)
3058 3056
     {
3059 3057
         if ($this->debug) {
3060
-            echo 'PARSING MODIFIERS : ' . $m[3] . "\n";
3058
+            echo 'PARSING MODIFIERS : '.$m[3]."\n";
3061 3059
         }
3062 3060
 
3063 3061
         if ($pointer !== null) {
@@ -3081,7 +3079,7 @@  discard block
 block discarded – undo
3081 3079
             }
3082 3080
             if ($cmdstrsrc[0] === ' ' || $cmdstrsrc[0] === ';' || substr($cmdstrsrc, 0, strlen($this->rd)) === $this->rd) {
3083 3081
                 if ($this->debug) {
3084
-                    echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND' . "\n";
3082
+                    echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND'."\n";
3085 3083
                 }
3086 3084
                 $continue = false;
3087 3085
                 if ($pointer !== null) {
@@ -3092,7 +3090,7 @@  discard block
 block discarded – undo
3092 3090
             $cmdstr   = $cmdstrsrc;
3093 3091
             $paramsep = ':';
3094 3092
             if (!preg_match('/^(@{0,2}[a-z_][a-z0-9_]*)(:)?/i', $cmdstr, $match)) {
3095
-                throw new CompilationException($this, 'Invalid modifier name, started with : ' . substr($cmdstr, 0, 10));
3093
+                throw new CompilationException($this, 'Invalid modifier name, started with : '.substr($cmdstr, 0, 10));
3096 3094
             }
3097 3095
             $paramspos = !empty($match[2]) ? strlen($match[1]) : false;
3098 3096
             $func      = $match[1];
@@ -3102,10 +3100,10 @@  discard block
 block discarded – undo
3102 3100
                 $cmdstrsrc = substr($cmdstrsrc, strlen($func));
3103 3101
                 $params    = array();
3104 3102
                 if ($this->debug) {
3105
-                    echo 'MODIFIER (' . $func . ') CALLED WITH NO PARAMS' . "\n";
3103
+                    echo 'MODIFIER ('.$func.') CALLED WITH NO PARAMS'."\n";
3106 3104
                 }
3107 3105
             } else {
3108
-                $paramstr = substr($cmdstr, $paramspos + 1);
3106
+                $paramstr = substr($cmdstr, $paramspos+1);
3109 3107
                 if (substr($paramstr, - 1, 1) === $paramsep) {
3110 3108
                     $paramstr = substr($paramstr, 0, - 1);
3111 3109
                 }
@@ -3114,41 +3112,41 @@  discard block
 block discarded – undo
3114 3112
                 $params = array();
3115 3113
                 while ($ptr < strlen($paramstr)) {
3116 3114
                     if ($this->debug) {
3117
-                        echo 'MODIFIER (' . $func . ') START PARAM PARSING WITH POINTER AT ' . $ptr . "\n";
3115
+                        echo 'MODIFIER ('.$func.') START PARAM PARSING WITH POINTER AT '.$ptr."\n";
3118 3116
                     }
3119 3117
                     if ($this->debug) {
3120
-                        echo $paramstr . '--' . $ptr . '--' . strlen($paramstr) . '--modifier' . "\n";
3118
+                        echo $paramstr.'--'.$ptr.'--'.strlen($paramstr).'--modifier'."\n";
3121 3119
                     }
3122 3120
                     $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'modifier', $ptr);
3123 3121
                     if ($this->debug) {
3124
-                        echo 'PARAM PARSED, POINTER AT ' . $ptr . "\n";
3122
+                        echo 'PARAM PARSED, POINTER AT '.$ptr."\n";
3125 3123
                     }
3126 3124
 
3127 3125
                     if ($ptr >= strlen($paramstr)) {
3128 3126
                         if ($this->debug) {
3129
-                            echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED' . "\n";
3127
+                            echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED'."\n";
3130 3128
                         }
3131 3129
                         break;
3132 3130
                     }
3133 3131
 
3134 3132
                     if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === '|' || $paramstr[$ptr] === ';' || substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) {
3135 3133
                         if ($this->debug) {
3136
-                            echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT ' . $ptr . "\n";
3134
+                            echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT '.$ptr."\n";
3137 3135
                         }
3138 3136
                         if ($paramstr[$ptr] !== '|') {
3139 3137
                             $continue = false;
3140 3138
                             if ($pointer !== null) {
3141
-                                $pointer -= strlen($paramstr) - $ptr;
3139
+                                $pointer -= strlen($paramstr)-$ptr;
3142 3140
                             }
3143 3141
                         }
3144
-                        ++ $ptr;
3142
+                        ++$ptr;
3145 3143
                         break;
3146 3144
                     }
3147 3145
                     if ($ptr < strlen($paramstr) && $paramstr[$ptr] === ':') {
3148
-                        ++ $ptr;
3146
+                        ++$ptr;
3149 3147
                     }
3150 3148
                 }
3151
-                $cmdstrsrc = substr($cmdstrsrc, strlen($func) + 1 + $ptr);
3149
+                $cmdstrsrc = substr($cmdstrsrc, strlen($func)+1+$ptr);
3152 3150
                 foreach ($params as $k => $p) {
3153 3151
                     if (is_array($p) && is_array($p[1])) {
3154 3152
                         $state |= 2;
@@ -3188,9 +3186,9 @@  discard block
 block discarded – undo
3188 3186
                 $params = self::implode_r($params);
3189 3187
 
3190 3188
                 if ($mapped) {
3191
-                    $output = '$this->arrayMap(\'' . $func . '\', array(' . $params . '))';
3189
+                    $output = '$this->arrayMap(\''.$func.'\', array('.$params.'))';
3192 3190
                 } else {
3193
-                    $output = $func . '(' . $params . ')';
3191
+                    $output = $func.'('.$params.')';
3194 3192
                 }
3195 3193
             } elseif ($pluginType & Core::PROXY_PLUGIN) {
3196 3194
                 $params = $this->mapParams($params, $this->getCore()->getPluginProxy()->getCallback($func), $state);
@@ -3208,19 +3206,19 @@  discard block
 block discarded – undo
3208 3206
                     $callback = $this->customPlugins[$func]['callback'];
3209 3207
                     if (is_array($callback)) {
3210 3208
                         if (is_object($callback[0])) {
3211
-                            $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(' . $params . '))';
3209
+                            $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array($this->getCustomPlugin(\''.$func.'\'), \''.$callback[1].'\'), array('.$params.'))';
3212 3210
                         } else {
3213
-                            $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(' . $params . '))';
3211
+                            $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array(\''.$callback[0].'\', \''.$callback[1].'\'), array('.$params.'))';
3214 3212
                         }
3215 3213
                     } elseif ($mapped) {
3216
-                        $output = '$this->arrayMap(\'' . $callback . '\', array(' . $params . '))';
3214
+                        $output = '$this->arrayMap(\''.$callback.'\', array('.$params.'))';
3217 3215
                     } else {
3218
-                        $output = $callback . '(' . $params . ')';
3216
+                        $output = $callback.'('.$params.')';
3219 3217
                     }
3220 3218
                 } elseif ($mapped) {
3221
-                    $output = '$this->arrayMap(\'smarty_modifier_' . $func . '\', array(' . $params . '))';
3219
+                    $output = '$this->arrayMap(\'smarty_modifier_'.$func.'\', array('.$params.'))';
3222 3220
                 } else {
3223
-                    $output = 'smarty_modifier_' . $func . '(' . $params . ')';
3221
+                    $output = 'smarty_modifier_'.$func.'('.$params.')';
3224 3222
                 }
3225 3223
             } else {
3226 3224
                 if ($pluginType & Core::CUSTOM_PLUGIN) {
@@ -3230,17 +3228,17 @@  discard block
 block discarded – undo
3230 3228
                         $callback   = array($pluginName, ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process');
3231 3229
                     }
3232 3230
                 } else {
3233
-                    if (class_exists('Plugin' . Core::toCamelCase($func)) !== false || function_exists('Plugin' .
3234
-                            Core::toCamelCase($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''))
3231
+                    if (class_exists('Plugin'.Core::toCamelCase($func)) !== false || function_exists('Plugin'.
3232
+                            Core::toCamelCase($func).(($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''))
3235 3233
                         !== false) {
3236
-                        $pluginName = 'Plugin' . Core::toCamelCase($func);
3234
+                        $pluginName = 'Plugin'.Core::toCamelCase($func);
3237 3235
                     } else {
3238
-                        $pluginName = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func);
3236
+                        $pluginName = Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func);
3239 3237
                     }
3240 3238
                     if ($pluginType & Core::CLASS_PLUGIN) {
3241 3239
                         $callback = array($pluginName, ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process');
3242 3240
                     } else {
3243
-                        $callback = $pluginName . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : '');
3241
+                        $callback = $pluginName.(($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : '');
3244 3242
                     }
3245 3243
                 }
3246 3244
                 $params = $this->mapParams($params, $callback, $state);
@@ -3258,10 +3256,10 @@  discard block
 block discarded – undo
3258 3256
                         if ($pluginType & Core::CUSTOM_PLUGIN) {
3259 3257
                             $funcCompiler = $this->customPlugins[$func]['callback'];
3260 3258
                         } else {
3261
-                            if (function_exists('Plugin' . Core::toCamelCase($func) . 'Compile') !== false) {
3262
-                                $funcCompiler = 'Plugin' . Core::toCamelCase($func) . 'Compile';
3259
+                            if (function_exists('Plugin'.Core::toCamelCase($func).'Compile') !== false) {
3260
+                                $funcCompiler = 'Plugin'.Core::toCamelCase($func).'Compile';
3263 3261
                             } else {
3264
-                                $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) .
3262
+                                $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func).
3265 3263
                                     'Compile';
3266 3264
                             }
3267 3265
                         }
@@ -3272,9 +3270,9 @@  discard block
 block discarded – undo
3272 3270
 
3273 3271
                         $params = self::implode_r($params);
3274 3272
                         if ($mapped) {
3275
-                            $output = '$this->arrayMap(\'' . $pluginName . '\', array(' . $params . '))';
3273
+                            $output = '$this->arrayMap(\''.$pluginName.'\', array('.$params.'))';
3276 3274
                         } else {
3277
-                            $output = $pluginName . '(' . $params . ')';
3275
+                            $output = $pluginName.'('.$params.')';
3278 3276
                         }
3279 3277
                     }
3280 3278
                 } else {
@@ -3286,7 +3284,7 @@  discard block
 block discarded – undo
3286 3284
                             $callback = $this->customPlugins[$func]['callback'];
3287 3285
                             if (!is_array($callback)) {
3288 3286
                                 if (!method_exists($callback, 'compile')) {
3289
-                                    throw new Exception('Custom plugin ' . $func . ' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use');
3287
+                                    throw new Exception('Custom plugin '.$func.' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use');
3290 3288
                                 }
3291 3289
                                 if (($ref = new ReflectionMethod($callback, 'compile')) && $ref->isStatic()) {
3292 3290
                                     $funcCompiler = array($callback, 'compile');
@@ -3297,10 +3295,10 @@  discard block
 block discarded – undo
3297 3295
                                 $funcCompiler = $callback;
3298 3296
                             }
3299 3297
                         } else {
3300
-                            if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) {
3301
-                                $funcCompiler = array('Plugin' . Core::toCamelCase($func), 'compile');
3298
+                            if (class_exists('Plugin'.Core::toCamelCase($func)) !== false) {
3299
+                                $funcCompiler = array('Plugin'.Core::toCamelCase($func), 'compile');
3302 3300
                             } else {
3303
-                                $funcCompiler = array(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func), 'compile');
3301
+                                $funcCompiler = array(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func), 'compile');
3304 3302
                             }
3305 3303
                             array_unshift($params, $this);
3306 3304
                         }
@@ -3311,26 +3309,26 @@  discard block
 block discarded – undo
3311 3309
                         if ($pluginType & Core::CUSTOM_PLUGIN) {
3312 3310
                             if (is_object($callback[0])) {
3313 3311
                                 if (is_array($this->getCore()->getCustomPlugin($func))) {
3314
-                                    $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->plugins[\'' . $func . '\'][\'callback\'][0], \'' . $callback[1] . '\'), array(' . $params . '))';
3312
+                                    $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array($this->plugins[\''.$func.'\'][\'callback\'][0], \''.$callback[1].'\'), array('.$params.'))';
3315 3313
                                 } else {
3316
-                                    $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(' . $params . '))';
3314
+                                    $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array($this->getCustomPlugin(\''.$func.'\'), \''.$callback[1].'\'), array('.$params.'))';
3317 3315
                                 }
3318 3316
                             } else {
3319
-                                $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(' . $params . '))';
3317
+                                $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array(\''.$callback[0].'\', \''.$callback[1].'\'), array('.$params.'))';
3320 3318
                             }
3321 3319
                         } elseif ($mapped) {
3322 3320
                             $output = '$this->arrayMap(array($this->getObjectPlugin(\''.
3323
-                                Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . '\'),
3324
-                            \'process\'), array(' . $params . '))';
3321
+                                Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func).'\'),
3322
+                            \'process\'), array(' . $params.'))';
3325 3323
                         } else {
3326
-                            if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) {
3327
-                                $output = '$this->classCall(\'Plugin' . Core::toCamelCase($func) . '\', array(' . $params . '))';
3328
-                            } elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($func)) !== false) {
3329
-                                $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . $func . '\', array(' . $params . '))';
3330
-                            } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func)) !== false) {
3331
-                                $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . $func . '\', array(' . $params . '))';
3324
+                            if (class_exists('Plugin'.Core::toCamelCase($func)) !== false) {
3325
+                                $output = '$this->classCall(\'Plugin'.Core::toCamelCase($func).'\', array('.$params.'))';
3326
+                            } elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($func)) !== false) {
3327
+                                $output = '$this->classCall(\''.Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.$func.'\', array('.$params.'))';
3328
+                            } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($func)) !== false) {
3329
+                                $output = '$this->classCall(\''.Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.$func.'\', array('.$params.'))';
3332 3330
                             } else {
3333
-                                $output = '$this->classCall(\'' . $func . '\', array(' . $params . '))';
3331
+                                $output = '$this->classCall(\''.$func.'\', array('.$params.'))';
3334 3332
                             }
3335 3333
                         }
3336 3334
                     }
@@ -3343,7 +3341,7 @@  discard block
 block discarded – undo
3343 3341
         } elseif ($curBlock === 'var' || $m[1] === null) {
3344 3342
             return $output;
3345 3343
         } elseif ($curBlock === 'string' || $curBlock === 'root') {
3346
-            return $m[1] . '.' . $output . '.' . $m[1] . (isset($add) ? $add : null);
3344
+            return $m[1].'.'.$output.'.'.$m[1].(isset($add) ? $add : null);
3347 3345
         }
3348 3346
 
3349 3347
         return '';
@@ -3366,14 +3364,14 @@  discard block
 block discarded – undo
3366 3364
             if (is_array($p)) {
3367 3365
                 $out2 = 'array(';
3368 3366
                 foreach ($p as $k2 => $v) {
3369
-                    $out2 .= var_export($k2, true) . ' => ' . (is_array($v) ? 'array(' . self::implode_r($v, true) . ')' : $v) . ', ';
3367
+                    $out2 .= var_export($k2, true).' => '.(is_array($v) ? 'array('.self::implode_r($v, true).')' : $v).', ';
3370 3368
                 }
3371
-                $p = rtrim($out2, ', ') . ')';
3369
+                $p = rtrim($out2, ', ').')';
3372 3370
             }
3373 3371
             if ($recursiveCall) {
3374
-                $out .= var_export($k, true) . ' => ' . $p . ', ';
3372
+                $out .= var_export($k, true).' => '.$p.', ';
3375 3373
             } else {
3376
-                $out .= $p . ', ';
3374
+                $out .= $p.', ';
3377 3375
             }
3378 3376
         }
3379 3377
 
@@ -3397,7 +3395,7 @@  discard block
 block discarded – undo
3397 3395
         if (($this->securityPolicy === null && (function_exists($name) || strtolower($name) === 'isset' || strtolower($name) === 'empty')) || ($this->securityPolicy !== null && array_key_exists(strtolower($name), $this->securityPolicy->getAllowedPhpFunctions()) !== false)) {
3398 3396
             $phpFunc = true;
3399 3397
         } elseif ($this->securityPolicy !== null && function_exists($name) && array_key_exists(strtolower($name), $this->securityPolicy->getAllowedPhpFunctions()) === false) {
3400
-            throw new SecurityException('Call to a disallowed php function : ' . $name);
3398
+            throw new SecurityException('Call to a disallowed php function : '.$name);
3401 3399
         }
3402 3400
 
3403 3401
         while ($pluginType <= 0) {
@@ -3408,61 +3406,61 @@  discard block
 block discarded – undo
3408 3406
             elseif (isset($this->customPlugins[$name])) {
3409 3407
                 $pluginType = $this->customPlugins[$name]['type'] | Core::CUSTOM_PLUGIN;
3410 3408
             } // Class blocks plugin
3411
-            elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name)) !== false) {
3409
+            elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($name)) !== false) {
3412 3410
                 $pluginType = Core::CLASS_PLUGIN;
3413
-                if (is_subclass_of(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name), 'Dwoo\Block\Plugin')) {
3411
+                if (is_subclass_of(Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($name), 'Dwoo\Block\Plugin')) {
3414 3412
                     $pluginType += Core::BLOCK_PLUGIN;
3415 3413
                 }
3416
-                $interfaces = class_implements(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name));
3414
+                $interfaces = class_implements(Core::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.Core::toCamelCase($name));
3417 3415
                 if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) {
3418 3416
                     $pluginType |= Core::COMPILABLE_PLUGIN;
3419 3417
                 }
3420 3418
             } // Class functions plugin
3421
-            elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name)) !== false) {
3422
-                $pluginType = Core::FUNC_PLUGIN + Core::CLASS_PLUGIN;
3423
-                $interfaces = class_implements(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name));
3419
+            elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($name)) !== false) {
3420
+                $pluginType = Core::FUNC_PLUGIN+Core::CLASS_PLUGIN;
3421
+                $interfaces = class_implements(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($name));
3424 3422
                 if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) {
3425 3423
                     $pluginType |= Core::COMPILABLE_PLUGIN;
3426 3424
                 }
3427 3425
             } // Class without namespace
3428
-            elseif (class_exists('Plugin' . Core::toCamelCase($name)) !== false) {
3426
+            elseif (class_exists('Plugin'.Core::toCamelCase($name)) !== false) {
3429 3427
                 $pluginType = Core::CLASS_PLUGIN;
3430
-                if (is_subclass_of('Plugin' . Core::toCamelCase($name), 'Dwoo\Block\Plugin')) {
3428
+                if (is_subclass_of('Plugin'.Core::toCamelCase($name), 'Dwoo\Block\Plugin')) {
3431 3429
                     $pluginType += Core::BLOCK_PLUGIN;
3432 3430
                 }
3433
-                $interfaces = class_implements('Plugin' . Core::toCamelCase($name));
3431
+                $interfaces = class_implements('Plugin'.Core::toCamelCase($name));
3434 3432
                 if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) {
3435 3433
                     $pluginType |= Core::COMPILABLE_PLUGIN;
3436 3434
                 }
3437 3435
             } // Function plugin (with/without namespaces)
3438
-            elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase ($name)) !==
3439
-                false || function_exists('Plugin' . Core::toCamelCase($name)) !== false) {
3436
+            elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($name)) !==
3437
+                false || function_exists('Plugin'.Core::toCamelCase($name)) !== false) {
3440 3438
                 $pluginType = Core::FUNC_PLUGIN;
3441 3439
             } // Function plugin compile (with/without namespaces)
3442
-            elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name) .
3443
-                    'Compile') !== false || function_exists('Plugin' . Core::toCamelCase($name) . 'Compile') !==
3440
+            elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin'.Core::toCamelCase($name).
3441
+                    'Compile') !== false || function_exists('Plugin'.Core::toCamelCase($name).'Compile') !==
3444 3442
                 false) {
3445 3443
                 $pluginType = Core::FUNC_PLUGIN | Core::COMPILABLE_PLUGIN;
3446 3444
             } // Helper plugin class compile
3447
-            elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($name)) !== false) {
3445
+            elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($name)) !== false) {
3448 3446
                 $pluginType = Core::CLASS_PLUGIN | Core::COMPILABLE_PLUGIN;
3449 3447
             } // Helper plugin function compile
3450
-            elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($name) . 'Compile') !== false) {
3448
+            elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS.'Plugin'.Core::toCamelCase($name).'Compile') !== false) {
3451 3449
                 $pluginType = Core::FUNC_PLUGIN | Core::COMPILABLE_PLUGIN;
3452 3450
             } // Smarty modifier
3453
-            elseif (function_exists('smarty_modifier_' . $name) !== false) {
3451
+            elseif (function_exists('smarty_modifier_'.$name) !== false) {
3454 3452
                 $pluginType = Core::SMARTY_MODIFIER;
3455 3453
             } // Smarty function
3456
-            elseif (function_exists('smarty_function_' . $name) !== false) {
3454
+            elseif (function_exists('smarty_function_'.$name) !== false) {
3457 3455
                 $pluginType = Core::SMARTY_FUNCTION;
3458 3456
             } // Smarty block
3459
-            elseif (function_exists('smarty_block_' . $name) !== false) {
3457
+            elseif (function_exists('smarty_block_'.$name) !== false) {
3460 3458
                 $pluginType = Core::SMARTY_BLOCK;
3461 3459
             } // Everything else
3462 3460
             else {
3463 3461
                 if ($pluginType === - 1) {
3464 3462
                     try {
3465
-                        $this->getCore()->getLoader()->loadPlugin('Plugin' . Core::toCamelCase($name));
3463
+                        $this->getCore()->getLoader()->loadPlugin('Plugin'.Core::toCamelCase($name));
3466 3464
                     }
3467 3465
                     catch (Exception $e) {
3468 3466
                         if (isset($phpFunc)) {
@@ -3475,9 +3473,9 @@  discard block
 block discarded – undo
3475 3473
                         }
3476 3474
                     }
3477 3475
                 } else {
3478
-                    throw new Exception('Plugin "' . $name . '" could not be found, type:' . $pluginType);
3476
+                    throw new Exception('Plugin "'.$name.'" could not be found, type:'.$pluginType);
3479 3477
                 }
3480
-                ++ $pluginType;
3478
+                ++$pluginType;
3481 3479
             }
3482 3480
         }
3483 3481
 
@@ -3546,15 +3544,15 @@  discard block
 block discarded – undo
3546 3544
         }
3547 3545
 
3548 3546
         // loops over the param map and assigns values from the template or default value for unset optional params
3549
-        foreach ($map as $k => $v){
3547
+        foreach ($map as $k => $v) {
3550 3548
             if ($v[0] === '*') {
3551 3549
                 // "rest" array parameter, fill every remaining params in it and then break
3552 3550
                 if (count($ps) === 0) {
3553 3551
                     if ($v[1] === false) {
3554 3552
                         throw new CompilationException(
3555
-                            $this, 'Rest argument missing for ' . str_replace(
3553
+                            $this, 'Rest argument missing for '.str_replace(
3556 3554
                                 array(
3557
-                                    Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin',
3555
+                                    Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin',
3558 3556
                                 'Compile'
3559 3557
                                 ), '', (is_array($callback) ? $callback[0] : $callback)
3560 3558
                             )
@@ -3587,7 +3585,7 @@  discard block
 block discarded – undo
3587 3585
                 // parameter is not defined and not optional, throw error
3588 3586
                 if (is_array($callback)) {
3589 3587
                     if (is_object($callback[0])) {
3590
-                        $name = get_class($callback[0]) . '::' . $callback[1];
3588
+                        $name = get_class($callback[0]).'::'.$callback[1];
3591 3589
                     } else {
3592 3590
                         $name = $callback[0];
3593 3591
                     }
@@ -3596,9 +3594,9 @@  discard block
 block discarded – undo
3596 3594
                 }
3597 3595
 
3598 3596
                 throw new CompilationException(
3599
-                    $this, 'Argument ' . $k . '/' . $v[0] . ' missing for ' . str_replace(
3597
+                    $this, 'Argument '.$k.'/'.$v[0].' missing for '.str_replace(
3600 3598
                         array(
3601
-                            Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin',
3599
+                            Core::NAMESPACE_PLUGINS_FUNCTIONS.'Plugin',
3602 3600
                         'Compile'
3603 3601
                         ), '', $name
3604 3602
                     )
Please login to merge, or discard this patch.
lib/Dwoo/Core.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
             }
378 378
 
379 379
             if ($doCache === true) {
380
-                $out = preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '<?php /*' . $dynamicId . '*/ echo \'$1\'; ?>', $out);
381
-                if (!class_exists(self::NAMESPACE_PLUGINS_BLOCKS . 'PluginDynamic')) {
380
+                $out = preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '<?php /*'.$dynamicId.'*/ echo \'$1\'; ?>', $out);
381
+                if (!class_exists(self::NAMESPACE_PLUGINS_BLOCKS.'PluginDynamic')) {
382 382
                     $this->getLoader()->loadPlugin('PluginDynamic');
383 383
                 }
384 384
                 $out = PluginDynamic::unescape($out, $dynamicId, $compiledTemplate);
@@ -588,16 +588,16 @@  discard block
 block discarded – undo
588 588
     public function addFilter($callback, $autoload = false)
589 589
     {
590 590
         if ($autoload) {
591
-            $class = self::NAMESPACE_PLUGINS_FILTERS . self::toCamelCase($callback);
591
+            $class = self::NAMESPACE_PLUGINS_FILTERS.self::toCamelCase($callback);
592 592
             if (!class_exists($class) && !function_exists($class)) {
593 593
                 try {
594 594
                     $this->getLoader()->loadPlugin($callback);
595 595
                 }
596 596
                 catch (Exception $e) {
597 597
                     if (strstr($callback, self::NAMESPACE_PLUGINS_FILTERS)) {
598
-                        throw new Exception('Wrong filter name : ' . $callback . ', the "Filter" prefix should not be used, please only use "' . str_replace('Filter', '', $callback) . '"');
598
+                        throw new Exception('Wrong filter name : '.$callback.', the "Filter" prefix should not be used, please only use "'.str_replace('Filter', '', $callback).'"');
599 599
                     } else {
600
-                        throw new Exception('Wrong filter name : ' . $callback . ', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter<name>"');
600
+                        throw new Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter<name>"');
601 601
                     }
602 602
                 }
603 603
             }
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
             } elseif (function_exists($class)) {
608 608
                 $callback = $class;
609 609
             } else {
610
-                throw new Exception('Wrong filter name : ' . $callback . ', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter<name>"');
610
+                throw new Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter<name>"');
611 611
             }
612 612
 
613 613
             $this->filters[] = $callback;
@@ -625,14 +625,14 @@  discard block
 block discarded – undo
625 625
      */
626 626
     public function removeFilter($callback)
627 627
     {
628
-        if (($index = array_search(self::NAMESPACE_PLUGINS_FILTERS. 'Filter' . self::toCamelCase($callback), $this->filters,
628
+        if (($index = array_search(self::NAMESPACE_PLUGINS_FILTERS.'Filter'.self::toCamelCase($callback), $this->filters,
629 629
                 true)) !==
630 630
             false) {
631 631
             unset($this->filters[$index]);
632 632
         } elseif (($index = array_search($callback, $this->filters, true)) !== false) {
633 633
             unset($this->filters[$index]);
634 634
         } else {
635
-            $class = self::NAMESPACE_PLUGINS_FILTERS . 'Filter' . $callback;
635
+            $class = self::NAMESPACE_PLUGINS_FILTERS.'Filter'.$callback;
636 636
             foreach ($this->filters as $index => $filter) {
637 637
                 if (is_array($filter) && $filter[0] instanceof $class) {
638 638
                     unset($this->filters[$index]);
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
     public function getCacheDir()
756 756
     {
757 757
         if ($this->cacheDir === null) {
758
-            $this->setCacheDir(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR);
758
+            $this->setCacheDir(dirname(__DIR__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR);
759 759
         }
760 760
 
761 761
         return $this->cacheDir;
@@ -771,12 +771,12 @@  discard block
 block discarded – undo
771 771
      */
772 772
     public function setCacheDir($dir)
773 773
     {
774
-        $this->cacheDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
774
+        $this->cacheDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
775 775
         if (!file_exists($this->cacheDir)) {
776 776
             mkdir($this->cacheDir, 0777, true);
777 777
         }
778 778
         if (is_writable($this->cacheDir) === false) {
779
-            throw new Exception('The cache directory must be writable, chmod "' . $this->cacheDir . '" to make it writable');
779
+            throw new Exception('The cache directory must be writable, chmod "'.$this->cacheDir.'" to make it writable');
780 780
         }
781 781
     }
782 782
 
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
     public function getCompileDir()
789 789
     {
790 790
         if ($this->compileDir === null) {
791
-            $this->setCompileDir(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'compiled' . DIRECTORY_SEPARATOR);
791
+            $this->setCompileDir(dirname(__DIR__).DIRECTORY_SEPARATOR.'compiled'.DIRECTORY_SEPARATOR);
792 792
         }
793 793
 
794 794
         return $this->compileDir;
@@ -804,12 +804,12 @@  discard block
 block discarded – undo
804 804
      */
805 805
     public function setCompileDir($dir)
806 806
     {
807
-        $this->compileDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
807
+        $this->compileDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
808 808
         if (!file_exists($this->compileDir)) {
809 809
             mkdir($this->compileDir, 0777, true);
810 810
         }
811 811
         if (is_writable($this->compileDir) === false) {
812
-            throw new Exception('The compile directory must be writable, chmod "' . $this->compileDir . '" to make it writable');
812
+            throw new Exception('The compile directory must be writable, chmod "'.$this->compileDir.'" to make it writable');
813 813
         }
814 814
     }
815 815
 
@@ -833,9 +833,9 @@  discard block
 block discarded – undo
833 833
      */
834 834
     public function setTemplateDir($dir)
835 835
     {
836
-        $tmpDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
836
+        $tmpDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
837 837
         if (is_dir($tmpDir) === false) {
838
-            throw new Exception('The template directory: "' . $tmpDir . '" does not exists, create the directory or specify an other location !');
838
+            throw new Exception('The template directory: "'.$tmpDir.'" does not exists, create the directory or specify an other location !');
839 839
         }
840 840
         $this->templateDir[] = $tmpDir;
841 841
     }
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
      */
860 860
     public function setCacheTime($seconds)
861 861
     {
862
-        $this->cacheTime = (int)$seconds;
862
+        $this->cacheTime = (int) $seconds;
863 863
     }
864 864
 
865 865
     /**
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
      */
884 884
     public function setCharset($charset)
885 885
     {
886
-        $this->charset = strtolower((string)$charset);
886
+        $this->charset = strtolower((string) $charset);
887 887
     }
888 888
 
889 889
     /**
@@ -1020,11 +1020,11 @@  discard block
 block discarded – undo
1020 1020
     public function clearCache($olderThan = - 1)
1021 1021
     {
1022 1022
         $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getCacheDir()), \RecursiveIteratorIterator::SELF_FIRST);
1023
-        $expired  = time() - $olderThan;
1023
+        $expired  = time()-$olderThan;
1024 1024
         $count    = 0;
1025 1025
         foreach ($iterator as $file) {
1026 1026
             if ($file->isFile() && $file->getCTime() < $expired) {
1027
-                $count += unlink((string)$file) ? 1 : 0;
1027
+                $count += unlink((string) $file) ? 1 : 0;
1028 1028
             }
1029 1029
         }
1030 1030
 
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
             return $class::templateFactory($this, $resourceId, $cacheTime, $cacheId, $compileId, $parentTemplate);
1058 1058
         }
1059 1059
 
1060
-        throw new Exception('Unknown resource type : ' . $resourceName);
1060
+        throw new Exception('Unknown resource type : '.$resourceName);
1061 1061
     }
1062 1062
 
1063 1063
     /**
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
         if (!($tplIdentifier = $this->template->getResourceIdentifier())) {
1158 1158
             $tplIdentifier = $this->template->getResourceName();
1159 1159
         }
1160
-        trigger_error('Dwoo error (in ' . $tplIdentifier . ') : ' . $message, $level);
1160
+        trigger_error('Dwoo error (in '.$tplIdentifier.') : '.$message, $level);
1161 1161
     }
1162 1162
 
1163 1163
     /**
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
             $class = $this->plugins[$blockName]['class'];
1175 1175
         } else {
1176 1176
             $class = current(array_filter([
1177
-                'Plugin' . self::toCamelCase($blockName),
1178
-                self::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . self::toCamelCase($blockName)
1177
+                'Plugin'.self::toCamelCase($blockName),
1178
+                self::NAMESPACE_PLUGINS_BLOCKS.'Plugin'.self::toCamelCase($blockName)
1179 1179
             ], 'class_exists'));
1180 1180
         }
1181 1181
 
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
     {
1240 1240
         $index = array_search($block, $this->stack, true);
1241 1241
         if ($index !== false && $index > 0) {
1242
-            return $this->stack[$index - 1];
1242
+            return $this->stack[$index-1];
1243 1243
         }
1244 1244
 
1245 1245
         return false;
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
         if (isset($this->plugins[$type])) {
1258 1258
             $type = $this->plugins[$type]['class'];
1259 1259
         } else {
1260
-            $type = self::NAMESPACE_PLUGINS_BLOCKS . 'Plugin_' . str_replace(self::NAMESPACE_PLUGINS_BLOCKS.'Plugin',
1260
+            $type = self::NAMESPACE_PLUGINS_BLOCKS.'Plugin_'.str_replace(self::NAMESPACE_PLUGINS_BLOCKS.'Plugin',
1261 1261
                     '', $type);
1262 1262
         }
1263 1263
 
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
 
1336 1336
                 if (is_string($callback) === false) {
1337 1337
                     while (($i = array_shift($keys)) !== null) {
1338
-                        $out[] = call_user_func_array($callback, array(1 => $items[$i]) + $params);
1338
+                        $out[] = call_user_func_array($callback, array(1 => $items[$i])+$params);
1339 1339
                     }
1340 1340
                 } elseif ($cnt === 1) {
1341 1341
                     while (($i = array_shift($keys)) !== null) {
@@ -1351,7 +1351,7 @@  discard block
 block discarded – undo
1351 1351
                     }
1352 1352
                 } else {
1353 1353
                     while (($i = array_shift($keys)) !== null) {
1354
-                        $out[] = call_user_func_array($callback, array(1 => $items[$i]) + $params);
1354
+                        $out[] = call_user_func_array($callback, array(1 => $items[$i])+$params);
1355 1355
                     }
1356 1356
                 }
1357 1357
             } else {
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 
1361 1361
                 if (is_string($callback) === false) {
1362 1362
                     while (($i = array_shift($keys)) !== null) {
1363
-                        $out[] = call_user_func_array($callback, array($items[$i]) + $params);
1363
+                        $out[] = call_user_func_array($callback, array($items[$i])+$params);
1364 1364
                     }
1365 1365
                 } elseif ($cnt === 1) {
1366 1366
                     while (($i = array_shift($keys)) !== null) {
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
                     }
1381 1381
                 } else {
1382 1382
                     while (($i = array_shift($keys)) !== null) {
1383
-                        $out[] = call_user_func_array($callback, array($items[$i]) + $params);
1383
+                        $out[] = call_user_func_array($callback, array($items[$i])+$params);
1384 1384
                     }
1385 1385
                 }
1386 1386
             }
@@ -1450,7 +1450,7 @@  discard block
 block discarded – undo
1450 1450
         $tree = $this->scopeTree;
1451 1451
         $cur  = $this->data;
1452 1452
 
1453
-        while ($parentLevels -- !== 0) {
1453
+        while ($parentLevels-- !== 0) {
1454 1454
             array_pop($tree);
1455 1455
         }
1456 1456
 
@@ -1488,7 +1488,7 @@  discard block
 block discarded – undo
1488 1488
                 } elseif ($varstr === '__' || $varstr === '_root') {
1489 1489
                     return $this->data;
1490 1490
                 } elseif ($varstr === '_' || $varstr === '_parent') {
1491
-                    $varstr = '.' . $varstr;
1491
+                    $varstr = '.'.$varstr;
1492 1492
                     $tree   = $this->scopeTree;
1493 1493
                     $cur    = $this->data;
1494 1494
                     array_pop($tree);
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
             }
1515 1515
 
1516 1516
             if (substr($varstr, 0, 1) === '.') {
1517
-                $varstr = 'dwoo' . $varstr;
1517
+                $varstr = 'dwoo'.$varstr;
1518 1518
             }
1519 1519
 
1520 1520
             preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m);
@@ -1621,7 +1621,7 @@  discard block
 block discarded – undo
1621 1621
     public function assignInScope($value, $scope)
1622 1622
     {
1623 1623
         if (!is_string($scope)) {
1624
-            $this->triggerError('Assignments must be done into strings, (' . gettype($scope) . ') ' . var_export($scope, true) . ' given', E_USER_ERROR);
1624
+            $this->triggerError('Assignments must be done into strings, ('.gettype($scope).') '.var_export($scope, true).' given', E_USER_ERROR);
1625 1625
         }
1626 1626
         if (strstr($scope, '.') === false && strstr($scope, '->') === false) {
1627 1627
             $this->scope[$scope] = $value;
@@ -1772,7 +1772,7 @@  discard block
 block discarded – undo
1772 1772
     {
1773 1773
         $proxy = $this->getPluginProxy();
1774 1774
         if (!$proxy) {
1775
-            throw new Exception('Call to undefined method ' . __CLASS__ . '::' . $method . '()');
1775
+            throw new Exception('Call to undefined method '.__CLASS__.'::'.$method.'()');
1776 1776
         }
1777 1777
 
1778 1778
         return call_user_func_array($proxy->getCallback($method), $args);
Please login to merge, or discard this patch.
lib/Dwoo/Loader.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function __construct($cacheDir)
63 63
     {
64
-        $this->corePluginDir = __DIR__ . DIRECTORY_SEPARATOR . 'Plugins';
65
-        $this->cacheDir      = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
64
+        $this->corePluginDir = __DIR__.DIRECTORY_SEPARATOR.'Plugins';
65
+        $this->cacheDir      = rtrim($cacheDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
66 66
 
67 67
         // include class paths or rebuild paths if the cache file isn't there
68
-        $cacheFile = $this->cacheDir . 'classpath.cache.d' . Core::RELEASE_TAG . '.php';
68
+        $cacheFile = $this->cacheDir.'classpath.cache.d'.Core::RELEASE_TAG.'.php';
69 69
 
70 70
         $chachedClassPath = null;
71 71
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             $chachedClassPath = unserialize(file_get_contents($cacheFile));
75 75
 
76 76
             if (is_array($chachedClassPath)) {
77
-                $this->classPath = $chachedClassPath + $this->classPath;
77
+                $this->classPath = $chachedClassPath+$this->classPath;
78 78
             }
79 79
         }
80 80
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         // save in file if it's the first call (not recursed)
114 114
         if ($cacheFile !== false) {
115 115
             if (!file_put_contents($cacheFile, serialize($this->classPath), LOCK_EX)) {
116
-                throw new Exception('Could not write into ' . $cacheFile . ', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()');
116
+                throw new Exception('Could not write into '.$cacheFile.', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()');
117 117
             }
118 118
             $this->classPath += $tmp;
119 119
         }
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
          * so we check for that before trying to include() the plugin.
139 139
          */
140 140
         if ((!isset($this->classPath[$class]) || !is_readable($this->classPath[$class])) || (!isset
141
-                ($this->classPath[$class . 'Compile']) || !is_readable($this->classPath[$class . 'Compile']))) {
141
+                ($this->classPath[$class.'Compile']) || !is_readable($this->classPath[$class.'Compile']))) {
142 142
             if ($forceRehash) {
143
-                $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d' .
144
-                    Core::RELEASE_TAG . '.php');
143
+                $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir.'classpath.cache.d'.
144
+                    Core::RELEASE_TAG.'.php');
145 145
                 foreach ($this->paths as $path => $file) {
146 146
                     $this->rebuildClassPathCache($path, $file);
147 147
                 }
148 148
                 if (isset($this->classPath[$class])) {
149 149
                     include_once $this->classPath[$class];
150
-                } elseif (isset($this->classPath[$class . 'Compile'])) {
151
-                    include_once $this->classPath[$class . 'Compile'];
150
+                } elseif (isset($this->classPath[$class.'Compile'])) {
151
+                    include_once $this->classPath[$class.'Compile'];
152 152
                 } else {
153
-                    throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
153
+                    throw new Exception('Plugin "'.$class.'" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
154 154
                 }
155 155
             } else {
156
-                throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
156
+                throw new Exception('Plugin "'.$class.'" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
157 157
             }
158 158
         }
159 159
     }
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
     {
176 176
         $pluginDir = realpath($pluginDirectory);
177 177
         if (!$pluginDir) {
178
-            throw new Exception('Plugin directory does not exist or can not be read : ' . $pluginDirectory);
178
+            throw new Exception('Plugin directory does not exist or can not be read : '.$pluginDirectory);
179 179
         }
180
-        $cacheFile = $this->cacheDir . 'classpath-' . substr(strtr($pluginDir, '/\\:' . PATH_SEPARATOR, '----'),
181
-                strlen($pluginDir) > 80 ? - 80 : 0) . '.d' . Core::RELEASE_TAG . '.php';
180
+        $cacheFile = $this->cacheDir.'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'),
181
+                strlen($pluginDir) > 80 ? -80 : 0).'.d'.Core::RELEASE_TAG.'.php';
182 182
         $this->paths[$pluginDir] = $cacheFile;
183 183
         if (file_exists($cacheFile)) {
184 184
             $classpath       = file_get_contents($cacheFile);
185
-            $this->classPath = unserialize($classpath) + $this->classPath;
185
+            $this->classPath = unserialize($classpath)+$this->classPath;
186 186
         } else {
187 187
             $this->rebuildClassPathCache($pluginDir, $cacheFile);
188 188
         }
Please login to merge, or discard this patch.