Completed
Branch 1.3.x (b833d8)
by Ben
05:10
created
tools/phptal_lint.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     {
28 28
         try
29 29
         {
30
-            if (! empty($_SERVER['REQUEST_URI'])) {
30
+            if (!empty($_SERVER['REQUEST_URI'])) {
31 31
                 throw new Exception("Please use this tool from command line");
32 32
             }
33 33
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                 echo " Skipped ".$this->plural($lint->skipped, "non-template file").".";
77 77
             }
78 78
             echo "\n";
79
-            if (! $custom_extensions && count($lint->skipped_filenames)) {
79
+            if (!$custom_extensions && count($lint->skipped_filenames)) {
80 80
                 echo "Skipped file(s): ", implode(', ', array_keys($lint->skipped_filenames)), ".\n";
81 81
             }
82 82
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                 echo "\n";
87 87
                 exit(2);
88 88
             } else if (count($lint->warnings)) {
89
-                echo "Found ".$this->plural(count($lint->warnings),"warning").":\n";
89
+                echo "Found ".$this->plural(count($lint->warnings), "warning").":\n";
90 90
                 $this->display_erorr_array($lint->warnings);
91 91
                 echo "\n";
92 92
                 exit(0);
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
                 exit($lint->checked ? 0 : 1);
96 96
             }
97 97
         }
98
-        catch(Exception $e) {
99
-            fwrite(STDERR, $e->getMessage() . "\n");
98
+        catch (Exception $e) {
99
+            fwrite(STDERR, $e->getMessage()."\n");
100 100
             $errcode = $e->getCode();
101 101
             exit($errcode ? $errcode : 1);
102 102
         }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     function usage()
120 120
     {
121 121
         $this->require_phptal();
122
-        echo "PHPTAL Lint 1.1.3 (PHPTAL ", strtr(PHPTAL_VERSION,"_","."), ")\n";
122
+        echo "PHPTAL Lint 1.1.3 (PHPTAL ", strtr(PHPTAL_VERSION, "_", "."), ")\n";
123 123
 
124 124
         echo "Usage: phptal_lint.php [-e extensions] [-i php_file_or_directory] file_or_directory_to_check ...\n";
125 125
         echo "  -e comma-separated list of extensions\n";
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
     function extended_getopt(array $options)
137 137
     {
138 138
         $results = array('--filenames--'=>array());
139
-        for ($i = 1; $i < count($_SERVER['argv']); $i ++) {
139
+        for ($i = 1; $i < count($_SERVER['argv']); $i++) {
140 140
             if (in_array($_SERVER['argv'][$i], $options)) {
141
-                $results[substr($_SERVER['argv'][$i], 1)][] = $_SERVER['argv'][++ $i];
141
+                $results[substr($_SERVER['argv'][$i], 1)][] = $_SERVER['argv'][++$i];
142 142
             } else if ($_SERVER['argv'][$i] == '--') {
143
-                $results['--filenames--'] = array_merge($results['--filenames--'], array_slice($_SERVER['argv'],$i+1));
143
+                $results['--filenames--'] = array_merge($results['--filenames--'], array_slice($_SERVER['argv'], $i+1));
144 144
                 break;
145 145
             } else if (substr($_SERVER['argv'][$i], 0, 1) == '-') {
146 146
                     $this->usage();
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     {
172 172
         if (class_exists('PHPTAL', false)) return;
173 173
 
174
-        $myphptal = dirname(__FILE__) . '/../classes/PHPTAL.php';
174
+        $myphptal = dirname(__FILE__).'/../classes/PHPTAL.php';
175 175
         if (file_exists($myphptal)) {
176 176
             require_once $myphptal;
177 177
         } else {
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     }
203 203
 
204 204
     function acceptExtensions(array $ext) {
205
-        $this->accept_pattern = '/\.(?:' . implode('|', $ext) . ')$/i';
205
+        $this->accept_pattern = '/\.(?:'.implode('|', $ext).')$/i';
206 206
     }
207 207
 
208 208
     protected function reportProgress($symbol)
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 
227 227
             if ($entry->isDir()) {
228 228
                 $this->reportProgress('.');
229
-                $this->scan($path . DIRECTORY_SEPARATOR . $filename);
229
+                $this->scan($path.DIRECTORY_SEPARATOR.$filename);
230 230
                 continue;
231 231
             }
232 232
 
233
-            if (! preg_match($this->accept_pattern, $filename)) {
233
+            if (!preg_match($this->accept_pattern, $filename)) {
234 234
                 $this->skipped++;
235 235
                 $this->skipped_filenames[$filename] = true;
236 236
                 continue;
237 237
             }
238 238
 
239
-            $result = $this->testFile($path . DIRECTORY_SEPARATOR . $filename);
239
+            $result = $this->testFile($path.DIRECTORY_SEPARATOR.$filename);
240 240
 
241 241
             if (self::TEST_OK == $result) {
242 242
                 $this->reportProgress('.');
@@ -258,25 +258,25 @@  discard block
 block discarded – undo
258 258
     function testFile($fullpath)
259 259
     {
260 260
         try {
261
-            $this->checked ++;
261
+            $this->checked++;
262 262
             $phptal = new PHPTAL($fullpath);
263 263
             $phptal->setForceReparse(true);
264 264
             $phptal->prepare();
265 265
             return self::TEST_OK;
266 266
         }
267
-        catch(PHPTAL_UnknownModifierException $e) {
267
+        catch (PHPTAL_UnknownModifierException $e) {
268 268
             if ($this->skipUnknownModifiers && is_callable(array($e, 'getModifierName'))) {
269 269
                 $this->warnings[] = array(dirname($fullpath), basename($fullpath), "Unknown expression modifier: ".$e->getModifierName()." (use -i to include your custom modifier functions)", $e->getLine());
270 270
                 return self::TEST_SKIPPED;
271 271
             }
272 272
             $log_exception = $e;
273 273
         }
274
-        catch(Exception $e) {
274
+        catch (Exception $e) {
275 275
             $log_exception = $e;
276 276
         }
277 277
 
278 278
         // Takes exception from either of the two catch blocks above
279
-        $this->errors[] = array(dirname($fullpath) , basename($fullpath) , $log_exception->getMessage() , $log_exception->getLine());
279
+        $this->errors[] = array(dirname($fullpath), basename($fullpath), $log_exception->getMessage(), $log_exception->getLine());
280 280
         return self::TEST_ERROR;
281 281
     }
282 282
 }
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute/PHPTAL/Cache.php 1 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/Dom/SaxXmlParser.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
             $builder->setSource($this->_file, $this->_line);
117 117
             $builder->onDocumentStart();
118 118
 
119
-            $i=0;
119
+            $i = 0;
120 120
             // remove BOM (UTF-8 byte order mark)...
121 121
             if (substr($src, 0, 3) === self::BOM_STR) {
122
-                $i=3;
122
+                $i = 3;
123 123
             }
124
-            for (; $i<$len; $i++) {
124
+            for (; $i < $len; $i++) {
125 125
                 $c = $src[$i]; // Change to substr($src, $i, 1); if you want to use mb_string.func_overload
126 126
 
127 127
                 if ($c === "\n") $builder->setSource($this->_file, ++$this->_line);
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                         if ($c !== '>') {
202 202
                             $this->raiseError("Expected '/>', but found '/$c' inside tag < $tagname >");
203 203
                         }
204
-                        $mark = $i+1;   // mark text start
204
+                        $mark = $i+1; // mark text start
205 205
                         $state = self::ST_TEXT;
206 206
                         $builder->onElementStart($tagname, $attributes);
207 207
                         $builder->onElementClose($tagname);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
                     case self::ST_TAG_BETWEEN_ATTRIBUTE:
211 211
                     case self::ST_TAG_ATTRIBUTES:
212 212
                         if ($c === '>') {
213
-                            $mark = $i+1;   // mark text start
213
+                            $mark = $i+1; // mark text start
214 214
                             $state = self::ST_TEXT;
215 215
                             $builder->onElementStart($tagname, $attributes);
216 216
                         } elseif ($c === '/') {
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
                     case self::ST_COMMENT:
227 227
                         if ($c === '>' && $i > $mark+4 && substr($src, $i-2, 2) === '--') {
228 228
 
229
-                            if (preg_match('/^-|--|-$/', substr($src, $mark +4, $i-$mark+1 -7))) {
229
+                            if (preg_match('/^-|--|-$/', substr($src, $mark+4, $i-$mark+1-7))) {
230 230
                                 $this->raiseError("Ill-formed comment. XML comments are not allowed to contain '--' or start/end with '-': ".substr($src, $mark+4, $i-$mark+1-7));
231 231
                             }
232 232
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
                             if ($c === '=') $state = self::ST_ATTR_VALUE;
291 291
                             else /* white char */ $state = self::ST_ATTR_EQ;
292
-                        } elseif ($c === '/' || $c==='>') {
292
+                        } elseif ($c === '/' || $c === '>') {
293 293
                             $attribute = substr($src, $mark, $i-$mark);
294 294
                             if (!$this->isValidQName($attribute)) {
295 295
                                 $this->raiseError("Invalid attribute name '$attribute'");
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 
324 324
                             // PHPTAL's code generator assumes input is escaped for double-quoted strings. Single-quoted attributes need to be converted.
325 325
                             // FIXME: it should be escaped at later stage.
326
-                            $attributes[$attribute] = str_replace('"',"&quot;", $attributes[$attribute]);
326
+                            $attributes[$attribute] = str_replace('"', "&quot;", $attributes[$attribute]);
327 327
                             $state = self::ST_TAG_BETWEEN_ATTRIBUTE;
328 328
                         }
329 329
                         break;
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
             $builder->onDocumentEnd();
349 349
         }
350
-        catch(PHPTAL_TemplateException $e)
350
+        catch (PHPTAL_TemplateException $e)
351 351
         {
352 352
             $e->hintSrcPosition($this->_file, $this->_line);
353 353
             throw $e;
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
             // $match expression below somehow triggers quite deep recurrency and stack overflow in preg
371 371
             // to avoid this, check string bit by bit, omitting ASCII fragments.
372 372
             if (strlen($str) > 200) {
373
-                $chunks = preg_split('/(?>[\x09\x0A\x0D\x20-\x7F]+)/',$str,null,PREG_SPLIT_NO_EMPTY);
373
+                $chunks = preg_split('/(?>[\x09\x0A\x0D\x20-\x7F]+)/', $str, null, PREG_SPLIT_NO_EMPTY);
374 374
                 foreach ($chunks as $chunk) {
375 375
                     if (strlen($chunk) < 200) {
376 376
                         $this->checkEncoding($chunk);
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
                . '|\xED[\x80-\x9F][\x80-\xBF]'        // excluding surrogates
390 390
                . '|\xF0[\x90-\xBF][\x80-\xBF]{2}'     // planes 1-3
391 391
                . '|[\xF1-\xF3][\x80-\xBF]{3}'         // planes 4-15
392
-               . '|\xF4[\x80-\x8F][\x80-\xBF]{2}';    // plane 16
392
+               . '|\xF4[\x80-\x8F][\x80-\xBF]{2}'; // plane 16
393 393
 
394
-            if (!preg_match('/^(?:(?>'.$match.'))+$/s',$str)) {
395
-                $res = preg_split('/((?>'.$match.')+)/s',$str,null,PREG_SPLIT_DELIM_CAPTURE);
396
-                for($i=0; $i < count($res); $i+=2)
394
+            if (!preg_match('/^(?:(?>'.$match.'))+$/s', $str)) {
395
+                $res = preg_split('/((?>'.$match.')+)/s', $str, null, PREG_SPLIT_DELIM_CAPTURE);
396
+                for ($i = 0; $i < count($res); $i += 2)
397 397
                 {
398 398
                     $res[$i] = self::convertBytesToEntities(array(1=>$res[$i]));
399 399
                 }
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
     private static function convertBytesToEntities(array $m)
426 426
     {
427 427
         $m = $m[1]; $out = '';
428
-        for($i=0; $i < strlen($m); $i++)
428
+        for ($i = 0; $i < strlen($m); $i++)
429 429
         {
430 430
             $out .= '&#X'.strtoupper(dechex(ord($m[$i]))).';';
431 431
         }
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         /* <?php ?> blocks can't reliably work in attributes (due to escaping impossible in XML)
443 443
            so they have to be converted into special TALES expression
444 444
         */
445
-        $types = ini_get('short_open_tag')?'php|=|':'php';
445
+        $types = ini_get('short_open_tag') ? 'php|=|' : 'php';
446 446
         $str = preg_replace_callback("/<\?($types)(.*?)\?>/", array('self', 'convertPHPBlockToTALES'), $str);
447 447
 
448 448
         // corrects all non-entities and neutralizes potentially problematic CDATA end marker
Please login to merge, or discard this patch.
classes/PHPTAL/Context.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      *
102 102
      * @return void
103 103
      */
104
-    public function setDocType($doctype,$called_from_macro)
104
+    public function setDocType($doctype, $called_from_macro)
105 105
     {
106 106
         // FIXME: this is temporary workaround for problem of DOCTYPE disappearing in cloned PHPTAL object (because clone keeps _parentContext)
107 107
         if (!$this->_docType) {
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      */
247 247
     public function pushSlots()
248 248
     {
249
-        $this->_slotsStack[] =  $this->_slots;
249
+        $this->_slotsStack[] = $this->_slots;
250 250
         $this->_slots = array();
251 251
     }
252 252
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         } else $pathinfo = '';
321 321
 
322 322
         if (!empty($basename)) {
323
-            $basename = "'" . $basename . "' ";
323
+            $basename = "'".$basename."' ";
324 324
         }
325 325
 
326 326
         if (is_array($base)) {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
      * @access private
351 351
      * @return mixed
352 352
      */
353
-    public static function path($base, $path, $nothrow=false)
353
+    public static function path($base, $path, $nothrow = false)
354 354
     {
355 355
         if ($base === null) {
356 356
             if ($nothrow) return null;
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                         $base = $base->__call($current, array());
414 414
                         continue;
415 415
                     }
416
-                    catch(BadMethodCallException $e) {}
416
+                    catch (BadMethodCallException $e) {}
417 417
                 }
418 418
 
419 419
                 if ($nothrow) {
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
             // array handling
427 427
             if (is_array($base)) {
428 428
                 // key or index
429
-                if (array_key_exists((string)$current, $base)) {
429
+                if (array_key_exists((string) $current, $base)) {
430 430
                     $base = $base[$current];
431 431
                     continue;
432 432
                 }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
  * @see PHPTAL_Context::path()
475 475
  * @deprecated
476 476
  */
477
-function phptal_path($base, $path, $nothrow=false)
477
+function phptal_path($base, $path, $nothrow = false)
478 478
 {
479 479
     return PHPTAL_Context::path($base, $path, $nothrow);
480 480
 }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 function phptal_isempty($var)
490 490
 {
491 491
     return $var === null || $var === false || $var === ''
492
-           || ((is_array($var) || $var instanceof Countable) && count($var)===0);
492
+           || ((is_array($var) || $var instanceof Countable) && count($var) === 0);
493 493
 }
494 494
 
495 495
 /**
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
     if (is_string($var)) {
529 529
         return $var;
530 530
     } elseif (is_bool($var)) {
531
-        return (int)$var;
531
+        return (int) $var;
532 532
     } elseif (is_array($var)) {
533 533
         return implode(', ', array_map('phptal_tostring', $var));
534 534
     } elseif ($var instanceof SimpleXMLElement) {
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
             return $xml;
543 543
         }
544 544
     }
545
-    return (string)phptal_unravel_closure($var);
545
+    return (string) phptal_unravel_closure($var);
546 546
 }
547 547
 
548 548
 /**
Please login to merge, or discard this patch.