Completed
Branch 1.2 (459185)
by David
04:06
created
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/Compiler.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	/**
273 273
 	 * returns the left and right template delimiters
274 274
 	 *
275
-	 * @return array containing the left and the right delimiters
275
+	 * @return string[] containing the left and the right delimiters
276 276
 	 */
277 277
 	public function getDelimiters()
278 278
 	{
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * adds a preprocessor to the compiler, it will be called
361 361
 	 * before the template is compiled
362 362
 	 *
363
-	 * @param mixed $callback either a valid callback to the preprocessor or a simple name if the autoload is set to true
363
+	 * @param string $callback either a valid callback to the preprocessor or a simple name if the autoload is set to true
364 364
 	 * @param bool $autoload if set to true, the preprocessor is auto-loaded from one of the plugin directories, else you must provide a valid callback
365 365
 	 */
366 366
 	public function addPreProcessor($callback, $autoload = false)
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 	 * returns the token of each parameter out of the given parameter array
1231 1231
 	 *
1232 1232
 	 * @param array $params parameter array
1233
-	 * @return array tokens
1233
+	 * @return Dwoo_Compiler tokens
1234 1234
 	 */
1235 1235
 	public function getParamTokens(array $params)
1236 1236
 	{
Please login to merge, or discard this patch.
Spacing   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 		} elseif (($index = array_search('Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback), $this->processors['pre'], true)) !== false) {
396 396
 			unset($this->processors['pre'][$index]);
397 397
 		} else {
398
-			$class = 'Dwoo_Processor_' . str_replace('Dwoo_Processor_', '', $callback);
398
+			$class = 'Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback);
399 399
 			foreach ($this->processors['pre'] as $index=>$proc) {
400 400
 				if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) {
401 401
 					unset($this->processors['pre'][$index]);
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 			unset($this->processors['post'][$index]);
444 444
 		} elseif (($index = array_search('Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback), $this->processors['post'], true)) !== false) {
445 445
 			unset($this->processors['post'][$index]);
446
-		} else	{
447
-			$class = 'Dwoo_Processor_' . str_replace('Dwoo_Processor_', '', $callback);
446
+		} else {
447
+			$class = 'Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback);
448 448
 			foreach ($this->processors['post'] as $index=>$proc) {
449 449
 				if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) {
450 450
 					unset($this->processors['post'][$index]);
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 	public function setTemplateSource($newSource, $fromPointer = false)
652 652
 	{
653 653
 		if ($fromPointer === true) {
654
-			$this->templateSource = substr($this->templateSource, 0, $this->pointer) . $newSource;
654
+			$this->templateSource = substr($this->templateSource, 0, $this->pointer).$newSource;
655 655
 		} else {
656 656
 			$this->templateSource = $newSource;
657 657
 		}
@@ -699,16 +699,16 @@  discard block
 block discarded – undo
699 699
 		$ptr = 0;
700 700
 		$this->dwoo = $dwoo;
701 701
 		$this->template = $template;
702
-		$this->templateSource =& $tpl;
703
-		$this->pointer =& $ptr;
702
+		$this->templateSource = & $tpl;
703
+		$this->pointer = & $ptr;
704 704
 
705 705
 		while (true) {
706 706
 			// if pointer is at the beginning, reset everything, that allows a plugin to externally reset the compiler if everything must be reparsed
707
-			if ($ptr===0) {
707
+			if ($ptr === 0) {
708 708
 				// resets variables
709 709
 				$this->usedPlugins = array();
710 710
 				$this->data = array();
711
-				$this->scope =& $this->data;
711
+				$this->scope = & $this->data;
712 712
 				$this->scopeTree = array();
713 713
 				$this->stack = array();
714 714
 				$this->line = 1;
@@ -719,10 +719,10 @@  discard block
 block discarded – undo
719 719
 
720 720
 				if ($this->debug) {
721 721
 					echo "\n";
722
-					echo 'COMPILER INIT' . "\n";
722
+					echo 'COMPILER INIT'."\n";
723 723
 				}
724 724
 
725
-				if ($this->debug) echo 'PROCESSING PREPROCESSORS ('.count($this->processors['pre']).')' . "\n";
725
+				if ($this->debug) echo 'PROCESSING PREPROCESSORS ('.count($this->processors['pre']).')'."\n";
726 726
 
727 727
 				// runs preprocessors
728 728
 				foreach ($this->processors['pre'] as $preProc) {
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 				unset($preProc);
739 739
 
740 740
 				// show template source if debug
741
-				if ($this->debug) echo '<pre>'.print_r(htmlentities($tpl), true).'</pre>' . "\n";
741
+				if ($this->debug) echo '<pre>'.print_r(htmlentities($tpl), true).'</pre>'."\n";
742 742
 
743 743
 				// strips php tags if required by the security policy
744 744
 				if ($this->securityPolicy !== null) {
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 					if (ini_get('short_open_tags')) {
747 747
 						$search = array('{<\?.*?\?>}', '{<%.*?%>}');
748 748
 					}
749
-					switch($this->securityPolicy->getPhpHandling()) {
749
+					switch ($this->securityPolicy->getPhpHandling()) {
750 750
 
751 751
 					case Dwoo_Security_Policy::PHP_ALLOW:
752 752
 						break;
@@ -766,14 +766,14 @@  discard block
 block discarded – undo
766 766
 				$this->push(substr($tpl, $ptr), 0);
767 767
 				break;
768 768
 			} elseif (substr($tpl, $pos-1, 1) === '\\' && substr($tpl, $pos-2, 1) !== '\\') {
769
-				$this->push(substr($tpl, $ptr, $pos-$ptr-1) . $this->ld);
769
+				$this->push(substr($tpl, $ptr, $pos-$ptr-1).$this->ld);
770 770
 				$ptr = $pos+strlen($this->ld);
771
-			} elseif (preg_match('/^'.$this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . 'literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr.'/s', substr($tpl, $pos), $litOpen)) {
772
-				if (!preg_match('/'.$this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . '\/literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr.'/s', $tpl, $litClose, PREG_OFFSET_CAPTURE, $pos)) {
771
+			} elseif (preg_match('/^'.$this->ldr.($this->allowLooseOpenings ? '\s*' : '').'literal'.($this->allowLooseOpenings ? '\s*' : '').$this->rdr.'/s', substr($tpl, $pos), $litOpen)) {
772
+				if (!preg_match('/'.$this->ldr.($this->allowLooseOpenings ? '\s*' : '').'\/literal'.($this->allowLooseOpenings ? '\s*' : '').$this->rdr.'/s', $tpl, $litClose, PREG_OFFSET_CAPTURE, $pos)) {
773 773
 					throw new Dwoo_Compilation_Exception($this, 'The {literal} blocks must be closed explicitly with {/literal}');
774 774
 				}
775 775
 				$endpos = $litClose[0][1];
776
-				$this->push(substr($tpl, $ptr, $pos-$ptr) . substr($tpl, $pos + strlen($litOpen[0]), $endpos-$pos-strlen($litOpen[0])));
776
+				$this->push(substr($tpl, $ptr, $pos-$ptr).substr($tpl, $pos+strlen($litOpen[0]), $endpos-$pos-strlen($litOpen[0])));
777 777
 				$ptr = $endpos+strlen($litClose[0][0]);
778 778
 			} else {
779 779
 				if (substr($tpl, $pos-2, 1) === '\\' && substr($tpl, $pos-1, 1) === '\\') {
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 				$pos += strlen($this->ld);
788 788
 				if ($this->allowLooseOpenings) {
789 789
 					while (substr($tpl, $pos, 1) === ' ') {
790
-						$pos+=1;
790
+						$pos += 1;
791 791
 					}
792 792
 				} else {
793 793
 					if (substr($tpl, $pos, 1) === ' ' || substr($tpl, $pos, 1) === "\r" || substr($tpl, $pos, 1) === "\n" || substr($tpl, $pos, 1) === "\t") {
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 						continue 2;
815 815
 					}
816 816
 
817
-					$len = $subptr - $ptr;
817
+					$len = $subptr-$ptr;
818 818
 					$this->push($parsed, substr_count(substr($tpl, $ptr, $len), "\n"));
819 819
 					$ptr += $len;
820 820
 
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 
828 828
 		$compiled .= $this->removeBlock('topLevelBlock');
829 829
 
830
-		if ($this->debug) echo 'PROCESSING POSTPROCESSORS' . "\n";
830
+		if ($this->debug) echo 'PROCESSING POSTPROCESSORS'."\n";
831 831
 
832 832
 		foreach ($this->processors['post'] as $postProc) {
833 833
 			if (is_array($postProc) && isset($postProc['autoload'])) {
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 		}
842 842
 		unset($postProc);
843 843
 
844
-		if ($this->debug) echo 'COMPILATION COMPLETE : MEM USAGE : '.memory_get_usage() . "\n";
844
+		if ($this->debug) echo 'COMPILATION COMPLETE : MEM USAGE : '.memory_get_usage()."\n";
845 845
 
846 846
 		$output = "<?php\n/* template head */\n";
847 847
 
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 				continue;
852 852
 			}
853 853
 
854
-			switch($type) {
854
+			switch ($type) {
855 855
 
856 856
 			case Dwoo_Core::BLOCK_PLUGIN:
857 857
 			case Dwoo_Core::CLASS_PLUGIN:
@@ -891,24 +891,24 @@  discard block
 block discarded – undo
891 891
 
892 892
 		$output .= $compiled."\n?>";
893 893
 
894
-		$output = preg_replace('/(?<!;|\}|\*\/|\n|\{)(\s*'.preg_quote(self::PHP_CLOSE, '/') . preg_quote(self::PHP_OPEN, '/').')/', ";\n", $output);
895
-		$output = str_replace(self::PHP_CLOSE . self::PHP_OPEN, "\n", $output);
894
+		$output = preg_replace('/(?<!;|\}|\*\/|\n|\{)(\s*'.preg_quote(self::PHP_CLOSE, '/').preg_quote(self::PHP_OPEN, '/').')/', ";\n", $output);
895
+		$output = str_replace(self::PHP_CLOSE.self::PHP_OPEN, "\n", $output);
896 896
 
897 897
 		// handle <?xml tag at the beginning
898 898
 		$output = preg_replace('#(/\* template body \*/ \?>\s*)<\?xml#is', '$1<?php echo \'<?xml\'; ?>', $output);
899 899
 
900 900
 		// add another line break after PHP closing tags that have a line break following,
901 901
 		// as we do not know whether it's intended, and PHP will strip it otherwise
902
-		$output = preg_replace('/(?<!"|<\?xml)\s*\?>\n/', '$0' . "\n", $output);
902
+		$output = preg_replace('/(?<!"|<\?xml)\s*\?>\n/', '$0'."\n", $output);
903 903
 
904 904
 		if ($this->debug) {
905
-			echo '=============================================================================================' . "\n";
905
+			echo '============================================================================================='."\n";
906 906
 			$lines = preg_split('{\r\n|\n|<br />}', $output);
907 907
 			array_shift($lines);
908 908
 			foreach ($lines as $i=>$line) {
909 909
 				echo ($i+1).'. '.$line."\r\n";
910 910
 			}
911
-			echo '=============================================================================================' . "\n";
911
+			echo '============================================================================================='."\n";
912 912
 		}
913 913
 
914 914
 		$this->template = $this->dwoo = null;
@@ -976,17 +976,17 @@  discard block
 block discarded – undo
976 976
 	{
977 977
 		$old = $this->scopeTree;
978 978
 
979
-		if ($scope===null) {
979
+		if ($scope === null) {
980 980
 			unset($this->scope);
981 981
 			$this->scope = null;
982 982
 		}
983 983
 
984
-		if (is_array($scope)===false) {
984
+		if (is_array($scope) === false) {
985 985
 			$scope = explode('.', $scope);
986 986
 		}
987 987
 
988
-		if ($absolute===true) {
989
-			$this->scope =& $this->data;
988
+		if ($absolute === true) {
989
+			$this->scope = & $this->data;
990 990
 			$this->scopeTree = array();
991 991
 		}
992 992
 
@@ -994,19 +994,19 @@  discard block
 block discarded – undo
994 994
 			if ($bit === '_parent' || $bit === '_') {
995 995
 				array_pop($this->scopeTree);
996 996
 				reset($this->scopeTree);
997
-				$this->scope =& $this->data;
997
+				$this->scope = & $this->data;
998 998
 				$cnt = count($this->scopeTree);
999
-				for ($i=0;$i<$cnt;$i++)
1000
-					$this->scope =& $this->scope[$this->scopeTree[$i]];
999
+				for ($i = 0; $i < $cnt; $i++)
1000
+					$this->scope = & $this->scope[$this->scopeTree[$i]];
1001 1001
 			} elseif ($bit === '_root' || $bit === '__') {
1002
-				$this->scope =& $this->data;
1002
+				$this->scope = & $this->data;
1003 1003
 				$this->scopeTree = array();
1004 1004
 			} elseif (isset($this->scope[$bit])) {
1005
-				$this->scope =& $this->scope[$bit];
1005
+				$this->scope = & $this->scope[$bit];
1006 1006
 				$this->scopeTree[] = $bit;
1007 1007
 			} else {
1008 1008
 				$this->scope[$bit] = array();
1009
-				$this->scope =& $this->scope[$bit];
1009
+				$this->scope = & $this->scope[$bit];
1010 1010
 				$this->scopeTree[] = $bit;
1011 1011
 			}
1012 1012
 		}
@@ -1033,8 +1033,8 @@  discard block
 block discarded – undo
1033 1033
 		$params = $this->mapParams($params, array($class, 'init'), $paramtype);
1034 1034
 
1035 1035
 		$this->stack[] = array('type' => $type, 'params' => $params, 'custom' => false, 'class' => $class, 'buffer' => null);
1036
-		$this->curBlock =& $this->stack[count($this->stack)-1];
1037
-		return call_user_func(array($class,'preProcessing'), $this, $params, '', '', $type);
1036
+		$this->curBlock = & $this->stack[count($this->stack)-1];
1037
+		return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type);
1038 1038
 	}
1039 1039
 
1040 1040
 	/**
@@ -1057,8 +1057,8 @@  discard block
 block discarded – undo
1057 1057
 		$params = $this->mapParams($params, array($class, 'init'), $paramtype);
1058 1058
 
1059 1059
 		$this->stack[] = array('type' => $type, 'params' => $params, 'custom' => true, 'class' => $class, 'buffer' => null);
1060
-		$this->curBlock =& $this->stack[count($this->stack)-1];
1061
-		return call_user_func(array($class,'preProcessing'), $this, $params, '', '', $type);
1060
+		$this->curBlock = & $this->stack[count($this->stack)-1];
1061
+		return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type);
1062 1062
 	}
1063 1063
 
1064 1064
 	/**
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 			$this->dwoo->getLoader()->loadPlugin($type);
1079 1079
 		}
1080 1080
 		$this->stack[] = array('type' => $type, 'params' => $params, 'custom' => false, 'class' => $class, 'buffer' => null);
1081
-		$this->curBlock =& $this->stack[count($this->stack)-1];
1081
+		$this->curBlock = & $this->stack[count($this->stack)-1];
1082 1082
 	}
1083 1083
 
1084 1084
 	/**
@@ -1106,11 +1106,11 @@  discard block
 block discarded – undo
1106 1106
 					$class = 'Dwoo_Plugin_'.$top['type'];
1107 1107
 				}
1108 1108
 				if (count($this->stack)) {
1109
-					$this->curBlock =& $this->stack[count($this->stack)-1];
1109
+					$this->curBlock = & $this->stack[count($this->stack)-1];
1110 1110
 					$this->push(call_user_func(array($class, 'postProcessing'), $this, $top['params'], '', '', $top['buffer']), 0);
1111 1111
 				} else {
1112 1112
 					$null = null;
1113
-					$this->curBlock =& $null;
1113
+					$this->curBlock = & $null;
1114 1114
 					$output = call_user_func(array($class, 'postProcessing'), $this, $top['params'], '', '', $top['buffer']);
1115 1115
 				}
1116 1116
 
@@ -1139,9 +1139,9 @@  discard block
 block discarded – undo
1139 1139
 	 */
1140 1140
 	public function &findBlock($type, $closeAlong = false)
1141 1141
 	{
1142
-		if ($closeAlong===true) {
1142
+		if ($closeAlong === true) {
1143 1143
 			while ($b = end($this->stack)) {
1144
-				if ($b['type']===$type) {
1144
+				if ($b['type'] === $type) {
1145 1145
 					return $this->stack[key($this->stack)];
1146 1146
 				}
1147 1147
 				$this->push($this->removeTopBlock(), 0);
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 		} else {
1150 1150
 			end($this->stack);
1151 1151
 			while ($b = current($this->stack)) {
1152
-				if ($b['type']===$type) {
1152
+				if ($b['type'] === $type) {
1153 1153
 					return $this->stack[key($this->stack)];
1154 1154
 				}
1155 1155
 				prev($this->stack);
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
 			$class = 'Dwoo_Plugin_'.$o['type'];
1190 1190
 		}
1191 1191
 
1192
-		$this->curBlock =& $this->stack[count($this->stack)-1];
1192
+		$this->curBlock = & $this->stack[count($this->stack)-1];
1193 1193
 
1194 1194
 		return call_user_func(array($class, 'postProcessing'), $this, $o['params'], '', '', $o['buffer']);
1195 1195
 	}
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 	 * @return string parsed values
1254 1254
 	 * @throws Dwoo_Compilation_Exception
1255 1255
 	 */
1256
-	protected function parse($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
1256
+	protected function parse($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
1257 1257
 	{
1258 1258
 		if ($this->debug) echo 'Compiler::'.__FUNCTION__."\n";
1259 1259
 
@@ -1266,11 +1266,11 @@  discard block
 block discarded – undo
1266 1266
 			throw new Dwoo_Compilation_Exception($this, 'Unexpected EOF, a template tag was not closed');
1267 1267
 		}
1268 1268
 
1269
-		while ($first===" " || $first==="\n" || $first==="\t" || $first==="\r") {
1269
+		while ($first === " " || $first === "\n" || $first === "\t" || $first === "\r") {
1270 1270
 			if ($curBlock === 'root' && substr($in, $from, strlen($this->rd)) === $this->rd) {
1271 1271
 				// end template tag
1272 1272
 				$pointer += strlen($this->rd);
1273
-				if ($this->debug) echo 'TEMPLATE PARSING ENDED' . "\n";
1273
+				if ($this->debug) echo 'TEMPLATE PARSING ENDED'."\n";
1274 1274
 				return false;
1275 1275
 			}
1276 1276
 			$from++;
@@ -1289,12 +1289,12 @@  discard block
 block discarded – undo
1289 1289
 
1290 1290
 		$substr = substr($in, $from, $to-$from);
1291 1291
 
1292
-		if ($this->debug) echo 'PARSE CALL : PARSING "<b>'.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').'</b>" @ '.$from.':'.$to.' in '.$curBlock.' : pointer='.$pointer. "\n";
1292
+		if ($this->debug) echo 'PARSE CALL : PARSING "<b>'.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...' : '').'</b>" @ '.$from.':'.$to.' in '.$curBlock.' : pointer='.$pointer."\n";
1293 1293
 		$parsed = "";
1294 1294
 
1295 1295
 		if ($curBlock === 'root' && $first === '*') {
1296 1296
 			$src = $this->getTemplateSource();
1297
-			$startpos = $this->getPointer() - strlen($this->ld);
1297
+			$startpos = $this->getPointer()-strlen($this->ld);
1298 1298
 			if (substr($src, $startpos, strlen($this->ld)) === $this->ld) {
1299 1299
 				if ($startpos > 0) {
1300 1300
 					do {
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 				if (!isset($whitespaceStart)) {
1311 1311
 					$startpos = $this->getPointer();
1312 1312
 				} else {
1313
-					$pointer -= $this->getPointer() - $startpos;
1313
+					$pointer -= $this->getPointer()-$startpos;
1314 1314
 				}
1315 1315
 
1316 1316
 				if ($this->allowNestedComments && strpos($src, $this->ld.'*', $this->getPointer()) !== false) {
@@ -1325,55 +1325,55 @@  discard block
 block discarded – undo
1325 1325
 
1326 1326
 						if ($open !== false && $close !== false) {
1327 1327
 							if ($open < $close) {
1328
-								$ptr = $open + strlen($comOpen);
1328
+								$ptr = $open+strlen($comOpen);
1329 1329
 								$level++;
1330 1330
 							} else {
1331
-								$ptr = $close + strlen($comClose);
1331
+								$ptr = $close+strlen($comClose);
1332 1332
 								$level--;
1333 1333
 							}
1334 1334
 						} elseif ($open !== false) {
1335
-							$ptr = $open + strlen($comOpen);
1335
+							$ptr = $open+strlen($comOpen);
1336 1336
 							$level++;
1337 1337
 						} elseif ($close !== false) {
1338
-							$ptr = $close + strlen($comClose);
1338
+							$ptr = $close+strlen($comClose);
1339 1339
 							$level--;
1340 1340
 						} else {
1341 1341
 							$ptr = strlen($src);
1342 1342
 						}
1343 1343
 					}
1344
-					$endpos = $ptr - strlen('*'.$this->rd);
1344
+					$endpos = $ptr-strlen('*'.$this->rd);
1345 1345
 				} else {
1346 1346
 					$endpos = strpos($src, '*'.$this->rd, $startpos);
1347 1347
 					if ($endpos == false) {
1348 1348
 						throw new Dwoo_Compilation_Exception($this, 'Un-ended comment');
1349 1349
 					}
1350 1350
 				}
1351
-				$pointer += $endpos - $startpos + strlen('*'.$this->rd);
1351
+				$pointer += $endpos-$startpos+strlen('*'.$this->rd);
1352 1352
 				if (isset($whitespaceStart) && preg_match('#^[\t ]*\r?\n#', substr($src, $endpos+strlen('*'.$this->rd)), $m)) {
1353 1353
 					$pointer += strlen($m[0]);
1354
-					$this->curBlock['buffer'] = substr($this->curBlock['buffer'], 0, strlen($this->curBlock['buffer']) - ($this->getPointer() - $startpos - strlen($this->ld)));
1354
+					$this->curBlock['buffer'] = substr($this->curBlock['buffer'], 0, strlen($this->curBlock['buffer'])-($this->getPointer()-$startpos-strlen($this->ld)));
1355 1355
 				}
1356 1356
 				return false;
1357 1357
 			}
1358 1358
 		}
1359 1359
 
1360
-		if ($first==='$') {
1360
+		if ($first === '$') {
1361 1361
 			// var
1362 1362
 			$out = $this->parseVar($in, $from, $to, $parsingParams, $curBlock, $pointer);
1363 1363
 			$parsed = 'var';
1364
-		} elseif ($first==='%' && preg_match('#^%[a-z_]#i', $substr)) {
1364
+		} elseif ($first === '%' && preg_match('#^%[a-z_]#i', $substr)) {
1365 1365
 			// const
1366 1366
 			$out = $this->parseConst($in, $from, $to, $parsingParams, $curBlock, $pointer);
1367
-		} elseif (($first==='"' || $first==="'") && !(is_array($parsingParams) && preg_match('#^([\'"])[a-z0-9_]+\1\s*=>?(?:\s+|[^=])#i', $substr))) {
1367
+		} elseif (($first === '"' || $first === "'") && !(is_array($parsingParams) && preg_match('#^([\'"])[a-z0-9_]+\1\s*=>?(?:\s+|[^=])#i', $substr))) {
1368 1368
 			// string
1369 1369
 			$out = $this->parseString($in, $from, $to, $parsingParams, $curBlock, $pointer);
1370
-		} 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)) {
1370
+		} 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)) {
1371 1371
 			// func
1372 1372
 			$out = $this->parseFunction($in, $from, $to, $parsingParams, $curBlock, $pointer);
1373 1373
 			$parsed = 'func';
1374 1374
 		} elseif ($first === ';') {
1375 1375
 			// instruction end
1376
-			if ($this->debug) echo 'END OF INSTRUCTION' . "\n";
1376
+			if ($this->debug) echo 'END OF INSTRUCTION'."\n";
1377 1377
 			if ($pointer !== null) {
1378 1378
 				$pointer++;
1379 1379
 			}
@@ -1393,22 +1393,22 @@  discard block
 block discarded – undo
1393 1393
 				if ($this->curBlock['type'] == 'else' || $this->curBlock['type'] == 'elseif') {
1394 1394
 					$pointer -= strlen($match[0]);
1395 1395
 				}
1396
-				if ($this->debug) echo 'TOP BLOCK CLOSED' . "\n";
1396
+				if ($this->debug) echo 'TOP BLOCK CLOSED'."\n";
1397 1397
 				return $this->removeTopBlock();
1398 1398
 			} else {
1399
-				if ($this->debug) echo 'BLOCK OF TYPE '.$match[1].' CLOSED' . "\n";
1399
+				if ($this->debug) echo 'BLOCK OF TYPE '.$match[1].' CLOSED'."\n";
1400 1400
 				return $this->removeBlock($match[1]);
1401 1401
 			}
1402 1402
 		} elseif ($curBlock === 'root' && substr($substr, 0, strlen($this->rd)) === $this->rd) {
1403 1403
 			// end template tag
1404
-			if ($this->debug) echo 'TAG PARSING ENDED' . "\n";
1404
+			if ($this->debug) echo 'TAG PARSING ENDED'."\n";
1405 1405
 			$pointer += strlen($this->rd);
1406 1406
 			return false;
1407
-		} elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*='.($curBlock === 'array' ? '>?':'').')(?:\s+|[^=]).*#i', $substr, $match)) {
1407
+		} elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*='.($curBlock === 'array' ? '>?' : '').')(?:\s+|[^=]).*#i', $substr, $match)) {
1408 1408
 			// named parameter
1409
-			if ($this->debug) echo 'NAMED PARAM FOUND' . "\n";
1409
+			if ($this->debug) echo 'NAMED PARAM FOUND'."\n";
1410 1410
 			$len = strlen($match[1]);
1411
-			while (substr($in, $from+$len, 1)===' ') {
1411
+			while (substr($in, $from+$len, 1) === ' ') {
1412 1412
 				$len++;
1413 1413
 			}
1414 1414
 			if ($pointer !== null) {
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
 				$out = $match[1];
1430 1430
 			}
1431 1431
 			$pointer += strlen($match[1]);
1432
-		} elseif ($substr!=='' && (is_array($parsingParams) || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'expression')) {
1432
+		} elseif ($substr !== '' && (is_array($parsingParams) || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'expression')) {
1433 1433
 			// unquoted string, bool or number
1434 1434
 			$out = $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer);
1435 1435
 		} else {
@@ -1444,19 +1444,19 @@  discard block
 block discarded – undo
1444 1444
 		$substr = substr($in, $pointer, $to-$pointer);
1445 1445
 
1446 1446
 		// var parsed, check if any var-extension applies
1447
-		if ($parsed==='var') {
1447
+		if ($parsed === 'var') {
1448 1448
 			if (preg_match('#^\s*([/%+*-])\s*([a-z0-9]|\$)#i', $substr, $match)) {
1449
-				if($this->debug) echo 'PARSING POST-VAR EXPRESSION '.$substr . "\n";
1449
+				if ($this->debug) echo 'PARSING POST-VAR EXPRESSION '.$substr."\n";
1450 1450
 				// parse expressions
1451
-				$pointer += strlen($match[0]) - 1;
1451
+				$pointer += strlen($match[0])-1;
1452 1452
 				if (is_array($parsingParams)) {
1453 1453
 					if ($match[2] == '$') {
1454 1454
 						$expr = $this->parseVar($in, $pointer, $to, array(), $curBlock, $pointer);
1455 1455
 					} else {
1456 1456
 						$expr = $this->parse($in, $pointer, $to, array(), 'expression', $pointer);
1457 1457
 					}
1458
-					$out[count($out)-1][0] .= $match[1] . $expr[0][0];
1459
-					$out[count($out)-1][1] .= $match[1] . $expr[0][1];
1458
+					$out[count($out)-1][0] .= $match[1].$expr[0][0];
1459
+					$out[count($out)-1][1] .= $match[1].$expr[0][1];
1460 1460
 				} else {
1461 1461
 					if ($match[2] == '$') {
1462 1462
 						$expr = $this->parseVar($in, $pointer, $to, false, $curBlock, $pointer);
@@ -1464,19 +1464,19 @@  discard block
 block discarded – undo
1464 1464
 						$expr = $this->parse($in, $pointer, $to, false, 'expression', $pointer);
1465 1465
 					}
1466 1466
 					if (is_array($out) && is_array($expr)) {
1467
-						$out[0] .= $match[1] . $expr[0];
1468
-						$out[1] .= $match[1] . $expr[1];
1467
+						$out[0] .= $match[1].$expr[0];
1468
+						$out[1] .= $match[1].$expr[1];
1469 1469
 					} elseif (is_array($out)) {
1470
-						$out[0] .= $match[1] . $expr;
1471
-						$out[1] .= $match[1] . $expr;
1470
+						$out[0] .= $match[1].$expr;
1471
+						$out[1] .= $match[1].$expr;
1472 1472
 					} elseif (is_array($expr)) {
1473
-						$out .= $match[1] . $expr[0];
1473
+						$out .= $match[1].$expr[0];
1474 1474
 					} else {
1475
-						$out .= $match[1] . $expr;
1475
+						$out .= $match[1].$expr;
1476 1476
 					}
1477 1477
 				}
1478 1478
 			} else if ($curBlock === 'root' && preg_match('#^(\s*(?:[+/*%-.]=|=|\+\+|--)\s*)(.*)#s', $substr, $match)) {
1479
-				if($this->debug) echo 'PARSING POST-VAR ASSIGNMENT '.$substr . "\n";
1479
+				if ($this->debug) echo 'PARSING POST-VAR ASSIGNMENT '.$substr."\n";
1480 1480
 				// parse assignment
1481 1481
 				$value = $match[2];
1482 1482
 				$operator = trim($match[1]);
@@ -1515,10 +1515,10 @@  discard block
 block discarded – undo
1515 1515
 				if ($this->autoEscape) {
1516 1516
 					$out = preg_replace('#\(is_string\(\$tmp=(.+?)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $out);
1517 1517
 				}
1518
-				$out = Dwoo_Compiler::PHP_OPEN. $echo . $out . $operator . implode(' ', $value) . Dwoo_Compiler::PHP_CLOSE;
1518
+				$out = Dwoo_Compiler::PHP_OPEN.$echo.$out.$operator.implode(' ', $value).Dwoo_Compiler::PHP_CLOSE;
1519 1519
 			} else if ($curBlock === 'array' && is_array($parsingParams) && preg_match('#^(\s*=>?\s*)#', $substr, $match)) {
1520 1520
 				// parse namedparam with var as name (only for array)
1521
-				if ($this->debug) echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND' . "\n";
1521
+				if ($this->debug) echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND'."\n";
1522 1522
 				$len = strlen($match[1]);
1523 1523
 				$var = $out[count($out)-1];
1524 1524
 				$pointer += $len;
@@ -1536,14 +1536,14 @@  discard block
 block discarded – undo
1536 1536
 			if (is_array($parsingParams)) {
1537 1537
 				$tmp = $this->replaceModifiers(array(null, null, $out[count($out)-1][0], $match[0]), $curBlock, $pointer);
1538 1538
 				$out[count($out)-1][0] = $tmp;
1539
-				$out[count($out)-1][1] .= substr($substr, $srcPointer, $srcPointer - $pointer);
1539
+				$out[count($out)-1][1] .= substr($substr, $srcPointer, $srcPointer-$pointer);
1540 1540
 			} else {
1541 1541
 				$out = $this->replaceModifiers(array(null, null, $out, $match[0]), $curBlock, $pointer);
1542 1542
 			}
1543 1543
 		}
1544 1544
 
1545 1545
 		// func parsed, check if any func-extension applies
1546
-		if ($parsed==='func' && preg_match('#^->[a-z0-9_]+(\s*\(.+|->[a-z_].*)?#is', $substr, $match)) {
1546
+		if ($parsed === 'func' && preg_match('#^->[a-z0-9_]+(\s*\(.+|->[a-z_].*)?#is', $substr, $match)) {
1547 1547
 			// parse method call or property read
1548 1548
 			$ptr = 0;
1549 1549
 
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
 		}
1561 1561
 
1562 1562
 		if ($curBlock === 'root' && substr($out, 0, strlen(self::PHP_OPEN)) !== self::PHP_OPEN) {
1563
-			return self::PHP_OPEN .'echo '.$out.';'. self::PHP_CLOSE;
1563
+			return self::PHP_OPEN.'echo '.$out.';'.self::PHP_CLOSE;
1564 1564
 		} else {
1565 1565
 			return $out;
1566 1566
 		}
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
 	 * @throws Dwoo_Exception
1580 1580
 	 * @throws Dwoo_Security_Exception
1581 1581
 	 */
1582
-	protected function parseFunction($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
1582
+	protected function parseFunction($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
1583 1583
 	{
1584 1584
 		$cmdstr = substr($in, $from, $to-$from);
1585 1585
 		preg_match('/^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?)(\s*'.$this->rdr.'|\s*;)?/i', $cmdstr, $match);
@@ -1594,21 +1594,21 @@  discard block
 block discarded – undo
1594 1594
 			$cmdstr = $match[1];
1595 1595
 		}
1596 1596
 
1597
-		if ($this->debug) echo 'FUNC FOUND ('.$func.')' . "\n";
1597
+		if ($this->debug) echo 'FUNC FOUND ('.$func.')'."\n";
1598 1598
 
1599 1599
 		$paramsep = '';
1600 1600
 
1601 1601
 		if (is_array($parsingParams) || $curBlock != 'root') {
1602 1602
 			$paramspos = strpos($cmdstr, '(');
1603 1603
 			$paramsep = ')';
1604
-		} elseif(preg_match_all('#^\s*[\\\\:a-z0-9_]+(\s*\(|\s+[^(])#i', $cmdstr, $match, PREG_OFFSET_CAPTURE)) {
1604
+		} elseif (preg_match_all('#^\s*[\\\\:a-z0-9_]+(\s*\(|\s+[^(])#i', $cmdstr, $match, PREG_OFFSET_CAPTURE)) {
1605 1605
 			$paramspos = $match[1][0][1];
1606
-			$paramsep = substr($match[1][0][0], -1) === '(' ? ')':'';
1607
-			if($paramsep === ')') {
1608
-				$paramspos += strlen($match[1][0][0]) - 1;
1609
-				if(substr($cmdstr, 0, 2) === 'if' || substr($cmdstr, 0, 6) === 'elseif') {
1606
+			$paramsep = substr($match[1][0][0], -1) === '(' ? ')' : '';
1607
+			if ($paramsep === ')') {
1608
+				$paramspos += strlen($match[1][0][0])-1;
1609
+				if (substr($cmdstr, 0, 2) === 'if' || substr($cmdstr, 0, 6) === 'elseif') {
1610 1610
 					$paramsep = '';
1611
-					if(strlen($match[1][0][0]) > 1) {
1611
+					if (strlen($match[1][0][0]) > 1) {
1612 1612
 						$paramspos--;
1613 1613
 					}
1614 1614
 				}
@@ -1640,7 +1640,7 @@  discard block
 block discarded – undo
1640 1640
 				$paramstr = substr($paramstr, 0, -1);
1641 1641
 			}
1642 1642
 
1643
-			if (strlen($paramstr)===0) {
1643
+			if (strlen($paramstr) === 0) {
1644 1644
 				$params = array();
1645 1645
 				$paramstr = '';
1646 1646
 			} else {
@@ -1656,17 +1656,17 @@  discard block
 block discarded – undo
1656 1656
 							}
1657 1657
 
1658 1658
 							if ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === ')') {
1659
-								if ($this->debug) echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT '.$ptr . "\n";
1659
+								if ($this->debug) echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT '.$ptr."\n";
1660 1660
 								break 2;
1661 1661
 							} elseif ($paramstr[$ptr] === ';') {
1662 1662
 								$ptr++;
1663
-								if ($this->debug) echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT '.$ptr . "\n";
1663
+								if ($this->debug) echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT '.$ptr."\n";
1664 1664
 								break 2;
1665 1665
 							} elseif ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === '/') {
1666
-								if ($this->debug) echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT '.$ptr . "\n";
1666
+								if ($this->debug) echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT '.$ptr."\n";
1667 1667
 								break 2;
1668 1668
 							} elseif (substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) {
1669
-								if ($this->debug) echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT '.$ptr . "\n";
1669
+								if ($this->debug) echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT '.$ptr."\n";
1670 1670
 								break 2;
1671 1671
 							}
1672 1672
 
@@ -1677,7 +1677,7 @@  discard block
 block discarded – undo
1677 1677
 							}
1678 1678
 						}
1679 1679
 
1680
-						if ($this->debug) echo 'FUNC START PARAM PARSING WITH POINTER AT '.$ptr . "\n";
1680
+						if ($this->debug) echo 'FUNC START PARAM PARSING WITH POINTER AT '.$ptr."\n";
1681 1681
 
1682 1682
 						if ($func === 'if' || $func === 'elseif' || $func === 'tif') {
1683 1683
 							$params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'condition', $ptr);
@@ -1687,7 +1687,7 @@  discard block
 block discarded – undo
1687 1687
 							$params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'function', $ptr);
1688 1688
 						}
1689 1689
 
1690
-						if ($this->debug) echo 'PARAM PARSED, POINTER AT '.$ptr.' ('.substr($paramstr, $ptr-1, 3).')' . "\n";
1690
+						if ($this->debug) echo 'PARAM PARSED, POINTER AT '.$ptr.' ('.substr($paramstr, $ptr-1, 3).')'."\n";
1691 1691
 					}
1692 1692
 				}
1693 1693
 				$paramstr = substr($paramstr, 0, $ptr);
@@ -1710,8 +1710,8 @@  discard block
 block discarded – undo
1710 1710
 		}
1711 1711
 
1712 1712
 		if ($pointer !== null) {
1713
-			$pointer += (isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func) + (isset($whitespace) ? $whitespace : 0);
1714
-			if ($this->debug) echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func)).' TO POINTER' . "\n";
1713
+			$pointer += (isset($paramstr) ? strlen($paramstr) : 0)+(')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1))+strlen($func)+(isset($whitespace) ? $whitespace : 0);
1714
+			if ($this->debug) echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0)+(')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1))+strlen($func)).' TO POINTER'."\n";
1715 1715
 		}
1716 1716
 
1717 1717
 		if ($curBlock === 'method' || $func === 'do' || strstr($func, '::') !== false) {
@@ -1840,7 +1840,7 @@  discard block
 block discarded – undo
1840 1840
 					else {
1841 1841
 						array_unshift($params, '$this');
1842 1842
 						$params = self::implode_r($params);
1843
-						$output = 'call_user_func(\'' . $callback . '\', ' . $params . ')';
1843
+						$output = 'call_user_func(\''.$callback.'\', '.$params.')';
1844 1844
 					}
1845 1845
 				} else {
1846 1846
 					array_unshift($params, '$this');
@@ -1947,12 +1947,12 @@  discard block
 block discarded – undo
1947 1947
 	 * @return string parsed values
1948 1948
 	 * @throws Dwoo_Compilation_Exception
1949 1949
 	 */
1950
-	protected function parseString($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
1950
+	protected function parseString($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
1951 1951
 	{
1952 1952
 		$substr = substr($in, $from, $to-$from);
1953 1953
 		$first = $substr[0];
1954 1954
 
1955
-		if ($this->debug) echo 'STRING FOUND (in '.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').')' . "\n";
1955
+		if ($this->debug) echo 'STRING FOUND (in '.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...' : '').')'."\n";
1956 1956
 		$strend = false;
1957 1957
 		$o = $from+1;
1958 1958
 		while ($strend === false) {
@@ -1965,7 +1965,7 @@  discard block
 block discarded – undo
1965 1965
 				$strend = false;
1966 1966
 			}
1967 1967
 		}
1968
-		if ($this->debug) echo 'STRING DELIMITED: '.substr($in, $from, $strend+1-$from) . "\n";
1968
+		if ($this->debug) echo 'STRING DELIMITED: '.substr($in, $from, $strend+1-$from)."\n";
1969 1969
 
1970 1970
 		$srcOutput = substr($in, $from, $strend+1-$from);
1971 1971
 
@@ -2014,12 +2014,12 @@  discard block
 block discarded – undo
2014 2014
 	 * @return string parsed values
2015 2015
 	 * @throws Dwoo_Compilation_Exception
2016 2016
 	 */
2017
-	protected function parseConst($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
2017
+	protected function parseConst($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
2018 2018
 	{
2019 2019
 		$substr = substr($in, $from, $to-$from);
2020 2020
 
2021 2021
 		if ($this->debug) {
2022
-			echo 'CONST FOUND : '.$substr . "\n";
2022
+			echo 'CONST FOUND : '.$substr."\n";
2023 2023
 		}
2024 2024
 
2025 2025
 		if (!preg_match('#^%([\\\\a-z0-9_:]+)#i', $substr, $m)) {
@@ -2075,14 +2075,14 @@  discard block
 block discarded – undo
2075 2075
 	 * @return string parsed values
2076 2076
 	 * @throws Dwoo_Compilation_Exception
2077 2077
 	 */
2078
-	protected function parseVar($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
2078
+	protected function parseVar($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
2079 2079
 	{
2080 2080
 		$substr = substr($in, $from, $to-$from);
2081 2081
 
2082
-		if (preg_match('#(\$?\.?[a-z0-9_:]*(?:(?:(?:\.|->)(?:[a-z0-9_:]+|(?R))|\[(?:[a-z0-9_:]+|(?R)|(["\'])[^\2]*?\2)\]))*)' . // var key
2083
-			($curBlock==='root' || $curBlock==='function' || $curBlock==='namedparam' || $curBlock==='condition' || $curBlock==='variable' || $curBlock==='expression' || $curBlock==='delimited_string' ? '(\(.*)?' : '()') . // method call
2084
-			($curBlock==='root' || $curBlock==='function' || $curBlock==='namedparam' || $curBlock==='condition' || $curBlock==='variable' || $curBlock==='delimited_string' ? '((?:(?:[+/*%=-])(?:(?<!=)=?-?[$%][a-z0-9.[\]>_:-]+(?:\([^)]*\))?|(?<!=)=?-?[0-9.,]*|[+-]))*)':'()') . // simple math expressions
2085
-			($curBlock!=='modifier' ? '((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').*?\5|:[^`]*))*))+)?':'(())') . // modifiers
2082
+		if (preg_match('#(\$?\.?[a-z0-9_:]*(?:(?:(?:\.|->)(?:[a-z0-9_:]+|(?R))|\[(?:[a-z0-9_:]+|(?R)|(["\'])[^\2]*?\2)\]))*)'.// var key
2083
+			($curBlock === 'root' || $curBlock === 'function' || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'variable' || $curBlock === 'expression' || $curBlock === 'delimited_string' ? '(\(.*)?' : '()').// method call
2084
+			($curBlock === 'root' || $curBlock === 'function' || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'variable' || $curBlock === 'delimited_string' ? '((?:(?:[+/*%=-])(?:(?<!=)=?-?[$%][a-z0-9.[\]>_:-]+(?:\([^)]*\))?|(?<!=)=?-?[0-9.,]*|[+-]))*)' : '()').// simple math expressions
2085
+			($curBlock !== 'modifier' ? '((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').*?\5|:[^`]*))*))+)?' : '(())').// modifiers
2086 2086
 			'#i', $substr, $match)) {
2087 2087
 			$key = substr($match[1], 1);
2088 2088
 
@@ -2097,9 +2097,9 @@  discard block
 block discarded – undo
2097 2097
 			}
2098 2098
 
2099 2099
 			if ($hasMethodCall) {
2100
-				$matchedLength -= strlen($match[3]) + strlen(substr($match[1], strrpos($match[1], '->')));
2100
+				$matchedLength -= strlen($match[3])+strlen(substr($match[1], strrpos($match[1], '->')));
2101 2101
 				$key = substr($match[1], 1, strrpos($match[1], '->')-1);
2102
-				$methodCall = substr($match[1], strrpos($match[1], '->')) . $match[3];
2102
+				$methodCall = substr($match[1], strrpos($match[1], '->')).$match[3];
2103 2103
 			}
2104 2104
 
2105 2105
 			if ($hasModifiers) {
@@ -2115,20 +2115,20 @@  discard block
 block discarded – undo
2115 2115
 
2116 2116
 			if ($this->debug) {
2117 2117
 				if ($hasMethodCall) {
2118
-					echo 'METHOD CALL FOUND : $'.$key.substr($methodCall, 0, 30) . "\n";
2118
+					echo 'METHOD CALL FOUND : $'.$key.substr($methodCall, 0, 30)."\n";
2119 2119
 				} else {
2120
-					echo 'VAR FOUND : $'.$key . "\n";
2120
+					echo 'VAR FOUND : $'.$key."\n";
2121 2121
 				}
2122 2122
 			}
2123 2123
 
2124 2124
 			$key = str_replace('"', '\\"', $key);
2125 2125
 
2126
-			$cnt=substr_count($key, '$');
2126
+			$cnt = substr_count($key, '$');
2127 2127
 			if ($cnt > 0) {
2128 2128
 				$uid = 0;
2129 2129
 				$parsed = array($uid => '');
2130
-				$current =& $parsed;
2131
-				$curTxt =& $parsed[$uid++];
2130
+				$current = & $parsed;
2131
+				$curTxt = & $parsed[$uid++];
2132 2132
 				$tree = array();
2133 2133
 				$chars = str_split($key, 1);
2134 2134
 				$inSplittedVar = false;
@@ -2139,31 +2139,31 @@  discard block
 block discarded – undo
2139 2139
 						if (count($tree) > 0) {
2140 2140
 							$bracketCount++;
2141 2141
 						} else {
2142
-							$tree[] =& $current;
2142
+							$tree[] = & $current;
2143 2143
 							$current[$uid] = array($uid+1 => '');
2144
-							$current =& $current[$uid++];
2145
-							$curTxt =& $current[$uid++];
2144
+							$current = & $current[$uid++];
2145
+							$curTxt = & $current[$uid++];
2146 2146
 							continue;
2147 2147
 						}
2148 2148
 					} elseif ($char === ']') {
2149 2149
 						if ($bracketCount > 0) {
2150 2150
 							$bracketCount--;
2151 2151
 						} else {
2152
-							$current =& $tree[count($tree)-1];
2152
+							$current = & $tree[count($tree)-1];
2153 2153
 							array_pop($tree);
2154 2154
 							if (current($chars) !== '[' && current($chars) !== false && current($chars) !== ']') {
2155 2155
 								$current[$uid] = '';
2156
-								$curTxt =& $current[$uid++];
2156
+								$curTxt = & $current[$uid++];
2157 2157
 							}
2158 2158
 							continue;
2159 2159
 						}
2160 2160
 					} elseif ($char === '$') {
2161 2161
 						if (count($tree) == 0) {
2162
-							$curTxt =& $current[$uid++];
2162
+							$curTxt = & $current[$uid++];
2163 2163
 							$inSplittedVar = true;
2164 2164
 						}
2165 2165
 					} elseif (($char === '.' || $char === '-') && count($tree) == 0 && $inSplittedVar) {
2166
-						$curTxt =& $current[$uid++];
2166
+						$curTxt = & $current[$uid++];
2167 2167
 						$inSplittedVar = false;
2168 2168
 					}
2169 2169
 
@@ -2171,11 +2171,11 @@  discard block
 block discarded – undo
2171 2171
 				}
2172 2172
 				unset($uid, $current, $curTxt, $tree, $chars);
2173 2173
 
2174
-				if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT : '.$key . "\n";
2174
+				if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT : '.$key."\n";
2175 2175
 
2176 2176
 				$key = $this->flattenVarTree($parsed);
2177 2177
 
2178
-				if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key . "\n";
2178
+				if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key."\n";
2179 2179
 
2180 2180
 				$output = preg_replace('#(^""\.|""\.|\.""$|(\()""\.|\.""(\)))#', '$2$3', '$this->readVar("'.$key.'")');
2181 2181
 			} else {
@@ -2199,7 +2199,7 @@  discard block
 block discarded – undo
2199 2199
 				preg_match_all('#(?:([+/*%=-])(=?-?[%$][a-z0-9.[\]>_:-]+(?:\([^)]*\))?|=?-?[0-9.,]+|\1))#i', $match[4], $expMatch);
2200 2200
 
2201 2201
 				foreach ($expMatch[1] as $k=>$operator) {
2202
-					if (substr($expMatch[2][$k], 0, 1)==='=') {
2202
+					if (substr($expMatch[2][$k], 0, 1) === '=') {
2203 2203
 						$assign = true;
2204 2204
 						if ($operator === '=') {
2205 2205
 							throw new Dwoo_Compilation_Exception($this, 'Invalid expression <em>'.$substr.'</em>, can not use "==" in expressions');
@@ -2211,11 +2211,11 @@  discard block
 block discarded – undo
2211 2211
 						$expMatch[2][$k] = substr($expMatch[2][$k], 1);
2212 2212
 					}
2213 2213
 
2214
-					if (substr($expMatch[2][$k], 0, 1)==='-' && strlen($expMatch[2][$k]) > 1) {
2214
+					if (substr($expMatch[2][$k], 0, 1) === '-' && strlen($expMatch[2][$k]) > 1) {
2215 2215
 						$operator .= '-';
2216 2216
 						$expMatch[2][$k] = substr($expMatch[2][$k], 1);
2217 2217
 					}
2218
-					if (($operator==='+'||$operator==='-') && $expMatch[2][$k]===$operator) {
2218
+					if (($operator === '+' || $operator === '-') && $expMatch[2][$k] === $operator) {
2219 2219
 						$output = '('.$output.$operator.$operator.')';
2220 2220
 						break;
2221 2221
 					} elseif (substr($expMatch[2][$k], 0, 1) === '$') {
@@ -2291,7 +2291,7 @@  discard block
 block discarded – undo
2291 2291
 				break;
2292 2292
 			}
2293 2293
 
2294
-			if(!preg_match('/^([a-z0-9_]+)(\(.*?\))?/i', substr($methodCall, $ptr), $methMatch)) {
2294
+			if (!preg_match('/^([a-z0-9_]+)(\(.*?\))?/i', substr($methodCall, $ptr), $methMatch)) {
2295 2295
 				break;
2296 2296
 			}
2297 2297
 
@@ -2307,7 +2307,7 @@  discard block
 block discarded – undo
2307 2307
 				// method
2308 2308
 				if (substr($methMatch[2], 0, 2) === '()') {
2309 2309
 					$parsedCall = $methMatch[1].'()';
2310
-					$ptr += strlen($methMatch[1]) + 2;
2310
+					$ptr += strlen($methMatch[1])+2;
2311 2311
 				} else {
2312 2312
 					$parsedCall = $this->parseFunction($methodCall, $ptr, strlen($methodCall), false, 'method', $ptr);
2313 2313
 				}
@@ -2416,7 +2416,7 @@  discard block
 block discarded – undo
2416 2416
 
2417 2417
 					while (count($m[1]) && $m[1][0] !== '->') {
2418 2418
 						$m[2][0] = preg_replace('/(^\\\([\'"])|\\\([\'"])$)/x', '$2$3', $m[2][0]);
2419
-						if(substr($m[2][0], 0, 1) == '"' || substr($m[2][0], 0, 1) == "'") {
2419
+						if (substr($m[2][0], 0, 1) == '"' || substr($m[2][0], 0, 1) == "'") {
2420 2420
 							$output .= '['.$m[2][0].']';
2421 2421
 						} else {
2422 2422
 							$output .= '["'.$m[2][0].'"]';
@@ -2432,7 +2432,7 @@  discard block
 block discarded – undo
2432 2432
 
2433 2433
 				if (count($m[2])) {
2434 2434
 					unset($m[0]);
2435
-					$output = '$this->readVarInto('.str_replace("\n", '', var_export($m, true)).', '.$output.', '.($curBlock == 'root' ? 'false': 'true').')';
2435
+					$output = '$this->readVarInto('.str_replace("\n", '', var_export($m, true)).', '.$output.', '.($curBlock == 'root' ? 'false' : 'true').')';
2436 2436
 				}
2437 2437
 			}
2438 2438
 		} else {
@@ -2452,25 +2452,25 @@  discard block
 block discarded – undo
2452 2452
 	 * @param bool $recursed leave that to false by default, it is only for internal use
2453 2453
 	 * @return string flattened tree
2454 2454
 	 */
2455
-	protected function flattenVarTree(array $tree, $recursed=false)
2455
+	protected function flattenVarTree(array $tree, $recursed = false)
2456 2456
 	{
2457
-		$out = $recursed ?  '".$this->readVarInto(' : '';
2457
+		$out = $recursed ? '".$this->readVarInto(' : '';
2458 2458
 		foreach ($tree as $bit) {
2459 2459
 			if (is_array($bit)) {
2460
-				$out.='.'.$this->flattenVarTree($bit, false);
2460
+				$out .= '.'.$this->flattenVarTree($bit, false);
2461 2461
 			} else {
2462 2462
 				$key = str_replace('"', '\\"', $bit);
2463 2463
 
2464
-				if (substr($key, 0, 1)==='$') {
2464
+				if (substr($key, 0, 1) === '$') {
2465 2465
 					$out .= '".'.$this->parseVar($key, 0, strlen($key), false, 'variable').'."';
2466 2466
 				} else {
2467 2467
 					$cnt = substr_count($key, '$');
2468 2468
 
2469
-					if ($this->debug) echo 'PARSING SUBVARS IN : '.$key . "\n";
2469
+					if ($this->debug) echo 'PARSING SUBVARS IN : '.$key."\n";
2470 2470
 					if ($cnt > 0) {
2471 2471
 						while (--$cnt >= 0) {
2472 2472
 							if (isset($last)) {
2473
-								$last = strrpos($key, '$', - (strlen($key) - $last + 1));
2473
+								$last = strrpos($key, '$', - (strlen($key)-$last+1));
2474 2474
 							} else {
2475 2475
 								$last = strrpos($key, '$');
2476 2476
 							}
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
 								$last,
2489 2489
 								$len
2490 2490
 							);
2491
-							if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key . "\n";
2491
+							if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key."\n";
2492 2492
 						}
2493 2493
 						unset($last);
2494 2494
 
@@ -2525,7 +2525,7 @@  discard block
 block discarded – undo
2525 2525
 	 * @return string parsed values
2526 2526
 	 * @throws Exception
2527 2527
 	 */
2528
-	protected function parseOthers($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
2528
+	protected function parseOthers($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
2529 2529
 	{
2530 2530
 		$first = $in[$from];
2531 2531
 		$substr = substr($in, $from, $to-$from);
@@ -2543,7 +2543,7 @@  discard block
 block discarded – undo
2543 2543
 		}
2544 2544
 
2545 2545
 		$breaker = false;
2546
-		while (list($k,$char) = each($breakChars)) {
2546
+		while (list($k, $char) = each($breakChars)) {
2547 2547
 			$test = strpos($substr, $char);
2548 2548
 			if ($test !== false && $test < $end) {
2549 2549
 				$end = $test;
@@ -2569,15 +2569,15 @@  discard block
 block discarded – undo
2569 2569
 		$substr = trim($substr);
2570 2570
 
2571 2571
 		if (strtolower($substr) === 'false' || strtolower($substr) === 'no' || strtolower($substr) === 'off') {
2572
-			if ($this->debug) echo 'BOOLEAN(FALSE) PARSED' . "\n";
2572
+			if ($this->debug) echo 'BOOLEAN(FALSE) PARSED'."\n";
2573 2573
 			$substr = 'false';
2574 2574
 			$type = self::T_BOOL;
2575 2575
 		} elseif (strtolower($substr) === 'true' || strtolower($substr) === 'yes' || strtolower($substr) === 'on') {
2576
-			if ($this->debug) echo 'BOOLEAN(TRUE) PARSED' . "\n";
2576
+			if ($this->debug) echo 'BOOLEAN(TRUE) PARSED'."\n";
2577 2577
 			$substr = 'true';
2578 2578
 			$type = self::T_BOOL;
2579 2579
 		} elseif ($substr === 'null' || $substr === 'NULL') {
2580
-			if ($this->debug) echo 'NULL PARSED' . "\n";
2580
+			if ($this->debug) echo 'NULL PARSED'."\n";
2581 2581
 			$substr = 'null';
2582 2582
 			$type = self::T_NULL;
2583 2583
 		} elseif (is_numeric($substr)) {
@@ -2586,19 +2586,19 @@  discard block
 block discarded – undo
2586 2586
 				$substr = (int) $substr;
2587 2587
 			}
2588 2588
 			$type = self::T_NUMERIC;
2589
-			if ($this->debug) echo 'NUMBER ('.$substr.') PARSED' . "\n";
2589
+			if ($this->debug) echo 'NUMBER ('.$substr.') PARSED'."\n";
2590 2590
 		} elseif (preg_match('{^-?(\d+|\d*(\.\d+))\s*([/*%+-]\s*-?(\d+|\d*(\.\d+)))+$}', $substr)) {
2591 2591
 			if ($this->debug) echo 'SIMPLE MATH PARSED . "\n"';
2592 2592
 			$type = self::T_MATH;
2593 2593
 			$substr = '('.$substr.')';
2594 2594
 		} elseif ($curBlock === 'condition' && array_search($substr, $breakChars, true) !== false) {
2595
-			if ($this->debug) echo 'BREAKCHAR ('.$substr.') PARSED' . "\n";
2595
+			if ($this->debug) echo 'BREAKCHAR ('.$substr.') PARSED'."\n";
2596 2596
 			$type = self::T_BREAKCHAR;
2597 2597
 			//$substr = '"'.$substr.'"';
2598 2598
 		} else {
2599 2599
 			$substr = $this->replaceStringVars('\''.str_replace('\'', '\\\'', $substr).'\'', '\'', $curBlock);
2600 2600
 			$type = self::T_UNQUOTED_STRING;
2601
-			if ($this->debug) echo 'BLABBER ('.$substr.') CASTED AS STRING' . "\n";
2601
+			if ($this->debug) echo 'BLABBER ('.$substr.') CASTED AS STRING'."\n";
2602 2602
 		}
2603 2603
 
2604 2604
 		if (is_array($parsingParams)) {
@@ -2621,10 +2621,10 @@  discard block
 block discarded – undo
2621 2621
 	 * @param string $curBlock the current parser-block being processed
2622 2622
 	 * @return string the original string with variables replaced
2623 2623
 	 */
2624
-	protected function replaceStringVars($string, $first, $curBlock='')
2624
+	protected function replaceStringVars($string, $first, $curBlock = '')
2625 2625
 	{
2626 2626
 		$pos = 0;
2627
-		if ($this->debug) echo 'STRING VAR REPLACEMENT : '.$string . "\n";
2627
+		if ($this->debug) echo 'STRING VAR REPLACEMENT : '.$string."\n";
2628 2628
 		// replace vars
2629 2629
 		while (($pos = strpos($string, '$', $pos)) !== false) {
2630 2630
 			$prev = substr($string, $pos-1, 1);
@@ -2633,17 +2633,17 @@  discard block
 block discarded – undo
2633 2633
 				continue;
2634 2634
 			}
2635 2635
 
2636
-			$var = $this->parse($string, $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string':'string')));
2636
+			$var = $this->parse($string, $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string')));
2637 2637
 			$len = $var[0];
2638
-			$var = $this->parse(str_replace('\\'.$first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string':'string')));
2638
+			$var = $this->parse(str_replace('\\'.$first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string')));
2639 2639
 
2640 2640
 			if ($prev === '`' && substr($string, $pos+$len, 1) === '`') {
2641 2641
 				$string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos-1, $len+2);
2642 2642
 			} else {
2643 2643
 				$string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos, $len);
2644 2644
 			}
2645
-			$pos += strlen($var[1]) + 2;
2646
-			if ($this->debug) echo 'STRING VAR REPLACEMENT DONE : '.$string . "\n";
2645
+			$pos += strlen($var[1])+2;
2646
+			if ($this->debug) echo 'STRING VAR REPLACEMENT DONE : '.$string."\n";
2647 2647
 		}
2648 2648
 
2649 2649
 		// handle modifiers
@@ -2651,7 +2651,7 @@  discard block
 block discarded – undo
2651 2651
 		$string = preg_replace_callback('#("|\')\.(.+?)\.\1((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').+?\4|:[^`]*))*))+)#i', array($this, 'replaceModifiers'), $string);
2652 2652
 
2653 2653
 		// replace escaped dollar operators by unescaped ones if required
2654
-		if ($first==="'") {
2654
+		if ($first === "'") {
2655 2655
 			$string = str_replace('\\$', '$', $string);
2656 2656
 		}
2657 2657
 
@@ -2669,7 +2669,7 @@  discard block
 block discarded – undo
2669 2669
 	 */
2670 2670
 	protected function replaceModifiers(array $m, $curBlock = null, &$pointer = null)
2671 2671
 	{
2672
-		if ($this->debug) echo 'PARSING MODIFIERS : '.$m[3] . "\n";
2672
+		if ($this->debug) echo 'PARSING MODIFIERS : '.$m[3]."\n";
2673 2673
 
2674 2674
 		if ($pointer !== null) {
2675 2675
 			$pointer += strlen($m[3]);
@@ -2691,7 +2691,7 @@  discard block
 block discarded – undo
2691 2691
 				continue;
2692 2692
 			}
2693 2693
 			if ($cmdstrsrc[0] === ' ' || $cmdstrsrc[0] === ';' || substr($cmdstrsrc, 0, strlen($this->rd)) === $this->rd) {
2694
-				if ($this->debug) echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND' . "\n";
2694
+				if ($this->debug) echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND'."\n";
2695 2695
 				$continue = false;
2696 2696
 				if ($pointer !== null) {
2697 2697
 					$pointer -= strlen($cmdstrsrc);
@@ -2710,7 +2710,7 @@  discard block
 block discarded – undo
2710 2710
 			if ($paramspos === false) {
2711 2711
 				$cmdstrsrc = substr($cmdstrsrc, strlen($func));
2712 2712
 				$params = array();
2713
-				if ($this->debug) echo 'MODIFIER ('.$func.') CALLED WITH NO PARAMS' . "\n";
2713
+				if ($this->debug) echo 'MODIFIER ('.$func.') CALLED WITH NO PARAMS'."\n";
2714 2714
 			} else {
2715 2715
 				$paramstr = substr($cmdstr, $paramspos+1);
2716 2716
 				if (substr($paramstr, -1, 1) === $paramsep) {
@@ -2720,22 +2720,22 @@  discard block
 block discarded – undo
2720 2720
 				$ptr = 0;
2721 2721
 				$params = array();
2722 2722
 				while ($ptr < strlen($paramstr)) {
2723
-					if ($this->debug) echo 'MODIFIER ('.$func.') START PARAM PARSING WITH POINTER AT '.$ptr . "\n";
2724
-					if ($this->debug) echo $paramstr.'--'.$ptr.'--'.strlen($paramstr).'--modifier' . "\n";
2723
+					if ($this->debug) echo 'MODIFIER ('.$func.') START PARAM PARSING WITH POINTER AT '.$ptr."\n";
2724
+					if ($this->debug) echo $paramstr.'--'.$ptr.'--'.strlen($paramstr).'--modifier'."\n";
2725 2725
 					$params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'modifier', $ptr);
2726
-					if ($this->debug) echo 'PARAM PARSED, POINTER AT '.$ptr . "\n";
2726
+					if ($this->debug) echo 'PARAM PARSED, POINTER AT '.$ptr."\n";
2727 2727
 
2728 2728
 					if ($ptr >= strlen($paramstr)) {
2729
-						if ($this->debug) echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED' . "\n";
2729
+						if ($this->debug) echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED'."\n";
2730 2730
 						break;
2731 2731
 					}
2732 2732
 
2733 2733
 					if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === '|' || $paramstr[$ptr] === ';' || substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) {
2734
-						if ($this->debug) echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT '.$ptr . "\n";
2734
+						if ($this->debug) echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT '.$ptr."\n";
2735 2735
 						if ($paramstr[$ptr] !== '|') {
2736 2736
 							$continue = false;
2737 2737
 							if ($pointer !== null) {
2738
-								$pointer -= strlen($paramstr) - $ptr;
2738
+								$pointer -= strlen($paramstr)-$ptr;
2739 2739
 							}
2740 2740
 						}
2741 2741
 						$ptr++;
@@ -2829,7 +2829,7 @@  discard block
 block discarded – undo
2829 2829
 					if ($pluginType & Dwoo_Core::CLASS_PLUGIN) {
2830 2830
 						$callback = array($pluginName, ($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) ? 'compile' : 'process');
2831 2831
 					} else {
2832
-						$callback = $pluginName . (($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) ? '_compile' : '');
2832
+						$callback = $pluginName.(($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) ? '_compile' : '');
2833 2833
 					}
2834 2834
 				}
2835 2835
 
@@ -2908,7 +2908,7 @@  discard block
 block discarded – undo
2908 2908
 		} elseif ($curBlock === 'var' || $m[1] === null) {
2909 2909
 			return $output;
2910 2910
 		} elseif ($curBlock === 'string' || $curBlock === 'root') {
2911
-			return $m[1].'.'.$output.'.'.$m[1].(isset($add)?$add:null);
2911
+			return $m[1].'.'.$output.'.'.$m[1].(isset($add) ? $add : null);
2912 2912
 		}
2913 2913
 
2914 2914
 		return '';
@@ -2987,9 +2987,9 @@  discard block
 block discarded – undo
2987 2987
 			} elseif (function_exists('smarty_block_'.$name) !== false) {
2988 2988
 				$pluginType = Dwoo_Core::SMARTY_BLOCK;
2989 2989
 			} else {
2990
-				if ($pluginType===-1) {
2990
+				if ($pluginType === -1) {
2991 2991
 					try {
2992
-						$this->dwoo->getLoader()->loadPlugin($name, isset($phpFunc)===false);
2992
+						$this->dwoo->getLoader()->loadPlugin($name, isset($phpFunc) === false);
2993 2993
 					} catch (Exception $e) {
2994 2994
 						if (isset($phpFunc)) {
2995 2995
 							$pluginType = Dwoo_Core::NATIVE_PLUGIN;
@@ -3046,7 +3046,7 @@  discard block
 block discarded – undo
3046 3046
 	 * @return array parameters sorted in the correct order with missing optional parameters filled
3047 3047
 	 * @throws Dwoo_Compilation_Exception
3048 3048
 	 */
3049
-	protected function mapParams(array $params, $callback, $callType=2, $map = null)
3049
+	protected function mapParams(array $params, $callback, $callType = 2, $map = null)
3050 3050
 	{
3051 3051
 		if (!$map) {
3052 3052
 			$map = $this->getParamMap($callback);
@@ -3065,11 +3065,11 @@  discard block
 block discarded – undo
3065 3065
 		}
3066 3066
 
3067 3067
 		// loops over the param map and assigns values from the template or default value for unset optional params
3068
-		while (list($k,$v) = each($map)) {
3068
+		while (list($k, $v) = each($map)) {
3069 3069
 			if ($v[0] === '*') {
3070 3070
 				// "rest" array parameter, fill every remaining params in it and then break
3071 3071
 				if (count($ps) === 0) {
3072
-					if ($v[1]===false) {
3072
+					if ($v[1] === false) {
3073 3073
 						throw new Dwoo_Compilation_Exception($this, 'Rest argument missing for '.str_replace(array('Dwoo_Plugin_', '_compile'), '', (is_array($callback) ? $callback[0] : $callback)));
3074 3074
 					} else {
3075 3075
 						break;
@@ -3095,11 +3095,11 @@  discard block
 block discarded – undo
3095 3095
 				// parameter is defined as ordered param
3096 3096
 				$paramlist[$v[0]] = $ps[$k];
3097 3097
 				unset($ps[$k]);
3098
-			} elseif ($v[1]===false) {
3098
+			} elseif ($v[1] === false) {
3099 3099
 				// parameter is not defined and not optional, throw error
3100 3100
 				if (is_array($callback)) {
3101 3101
 					if (is_object($callback[0])) {
3102
-						$name = get_class($callback[0]) . '::' . $callback[1];
3102
+						$name = get_class($callback[0]).'::'.$callback[1];
3103 3103
 					} else {
3104 3104
 						$name = $callback[0];
3105 3105
 					}
@@ -3108,7 +3108,7 @@  discard block
 block discarded – undo
3108 3108
 				}
3109 3109
 
3110 3110
 				throw new Dwoo_Compilation_Exception($this, 'Argument '.$k.'/'.$v[0].' missing for '.str_replace(array('Dwoo_Plugin_', '_compile'), '', $name));
3111
-			} elseif ($v[2]===null) {
3111
+			} elseif ($v[2] === null) {
3112 3112
 				// enforce lowercased null if default value is null (php outputs NULL with var export)
3113 3113
 				$paramlist[$v[0]] = array('null', null, self::T_NULL);
3114 3114
 			} else {
Please login to merge, or discard this patch.
Braces   +169 added lines, -63 removed lines patch added patch discarded remove patch
@@ -722,7 +722,9 @@  discard block
 block discarded – undo
722 722
 					echo 'COMPILER INIT' . "\n";
723 723
 				}
724 724
 
725
-				if ($this->debug) echo 'PROCESSING PREPROCESSORS ('.count($this->processors['pre']).')' . "\n";
725
+				if ($this->debug) {
726
+					echo 'PROCESSING PREPROCESSORS ('.count($this->processors['pre']).')' . "\n";
727
+				}
726 728
 
727 729
 				// runs preprocessors
728 730
 				foreach ($this->processors['pre'] as $preProc) {
@@ -738,7 +740,9 @@  discard block
 block discarded – undo
738 740
 				unset($preProc);
739 741
 
740 742
 				// show template source if debug
741
-				if ($this->debug) echo '<pre>'.print_r(htmlentities($tpl), true).'</pre>' . "\n";
743
+				if ($this->debug) {
744
+					echo '<pre>'.print_r(htmlentities($tpl), true).'</pre>' . "\n";
745
+				}
742 746
 
743 747
 				// strips php tags if required by the security policy
744 748
 				if ($this->securityPolicy !== null) {
@@ -827,7 +831,9 @@  discard block
 block discarded – undo
827 831
 
828 832
 		$compiled .= $this->removeBlock('topLevelBlock');
829 833
 
830
-		if ($this->debug) echo 'PROCESSING POSTPROCESSORS' . "\n";
834
+		if ($this->debug) {
835
+			echo 'PROCESSING POSTPROCESSORS' . "\n";
836
+		}
831 837
 
832 838
 		foreach ($this->processors['post'] as $postProc) {
833 839
 			if (is_array($postProc) && isset($postProc['autoload'])) {
@@ -841,7 +847,9 @@  discard block
 block discarded – undo
841 847
 		}
842 848
 		unset($postProc);
843 849
 
844
-		if ($this->debug) echo 'COMPILATION COMPLETE : MEM USAGE : '.memory_get_usage() . "\n";
850
+		if ($this->debug) {
851
+			echo 'COMPILATION COMPLETE : MEM USAGE : '.memory_get_usage() . "\n";
852
+		}
845 853
 
846 854
 		$output = "<?php\n/* template head */\n";
847 855
 
@@ -924,7 +932,9 @@  discard block
 block discarded – undo
924 932
 	 */
925 933
 	protected function resolveSubTemplateDependencies($function)
926 934
 	{
927
-		if ($this->debug) echo 'Compiler::'.__FUNCTION__."\n";
935
+		if ($this->debug) {
936
+			echo 'Compiler::'.__FUNCTION__."\n";
937
+		}
928 938
 
929 939
 		$body = $this->templatePlugins[$function]['body'];
930 940
 		foreach ($this->templatePlugins as $func => $attr) {
@@ -996,8 +1006,9 @@  discard block
 block discarded – undo
996 1006
 				reset($this->scopeTree);
997 1007
 				$this->scope =& $this->data;
998 1008
 				$cnt = count($this->scopeTree);
999
-				for ($i=0;$i<$cnt;$i++)
1000
-					$this->scope =& $this->scope[$this->scopeTree[$i]];
1009
+				for ($i=0;$i<$cnt;$i++) {
1010
+									$this->scope =& $this->scope[$this->scopeTree[$i]];
1011
+				}
1001 1012
 			} elseif ($bit === '_root' || $bit === '__') {
1002 1013
 				$this->scope =& $this->data;
1003 1014
 				$this->scopeTree = array();
@@ -1024,7 +1035,9 @@  discard block
 block discarded – undo
1024 1035
 	 */
1025 1036
 	public function addBlock($type, array $params, $paramtype)
1026 1037
 	{
1027
-		if ($this->debug) echo 'Compiler::'.__FUNCTION__."\n";
1038
+		if ($this->debug) {
1039
+			echo 'Compiler::'.__FUNCTION__."\n";
1040
+		}
1028 1041
 
1029 1042
 		$class = 'Dwoo_Plugin_'.$type;
1030 1043
 		if (class_exists($class) === false) {
@@ -1071,7 +1084,9 @@  discard block
 block discarded – undo
1071 1084
 	 */
1072 1085
 	public function injectBlock($type, array $params)
1073 1086
 	{
1074
-		if ($this->debug) echo 'Compiler::'.__FUNCTION__."\n";
1087
+		if ($this->debug) {
1088
+			echo 'Compiler::'.__FUNCTION__."\n";
1089
+		}
1075 1090
 
1076 1091
 		$class = 'Dwoo_Plugin_'.$type;
1077 1092
 		if (class_exists($class) === false) {
@@ -1090,7 +1105,9 @@  discard block
 block discarded – undo
1090 1105
 	 */
1091 1106
 	public function removeBlock($type)
1092 1107
 	{
1093
-		if ($this->debug) echo 'Compiler::'.__FUNCTION__."\n";
1108
+		if ($this->debug) {
1109
+			echo 'Compiler::'.__FUNCTION__."\n";
1110
+		}
1094 1111
 
1095 1112
 		$output = '';
1096 1113
 
@@ -1177,7 +1194,9 @@  discard block
 block discarded – undo
1177 1194
 	 */
1178 1195
 	public function removeTopBlock()
1179 1196
 	{
1180
-		if ($this->debug) echo 'Compiler::'.__FUNCTION__."\n";
1197
+		if ($this->debug) {
1198
+			echo 'Compiler::'.__FUNCTION__."\n";
1199
+		}
1181 1200
 
1182 1201
 		$o = array_pop($this->stack);
1183 1202
 		if ($o === null) {
@@ -1255,7 +1274,9 @@  discard block
 block discarded – undo
1255 1274
 	 */
1256 1275
 	protected function parse($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
1257 1276
 	{
1258
-		if ($this->debug) echo 'Compiler::'.__FUNCTION__."\n";
1277
+		if ($this->debug) {
1278
+			echo 'Compiler::'.__FUNCTION__."\n";
1279
+		}
1259 1280
 
1260 1281
 		if ($to === null) {
1261 1282
 			$to = strlen($in);
@@ -1270,7 +1291,9 @@  discard block
 block discarded – undo
1270 1291
 			if ($curBlock === 'root' && substr($in, $from, strlen($this->rd)) === $this->rd) {
1271 1292
 				// end template tag
1272 1293
 				$pointer += strlen($this->rd);
1273
-				if ($this->debug) echo 'TEMPLATE PARSING ENDED' . "\n";
1294
+				if ($this->debug) {
1295
+					echo 'TEMPLATE PARSING ENDED' . "\n";
1296
+				}
1274 1297
 				return false;
1275 1298
 			}
1276 1299
 			$from++;
@@ -1289,7 +1312,9 @@  discard block
 block discarded – undo
1289 1312
 
1290 1313
 		$substr = substr($in, $from, $to-$from);
1291 1314
 
1292
-		if ($this->debug) echo 'PARSE CALL : PARSING "<b>'.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').'</b>" @ '.$from.':'.$to.' in '.$curBlock.' : pointer='.$pointer. "\n";
1315
+		if ($this->debug) {
1316
+			echo 'PARSE CALL : PARSING "<b>'.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').'</b>" @ '.$from.':'.$to.' in '.$curBlock.' : pointer='.$pointer. "\n";
1317
+		}
1293 1318
 		$parsed = "";
1294 1319
 
1295 1320
 		if ($curBlock === 'root' && $first === '*') {
@@ -1373,7 +1398,9 @@  discard block
 block discarded – undo
1373 1398
 			$parsed = 'func';
1374 1399
 		} elseif ($first === ';') {
1375 1400
 			// instruction end
1376
-			if ($this->debug) echo 'END OF INSTRUCTION' . "\n";
1401
+			if ($this->debug) {
1402
+				echo 'END OF INSTRUCTION' . "\n";
1403
+			}
1377 1404
 			if ($pointer !== null) {
1378 1405
 				$pointer++;
1379 1406
 			}
@@ -1393,20 +1420,28 @@  discard block
 block discarded – undo
1393 1420
 				if ($this->curBlock['type'] == 'else' || $this->curBlock['type'] == 'elseif') {
1394 1421
 					$pointer -= strlen($match[0]);
1395 1422
 				}
1396
-				if ($this->debug) echo 'TOP BLOCK CLOSED' . "\n";
1423
+				if ($this->debug) {
1424
+					echo 'TOP BLOCK CLOSED' . "\n";
1425
+				}
1397 1426
 				return $this->removeTopBlock();
1398 1427
 			} else {
1399
-				if ($this->debug) echo 'BLOCK OF TYPE '.$match[1].' CLOSED' . "\n";
1428
+				if ($this->debug) {
1429
+					echo 'BLOCK OF TYPE '.$match[1].' CLOSED' . "\n";
1430
+				}
1400 1431
 				return $this->removeBlock($match[1]);
1401 1432
 			}
1402 1433
 		} elseif ($curBlock === 'root' && substr($substr, 0, strlen($this->rd)) === $this->rd) {
1403 1434
 			// end template tag
1404
-			if ($this->debug) echo 'TAG PARSING ENDED' . "\n";
1435
+			if ($this->debug) {
1436
+				echo 'TAG PARSING ENDED' . "\n";
1437
+			}
1405 1438
 			$pointer += strlen($this->rd);
1406 1439
 			return false;
1407 1440
 		} elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*='.($curBlock === 'array' ? '>?':'').')(?:\s+|[^=]).*#i', $substr, $match)) {
1408 1441
 			// named parameter
1409
-			if ($this->debug) echo 'NAMED PARAM FOUND' . "\n";
1442
+			if ($this->debug) {
1443
+				echo 'NAMED PARAM FOUND' . "\n";
1444
+			}
1410 1445
 			$len = strlen($match[1]);
1411 1446
 			while (substr($in, $from+$len, 1)===' ') {
1412 1447
 				$len++;
@@ -1446,7 +1481,9 @@  discard block
 block discarded – undo
1446 1481
 		// var parsed, check if any var-extension applies
1447 1482
 		if ($parsed==='var') {
1448 1483
 			if (preg_match('#^\s*([/%+*-])\s*([a-z0-9]|\$)#i', $substr, $match)) {
1449
-				if($this->debug) echo 'PARSING POST-VAR EXPRESSION '.$substr . "\n";
1484
+				if($this->debug) {
1485
+					echo 'PARSING POST-VAR EXPRESSION '.$substr . "\n";
1486
+				}
1450 1487
 				// parse expressions
1451 1488
 				$pointer += strlen($match[0]) - 1;
1452 1489
 				if (is_array($parsingParams)) {
@@ -1476,7 +1513,9 @@  discard block
 block discarded – undo
1476 1513
 					}
1477 1514
 				}
1478 1515
 			} else if ($curBlock === 'root' && preg_match('#^(\s*(?:[+/*%-.]=|=|\+\+|--)\s*)(.*)#s', $substr, $match)) {
1479
-				if($this->debug) echo 'PARSING POST-VAR ASSIGNMENT '.$substr . "\n";
1516
+				if($this->debug) {
1517
+					echo 'PARSING POST-VAR ASSIGNMENT '.$substr . "\n";
1518
+				}
1480 1519
 				// parse assignment
1481 1520
 				$value = $match[2];
1482 1521
 				$operator = trim($match[1]);
@@ -1518,7 +1557,9 @@  discard block
 block discarded – undo
1518 1557
 				$out = Dwoo_Compiler::PHP_OPEN. $echo . $out . $operator . implode(' ', $value) . Dwoo_Compiler::PHP_CLOSE;
1519 1558
 			} else if ($curBlock === 'array' && is_array($parsingParams) && preg_match('#^(\s*=>?\s*)#', $substr, $match)) {
1520 1559
 				// parse namedparam with var as name (only for array)
1521
-				if ($this->debug) echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND' . "\n";
1560
+				if ($this->debug) {
1561
+					echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND' . "\n";
1562
+				}
1522 1563
 				$len = strlen($match[1]);
1523 1564
 				$var = $out[count($out)-1];
1524 1565
 				$pointer += $len;
@@ -1594,7 +1635,9 @@  discard block
 block discarded – undo
1594 1635
 			$cmdstr = $match[1];
1595 1636
 		}
1596 1637
 
1597
-		if ($this->debug) echo 'FUNC FOUND ('.$func.')' . "\n";
1638
+		if ($this->debug) {
1639
+			echo 'FUNC FOUND ('.$func.')' . "\n";
1640
+		}
1598 1641
 
1599 1642
 		$paramsep = '';
1600 1643
 
@@ -1656,17 +1699,25 @@  discard block
 block discarded – undo
1656 1699
 							}
1657 1700
 
1658 1701
 							if ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === ')') {
1659
-								if ($this->debug) echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT '.$ptr . "\n";
1702
+								if ($this->debug) {
1703
+									echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT '.$ptr . "\n";
1704
+								}
1660 1705
 								break 2;
1661 1706
 							} elseif ($paramstr[$ptr] === ';') {
1662 1707
 								$ptr++;
1663
-								if ($this->debug) echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT '.$ptr . "\n";
1708
+								if ($this->debug) {
1709
+									echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT '.$ptr . "\n";
1710
+								}
1664 1711
 								break 2;
1665 1712
 							} elseif ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === '/') {
1666
-								if ($this->debug) echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT '.$ptr . "\n";
1713
+								if ($this->debug) {
1714
+									echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT '.$ptr . "\n";
1715
+								}
1667 1716
 								break 2;
1668 1717
 							} elseif (substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) {
1669
-								if ($this->debug) echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT '.$ptr . "\n";
1718
+								if ($this->debug) {
1719
+									echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT '.$ptr . "\n";
1720
+								}
1670 1721
 								break 2;
1671 1722
 							}
1672 1723
 
@@ -1677,7 +1728,9 @@  discard block
 block discarded – undo
1677 1728
 							}
1678 1729
 						}
1679 1730
 
1680
-						if ($this->debug) echo 'FUNC START PARAM PARSING WITH POINTER AT '.$ptr . "\n";
1731
+						if ($this->debug) {
1732
+							echo 'FUNC START PARAM PARSING WITH POINTER AT '.$ptr . "\n";
1733
+						}
1681 1734
 
1682 1735
 						if ($func === 'if' || $func === 'elseif' || $func === 'tif') {
1683 1736
 							$params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'condition', $ptr);
@@ -1687,7 +1740,9 @@  discard block
 block discarded – undo
1687 1740
 							$params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'function', $ptr);
1688 1741
 						}
1689 1742
 
1690
-						if ($this->debug) echo 'PARAM PARSED, POINTER AT '.$ptr.' ('.substr($paramstr, $ptr-1, 3).')' . "\n";
1743
+						if ($this->debug) {
1744
+							echo 'PARAM PARSED, POINTER AT '.$ptr.' ('.substr($paramstr, $ptr-1, 3).')' . "\n";
1745
+						}
1691 1746
 					}
1692 1747
 				}
1693 1748
 				$paramstr = substr($paramstr, 0, $ptr);
@@ -1711,7 +1766,9 @@  discard block
 block discarded – undo
1711 1766
 
1712 1767
 		if ($pointer !== null) {
1713 1768
 			$pointer += (isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func) + (isset($whitespace) ? $whitespace : 0);
1714
-			if ($this->debug) echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func)).' TO POINTER' . "\n";
1769
+			if ($this->debug) {
1770
+				echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func)).' TO POINTER' . "\n";
1771
+			}
1715 1772
 		}
1716 1773
 
1717 1774
 		if ($curBlock === 'method' || $func === 'do' || strstr($func, '::') !== false) {
@@ -1836,8 +1893,7 @@  discard block
 block discarded – undo
1836 1893
 					if ($callback instanceof \Closure) {
1837 1894
 						array_unshift($params, $this->getDwoo());
1838 1895
 						$output = call_user_func_array($callback, $params);
1839
-					}
1840
-					else {
1896
+					} else {
1841 1897
 						array_unshift($params, '$this');
1842 1898
 						$params = self::implode_r($params);
1843 1899
 						$output = 'call_user_func(\'' . $callback . '\', ' . $params . ')';
@@ -1952,7 +2008,9 @@  discard block
 block discarded – undo
1952 2008
 		$substr = substr($in, $from, $to-$from);
1953 2009
 		$first = $substr[0];
1954 2010
 
1955
-		if ($this->debug) echo 'STRING FOUND (in '.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').')' . "\n";
2011
+		if ($this->debug) {
2012
+			echo 'STRING FOUND (in '.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').')' . "\n";
2013
+		}
1956 2014
 		$strend = false;
1957 2015
 		$o = $from+1;
1958 2016
 		while ($strend === false) {
@@ -1965,7 +2023,9 @@  discard block
 block discarded – undo
1965 2023
 				$strend = false;
1966 2024
 			}
1967 2025
 		}
1968
-		if ($this->debug) echo 'STRING DELIMITED: '.substr($in, $from, $strend+1-$from) . "\n";
2026
+		if ($this->debug) {
2027
+			echo 'STRING DELIMITED: '.substr($in, $from, $strend+1-$from) . "\n";
2028
+		}
1969 2029
 
1970 2030
 		$srcOutput = substr($in, $from, $strend+1-$from);
1971 2031
 
@@ -2171,11 +2231,15 @@  discard block
 block discarded – undo
2171 2231
 				}
2172 2232
 				unset($uid, $current, $curTxt, $tree, $chars);
2173 2233
 
2174
-				if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT : '.$key . "\n";
2234
+				if ($this->debug) {
2235
+					echo 'RECURSIVE VAR REPLACEMENT : '.$key . "\n";
2236
+				}
2175 2237
 
2176 2238
 				$key = $this->flattenVarTree($parsed);
2177 2239
 
2178
-				if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key . "\n";
2240
+				if ($this->debug) {
2241
+					echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key . "\n";
2242
+				}
2179 2243
 
2180 2244
 				$output = preg_replace('#(^""\.|""\.|\.""$|(\()""\.|\.""(\)))#', '$2$3', '$this->readVar("'.$key.'")');
2181 2245
 			} else {
@@ -2355,8 +2419,9 @@  discard block
 block discarded – undo
2355 2419
 				$global = 'COOKIE';
2356 2420
 			}
2357 2421
 			$key = '$_'.$global;
2358
-			foreach (explode('.', ltrim($m[2], '.')) as $part)
2359
-				$key .= '['.var_export($part, true).']';
2422
+			foreach (explode('.', ltrim($m[2], '.')) as $part) {
2423
+							$key .= '['.var_export($part, true).']';
2424
+			}
2360 2425
 			if ($curBlock === 'root') {
2361 2426
 				$output = $key;
2362 2427
 			} else {
@@ -2466,7 +2531,9 @@  discard block
 block discarded – undo
2466 2531
 				} else {
2467 2532
 					$cnt = substr_count($key, '$');
2468 2533
 
2469
-					if ($this->debug) echo 'PARSING SUBVARS IN : '.$key . "\n";
2534
+					if ($this->debug) {
2535
+						echo 'PARSING SUBVARS IN : '.$key . "\n";
2536
+					}
2470 2537
 					if ($cnt > 0) {
2471 2538
 						while (--$cnt >= 0) {
2472 2539
 							if (isset($last)) {
@@ -2488,7 +2555,9 @@  discard block
 block discarded – undo
2488 2555
 								$last,
2489 2556
 								$len
2490 2557
 							);
2491
-							if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key . "\n";
2558
+							if ($this->debug) {
2559
+								echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key . "\n";
2560
+							}
2492 2561
 						}
2493 2562
 						unset($last);
2494 2563
 
@@ -2569,15 +2638,21 @@  discard block
 block discarded – undo
2569 2638
 		$substr = trim($substr);
2570 2639
 
2571 2640
 		if (strtolower($substr) === 'false' || strtolower($substr) === 'no' || strtolower($substr) === 'off') {
2572
-			if ($this->debug) echo 'BOOLEAN(FALSE) PARSED' . "\n";
2641
+			if ($this->debug) {
2642
+				echo 'BOOLEAN(FALSE) PARSED' . "\n";
2643
+			}
2573 2644
 			$substr = 'false';
2574 2645
 			$type = self::T_BOOL;
2575 2646
 		} elseif (strtolower($substr) === 'true' || strtolower($substr) === 'yes' || strtolower($substr) === 'on') {
2576
-			if ($this->debug) echo 'BOOLEAN(TRUE) PARSED' . "\n";
2647
+			if ($this->debug) {
2648
+				echo 'BOOLEAN(TRUE) PARSED' . "\n";
2649
+			}
2577 2650
 			$substr = 'true';
2578 2651
 			$type = self::T_BOOL;
2579 2652
 		} elseif ($substr === 'null' || $substr === 'NULL') {
2580
-			if ($this->debug) echo 'NULL PARSED' . "\n";
2653
+			if ($this->debug) {
2654
+				echo 'NULL PARSED' . "\n";
2655
+			}
2581 2656
 			$substr = 'null';
2582 2657
 			$type = self::T_NULL;
2583 2658
 		} elseif (is_numeric($substr)) {
@@ -2586,19 +2661,27 @@  discard block
 block discarded – undo
2586 2661
 				$substr = (int) $substr;
2587 2662
 			}
2588 2663
 			$type = self::T_NUMERIC;
2589
-			if ($this->debug) echo 'NUMBER ('.$substr.') PARSED' . "\n";
2664
+			if ($this->debug) {
2665
+				echo 'NUMBER ('.$substr.') PARSED' . "\n";
2666
+			}
2590 2667
 		} elseif (preg_match('{^-?(\d+|\d*(\.\d+))\s*([/*%+-]\s*-?(\d+|\d*(\.\d+)))+$}', $substr)) {
2591
-			if ($this->debug) echo 'SIMPLE MATH PARSED . "\n"';
2668
+			if ($this->debug) {
2669
+				echo 'SIMPLE MATH PARSED . "\n"';
2670
+			}
2592 2671
 			$type = self::T_MATH;
2593 2672
 			$substr = '('.$substr.')';
2594 2673
 		} elseif ($curBlock === 'condition' && array_search($substr, $breakChars, true) !== false) {
2595
-			if ($this->debug) echo 'BREAKCHAR ('.$substr.') PARSED' . "\n";
2674
+			if ($this->debug) {
2675
+				echo 'BREAKCHAR ('.$substr.') PARSED' . "\n";
2676
+			}
2596 2677
 			$type = self::T_BREAKCHAR;
2597 2678
 			//$substr = '"'.$substr.'"';
2598 2679
 		} else {
2599 2680
 			$substr = $this->replaceStringVars('\''.str_replace('\'', '\\\'', $substr).'\'', '\'', $curBlock);
2600 2681
 			$type = self::T_UNQUOTED_STRING;
2601
-			if ($this->debug) echo 'BLABBER ('.$substr.') CASTED AS STRING' . "\n";
2682
+			if ($this->debug) {
2683
+				echo 'BLABBER ('.$substr.') CASTED AS STRING' . "\n";
2684
+			}
2602 2685
 		}
2603 2686
 
2604 2687
 		if (is_array($parsingParams)) {
@@ -2624,7 +2707,9 @@  discard block
 block discarded – undo
2624 2707
 	protected function replaceStringVars($string, $first, $curBlock='')
2625 2708
 	{
2626 2709
 		$pos = 0;
2627
-		if ($this->debug) echo 'STRING VAR REPLACEMENT : '.$string . "\n";
2710
+		if ($this->debug) {
2711
+			echo 'STRING VAR REPLACEMENT : '.$string . "\n";
2712
+		}
2628 2713
 		// replace vars
2629 2714
 		while (($pos = strpos($string, '$', $pos)) !== false) {
2630 2715
 			$prev = substr($string, $pos-1, 1);
@@ -2643,7 +2728,9 @@  discard block
 block discarded – undo
2643 2728
 				$string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos, $len);
2644 2729
 			}
2645 2730
 			$pos += strlen($var[1]) + 2;
2646
-			if ($this->debug) echo 'STRING VAR REPLACEMENT DONE : '.$string . "\n";
2731
+			if ($this->debug) {
2732
+				echo 'STRING VAR REPLACEMENT DONE : '.$string . "\n";
2733
+			}
2647 2734
 		}
2648 2735
 
2649 2736
 		// handle modifiers
@@ -2669,7 +2756,9 @@  discard block
 block discarded – undo
2669 2756
 	 */
2670 2757
 	protected function replaceModifiers(array $m, $curBlock = null, &$pointer = null)
2671 2758
 	{
2672
-		if ($this->debug) echo 'PARSING MODIFIERS : '.$m[3] . "\n";
2759
+		if ($this->debug) {
2760
+			echo 'PARSING MODIFIERS : '.$m[3] . "\n";
2761
+		}
2673 2762
 
2674 2763
 		if ($pointer !== null) {
2675 2764
 			$pointer += strlen($m[3]);
@@ -2691,7 +2780,9 @@  discard block
 block discarded – undo
2691 2780
 				continue;
2692 2781
 			}
2693 2782
 			if ($cmdstrsrc[0] === ' ' || $cmdstrsrc[0] === ';' || substr($cmdstrsrc, 0, strlen($this->rd)) === $this->rd) {
2694
-				if ($this->debug) echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND' . "\n";
2783
+				if ($this->debug) {
2784
+					echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND' . "\n";
2785
+				}
2695 2786
 				$continue = false;
2696 2787
 				if ($pointer !== null) {
2697 2788
 					$pointer -= strlen($cmdstrsrc);
@@ -2710,7 +2801,9 @@  discard block
 block discarded – undo
2710 2801
 			if ($paramspos === false) {
2711 2802
 				$cmdstrsrc = substr($cmdstrsrc, strlen($func));
2712 2803
 				$params = array();
2713
-				if ($this->debug) echo 'MODIFIER ('.$func.') CALLED WITH NO PARAMS' . "\n";
2804
+				if ($this->debug) {
2805
+					echo 'MODIFIER ('.$func.') CALLED WITH NO PARAMS' . "\n";
2806
+				}
2714 2807
 			} else {
2715 2808
 				$paramstr = substr($cmdstr, $paramspos+1);
2716 2809
 				if (substr($paramstr, -1, 1) === $paramsep) {
@@ -2720,18 +2813,28 @@  discard block
 block discarded – undo
2720 2813
 				$ptr = 0;
2721 2814
 				$params = array();
2722 2815
 				while ($ptr < strlen($paramstr)) {
2723
-					if ($this->debug) echo 'MODIFIER ('.$func.') START PARAM PARSING WITH POINTER AT '.$ptr . "\n";
2724
-					if ($this->debug) echo $paramstr.'--'.$ptr.'--'.strlen($paramstr).'--modifier' . "\n";
2816
+					if ($this->debug) {
2817
+						echo 'MODIFIER ('.$func.') START PARAM PARSING WITH POINTER AT '.$ptr . "\n";
2818
+					}
2819
+					if ($this->debug) {
2820
+						echo $paramstr.'--'.$ptr.'--'.strlen($paramstr).'--modifier' . "\n";
2821
+					}
2725 2822
 					$params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'modifier', $ptr);
2726
-					if ($this->debug) echo 'PARAM PARSED, POINTER AT '.$ptr . "\n";
2823
+					if ($this->debug) {
2824
+						echo 'PARAM PARSED, POINTER AT '.$ptr . "\n";
2825
+					}
2727 2826
 
2728 2827
 					if ($ptr >= strlen($paramstr)) {
2729
-						if ($this->debug) echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED' . "\n";
2828
+						if ($this->debug) {
2829
+							echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED' . "\n";
2830
+						}
2730 2831
 						break;
2731 2832
 					}
2732 2833
 
2733 2834
 					if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === '|' || $paramstr[$ptr] === ';' || substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) {
2734
-						if ($this->debug) echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT '.$ptr . "\n";
2835
+						if ($this->debug) {
2836
+							echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT '.$ptr . "\n";
2837
+						}
2735 2838
 						if ($paramstr[$ptr] !== '|') {
2736 2839
 							$continue = false;
2737 2840
 							if ($pointer !== null) {
@@ -2792,8 +2895,9 @@  discard block
 block discarded – undo
2792 2895
 				}
2793 2896
 			} elseif ($pluginType & Dwoo_Core::PROXY_PLUGIN) {
2794 2897
 				$params = $this->mapParams($params, $this->getDwoo()->getPluginProxy()->getCallback($func), $state);
2795
-				foreach ($params as &$p)
2796
-					$p = $p[0];
2898
+				foreach ($params as &$p) {
2899
+									$p = $p[0];
2900
+				}
2797 2901
 				$output = call_user_func(array($this->dwoo->getPluginProxy(), 'getCode'), $func, $params);
2798 2902
 			} elseif ($pluginType & Dwoo_Core::SMARTY_MODIFIER) {
2799 2903
 				$params = $this->mapParams($params, null, $state);
@@ -2835,8 +2939,9 @@  discard block
 block discarded – undo
2835 2939
 
2836 2940
 				$params = $this->mapParams($params, $callback, $state);
2837 2941
 
2838
-				foreach ($params as &$p)
2839
-					$p = $p[0];
2942
+				foreach ($params as &$p) {
2943
+									$p = $p[0];
2944
+				}
2840 2945
 
2841 2946
 				if ($pluginType & Dwoo_Core::FUNC_PLUGIN) {
2842 2947
 					if ($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) {
@@ -2929,8 +3034,9 @@  discard block
 block discarded – undo
2929 3034
 		foreach ($params as $k=>$p) {
2930 3035
 			if (is_array($p)) {
2931 3036
 				$out2 = 'array(';
2932
-				foreach ($p as $k2=>$v)
2933
-					$out2 .= var_export($k2, true).' => '.(is_array($v) ? 'array('.self::implode_r($v, true).')' : $v).', ';
3037
+				foreach ($p as $k2=>$v) {
3038
+									$out2 .= var_export($k2, true).' => '.(is_array($v) ? 'array('.self::implode_r($v, true).')' : $v).', ';
3039
+				}
2934 3040
 				$p = rtrim($out2, ', ').')';
2935 3041
 			}
2936 3042
 			if ($recursiveCall) {
Please login to merge, or discard this patch.
lib/Dwoo/Adapters/Agavi/DwooRenderer.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	protected function getEngine()
128 128
 	{
129
-		if($this->dwoo) {
129
+		if ($this->dwoo) {
130 130
 			return $this->dwoo;
131 131
 		}
132 132
 
133 133
 		// this triggers Agavi autoload
134
-		if(!class_exists('Dwoo')) {
134
+		if (!class_exists('Dwoo')) {
135 135
 			if (file_exists(dirname(__FILE__).'/../../../dwooAutoload.php')) {
136 136
 				// file was dropped with the entire dwoo package
137 137
 				require dirname(__FILE__).'/../../../dwooAutoload.php';
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 
144 144
 		$parentMode = fileperms(AgaviConfig::get('core.cache_dir'));
145 145
 
146
-		$compileDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::COMPILE_DIR . DIRECTORY_SEPARATOR . self::COMPILE_SUBDIR;
146
+		$compileDir = AgaviConfig::get('core.cache_dir').DIRECTORY_SEPARATOR.self::COMPILE_DIR.DIRECTORY_SEPARATOR.self::COMPILE_SUBDIR;
147 147
 		AgaviToolkit::mkdir($compileDir, $parentMode, true);
148 148
 
149
-		$cacheDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::CACHE_DIR;
149
+		$cacheDir = AgaviConfig::get('core.cache_dir').DIRECTORY_SEPARATOR.self::CACHE_DIR;
150 150
 		AgaviToolkit::mkdir($cacheDir, $parentMode, true);
151 151
 
152 152
 		$this->dwoo = new Dwoo_Core($compileDir, $cacheDir);
@@ -177,23 +177,23 @@  discard block
 block discarded – undo
177 177
 		$engine = $this->getEngine();
178 178
 
179 179
 		$data = array();
180
-		if($this->extractVars) {
180
+		if ($this->extractVars) {
181 181
 			$data = $attributes;
182 182
 		} else {
183 183
 			$data[$this->varName] = &$attributes;
184 184
 		}
185 185
 
186
-		$data[$this->slotsVarName] =& $slots;
186
+		$data[$this->slotsVarName] = & $slots;
187 187
 
188
-		foreach($this->assigns as $key => $getter) {
188
+		foreach ($this->assigns as $key => $getter) {
189 189
 			$data[$key] = $this->getContext()->$getter();
190 190
 		}
191 191
 
192
-		foreach($moreAssigns as $key => &$value) {
193
-			if(isset($this->moreAssignNames[$key])) {
192
+		foreach ($moreAssigns as $key => &$value) {
193
+			if (isset($this->moreAssignNames[$key])) {
194 194
 				$key = $this->moreAssignNames[$key];
195 195
 			}
196
-			$data[$key] =& $value;
196
+			$data[$key] = & $value;
197 197
 		}
198 198
 
199 199
 		return $engine->get($layer->getResourceStreamIdentifier(), $data);
Please login to merge, or discard this patch.