Completed
Branch 1.3.x (b833d8)
by Ben
05:10
created
classes/PHPTAL/Php/Attribute/PHPTAL/Cache.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,12 +67,12 @@
 block discarded – undo
67 67
         } elseif ($cache_per_expression == 'nothing') {
68 68
             /* do nothing */
69 69
         } elseif ($cache_per_expression) {
70
-             $code = $codewriter->evaluateExpression($cache_per_expression);
70
+                $code = $codewriter->evaluateExpression($cache_per_expression);
71 71
 
72
-             if (is_array($code)) throw new PHPTAL_ParserException("Chained expressions in per-cache directive are not supported",
72
+                if (is_array($code)) throw new PHPTAL_ParserException("Chained expressions in per-cache directive are not supported",
73 73
                                                 $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
74 74
 
75
-             $cache_tag = '('.$code.')."@".' . $cache_tag;
75
+                $cache_tag = '('.$code.')."@".' . $cache_tag;
76 76
         }
77 77
 
78 78
         $this->cache_filename_var = $codewriter->createTempVariable();
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,8 +50,10 @@  discard block
 block discarded – undo
50 50
         if (!is_numeric($cache_len)) {
51 51
             $cache_len = $codewriter->evaluateExpression($cache_len);
52 52
 
53
-            if (is_array($cache_len)) throw new PHPTAL_ParserException("Chained expressions in cache length are not supported",
53
+            if (is_array($cache_len)) {
54
+                throw new PHPTAL_ParserException("Chained expressions in cache length are not supported",
54 55
                                         $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
56
+            }
55 57
         }
56 58
         switch ($matches[2]) {
57 59
             case 'd': $cache_len .= '*24'; /* no break */
@@ -69,8 +71,10 @@  discard block
 block discarded – undo
69 71
         } elseif ($cache_per_expression) {
70 72
              $code = $codewriter->evaluateExpression($cache_per_expression);
71 73
 
72
-             if (is_array($code)) throw new PHPTAL_ParserException("Chained expressions in per-cache directive are not supported",
74
+             if (is_array($code)) {
75
+                 throw new PHPTAL_ParserException("Chained expressions in per-cache directive are not supported",
73 76
                                                 $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
77
+             }
74 78
 
75 79
              $cache_tag = '('.$code.')."@".' . $cache_tag;
76 80
         }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
             case 'm': $cache_len .= '*60'; /* no break */
60 60
         }
61 61
 
62
-        $cache_tag = '"'.addslashes( $this->phpelement->getQualifiedName() . ':' . $this->phpelement->getSourceLine()).'"';
62
+        $cache_tag = '"'.addslashes($this->phpelement->getQualifiedName().':'.$this->phpelement->getSourceLine()).'"';
63 63
 
64
-        $cache_per_expression = isset($matches[3])?trim($matches[3]):null;
64
+        $cache_per_expression = isset($matches[3]) ?trim($matches[3]) : null;
65 65
         if ($cache_per_expression == 'url') {
66 66
             $cache_tag .= '.$_SERVER["REQUEST_URI"]';
67 67
         } elseif ($cache_per_expression == 'nothing') {
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
              if (is_array($code)) throw new PHPTAL_ParserException("Chained expressions in per-cache directive are not supported",
73 73
                                                 $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
74 74
 
75
-             $cache_tag = '('.$code.')."@".' . $cache_tag;
75
+             $cache_tag = '('.$code.')."@".'.$cache_tag;
76 76
         }
77 77
 
78 78
         $this->cache_filename_var = $codewriter->createTempVariable();
79
-        $codewriter->doSetVar($this->cache_filename_var, $codewriter->str($codewriter->getCacheFilesBaseName()).'.md5('.$cache_tag.')' );
79
+        $codewriter->doSetVar($this->cache_filename_var, $codewriter->str($codewriter->getCacheFilesBaseName()).'.md5('.$cache_tag.')');
80 80
 
81 81
         $cond = '!file_exists('.$this->cache_filename_var.') || time() - '.$cache_len.' >= filemtime('.$this->cache_filename_var.')';
82 82
 
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute/PHPTAL/Tales.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,9 @@
 block discarded – undo
24 24
         $mode = trim($this->expression);
25 25
         $mode = strtolower($mode);
26 26
 
27
-        if ($mode == '' || $mode == 'default')
28
-            $mode = 'tales';
27
+        if ($mode == '' || $mode == 'default') {
28
+                    $mode = 'tales';
29
+        }
29 30
 
30 31
         if ($mode != 'php' && $mode != 'tales') {
31 32
             throw new PHPTAL_TemplateException("Unsupported TALES mode '$mode'",
Please login to merge, or discard this patch.
classes/PHPTAL/Php/TalesChainExecutor.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -79,10 +79,12 @@
 block discarded – undo
79 79
                 $this->_reader->talesChainPart($this, $exp, $lastkey === $key);
80 80
             }
81 81
 
82
-            if ($this->_state == self::CHAIN_BREAK)
83
-                break;
84
-            if ($this->_state == self::CHAIN_CONT)
85
-                continue;
82
+            if ($this->_state == self::CHAIN_BREAK) {
83
+                            break;
84
+            }
85
+            if ($this->_state == self::CHAIN_CONT) {
86
+                            continue;
87
+            }
86 88
         }
87 89
 
88 90
         $this->codewriter->doEnd('if');
Please login to merge, or discard this patch.
classes/PHPTAL/Php/CodeWriter.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
     /**
25 25
      * max id of variable to give as temp
26 26
      */
27
-    private $temp_var_counter=0;
27
+    private $temp_var_counter = 0;
28 28
     /**
29 29
      * stack with free'd variables
30 30
      */
31
-    private $temp_recycling=array();
31
+    private $temp_recycling = array();
32 32
 
33 33
     /**
34 34
      * keeps track of seen functions for function_exists
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
     public function recycleTempVariable($var)
51 51
     {
52
-        if (substr($var, 0, 6)!=='$_tmp_') throw new PHPTAL_Exception("Invalid variable recycled");
52
+        if (substr($var, 0, 6) !== '$_tmp_') throw new PHPTAL_Exception("Invalid variable recycled");
53 53
         $this->temp_recycling[] = $var;
54 54
     }
55 55
 
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
 
141 141
     public function indent()
142 142
     {
143
-        $this->_indentation ++;
143
+        $this->_indentation++;
144 144
     }
145 145
 
146 146
     public function unindent()
147 147
     {
148
-        $this->_indentation --;
148
+        $this->_indentation--;
149 149
     }
150 150
 
151 151
     public function flush()
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
             }
188 188
             $this->_result .= $codeLine;
189 189
         }
190
-        $this->_result .= "?>\n";// PHP consumes newline
190
+        $this->_result .= "?>\n"; // PHP consumes newline
191 191
         $this->_codeBuffer = array();
192 192
     }
193 193
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     public function doDoctype($called_from_macro = false)
208 208
     {
209 209
         if ($this->_doctype) {
210
-            $code = '$ctx->setDocType('.$this->str($this->_doctype).','.($called_from_macro?'true':'false').')';
210
+            $code = '$ctx->setDocType('.$this->str($this->_doctype).','.($called_from_macro ? 'true' : 'false').')';
211 211
             $this->pushCode($code);
212 212
         }
213 213
     }
@@ -220,21 +220,21 @@  discard block
 block discarded – undo
220 220
     public function doXmlDeclaration($called_from_macro = false)
221 221
     {
222 222
         if ($this->_xmldeclaration && $this->getOutputMode() !== PHPTAL::HTML5) {
223
-            $code = '$ctx->setXmlDeclaration('.$this->str($this->_xmldeclaration).','.($called_from_macro?'true':'false').')';
223
+            $code = '$ctx->setXmlDeclaration('.$this->str($this->_xmldeclaration).','.($called_from_macro ? 'true' : 'false').')';
224 224
             $this->pushCode($code);
225 225
         }
226 226
     }
227 227
 
228 228
     public function functionExists($name)
229 229
     {
230
-        return isset($this->known_functions[$this->_functionPrefix . $name]);
230
+        return isset($this->known_functions[$this->_functionPrefix.$name]);
231 231
     }
232 232
 
233 233
     public function doTemplateFile($functionName, PHPTAL_Dom_Element $treeGen)
234 234
     {
235 235
         $this->doComment("\n*** DO NOT EDIT THIS FILE ***\n\nGenerated by PHPTAL from ".$treeGen->getSourceFile()." (edit that file instead)");
236 236
         $this->doFunction($functionName, 'PHPTAL $tpl, PHPTAL_Context $ctx');
237
-        $this->setFunctionPrefix($functionName . "_");
237
+        $this->setFunctionPrefix($functionName."_");
238 238
         $this->doSetVar('$_thistpl', '$tpl');
239 239
         $this->doInitTranslator();
240 240
         $treeGen->generateCode($this);
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 
245 245
     public function doFunction($name, $params)
246 246
     {
247
-        $name = $this->_functionPrefix . $name;
247
+        $name = $this->_functionPrefix.$name;
248 248
         $this->known_functions[$name] = true;
249 249
 
250 250
         $this->pushCodeWriterContext();
251 251
         $this->pushCode("function $name($params) {\n");
252 252
         $this->indent();
253
-        $this->_segments[] =  'function';
253
+        $this->_segments[] = 'function';
254 254
     }
255 255
 
256 256
     public function doComment($comment)
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
     public function doForeach($out, $source)
283 283
     {
284
-        $this->_segments[] =  'foreach';
284
+        $this->_segments[] = 'foreach';
285 285
         $this->pushCode("foreach ($source as $out):");
286 286
         $this->indent();
287 287
     }
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             $this->flush();
305 305
             $functionCode = $this->_result;
306 306
             $this->popCodeWriterContext();
307
-            $this->_result = $functionCode . $this->_result;
307
+            $this->_result = $functionCode.$this->_result;
308 308
         } elseif ($segment == 'try')
309 309
             $this->pushCode('}');
310 310
         elseif ($segment == 'catch')
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
     public function doTry()
317 317
     {
318
-        $this->_segments[] =  'try';
318
+        $this->_segments[] = 'try';
319 319
         $this->pushCode('try {');
320 320
         $this->indent();
321 321
     }
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
     public function doCatch($catch)
329 329
     {
330 330
         $this->doEnd('try');
331
-        $this->_segments[] =  'catch';
331
+        $this->_segments[] = 'catch';
332 332
         $this->pushCode('catch('.$catch.') {');
333 333
         $this->indent();
334 334
     }
335 335
 
336 336
     public function doIf($condition)
337 337
     {
338
-        $this->_segments[] =  'if';
338
+        $this->_segments[] = 'if';
339 339
         $this->pushCode('if ('.$condition.'): ');
340 340
         $this->indent();
341 341
     }
@@ -387,14 +387,14 @@  discard block
 block discarded – undo
387 387
     {
388 388
         if ($html === "") return;
389 389
         $this->flushCode();
390
-        $this->_htmlBuffer[] =  $html;
390
+        $this->_htmlBuffer[] = $html;
391 391
     }
392 392
 
393 393
     public function pushCode($codeLine)
394 394
     {
395 395
         $this->flushHtml();
396
-        $codeLine = $this->indentSpaces() . $codeLine;
397
-        $this->_codeBuffer[] =  $codeLine;
396
+        $codeLine = $this->indentSpaces().$codeLine;
397
+        $this->_codeBuffer[] = $codeLine;
398 398
     }
399 399
 
400 400
     /**
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
      */
403 403
     public function str($string)
404 404
     {
405
-        return "'".strtr($string,array("'"=>'\\\'','\\'=>'\\\\'))."'";
405
+        return "'".strtr($string, array("'"=>'\\\'', '\\'=>'\\\\'))."'";
406 406
     }
407 407
 
408 408
     public function escapeCode($code)
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 
480 480
     private function pushCodeWriterContext()
481 481
     {
482
-        $this->_contexts[] =  clone $this;
482
+        $this->_contexts[] = clone $this;
483 483
         $this->_result = "";
484 484
         $this->_indentation = 0;
485 485
         $this->_codeBuffer = array();
Please login to merge, or discard this patch.
Braces   +45 added lines, -20 removed lines patch added patch discarded remove patch
@@ -43,13 +43,17 @@  discard block
 block discarded – undo
43 43
 
44 44
     public function createTempVariable()
45 45
     {
46
-        if (count($this->temp_recycling)) return array_shift($this->temp_recycling);
46
+        if (count($this->temp_recycling)) {
47
+            return array_shift($this->temp_recycling);
48
+        }
47 49
         return '$_tmp_'.(++$this->temp_var_counter);
48 50
     }
49 51
 
50 52
     public function recycleTempVariable($var)
51 53
     {
52
-        if (substr($var, 0, 6)!=='$_tmp_') throw new PHPTAL_Exception("Invalid variable recycled");
54
+        if (substr($var, 0, 6)!=='$_tmp_') {
55
+            throw new PHPTAL_Exception("Invalid variable recycled");
56
+        }
53 57
         $this->temp_recycling[] = $var;
54 58
     }
55 59
 
@@ -129,7 +133,9 @@  discard block
 block discarded – undo
129 133
     {
130 134
         preg_match_all('/(?:[^;]+|;;)+/sm', $src, $array);
131 135
         $array = $array[0];
132
-        foreach ($array as &$a) $a = str_replace(';;', ';', $a);
136
+        foreach ($array as &$a) {
137
+            $a = str_replace(';;', ';', $a);
138
+        }
133 139
         return $array;
134 140
     }
135 141
 
@@ -165,16 +171,22 @@  discard block
 block discarded – undo
165 171
 
166 172
     public function flushCode()
167 173
     {
168
-        if (count($this->_codeBuffer) == 0) return;
174
+        if (count($this->_codeBuffer) == 0) {
175
+            return;
176
+        }
169 177
 
170 178
         // special treatment for one code line
171 179
         if (count($this->_codeBuffer) == 1) {
172 180
             $codeLine = $this->_codeBuffer[0];
173 181
             // avoid adding ; after } and {
174
-            if (!preg_match('/\}\s*$|\{\s*$/', $codeLine))
175
-                $this->_result .= '<?php '.$codeLine."; ?>\n"; // PHP consumes newline
176
-            else
177
-                $this->_result .= '<?php '.$codeLine." ?>\n"; // PHP consumes newline
182
+            if (!preg_match('/\}\s*$|\{\s*$/', $codeLine)) {
183
+                            $this->_result .= '<?php '.$codeLine."; ?>\n";
184
+            }
185
+            // PHP consumes newline
186
+            else {
187
+                            $this->_result .= '<?php '.$codeLine." ?>\n";
188
+            }
189
+            // PHP consumes newline
178 190
             $this->_codeBuffer = array();
179 191
             return;
180 192
         }
@@ -193,7 +205,9 @@  discard block
 block discarded – undo
193 205
 
194 206
     public function flushHtml()
195 207
     {
196
-        if (count($this->_htmlBuffer) == 0) return;
208
+        if (count($this->_htmlBuffer) == 0) {
209
+            return;
210
+        }
197 211
 
198 212
         $this->_result .= implode('', $this->_htmlBuffer);
199 213
         $this->_htmlBuffer = array();
@@ -289,7 +303,9 @@  discard block
 block discarded – undo
289 303
     public function doEnd($expects = null)
290 304
     {
291 305
         if (!count($this->_segments)) {
292
-            if (!$expects) $expects = 'anything';
306
+            if (!$expects) {
307
+                $expects = 'anything';
308
+            }
293 309
             throw new PHPTAL_Exception("Bug: CodeWriter generated end of block without $expects open");
294 310
         }
295 311
 
@@ -305,12 +321,13 @@  discard block
 block discarded – undo
305 321
             $functionCode = $this->_result;
306 322
             $this->popCodeWriterContext();
307 323
             $this->_result = $functionCode . $this->_result;
308
-        } elseif ($segment == 'try')
309
-            $this->pushCode('}');
310
-        elseif ($segment == 'catch')
311
-            $this->pushCode('}');
312
-        else
313
-            $this->pushCode("end$segment");
324
+        } elseif ($segment == 'try') {
325
+                    $this->pushCode('}');
326
+        } elseif ($segment == 'catch') {
327
+                    $this->pushCode('}');
328
+        } else {
329
+                    $this->pushCode("end$segment");
330
+        }
314 331
     }
315 332
 
316 333
     public function doTry()
@@ -362,14 +379,18 @@  discard block
 block discarded – undo
362 379
 
363 380
     public function doEcho($code)
364 381
     {
365
-        if ($code === "''") return;
382
+        if ($code === "''") {
383
+            return;
384
+        }
366 385
         $this->flush();
367 386
         $this->pushCode('echo '.$this->escapeCode($code));
368 387
     }
369 388
 
370 389
     public function doEchoRaw($code)
371 390
     {
372
-        if ($code === "''") return;
391
+        if ($code === "''") {
392
+            return;
393
+        }
373 394
         $this->pushCode('echo '.$this->stringifyCode($code));
374 395
     }
375 396
 
@@ -385,7 +406,9 @@  discard block
 block discarded – undo
385 406
 
386 407
     public function pushHTML($html)
387 408
     {
388
-        if ($html === "") return;
409
+        if ($html === "") {
410
+            return;
411
+        }
389 412
         $this->flushCode();
390 413
         $this->_htmlBuffer[] =  $html;
391 414
     }
@@ -444,11 +467,13 @@  discard block
 block discarded – undo
444 467
     {
445 468
         // FIXME: interpolation is done _after_ that function, so ${} must be forbidden for now
446 469
 
447
-        if ($this->getEncoding() == 'UTF-8') // HTML 5: 8.1.2.3 Attributes ; http://code.google.com/p/html5lib/issues/detail?id=93
470
+        if ($this->getEncoding() == 'UTF-8') {
471
+            // HTML 5: 8.1.2.3 Attributes ; http://code.google.com/p/html5lib/issues/detail?id=93
448 472
         {
449 473
             // regex excludes unicode control characters, all kinds of whitespace and unsafe characters
450 474
             // and trailing / to avoid confusion with self-closing syntax
451 475
             $unsafe_attr_regex = '/^$|[&=\'"><\s`\pM\pC\pZ\p{Pc}\p{Sk}]|\/$|\${/u';
476
+        }
452 477
         } else {
453 478
             $unsafe_attr_regex = '/^$|[&=\'"><\s`\0177-\377]|\/$|\${/';
454 479
         }
Please login to merge, or discard this patch.
classes/PHPTAL/RepeatController.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function __construct($source)
59 59
     {
60
-        if ( is_string($source) ) {
61
-            $this->iterator = new ArrayIterator( str_split($source) );  // FIXME: invalid for UTF-8 encoding, use preg_match_all('/./u') trick
62
-        } elseif ( is_array($source) ) {
60
+        if (is_string($source)) {
61
+            $this->iterator = new ArrayIterator(str_split($source)); // FIXME: invalid for UTF-8 encoding, use preg_match_all('/./u') trick
62
+        } elseif (is_array($source)) {
63 63
             $this->iterator = new ArrayIterator($source);
64 64
         } elseif ($source instanceof IteratorAggregate) {
65 65
             $this->iterator = $source->getIterator();
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
         } elseif ($source instanceof Traversable) {
75 75
             $this->iterator = new IteratorIterator($source);
76 76
         } elseif ($source instanceof Closure) {
77
-            $this->iterator = new ArrayIterator( (array) $source() );
77
+            $this->iterator = new ArrayIterator((array) $source());
78 78
         } elseif ($source instanceof stdClass) {
79
-            $this->iterator = new ArrayIterator( (array) $source );
79
+            $this->iterator = new ArrayIterator((array) $source);
80 80
         } else {
81
-            $this->iterator = new ArrayIterator( array() );
81
+            $this->iterator = new ArrayIterator(array());
82 82
         }
83 83
     }
84 84
 
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
         if ($this->length === null) {
121 121
             if ($this->iterator instanceof Countable) {
122 122
                 return $this->length = count($this->iterator);
123
-            } elseif ( is_object($this->iterator) ) {
123
+            } elseif (is_object($this->iterator)) {
124 124
                 // for backwards compatibility with existing PHPTAL templates
125
-                if ( method_exists($this->iterator, 'size') ) {
125
+                if (method_exists($this->iterator, 'size')) {
126 126
                     return $this->length = $this->iterator->size();
127
-                } elseif ( method_exists($this->iterator, 'length') ) {
127
+                } elseif (method_exists($this->iterator, 'length')) {
128 128
                     return $this->length = $this->iterator->length();
129 129
                 }
130 130
             }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
         if ($this->length === '_PHPTAL_LENGTH_UNKNOWN_') // return length if end is discovered
135 135
         {
136
-            return $this->end ? $this->index + 1 : null;
136
+            return $this->end ? $this->index+1 : null;
137 137
         }
138 138
         return $this->length;
139 139
     }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     {
204 204
         switch ($var) {
205 205
             case 'number':
206
-                return $this->index + 1;
206
+                return $this->index+1;
207 207
             case 'start':
208 208
                 return $this->index === 0;
209 209
             case 'even':
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
             case 'length':
214 214
                 return $this->length();
215 215
             case 'letter':
216
-                return strtolower( $this->int2letter($this->index+1) );
216
+                return strtolower($this->int2letter($this->index+1));
217 217
             case 'Letter':
218
-                return strtoupper( $this->int2letter($this->index+1) );
218
+                return strtoupper($this->int2letter($this->index+1));
219 219
             case 'roman':
220
-                return strtolower( $this->int2roman($this->index+1) );
220
+                return strtolower($this->int2roman($this->index+1));
221 221
             case 'Roman':
222
-                return strtoupper( $this->int2roman($this->index+1) );
222
+                return strtoupper($this->int2roman($this->index+1));
223 223
 
224 224
             case 'groups':
225 225
                 $this->initializeGroups();
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             case 'last':
235 235
                 $this->initializeGroups();
236 236
                 // Compare the next one with the dictionary
237
-                $res = $this->groups->last( $this->iterator->current() );
237
+                $res = $this->groups->last($this->iterator->current());
238 238
                 return is_bool($res) ? $res : $this->groups;
239 239
 
240 240
             default:
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         $this->key = $this->iterator->key();
256 256
 
257 257
         $this->iterator->next();
258
-        if ( !$this->iterator->valid() ) {
258
+        if (!$this->iterator->valid()) {
259 259
             $this->valid = false;
260 260
             $this->end = true;
261 261
         }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
         $letters = '';
278 278
         while ($int > 0) {
279 279
             $int--;
280
-            $letters = $lookup[$int % $size] . $letters;
280
+            $letters = $lookup[$int % $size].$letters;
281 281
             $int = floor($int / $size);
282 282
         }
283 283
         return $letters;
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -131,10 +131,12 @@  discard block
 block discarded – undo
131 131
             $this->length = '_PHPTAL_LENGTH_UNKNOWN_';
132 132
         }
133 133
 
134
-        if ($this->length === '_PHPTAL_LENGTH_UNKNOWN_') // return length if end is discovered
134
+        if ($this->length === '_PHPTAL_LENGTH_UNKNOWN_') {
135
+            // return length if end is discovered
135 136
         {
136 137
             return $this->end ? $this->index + 1 : null;
137 138
         }
139
+        }
138 140
         return $this->length;
139 141
     }
140 142
 
@@ -173,7 +175,9 @@  discard block
 block discarded – undo
173 175
         $this->index++;
174 176
 
175 177
         // Prefetch the next element
176
-        if ($this->validOnNext) $this->prefetch();
178
+        if ($this->validOnNext) {
179
+            $this->prefetch();
180
+        }
177 181
 
178 182
         if ($this->uses_groups) {
179 183
             // Notify the grouping helper of the change
Please login to merge, or discard this patch.
classes/PHPTAL/RepeatControllerGroups.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function first($data)
56 56
     {
57
-        if ( !is_array($data) && !is_object($data) && !is_null($data) ) {
57
+        if (!is_array($data) && !is_object($data) && !is_null($data)) {
58 58
 
59
-            if ( !isset($this->cache['F']) ) {
59
+            if (!isset($this->cache['F'])) {
60 60
 
61 61
                 $hash = md5($data);
62 62
 
63
-                if ( !isset($this->dict['F']) || $this->dict['F'] !== $hash ) {
63
+                if (!isset($this->dict['F']) || $this->dict['F'] !== $hash) {
64 64
                     $this->dict['F'] = $hash;
65 65
                     $res = true;
66 66
                 } else {
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function last($data)
91 91
     {
92
-        if ( !is_array($data) && !is_object($data) && !is_null($data) ) {
92
+        if (!is_array($data) && !is_object($data) && !is_null($data)) {
93 93
 
94
-            if ( !isset($this->cache['L']) ) {
94
+            if (!isset($this->cache['L'])) {
95 95
 
96 96
                 $hash = md5($data);
97 97
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         // When the iterator item is empty we just let the tal
132 132
         // expression consume by continuously returning this
133 133
         // same object which should evaluate to true for 'last'
134
-        if ( is_null($this->data) ) {
134
+        if (is_null($this->data)) {
135 135
             return $this;
136 136
         }
137 137
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         $value = PHPTAL_Context::path($this->data, $var, true);
140 140
 
141 141
         // Check if it's an object or an array
142
-        if ( is_array($value) || is_object($value) ) {
142
+        if (is_array($value) || is_object($value)) {
143 143
             // Move the context to the requested variable and return
144 144
             $this->data = $value;
145 145
             $this->addVarName($var);
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
         $hash = md5($value);
151 151
 
152 152
         // compute a path for the variable to use as dictionary key
153
-        $path = $this->branch . $this->getVarPath() . $var;
153
+        $path = $this->branch.$this->getVarPath().$var;
154 154
 
155 155
         // If we don't know about this var store in the dictionary
156
-        if ( !isset($this->cache[$path]) ) {
156
+        if (!isset($this->cache[$path])) {
157 157
 
158
-            if ( !isset($this->dict[$path]) ) {
158
+            if (!isset($this->dict[$path])) {
159 159
                 $this->dict[$path] = $hash;
160 160
                 $res = $this->branch === 'F';
161 161
             } else {
@@ -194,6 +194,6 @@  discard block
 block discarded – undo
194 194
      */
195 195
     protected function getVarPath()
196 196
     {
197
-        return implode('/', $this->vars) . '/';
197
+        return implode('/', $this->vars).'/';
198 198
     }
199 199
 }
Please login to merge, or discard this patch.
classes/PHPTAL/FileSource.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@
 block discarded – undo
25 25
     public function __construct($path)
26 26
     {
27 27
         $this->_path = realpath($path);
28
-        if ($this->_path === false) throw new PHPTAL_IOException("Unable to find real path of file '$path' (in ".getcwd().')');
28
+        if ($this->_path === false) {
29
+            throw new PHPTAL_IOException("Unable to find real path of file '$path' (in ".getcwd().')');
30
+        }
29 31
     }
30 32
 
31 33
     public function getRealPath()
Please login to merge, or discard this patch.
classes/PHPTAL/Tokenizer.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,9 @@  discard block
 block discarded – undo
36 36
 
37 37
     function skipSpace()
38 38
     {
39
-        while ($this->current_token === 'SPACE') $this->nextToken();
39
+        while ($this->current_token === 'SPACE') {
40
+            $this->nextToken();
41
+        }
40 42
     }
41 43
 
42 44
     function nextToken()
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
         }
48 50
 
49 51
         //if (!preg_match_all($this->regex, $this->str, $m, PREG_SET_ORDER, $this->offset)) throw new Exception("FAIL {$this->regex} at {$this->offset}");
50
-        if (!preg_match($this->regex, $this->str, $m, null, $this->offset)) throw new Exception("FAIL {$this->regex} didn't match '{$this->str}' at {$this->offset}");
52
+        if (!preg_match($this->regex, $this->str, $m, null, $this->offset)) {
53
+            throw new Exception("FAIL {$this->regex} didn't match '{$this->str}' at {$this->offset}");
54
+        }
51 55
 
52 56
         $this->offset += strlen($m[0]); // in bytes
53 57
 
Please login to merge, or discard this patch.
classes/PHPTAL/Tales.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  * @see PHPTAL_Php_TalesInternal::compileToPHPExpressions()
37 37
  * @return string
38 38
  */
39
-function phptal_tale($expression, $nothrow=false)
39
+function phptal_tale($expression, $nothrow = false)
40 40
 {
41 41
     return PHPTAL_Php_TalesInternal::compileToPHPExpression($expression, $nothrow);
42 42
 }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
  * @param bool $nothrow if true, invalid expression will return NULL (at run time) rather than throwing exception
52 52
  * @return string or array
53 53
  */
54
-function phptal_tales($expression, $nothrow=false)
54
+function phptal_tales($expression, $nothrow = false)
55 55
 {
56 56
     return PHPTAL_Php_TalesInternal::compileToPHPExpressions($expression, $nothrow);
57 57
 }
Please login to merge, or discard this patch.