@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | { |
61 | 61 | $p = array(); |
62 | 62 | |
63 | - foreach($params as $k => $v) { |
|
64 | - $v = (string)$v; |
|
63 | + foreach ($params as $k => $v) { |
|
64 | + $v = (string) $v; |
|
65 | 65 | if (substr($v, 0, 1) === '"' || substr($v, 0, 1) === '\'') { |
66 | 66 | $vmod = strtolower(substr($v, 1, - 1)); |
67 | 67 | } else { |
@@ -170,59 +170,59 @@ discard block |
||
170 | 170 | $p[] = $v; |
171 | 171 | break; |
172 | 172 | } |
173 | - if (isset($params[$k + 1]) && strtolower(trim($params[$k + 1], '"\'')) === 'not' && $tokens[$k + 1] === Compiler::T_UNQUOTED_STRING) { |
|
173 | + if (isset($params[$k+1]) && strtolower(trim($params[$k+1], '"\'')) === 'not' && $tokens[$k+1] === Compiler::T_UNQUOTED_STRING) { |
|
174 | 174 | $negate = true; |
175 | 175 | next($params); |
176 | 176 | } else { |
177 | 177 | $negate = false; |
178 | 178 | } |
179 | - $ptr = 1 + (int)$negate; |
|
180 | - if ($tokens[$k + $ptr] !== Compiler::T_UNQUOTED_STRING) { |
|
179 | + $ptr = 1+(int) $negate; |
|
180 | + if ($tokens[$k+$ptr] !== Compiler::T_UNQUOTED_STRING) { |
|
181 | 181 | break; |
182 | 182 | } |
183 | - if (!isset($params[$k + $ptr])) { |
|
184 | - $params[$k + $ptr] = ''; |
|
183 | + if (!isset($params[$k+$ptr])) { |
|
184 | + $params[$k+$ptr] = ''; |
|
185 | 185 | } else { |
186 | - $params[$k + $ptr] = trim($params[$k + $ptr], '"\''); |
|
186 | + $params[$k+$ptr] = trim($params[$k+$ptr], '"\''); |
|
187 | 187 | } |
188 | - switch ($params[$k + $ptr]) { |
|
188 | + switch ($params[$k+$ptr]) { |
|
189 | 189 | |
190 | 190 | case 'div': |
191 | - if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') { |
|
192 | - $p[] = ' % ' . $params[$k + $ptr + 2] . ' ' . ($negate ? '!' : '=') . '== 0'; |
|
191 | + if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') { |
|
192 | + $p[] = ' % '.$params[$k+$ptr+2].' '.($negate ? '!' : '=').'== 0'; |
|
193 | 193 | next($params); |
194 | 194 | next($params); |
195 | 195 | next($params); |
196 | 196 | } else { |
197 | - throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] div by $b", found ' . $params[$k - 1] . ' is ' . ($negate ? 'not ' : '') . 'div ' . $params[$k + $ptr + 1] . ' ' . $params[$k + $ptr + 2]); |
|
197 | + throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] div by $b", found '.$params[$k-1].' is '.($negate ? 'not ' : '').'div '.$params[$k+$ptr+1].' '.$params[$k+$ptr+2]); |
|
198 | 198 | } |
199 | 199 | break; |
200 | 200 | case 'even': |
201 | 201 | $a = array_pop($p); |
202 | - if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') { |
|
203 | - $b = $params[$k + $ptr + 2]; |
|
204 | - $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '!' : '=') . '== 0'; |
|
202 | + if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') { |
|
203 | + $b = $params[$k+$ptr+2]; |
|
204 | + $p[] = '('.$a.' / '.$b.') % 2 '.($negate ? '!' : '=').'== 0'; |
|
205 | 205 | next($params); |
206 | 206 | next($params); |
207 | 207 | } else { |
208 | - $p[] = $a . ' % 2 ' . ($negate ? '!' : '=') . '== 0'; |
|
208 | + $p[] = $a.' % 2 '.($negate ? '!' : '=').'== 0'; |
|
209 | 209 | } |
210 | 210 | next($params); |
211 | 211 | break; |
212 | 212 | case 'odd': |
213 | 213 | $a = array_pop($p); |
214 | - if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') { |
|
215 | - $b = $params[$k + $ptr + 2]; |
|
216 | - $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '=' : '!') . '== 0'; |
|
214 | + if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') { |
|
215 | + $b = $params[$k+$ptr+2]; |
|
216 | + $p[] = '('.$a.' / '.$b.') % 2 '.($negate ? '=' : '!').'== 0'; |
|
217 | 217 | next($params); |
218 | 218 | next($params); |
219 | 219 | } else { |
220 | - $p[] = $a . ' % 2 ' . ($negate ? '=' : '!') . '== 0'; |
|
220 | + $p[] = $a.' % 2 '.($negate ? '=' : '!').'== 0'; |
|
221 | 221 | } |
222 | 222 | next($params); |
223 | 223 | break; |
224 | 224 | default: |
225 | - throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] (div|even|odd) [by $b]", found ' . $params[$k - 1] . ' is ' . $params[$k + $ptr + 1]); |
|
225 | + throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] (div|even|odd) [by $b]", found '.$params[$k-1].' is '.$params[$k+$ptr+1]); |
|
226 | 226 | } |
227 | 227 | break; |
228 | 228 | default: |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | { |
261 | 261 | $tokens = $compiler->getParamTokens($params); |
262 | 262 | $params = $compiler->getCompiledParams($params); |
263 | - $pre = Compiler::PHP_OPEN . 'if (' . implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)) . ") {\n" . Compiler::PHP_CLOSE; |
|
263 | + $pre = Compiler::PHP_OPEN.'if ('.implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)).") {\n".Compiler::PHP_CLOSE; |
|
264 | 264 | |
265 | - $post = Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; |
|
265 | + $post = Compiler::PHP_OPEN."\n}".Compiler::PHP_CLOSE; |
|
266 | 266 | |
267 | 267 | if (isset($params['hasElse'])) { |
268 | 268 | $post .= $params['hasElse']; |
269 | 269 | } |
270 | 270 | |
271 | - return $pre . $content . $post; |
|
271 | + return $pre.$content.$post; |
|
272 | 272 | } |
273 | 273 | } |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | break; |
73 | 73 | } |
74 | 74 | |
75 | - $this->wrap = (int)$wrap; |
|
76 | - $this->wrapChar = (string)$wrap_char; |
|
77 | - $this->wrapCut = (bool)$wrap_cut; |
|
78 | - $this->indent = (int)$indent; |
|
79 | - $this->indChar = (string)$indent_char; |
|
80 | - $this->indFirst = (int)$indent_first + $this->indent; |
|
81 | - $this->assign = (string)$assign; |
|
75 | + $this->wrap = (int) $wrap; |
|
76 | + $this->wrapChar = (string) $wrap_char; |
|
77 | + $this->wrapCut = (bool) $wrap_cut; |
|
78 | + $this->indent = (int) $indent; |
|
79 | + $this->indChar = (string) $indent_char; |
|
80 | + $this->indFirst = (int) $indent_first+$this->indent; |
|
81 | + $this->assign = (string) $assign; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | "\r" |
93 | 93 | ), "\n", $this->buffer)); |
94 | 94 | |
95 | - foreach($pgs as $i => $v) { |
|
95 | + foreach ($pgs as $i => $v) { |
|
96 | 96 | if (empty($pgs[$i])) { |
97 | 97 | continue; |
98 | 98 | } |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | ), str_replace("\n", '', $pgs[$i])); |
108 | 108 | |
109 | 109 | // wordwraps + indents lines |
110 | - $pgs[$i] = str_repeat($this->indChar, $this->indFirst) . wordwrap($pgs[$i], max($this->wrap - $this->indent, 1), $this->wrapChar . str_repeat($this->indChar, $this->indent), $this->wrapCut); |
|
110 | + $pgs[$i] = str_repeat($this->indChar, $this->indFirst).wordwrap($pgs[$i], max($this->wrap-$this->indent, 1), $this->wrapChar.str_repeat($this->indChar, $this->indent), $this->wrapCut); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | if ($this->assign !== '') { |
114 | - $this->core->assignInScope(implode($this->wrapChar . $this->wrapChar, $pgs), $this->assign); |
|
114 | + $this->core->assignInScope(implode($this->wrapChar.$this->wrapChar, $pgs), $this->assign); |
|
115 | 115 | } else { |
116 | - return implode($this->wrapChar . $this->wrapChar, $pgs); |
|
116 | + return implode($this->wrapChar.$this->wrapChar, $pgs); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |