Completed
Branch 1.2 (459185)
by David
04:06
created
lib/plugins/builtin/functions/math.php 1 patch
Spacing   +14 added lines, -16 removed lines patch added patch discarded remove patch
@@ -28,13 +28,12 @@  discard block
 block discarded – undo
28 28
  * @date       2008-10-23
29 29
  * @package    Dwoo
30 30
  */
31
-function Dwoo_Plugin_math_compile(Dwoo_Compiler $compiler, $equation, $format='', $assign='', array $rest=array())
31
+function Dwoo_Plugin_math_compile(Dwoo_Compiler $compiler, $equation, $format = '', $assign = '', array $rest = array())
32 32
 {
33 33
 	/**
34 34
 	 * Holds the allowed function, characters, operators and constants
35 35
 	 */
36
-	$allowed = array
37
-	(
36
+	$allowed = array(
38 37
 		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
39 38
 		'+', '-', '/', '*', '.', ' ', '<<', '>>', '%', '&', '^', '|', '~',
40 39
 		'abs(', 'ceil(', 'floor(', 'exp(', 'log10(',
@@ -45,8 +44,7 @@  discard block
 block discarded – undo
45 44
 	/**
46 45
 	 * Holds the functions that can accept multiple arguments
47 46
 	 */
48
-	$funcs = array
49
-	(
47
+	$funcs = array(
50 48
  		'round(', 'log(', 'pow(',
51 49
 		'max(', 'min(', 'rand(',
52 50
  	);
@@ -64,12 +62,12 @@  discard block
 block discarded – undo
64 62
 		$substr = substr($equation, 0, $ptr);
65 63
 		if (array_search($substr, $allowed) !== false) {
66 64
 			// allowed string
67
-			$out.=$substr;
65
+			$out .= $substr;
68 66
 			$equation = substr($equation, $ptr);
69 67
 			$ptr = 0;
70 68
 		} elseif (array_search($substr, $funcs) !== false) {
71 69
 			// allowed func
72
-			$out.=$substr;
70
+			$out .= $substr;
73 71
 			$equation = substr($equation, $ptr);
74 72
 			$ptr = 0;
75 73
 			$allowcomma++;
@@ -78,7 +76,7 @@  discard block
 block discarded – undo
78 76
 			}
79 77
 		} elseif (isset($rest[$substr])) {
80 78
 			// variable
81
-			$out.=$rest[$substr];
79
+			$out .= $rest[$substr];
82 80
 			$equation = substr($equation, $ptr);
83 81
 			$ptr = 0;
84 82
 		} elseif ($substr === $open) {
@@ -87,28 +85,28 @@  discard block
 block discarded – undo
87 85
 			if (empty($m)) {
88 86
 				preg_match('#.*?'.str_replace('.', '\\.', $close).'#', substr($equation, 2), $m);
89 87
 			}
90
-			$out.=substr($m[0], 0, -2);
88
+			$out .= substr($m[0], 0, -2);
91 89
 			$equation = substr($equation, strlen($m[0])+2);
92 90
 			$ptr = 0;
93
-		} elseif ($substr==='(') {
91
+		} elseif ($substr === '(') {
94 92
 			// opening parenthesis
95
-			if ($allowcomma>0) {
93
+			if ($allowcomma > 0) {
96 94
 				$allowcomma++;
97 95
 			}
98 96
 
99
-			$out.=$substr;
97
+			$out .= $substr;
100 98
 			$equation = substr($equation, $ptr);
101 99
 			$ptr = 0;
102
-		} elseif ($substr===')') {
100
+		} elseif ($substr === ')') {
103 101
 			// closing parenthesis
104
-			if ($allowcomma>0) {
102
+			if ($allowcomma > 0) {
105 103
 				$allowcomma--;
106
-				if ($allowcomma===0) {
104
+				if ($allowcomma === 0) {
107 105
 					array_pop($allowed);
108 106
 				}
109 107
 			}
110 108
 
111
-			$out.=$substr;
109
+			$out .= $substr;
112 110
 			$equation = substr($equation, $ptr);
113 111
 			$ptr = 0;
114 112
 		} elseif ($ptr >= strlen($equation)) {
Please login to merge, or discard this patch.
lib/plugins/builtin/functions/extends.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 	public static function compile(Dwoo_Compiler $compiler, $file)
28 28
 	{
29 29
 		list($l, $r) = $compiler->getDelimiters();
30
-		self::$l = preg_quote($l,'/');
31
-		self::$r = preg_quote($r,'/');
30
+		self::$l = preg_quote($l, '/');
31
+		self::$r = preg_quote($r, '/');
32 32
 		self::$regex = '/
33 33
 			'.self::$l.'block\s(["\']?)(.+?)\1'.self::$r.'(?:\r?\n?)
34 34
 			((?:
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 			self::$r = '\s*'.self::$r;
50 50
 		}
51 51
 		$inheritanceTree = array(array('source'=>$compiler->getTemplateSource()));
52
-		$curPath = dirname($compiler->getDwoo()->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR;
52
+		$curPath = dirname($compiler->getDwoo()->getTemplate()->getResourceIdentifier()).DIRECTORY_SEPARATOR;
53 53
 		$curTpl = $compiler->getDwoo()->getTemplate();
54 54
 
55 55
 		while (!empty($file)) {
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 			$inheritanceTree[] = $newParent;
91 91
 
92 92
 			if (preg_match('/^'.self::$l.'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?'.self::$r.'/i', $parent->getSource(), $match)) {
93
-				$curPath = dirname($identifier) . DIRECTORY_SEPARATOR;
93
+				$curPath = dirname($identifier).DIRECTORY_SEPARATOR;
94 94
 				if (isset($match[2]) && $match[2] == '"') {
95 95
 					$file = '"'.str_replace('"', '\\"', substr($match[1], 1, -1)).'"';
96 96
 				} elseif (isset($match[2]) && $match[2] == "'") {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		}
141 141
 
142 142
 		if (preg_match(self::$regex, $matches[3])) {
143
-			return preg_replace_callback(self::$regex, array('Dwoo_Plugin_extends', 'replaceBlock'), $matches[3] );
143
+			return preg_replace_callback(self::$regex, array('Dwoo_Plugin_extends', 'replaceBlock'), $matches[3]);
144 144
 		}
145 145
 
146 146
 		if (self::$lastReplacement) {
Please login to merge, or discard this patch.
lib/plugins/builtin/functions/replace.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
  */
21 21
 function Dwoo_Plugin_replace_compile(Dwoo_Compiler $compiler, $value, $search, $replace, $case_sensitive = true)
22 22
 {
23
-	if ($case_sensitive == 'false' || (bool)$case_sensitive === false) {
23
+	if ($case_sensitive == 'false' || (bool) $case_sensitive === false) {
24 24
 		return 'str_ireplace('.$search.', '.$replace.', '.$value.')';
25 25
 	} else {
26 26
 		return 'str_replace('.$search.', '.$replace.', '.$value.')';
Please login to merge, or discard this patch.
lib/plugins/builtin/functions/strip_tags.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@
 block discarded – undo
17 17
  * @date       2008-10-23
18 18
  * @package    Dwoo
19 19
  */
20
-function Dwoo_Plugin_strip_tags_compile(Dwoo_Compiler $compiler, $value, $addspace=true)
20
+function Dwoo_Plugin_strip_tags_compile(Dwoo_Compiler $compiler, $value, $addspace = true)
21 21
 {
22
-	if ($addspace==='true') {
22
+	if ($addspace === 'true') {
23 23
 		return "preg_replace('#<[^>]*>#', ' ', $value)";
24 24
 	} else {
25 25
 		return "strip_tags($value)";
Please login to merge, or discard this patch.
lib/plugins/builtin/functions/mailto.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * @date       2009-07-18
25 25
  * @package    Dwoo
26 26
  */
27
-function Dwoo_Plugin_mailto(Dwoo_Core $dwoo, $address, $text=null, $subject=null, $encode=null, $cc=null, $bcc=null, $newsgroups=null, $followupto=null, $extra=null)
27
+function Dwoo_Plugin_mailto(Dwoo_Core $dwoo, $address, $text = null, $subject = null, $encode = null, $cc = null, $bcc = null, $newsgroups = null, $followupto = null, $extra = null)
28 28
 {
29 29
 	if (empty($address)) {
30 30
 		return '';
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	$address = rtrim($address, '?&');
56 56
 
57 57
 	// output
58
-	switch($encode)
58
+	switch ($encode)
59 59
 	{
60 60
 
61 61
 	case 'none':
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		$len = strlen($str);
69 69
 
70 70
 		$out = '';
71
-		for ($i=0; $i<$len; $i++) {
71
+		for ($i = 0; $i < $len; $i++) {
72 72
 			$out .= '%'.bin2hex($str[$i]);
73 73
 		}
74 74
 		return '<script type="text/javascript">eval(unescape(\''.$out.'\'));</script>';
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 		$len = strlen($str);
83 83
 
84 84
 		$out = '<script type="text/javascript">'."\n<!--\ndocument.write(String.fromCharCode(";
85
-		for ($i=0; $i<$len; $i++) {
85
+		for ($i = 0; $i < $len; $i++) {
86 86
 			$out .= ord($str[$i]).',';
87 87
 		}
88
-		return rtrim($out, ',') . "));\n-->\n</script>\n";
88
+		return rtrim($out, ',')."));\n-->\n</script>\n";
89 89
 
90 90
 		break;
91 91
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
 		$out = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;';
98 98
 		$len = strlen($address);
99
-		for ($i=0; $i<$len; $i++) {
99
+		for ($i = 0; $i < $len; $i++) {
100 100
 			if (preg_match('#\w#', $address[$i])) {
101 101
 				$out .= '%'.bin2hex($address[$i]);
102 102
 			} else {
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		}
106 106
 		$out .= '" '.$extra.'>';
107 107
 		$len = strlen($text);
108
-		for ($i=0; $i<$len; $i++) {
108
+		for ($i = 0; $i < $len; $i++) {
109 109
 			$out .= '&#x'.bin2hex($text[$i]);
110 110
 		}
111 111
 		return $out.'</a>';
Please login to merge, or discard this patch.
lib/plugins/builtin/functions/indent.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
  * @date       2008-10-23
19 19
  * @package    Dwoo
20 20
  */
21
-function Dwoo_Plugin_indent_compile(Dwoo_Compiler $compiler, $value, $by=4, $char=' ')
21
+function Dwoo_Plugin_indent_compile(Dwoo_Compiler $compiler, $value, $by = 4, $char = ' ')
22 22
 {
23 23
 	return "preg_replace('#^#m', '".str_repeat(substr($char, 1, -1), trim($by, '"\''))."', $value)";
24 24
 }
Please login to merge, or discard this patch.
lib/Dwoo/Core.php 1 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/Smarty/Adapter.php 1 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/Data.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	{
93 93
 		if (is_array($name)) {
94 94
 			reset($name);
95
-			while (list($k,$v) = each($name))
95
+			while (list($k, $v) = each($name))
96 96
 				$this->data[$k] = $v;
97 97
 		} else {
98 98
 			$this->data[$name] = $val;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function assignByRef($name, &$val)
121 121
 	{
122
-		$this->data[$name] =& $val;
122
+		$this->data[$name] = & $val;
123 123
 	}
124 124
 
125 125
 	/**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 				}
141 141
 
142 142
 				if ($merge === true && is_array($val)) {
143
-					$this->data[$key] = $val + $this->data[$key];
143
+					$this->data[$key] = $val+$this->data[$key];
144 144
 				} else {
145 145
 					$this->data[$key][] = $val;
146 146
 				}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 			}
154 154
 
155 155
 			if ($merge === true && is_array($val)) {
156
-				$this->data[$name] = $val + $this->data[$name];
156
+				$this->data[$name] = $val+$this->data[$name];
157 157
 			} else {
158 158
 				$this->data[$name][] = $val;
159 159
 			}
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 
177 177
    		if ($merge === true && is_array($val)) {
178 178
    			foreach ($val as $key => &$value) {
179
-   				$this->data[$name][$key] =& $value;
179
+   				$this->data[$name][$key] = & $value;
180 180
    			}
181 181
    		} else {
182
-   			$this->data[$name][] =& $val;
182
+   			$this->data[$name][] = & $val;
183 183
    		}
184 184
    	}
185 185
    	
Please login to merge, or discard this patch.