Completed
Branch 1.2 (e91c8b)
by David
04:07
created
lib/Dwoo/Template/File.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @return boolean True cache file existance and it's modification time
108 108
 	 */
109 109
 	protected function isValidCompiledFile($file) {
110
-		return parent::isValidCompiledFile($file) && (int)$this->getUid() <= filemtime($file);
110
+		return parent::isValidCompiledFile($file) && (int) $this->getUid() <= filemtime($file);
111 111
 	}
112 112
 
113 113
 	/**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			foreach ($this->includePath as $path) {
146 146
 				$path = rtrim($path, DIRECTORY_SEPARATOR);
147 147
 				if (file_exists($path.DIRECTORY_SEPARATOR.$this->file) === true) {
148
-					$this->resolvedPath = $path . DIRECTORY_SEPARATOR . $this->file;
148
+					$this->resolvedPath = $path.DIRECTORY_SEPARATOR.$this->file;
149 149
 					return $this->resolvedPath;
150 150
 				}
151 151
 			}
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 	protected function getCompiledFilename(Dwoo_Core $dwoo)
251 251
 	{
252 252
 		// no compile id was provided, set default
253
-		if ($this->compileId===null) {
253
+		if ($this->compileId === null) {
254 254
 			$this->compileId = str_replace('../', '__', strtr($this->getResourceIdentifier(), '\\:', '/-'));
255 255
 		}
256
-		return $dwoo->getCompileDir() . $this->compileId.'.d'.Dwoo_Core::RELEASE_TAG.'.php';
256
+		return $dwoo->getCompileDir().$this->compileId.'.d'.Dwoo_Core::RELEASE_TAG.'.php';
257 257
 	}
258 258
 
259 259
 	/**
Please login to merge, or discard this patch.
lib/Dwoo/Core.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1538,8 +1538,9 @@
 block discarded – undo
1538 1538
                 array_pop($this->scopeTree);
1539 1539
                 $this->scope =& $this->data;
1540 1540
                 $cnt = count($this->scopeTree);
1541
-                for ($i=0;$i<$cnt;$i++)
1542
-                    $this->scope =& $this->scope[$this->scopeTree[$i]];
1541
+                for ($i=0;$i<$cnt;$i++) {
1542
+                                    $this->scope =& $this->scope[$this->scopeTree[$i]];
1543
+                }
1543 1544
             } elseif ($bit === '__' || $bit === '_root') {
1544 1545
                 $this->scope =& $this->data;
1545 1546
                 $this->scopeTree = array();
Please login to merge, or discard this patch.
Spacing   +65 added lines, -69 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (!defined('DWOO_DIRECTORY')) {
4
-	define('DWOO_DIRECTORY', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
4
+	define('DWOO_DIRECTORY', dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR);
5 5
 }
6 6
 /**
7 7
  * main dwoo class, allows communication between the compiler, template and data classes
@@ -162,15 +162,12 @@  discard block
 block discarded – undo
162 162
      *
163 163
      * @var array
164 164
      */
165
-    protected $resources = array
166
-    (
167
-        'file'      =>  array
168
-        (
165
+    protected $resources = array(
166
+        'file'      =>  array(
169 167
             'class'     =>  'Dwoo_Template_File',
170 168
             'compiler'  =>  null
171 169
         ),
172
-        'string'    =>  array
173
-        (
170
+        'string'    =>  array(
174 171
             'class'     =>  'Dwoo_Template_String',
175 172
             'compiler'  =>  null
176 173
         )
@@ -437,8 +434,7 @@  discard block
 block discarded – undo
437 434
      */
438 435
     protected function initGlobals()
439 436
     {
440
-        $this->globals = array
441
-        (
437
+        $this->globals = array(
442 438
             'version'   =>  self::VERSION,
443 439
             'ad'        =>  '<a href="http://dwoo.org/">Powered by Dwoo</a>',
444 440
             'now'       =>  $_SERVER['REQUEST_TIME'],
@@ -457,7 +453,7 @@  discard block
 block discarded – undo
457 453
     protected function initRuntimeVars(Dwoo_ITemplate $tpl)
458 454
     {
459 455
         $this->runtimePlugins = array();
460
-        $this->scope =& $this->data;
456
+        $this->scope = & $this->data;
461 457
         $this->scopeTree = array();
462 458
         $this->stack = array();
463 459
         $this->curBlock = null;
@@ -487,7 +483,7 @@  discard block
 block discarded – undo
487 483
             } else {
488 484
                 $this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0]), 'function'=>$callback[1]);
489 485
             }
490
-        } elseif(is_string($callback)) {
486
+        } elseif (is_string($callback)) {
491 487
 			if (class_exists($callback)) {
492 488
 				if (is_subclass_of($callback, 'Dwoo_Block_Plugin')) {
493 489
 					$this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback);
@@ -499,7 +495,7 @@  discard block
 block discarded – undo
499 495
 			} else {
500 496
 				throw new Dwoo_Exception('Callback could not be processed correctly, please check that the function/class you used exists');
501 497
 			}
502
-		} elseif($callback instanceof \Closure) {
498
+		} elseif ($callback instanceof \Closure) {
503 499
 			$this->plugins[$name] = array('type'=>self::FUNC_PLUGIN | $compilable, 'callback'=>$callback);
504 500
 		} else {
505 501
             throw new Dwoo_Exception('Callback could not be processed correctly, please check that the function/class you used exists');
@@ -566,8 +562,8 @@  discard block
 block discarded – undo
566 562
             unset($this->filters[$index]);
567 563
         } elseif (($index = array_search($callback, $this->filters, true)) !== false) {
568 564
             unset($this->filters[$index]);
569
-        } else  {
570
-            $class = 'Dwoo_Filter_' . $callback;
565
+        } else {
566
+            $class = 'Dwoo_Filter_'.$callback;
571 567
             foreach ($this->filters as $index=>$filter) {
572 568
                 if (is_array($filter) && $filter[0] instanceof $class) {
573 569
                     unset($this->filters[$index]);
@@ -610,7 +606,7 @@  discard block
 block discarded – undo
610 606
     public function removeResource($name)
611 607
     {
612 608
         unset($this->resources[$name]);
613
-        if ($name==='file') {
609
+        if ($name === 'file') {
614 610
             $this->resources['file'] = array('class'=>'Dwoo_Template_File', 'compiler'=>null);
615 611
         }
616 612
     }
@@ -862,7 +858,7 @@  discard block
 block discarded – undo
862 858
 			new \RecursiveDirectoryIterator($this->getCompileDir()),
863 859
 			\RecursiveIteratorIterator::SELF_FIRST
864 860
 		);
865
-		$count    = 0;
861
+		$count = 0;
866 862
 		/** @var \SplFileInfo $file */
867 863
 		foreach ($iterator as $file) {
868 864
 			if ($file->isFile()) {
@@ -878,13 +874,13 @@  discard block
 block discarded – undo
878 874
      * @param int $olderThan minimum time (in seconds) required for a cached template to be cleared
879 875
      * @return int the amount of templates cleared
880 876
      */
881
-    public function clearCache($olderThan=-1)
877
+    public function clearCache($olderThan = -1)
882 878
     {
883 879
 		$iterator = new \RecursiveIteratorIterator(
884 880
 			new \RecursiveDirectoryIterator($this->getCacheDir()),
885 881
 			\RecursiveIteratorIterator::SELF_FIRST
886 882
 		);
887
-        $expired = time() - $olderThan;
883
+        $expired = time()-$olderThan;
888 884
         $count = 0;
889 885
 		/** @var \SplFileInfo $file */
890 886
         foreach ($iterator as $file) {
@@ -924,7 +920,7 @@  discard block
 block discarded – undo
924 920
      *                              and return true only if it's not empty
925 921
      * @return int|bool true if it's an array|arrayaccess (or the item count if $checkIsEmpty is true) or false if it's not an array|arrayaccess (or 0 if $checkIsEmpty is true)
926 922
      */
927
-    public function isArray($value, $checkIsEmpty=false)
923
+    public function isArray($value, $checkIsEmpty = false)
928 924
     {
929 925
         if (is_array($value) === true || $value instanceof ArrayAccess) {
930 926
             if ($checkIsEmpty === false) {
@@ -943,7 +939,7 @@  discard block
 block discarded – undo
943 939
      *                              and return true only if it's not empty
944 940
      * @return int|bool true if it's an array|traversable (or the item count if $checkIsEmpty is true) or false if it's not an array|traversable (or 0 if $checkIsEmpty is true)
945 941
      */
946
-    public function isTraversable($value, $checkIsEmpty=false)
942
+    public function isTraversable($value, $checkIsEmpty = false)
947 943
     {
948 944
         if (is_array($value) === true) {
949 945
             if ($checkIsEmpty === false) {
@@ -993,7 +989,7 @@  discard block
 block discarded – undo
993 989
      * @param string $message the error message
994 990
      * @param int $level the error level, one of the PHP's E_* constants
995 991
      */
996
-    public function triggerError($message, $level=E_USER_NOTICE)
992
+    public function triggerError($message, $level = E_USER_NOTICE)
997 993
     {
998 994
         if (!($tplIdentifier = $this->template->getResourceIdentifier())) {
999 995
             $tplIdentifier = $this->template->getResourceName();
@@ -1012,7 +1008,7 @@  discard block
 block discarded – undo
1012 1008
      * @param array $args the arguments to be passed to the block's init() function
1013 1009
      * @return Dwoo_Block_Plugin the newly created block
1014 1010
      */
1015
-    public function addStack($blockName, array $args=array())
1011
+    public function addStack($blockName, array $args = array())
1016 1012
     {
1017 1013
         if (isset($this->plugins[$blockName])) {
1018 1014
             $class = $this->plugins[$blockName]['class'];
@@ -1031,18 +1027,18 @@  discard block
 block discarded – undo
1031 1027
         $block = new $class($this);
1032 1028
 
1033 1029
         $cnt = count($args);
1034
-        if ($cnt===0) {
1030
+        if ($cnt === 0) {
1035 1031
             $block->init();
1036
-        } elseif ($cnt===1) {
1032
+        } elseif ($cnt === 1) {
1037 1033
             $block->init($args[0]);
1038
-        } elseif ($cnt===2) {
1034
+        } elseif ($cnt === 2) {
1039 1035
             $block->init($args[0], $args[1]);
1040
-        } elseif ($cnt===3) {
1036
+        } elseif ($cnt === 3) {
1041 1037
             $block->init($args[0], $args[1], $args[2]);
1042
-        } elseif ($cnt===4) {
1038
+        } elseif ($cnt === 4) {
1043 1039
             $block->init($args[0], $args[1], $args[2], $args[3]);
1044 1040
         } else {
1045
-            call_user_func_array(array($block,'init'), $args);
1041
+            call_user_func_array(array($block, 'init'), $args);
1046 1042
         }
1047 1043
 
1048 1044
         $this->stack[] = $this->curBlock = $block;
@@ -1063,15 +1059,15 @@  discard block
 block discarded – undo
1063 1059
         ob_clean();
1064 1060
 
1065 1061
         $cnt = count($args);
1066
-        if ($cnt===0) {
1062
+        if ($cnt === 0) {
1067 1063
             $this->curBlock->end();
1068
-        } elseif ($cnt===1) {
1064
+        } elseif ($cnt === 1) {
1069 1065
             $this->curBlock->end($args[0]);
1070
-        } elseif ($cnt===2) {
1066
+        } elseif ($cnt === 2) {
1071 1067
             $this->curBlock->end($args[0], $args[1]);
1072
-        } elseif ($cnt===3) {
1068
+        } elseif ($cnt === 3) {
1073 1069
             $this->curBlock->end($args[0], $args[1], $args[2]);
1074
-        } elseif ($cnt===4) {
1070
+        } elseif ($cnt === 4) {
1075 1071
             $this->curBlock->end($args[0], $args[1], $args[2], $args[3]);
1076 1072
         } else {
1077 1073
             call_user_func_array(array($this->curBlock, 'end'), $args);
@@ -1083,7 +1079,7 @@  discard block
 block discarded – undo
1083 1079
             $this->curBlock = end($this->stack);
1084 1080
             $this->curBlock->buffer($tmp->process());
1085 1081
         } else {
1086
-            if($this->buffer !== '') {
1082
+            if ($this->buffer !== '') {
1087 1083
                 echo $this->buffer;
1088 1084
                 $this->buffer = '';
1089 1085
             }
@@ -1164,15 +1160,15 @@  discard block
 block discarded – undo
1164 1160
         $plugin = $this->getObjectPlugin($class);
1165 1161
 
1166 1162
         $cnt = count($params);
1167
-        if ($cnt===0) {
1163
+        if ($cnt === 0) {
1168 1164
             return $plugin->process();
1169
-        } elseif ($cnt===1) {
1165
+        } elseif ($cnt === 1) {
1170 1166
             return $plugin->process($params[0]);
1171
-        } elseif ($cnt===2) {
1167
+        } elseif ($cnt === 2) {
1172 1168
             return $plugin->process($params[0], $params[1]);
1173
-        } elseif ($cnt===3) {
1169
+        } elseif ($cnt === 3) {
1174 1170
             return $plugin->process($params[0], $params[1], $params[2]);
1175
-        } elseif ($cnt===4) {
1171
+        } elseif ($cnt === 4) {
1176 1172
             return $plugin->process($params[0], $params[1], $params[2], $params[3]);
1177 1173
         } else {
1178 1174
             return call_user_func_array(array($plugin, 'process'), $params);
@@ -1208,23 +1204,23 @@  discard block
 block discarded – undo
1208 1204
 
1209 1205
                 if (is_string($callback) === false) {
1210 1206
                     while (($i = array_shift($keys)) !== null) {
1211
-                        $out[] = call_user_func_array($callback, array(1=>$items[$i]) + $params);
1207
+                        $out[] = call_user_func_array($callback, array(1=>$items[$i])+$params);
1212 1208
                     }
1213
-                } elseif ($cnt===1) {
1209
+                } elseif ($cnt === 1) {
1214 1210
                     while (($i = array_shift($keys)) !== null) {
1215 1211
                         $out[] = $callback($this, $items[$i]);
1216 1212
                     }
1217
-                } elseif ($cnt===2) {
1213
+                } elseif ($cnt === 2) {
1218 1214
                     while (($i = array_shift($keys)) !== null) {
1219 1215
                         $out[] = $callback($this, $items[$i], $params[2]);
1220 1216
                     }
1221
-                } elseif ($cnt===3) {
1217
+                } elseif ($cnt === 3) {
1222 1218
                     while (($i = array_shift($keys)) !== null) {
1223 1219
                         $out[] = $callback($this, $items[$i], $params[2], $params[3]);
1224 1220
                     }
1225 1221
                 } else {
1226 1222
                     while (($i = array_shift($keys)) !== null) {
1227
-                        $out[] = call_user_func_array($callback, array(1=>$items[$i]) + $params);
1223
+                        $out[] = call_user_func_array($callback, array(1=>$items[$i])+$params);
1228 1224
                     }
1229 1225
                 }
1230 1226
             } else {
@@ -1233,27 +1229,27 @@  discard block
 block discarded – undo
1233 1229
 
1234 1230
                 if (is_string($callback) === false) {
1235 1231
                     while (($i = array_shift($keys)) !== null) {
1236
-                        $out[] = call_user_func_array($callback, array($items[$i]) + $params);
1232
+                        $out[] = call_user_func_array($callback, array($items[$i])+$params);
1237 1233
                     }
1238
-                } elseif ($cnt===1) {
1234
+                } elseif ($cnt === 1) {
1239 1235
                     while (($i = array_shift($keys)) !== null) {
1240 1236
                         $out[] = $callback($items[$i]);
1241 1237
                     }
1242
-                } elseif ($cnt===2) {
1238
+                } elseif ($cnt === 2) {
1243 1239
                     while (($i = array_shift($keys)) !== null) {
1244 1240
                         $out[] = $callback($items[$i], $params[1]);
1245 1241
                     }
1246
-                } elseif ($cnt===3) {
1242
+                } elseif ($cnt === 3) {
1247 1243
                     while (($i = array_shift($keys)) !== null) {
1248 1244
                         $out[] = $callback($items[$i], $params[1], $params[2]);
1249 1245
                     }
1250
-                } elseif ($cnt===4) {
1246
+                } elseif ($cnt === 4) {
1251 1247
                     while (($i = array_shift($keys)) !== null) {
1252 1248
                         $out[] = $callback($items[$i], $params[1], $params[2], $params[3]);
1253 1249
                     }
1254 1250
                 } else {
1255 1251
                     while (($i = array_shift($keys)) !== null) {
1256
-                        $out[] = call_user_func_array($callback, array($items[$i]) + $params);
1252
+                        $out[] = call_user_func_array($callback, array($items[$i])+$params);
1257 1253
                     }
1258 1254
                 }
1259 1255
             }
@@ -1318,7 +1314,7 @@  discard block
 block discarded – undo
1318 1314
         $tree = $this->scopeTree;
1319 1315
         $cur = $this->data;
1320 1316
 
1321
-        while ($parentLevels--!==0) {
1317
+        while ($parentLevels-- !== 0) {
1322 1318
             array_pop($tree);
1323 1319
         }
1324 1320
 
@@ -1330,7 +1326,7 @@  discard block
 block discarded – undo
1330 1326
             }
1331 1327
         }
1332 1328
 
1333
-        if ($varstr!==null) {
1329
+        if ($varstr !== null) {
1334 1330
             return $this->readVarInto($varstr, $cur);
1335 1331
         } else {
1336 1332
             return $cur;
@@ -1345,14 +1341,14 @@  discard block
 block discarded – undo
1345 1341
      */
1346 1342
     public function readVar($varstr)
1347 1343
     {
1348
-        if (is_array($varstr)===true) {
1344
+        if (is_array($varstr) === true) {
1349 1345
             $m = $varstr;
1350 1346
             unset($varstr);
1351 1347
         } else {
1352 1348
             if (strstr($varstr, '.') === false && strstr($varstr, '[') === false && strstr($varstr, '->') === false) {
1353 1349
                 if ($varstr === 'dwoo') {
1354 1350
                     return $this->globals;
1355
-                } elseif ($varstr === '__' || $varstr === '_root' ) {
1351
+                } elseif ($varstr === '__' || $varstr === '_root') {
1356 1352
                     return $this->data;
1357 1353
                 } elseif ($varstr === '_' || $varstr === '_parent') {
1358 1354
                     $varstr = '.'.$varstr;
@@ -1488,8 +1484,8 @@  discard block
 block discarded – undo
1488 1484
      */
1489 1485
     public function assignInScope($value, $scope)
1490 1486
     {
1491
-        $tree =& $this->scopeTree;
1492
-        $data =& $this->data;
1487
+        $tree = & $this->scopeTree;
1488
+        $data = & $this->data;
1493 1489
 
1494 1490
         if (!is_string($scope)) {
1495 1491
             $this->triggerError('Assignments must be done into strings, ('.gettype($scope).') '.var_export($scope, true).' given', E_USER_ERROR);
@@ -1500,7 +1496,7 @@  discard block
 block discarded – undo
1500 1496
             // TODO handle _root/_parent scopes ?
1501 1497
             preg_match_all('#(\[|->|\.)?([^.[\]-]+)\]?#i', $scope, $m);
1502 1498
 
1503
-            $cur =& $this->scope;
1499
+            $cur = & $this->scope;
1504 1500
             $last = array(array_pop($m[1]), array_pop($m[2]));
1505 1501
 
1506 1502
             while (list($k, $sep) = each($m[1])) {
@@ -1508,12 +1504,12 @@  discard block
 block discarded – undo
1508 1504
                     if (is_array($cur) === false) {
1509 1505
                         $cur = array();
1510 1506
                     }
1511
-                    $cur =& $cur[$m[2][$k]];
1507
+                    $cur = & $cur[$m[2][$k]];
1512 1508
                 } elseif ($sep === '->') {
1513 1509
                     if (is_object($cur) === false) {
1514 1510
                         $cur = new stdClass;
1515 1511
                     }
1516
-                    $cur =& $cur->$m[2][$k];
1512
+                    $cur = & $cur->$m[2][$k];
1517 1513
                 } else {
1518 1514
                     return false;
1519 1515
                 }
@@ -1546,31 +1542,31 @@  discard block
 block discarded – undo
1546 1542
     {
1547 1543
         $old = $this->scopeTree;
1548 1544
 
1549
-        if (is_string($scope)===true) {
1545
+        if (is_string($scope) === true) {
1550 1546
             $scope = explode('.', $scope);
1551 1547
         }
1552 1548
 
1553
-        if ($absolute===true) {
1554
-            $this->scope =& $this->data;
1549
+        if ($absolute === true) {
1550
+            $this->scope = & $this->data;
1555 1551
             $this->scopeTree = array();
1556 1552
         }
1557 1553
 
1558 1554
         while (($bit = array_shift($scope)) !== null) {
1559 1555
             if ($bit === '_' || $bit === '_parent') {
1560 1556
                 array_pop($this->scopeTree);
1561
-                $this->scope =& $this->data;
1557
+                $this->scope = & $this->data;
1562 1558
                 $cnt = count($this->scopeTree);
1563
-                for ($i=0;$i<$cnt;$i++)
1564
-                    $this->scope =& $this->scope[$this->scopeTree[$i]];
1559
+                for ($i = 0; $i < $cnt; $i++)
1560
+                    $this->scope = & $this->scope[$this->scopeTree[$i]];
1565 1561
             } elseif ($bit === '__' || $bit === '_root') {
1566
-                $this->scope =& $this->data;
1562
+                $this->scope = & $this->data;
1567 1563
                 $this->scopeTree = array();
1568 1564
             } elseif (isset($this->scope[$bit])) {
1569
-                if($this->scope instanceof ArrayAccess) {
1565
+                if ($this->scope instanceof ArrayAccess) {
1570 1566
                     $tmp = $this->scope[$bit];
1571
-                    $this->scope =& $tmp;
1567
+                    $this->scope = & $tmp;
1572 1568
                 } else {
1573
-                    $this->scope =& $this->scope[$bit];
1569
+                    $this->scope = & $this->scope[$bit];
1574 1570
                 }
1575 1571
                 $this->scopeTree[] = $bit;
1576 1572
             } else {
Please login to merge, or discard this patch.
lib/Dwoo/Block/Plugin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,6 +98,6 @@
 block discarded – undo
98 98
 	 */
99 99
 	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
100 100
 	{
101
-		return $content . Dwoo_Compiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.Dwoo_Compiler::PHP_CLOSE;
101
+		return $content.Dwoo_Compiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.Dwoo_Compiler::PHP_CLOSE;
102 102
 	}
103 103
 }
Please login to merge, or discard this patch.
lib/Dwoo/Loader.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
 
45 45
 	public function __construct($cacheDir)
46 46
 	{
47
-		$this->corePluginDir = DWOO_DIRECTORY . 'plugins';
48
-		$this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
47
+		$this->corePluginDir = DWOO_DIRECTORY.'plugins';
48
+		$this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
49 49
 
50 50
 		// include class paths or rebuild paths if the cache file isn't there
51 51
 		$cacheFile = $this->cacheDir.'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php';
52 52
 		if (file_exists($cacheFile)) {
53 53
 			$classpath = file_get_contents($cacheFile);
54
-			$this->classPath = unserialize($classpath) + $this->classPath;
54
+			$this->classPath = unserialize($classpath)+$this->classPath;
55 55
 		} else {
56 56
 			$this->rebuildClassPathCache($this->corePluginDir, $cacheFile);
57 57
 		}
@@ -65,25 +65,25 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	protected function rebuildClassPathCache($path, $cacheFile)
67 67
 	{
68
-		if ($cacheFile!==false) {
68
+		if ($cacheFile !== false) {
69 69
 			$tmp = $this->classPath;
70 70
 			$this->classPath = array();
71 71
 		}
72 72
 
73 73
 		// iterates over all files/folders
74
-		$list = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*');
74
+		$list = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*');
75 75
 		if (is_array($list)) {
76 76
 			foreach ($list as $f) {
77 77
 				if (is_dir($f)) {
78 78
 					$this->rebuildClassPathCache($f, false);
79 79
 				} else {
80
-					$this->classPath[str_replace(array('function.','block.','modifier.','outputfilter.','filter.','prefilter.','postfilter.','pre.','post.','output.','shared.','helper.'), '', basename($f, '.php'))] = $f;
80
+					$this->classPath[str_replace(array('function.', 'block.', 'modifier.', 'outputfilter.', 'filter.', 'prefilter.', 'postfilter.', 'pre.', 'post.', 'output.', 'shared.', 'helper.'), '', basename($f, '.php'))] = $f;
81 81
 				}
82 82
 			}
83 83
 		}
84 84
 
85 85
 		// save in file if it's the first call (not recursed)
86
-		if ($cacheFile!==false) {
86
+		if ($cacheFile !== false) {
87 87
 			if (!file_put_contents($cacheFile, serialize($this->classPath))) {
88 88
 				throw new Dwoo_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()');
89 89
 			}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 			!(include $this->classPath[$class]))
110 110
 		{
111 111
 			if ($forceRehash) {
112
-				$this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php');
112
+				$this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir.'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php');
113 113
 				foreach ($this->paths as $path=>$file) {
114 114
 					$this->rebuildClassPathCache($path, $file);
115 115
 				}
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 		if (!$pluginDir) {
143 143
 			throw new Dwoo_Exception('Plugin directory does not exist or can not be read : '.$pluginDirectory);
144 144
 		}
145
-		$cacheFile = $this->cacheDir . 'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'), strlen($pluginDir) > 80 ? -80 : 0).'.d'.Dwoo_Core::RELEASE_TAG.'.php';
145
+		$cacheFile = $this->cacheDir.'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'), strlen($pluginDir) > 80 ? -80 : 0).'.d'.Dwoo_Core::RELEASE_TAG.'.php';
146 146
 		$this->paths[$pluginDir] = $cacheFile;
147 147
 		if (file_exists($cacheFile)) {
148 148
 			$classpath = file_get_contents($cacheFile);
149
-			$this->classPath = unserialize($classpath) + $this->classPath;
149
+			$this->classPath = unserialize($classpath)+$this->classPath;
150 150
 		} else {
151 151
 			$this->rebuildClassPathCache($pluginDir, $cacheFile);
152 152
 		}
Please login to merge, or discard this patch.
lib/Dwoo/Smarty/Adapter.php 2 patches
Braces   +18 added lines, -14 removed lines patch added patch discarded remove patch
@@ -297,9 +297,10 @@  discard block
 block discarded – undo
297 297
 
298 298
 	public function unregister_prefilter($callback)
299 299
 	{
300
-		foreach ($this->_filters['pre'] as $index => $processor)
301
-			if ($processor->callback === $callback) {
300
+		foreach ($this->_filters['pre'] as $index => $processor) {
301
+					if ($processor->callback === $callback) {
302 302
 				$this->compiler->removePostProcessor($processor);
303
+		}
303 304
 				unset($this->_filters['pre'][$index]);
304 305
 			}
305 306
 	}
@@ -314,9 +315,10 @@  discard block
 block discarded – undo
314 315
 
315 316
 	public function unregister_postfilter($callback)
316 317
 	{
317
-		foreach ($this->_filters['post'] as $index => $processor)
318
-			if ($processor->callback === $callback) {
318
+		foreach ($this->_filters['post'] as $index => $processor) {
319
+					if ($processor->callback === $callback) {
319 320
 				$this->compiler->removePostProcessor($processor);
321
+		}
320 322
 				unset($this->_filters['post'][$index]);
321 323
 			}
322 324
 	}
@@ -331,9 +333,10 @@  discard block
 block discarded – undo
331 333
 
332 334
 	public function unregister_outputfilter($callback)
333 335
 	{
334
-		foreach ($this->_filters['output'] as $index => $filter)
335
-			if ($filter->callback === $callback) {
336
+		foreach ($this->_filters['output'] as $index => $filter) {
337
+					if ($filter->callback === $callback) {
336 338
 				$this->removeOutputFilter($filter);
339
+		}
337 340
 				unset($this->_filters['output'][$index]);
338 341
 			}
339 342
 	}
@@ -419,10 +422,11 @@  discard block
 block discarded – undo
419 422
 		}
420 423
 
421 424
 		$data = $this->dataProvider->getData();
422
-   		if ($name === null)
423
-   			return $data;
424
-   		elseif (isset($data[$name]))
425
-   			return $data[$name];
425
+   		if ($name === null) {
426
+   		   			return $data;
427
+   		} elseif (isset($data[$name])) {
428
+   		   			return $data[$name];
429
+   		}
426 430
    		return null;
427 431
    	}
428 432
 
@@ -450,8 +454,9 @@  discard block
 block discarded – undo
450 454
 
451 455
 	protected function makeTemplate($file, $cacheId, $compileId)
452 456
 	{
453
-   		if ($compileId === null)
454
-   			$compileId = $this->compile_id;
457
+   		if ($compileId === null) {
458
+   		   			$compileId = $this->compile_id;
459
+   		}
455 460
 
456 461
 		$hash = bin2hex(md5($file.$cacheId.$compileId, true));
457 462
 		if (!isset(self::$tplCache[$hash])) {
@@ -511,8 +516,7 @@  discard block
 block discarded – undo
511 516
 {
512 517
 	interface Smarty {}
513 518
 	class Dwoo_Smarty_Adapter extends Dwoo_Smarty__Adapter implements Smarty {}
514
-}
515
-else
519
+} else
516 520
 {
517 521
 	class Dwoo_Smarty_Adapter extends Dwoo_Smarty__Adapter {}
518 522
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -25 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@  discard block
 block discarded – undo
5 5
 }
6 6
 
7 7
 if (!defined('SMARTY_PHP_PASSTHRU')) {
8
-	define('SMARTY_PHP_PASSTHRU',   0);
9
-	define('SMARTY_PHP_QUOTE',      1);
10
-	define('SMARTY_PHP_REMOVE',     2);
11
-	define('SMARTY_PHP_ALLOW',      3);
8
+	define('SMARTY_PHP_PASSTHRU', 0);
9
+	define('SMARTY_PHP_QUOTE', 1);
10
+	define('SMARTY_PHP_REMOVE', 2);
11
+	define('SMARTY_PHP_ALLOW', 3);
12 12
 }
13 13
 
14 14
 /**
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	// magic get/set/call functions that handle unsupported features
33 33
 	public function __set($p, $v)
34 34
 	{
35
-		if ($p==='scope') {
35
+		if ($p === 'scope') {
36 36
 			$this->scope = $v;
37 37
 			return;
38 38
 		}
39
-		if ($p==='data') {
39
+		if ($p === 'data') {
40 40
 			$this->data = $v;
41 41
 			return;
42 42
 		}
@@ -80,15 +80,12 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 
82 82
 	// list of unsupported properties and methods
83
-	protected $compat = array
84
-	(
85
-		'methods' => array
86
-		(
83
+	protected $compat = array(
84
+		'methods' => array(
87 85
 			'register_resource', 'unregister_resource', 'load_filter', 'clear_compiled_tpl',
88 86
 			'clear_config', 'get_config_vars', 'config_load'
89 87
 		),
90
-		'properties' => array
91
-		(
88
+		'properties' => array(
92 89
 			'cache_handler_func' => null,
93 90
 			'debugging' => false,
94 91
 			'error_reporting' => null,
@@ -115,11 +112,9 @@  discard block
 block discarded – undo
115 112
 	public $trusted_dir = array();
116 113
 	public $secure_dir = array();
117 114
 	public $php_handling = SMARTY_PHP_PASSTHRU;
118
-	public $security_settings = array
119
-	(
115
+	public $security_settings = array(
120 116
 		'PHP_HANDLING'    => false,
121
-		'IF_FUNCS'        => array
122
-		(
117
+		'IF_FUNCS'        => array(
123 118
 			'list', 'empty', 'count', 'sizeof',
124 119
 			'in_array', 'is_array',
125 120
 		),
@@ -162,12 +157,12 @@  discard block
 block discarded – undo
162 157
 		$this->compiler = new Dwoo_Compiler();
163 158
 	}
164 159
 
165
-	public function display($filename, $cacheId=null, $compileId=null)
160
+	public function display($filename, $cacheId = null, $compileId = null)
166 161
 	{
167 162
 		$this->fetch($filename, $cacheId, $compileId, true);
168 163
 	}
169 164
 
170
-	public function fetch($filename, $cacheId=null, $compileId=null, $display=false)
165
+	public function fetch($filename, $cacheId = null, $compileId = null, $display = false)
171 166
 	{
172 167
 		$this->setCacheDir($this->cache_dir);
173 168
 		$this->setCompileDir($this->compile_dir);
@@ -180,7 +175,7 @@  discard block
 block discarded – undo
180 175
 			if ($this->security_settings['PHP_TAGS']) {
181 176
 				$phpTags = SMARTY_PHP_ALLOW;
182 177
 			}
183
-			switch($phpTags) {
178
+			switch ($phpTags) {
184 179
 				case SMARTY_PHP_ALLOW:
185 180
 				case SMARTY_PHP_PASSTHRU:
186 181
 					$phpTags = Dwoo_Security_Policy::PHP_ALLOW;
@@ -235,7 +230,7 @@  discard block
 block discarded – undo
235 230
 
236 231
 		$this->compiler->setDelimiters($this->left_delimiter, $this->right_delimiter);
237 232
 
238
-		return $this->get($tpl, $this->dataProvider, $this->compiler, $display===true);
233
+		return $this->get($tpl, $this->dataProvider, $this->compiler, $display === true);
239 234
 	}
240 235
 
241 236
 	public function get($_tpl, $data = array(), $_compiler = null, $_output = false)
@@ -246,7 +241,7 @@  discard block
 block discarded – undo
246 241
 		return parent::get($_tpl, $data, $_compiler, $_output);
247 242
 	}
248 243
 
249
-	public function register_function($name, $callback, $cacheable=true, $cache_attrs=null)
244
+	public function register_function($name, $callback, $cacheable = true, $cache_attrs = null)
250 245
 	{
251 246
 		if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_FUNCTION) {
252 247
 			throw new Dwoo_Exception('Multiple plugins of different types can not share the same name');
@@ -259,7 +254,7 @@  discard block
 block discarded – undo
259 254
 		unset($this->plugins[$name]);
260 255
 	}
261 256
 
262
-	public function register_block($name, $callback, $cacheable=true, $cache_attrs=null)
257
+	public function register_block($name, $callback, $cacheable = true, $cache_attrs = null)
263 258
 	{
264 259
 		if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_BLOCK) {
265 260
 			throw new Dwoo_Exception('Multiple plugins of different types can not share the same name');
@@ -390,7 +385,7 @@  discard block
 block discarded – undo
390 385
    		return $this->isCached($this->makeTemplate($tpl, $cacheId, $compileId));
391 386
    	}
392 387
 
393
-   	public function append_by_ref($var, &$value, $merge=false)
388
+   	public function append_by_ref($var, &$value, $merge = false)
394 389
    	{
395 390
    		$this->dataProvider->appendByRef($var, $value, $merge);
396 391
    	}
@@ -410,7 +405,7 @@  discard block
 block discarded – undo
410 405
    		$this->dataProvider->clear();
411 406
    	}
412 407
 
413
-	public function get_template_vars($name=null)
408
+	public function get_template_vars($name = null)
414 409
 	{
415 410
 		if ($this->show_compat_errors) {
416 411
 			trigger_error('get_template_vars does not return values by reference, if you try to modify the data that way you should modify your code.', E_USER_NOTICE);
@@ -465,7 +460,7 @@  discard block
 block discarded – undo
465 460
 		return self::$tplCache[$hash];
466 461
 	}
467 462
 
468
-	public function triggerError($message, $level=E_USER_NOTICE)
463
+	public function triggerError($message, $level = E_USER_NOTICE)
469 464
 	{
470 465
 		if (is_object($this->template)) {
471 466
 			return parent::triggerError($message, $level);
Please login to merge, or discard this patch.
lib/Dwoo/Plugin.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		$out = '';
73 73
 		foreach ($params as $attr=>$val) {
74 74
 			$out .= ' '.$attr.'=';
75
-			if (trim($val, '"\'')=='' || $val=='null') {
75
+			if (trim($val, '"\'') == '' || $val == 'null') {
76 76
 				$out .= str_replace($delim, '\\'.$delim, '""');
77 77
 			} elseif (substr($val, 0, 1) === $delim && substr($val, -1) === $delim) {
78 78
 				$out .= str_replace($delim, '\\'.$delim, '"'.substr($val, 1, -1).'"');
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 					$escapedVal = '.'.$val.'.';
89 89
 				}
90 90
 
91
-				$out .= str_replace($delim, '\\'.$delim, '"') .
92
-					$delim . $escapedVal . $delim .
91
+				$out .= str_replace($delim, '\\'.$delim, '"').
92
+					$delim.$escapedVal.$delim.
93 93
 					str_replace($delim, '\\'.$delim, '"');
94 94
 			}
95 95
 		}
Please login to merge, or discard this patch.
lib/Dwoo/Security/Policy.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,8 +45,7 @@
 block discarded – undo
45 45
 	 *
46 46
 	 * @var array
47 47
 	 */
48
-	protected $allowedPhpFunctions = array
49
-	(
48
+	protected $allowedPhpFunctions = array(
50 49
 		'str_repeat' => true,
51 50
 		'number_format' => true,
52 51
 		'htmlentities' => true,
Please login to merge, or discard this patch.
Braces   +30 added lines, -24 removed lines patch added patch discarded remove patch
@@ -100,11 +100,12 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function allowPhpFunction($func)
102 102
 	{
103
-		if (is_array($func))
104
-			foreach ($func as $fname)
103
+		if (is_array($func)) {
104
+					foreach ($func as $fname)
105 105
 				$this->allowedPhpFunctions[strtolower($fname)] = true;
106
-		else
107
-			$this->allowedPhpFunctions[strtolower($func)] = true;
106
+		} else {
107
+					$this->allowedPhpFunctions[strtolower($func)] = true;
108
+		}
108 109
 	}
109 110
 
110 111
 	/**
@@ -114,11 +115,12 @@  discard block
 block discarded – undo
114 115
 	 */
115 116
 	public function disallowPhpFunction($func)
116 117
 	{
117
-		if (is_array($func))
118
-			foreach ($func as $fname)
118
+		if (is_array($func)) {
119
+					foreach ($func as $fname)
119 120
 				unset($this->allowedPhpFunctions[strtolower($fname)]);
120
-		else
121
-			unset($this->allowedPhpFunctions[strtolower($func)]);
121
+		} else {
122
+					unset($this->allowedPhpFunctions[strtolower($func)]);
123
+		}
122 124
 	}
123 125
 
124 126
 	/**
@@ -142,11 +144,12 @@  discard block
 block discarded – undo
142 144
 	 */
143 145
 	public function allowMethod($class, $method = null)
144 146
 	{
145
-		if (is_array($class))
146
-			foreach ($class as $elem)
147
+		if (is_array($class)) {
148
+					foreach ($class as $elem)
147 149
 				$this->allowedMethods[strtolower($elem[0])][strtolower($elem[1])] = true;
148
-		else
149
-			$this->allowedMethods[strtolower($class)][strtolower($method)] = true;
150
+		} else {
151
+					$this->allowedMethods[strtolower($class)][strtolower($method)] = true;
152
+		}
150 153
 	}
151 154
 
152 155
 	/**
@@ -157,11 +160,12 @@  discard block
 block discarded – undo
157 160
 	 */
158 161
 	public function disallowMethod($class, $method = null)
159 162
 	{
160
-		if (is_array($class))
161
-			foreach ($class as $elem)
163
+		if (is_array($class)) {
164
+					foreach ($class as $elem)
162 165
 				unset($this->allowedMethods[strtolower($elem[0])][strtolower($elem[1])]);
163
-		else
164
-			unset($this->allowedMethods[strtolower($class)][strtolower($method)]);
166
+		} else {
167
+					unset($this->allowedMethods[strtolower($class)][strtolower($method)]);
168
+		}
165 169
 	}
166 170
 
167 171
 	/**
@@ -185,11 +189,12 @@  discard block
 block discarded – undo
185 189
 	 */
186 190
 	public function allowDirectory($path)
187 191
 	{
188
-		if (is_array($path))
189
-			foreach ($path as $dir)
192
+		if (is_array($path)) {
193
+					foreach ($path as $dir)
190 194
 				$this->allowedDirectories[realpath($dir)] = true;
191
-		else
192
-			$this->allowedDirectories[realpath($path)] = true;
195
+		} else {
196
+					$this->allowedDirectories[realpath($path)] = true;
197
+		}
193 198
 	}
194 199
 
195 200
 	/**
@@ -199,11 +204,12 @@  discard block
 block discarded – undo
199 204
 	 */
200 205
 	public function disallowDirectory($path)
201 206
 	{
202
-		if (is_array($path))
203
-			foreach ($path as $dir)
207
+		if (is_array($path)) {
208
+					foreach ($path as $dir)
204 209
 				unset($this->allowedDirectories[realpath($dir)]);
205
-		else
206
-			unset($this->allowedDirectories[realpath($path)]);
210
+		} else {
211
+					unset($this->allowedDirectories[realpath($path)]);
212
+		}
207 213
 	}
208 214
 
209 215
 	/**
Please login to merge, or discard this patch.
lib/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,14 +97,14 @@
 block discarded – undo
97 97
         $CI->benchmark->mark('dwoo_parse_start');
98 98
 
99 99
         // Check if file exists
100
-        if ( !file_exists($this->template_dir . $sTemplate ) ) {
100
+        if (!file_exists($this->template_dir.$sTemplate)) {
101 101
             $message = sprintf('Template file \'%s\' not found.', $sTemplate);
102 102
             show_error($message);
103 103
             log_message('error', $message);
104 104
         }
105 105
 
106 106
         // Create new template
107
-        $tpl = new Dwoo_Template_File($this->template_dir . $sTemplate);
107
+        $tpl = new Dwoo_Template_File($this->template_dir.$sTemplate);
108 108
 
109 109
         // render the template
110 110
         $template = $this->get($tpl, $this->dwoo_data);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php if (!defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 
3 5
 require "dwoo/dwooAutoload.php";
4 6
 
Please login to merge, or discard this patch.
lib/Dwoo/Adapters/CodeIgniter/config/dwootemplate.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
2 2
 
3 3
 // The name of the directory where templates are located.
4
-$config['template_dir'] = dirname(FCPATH) . '/../application/views/';
4
+$config['template_dir'] = dirname(FCPATH).'/../application/views/';
5 5
 
6 6
 // The directory where compiled templates are located
7
-$config['compileDir']   = dirname(FCPATH) . '/../compile/';
7
+$config['compileDir']   = dirname(FCPATH).'/../compile/';
8 8
 
9 9
 //This tells Dwoo whether or not to cache the output of the templates to the $cache_dir.
10 10
 $config['caching']      = 0;
11
-$config['cacheDir']     = dirname(FCPATH) . '/../cache/';
11
+$config['cacheDir']     = dirname(FCPATH).'/../cache/';
12 12
 $config['cacheTime']    = 0;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php  if (!defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 
3 5
 // The name of the directory where templates are located.
4 6
 $config['template_dir'] = dirname(FCPATH) . '/../application/views/';
Please login to merge, or discard this patch.