Completed
Branch 1.11.x (83359d)
by Ben
18s
created
classes/PHPTAL/FileSourceResolver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     public function resolve($path)
30 30
     {
31 31
         foreach ($this->_repositories as $repository) {
32
-            $file = $repository . DIRECTORY_SEPARATOR . $path;
32
+            $file = $repository.DIRECTORY_SEPARATOR.$path;
33 33
             if (file_exists($file)) {
34 34
                 return new PHPTAL_FileSource($file);
35 35
             }
Please login to merge, or discard this patch.
classes/PHPTAL/ExceptionHandler.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,11 +64,11 @@
 block discarded – undo
64 64
 
65 65
         if (ini_get('display_errors')) {
66 66
             $title = get_class($e).': '.htmlspecialchars($e->getMessage());
67
-            $body = "<p><strong>\n".htmlspecialchars($e->getMessage()).'</strong></p>' .
67
+            $body = "<p><strong>\n".htmlspecialchars($e->getMessage()).'</strong></p>'.
68 68
                     '<p>In '.htmlspecialchars($line)."</p><pre>\n".htmlspecialchars($e->getTraceAsString()).'</pre>';
69 69
         } else {
70 70
             $title = "PHPTAL Exception";
71
-            $body = "<p>This page cannot be displayed.</p><hr/>" .
71
+            $body = "<p>This page cannot be displayed.</p><hr/>".
72 72
                     "<p><small>Enable <code>display_errors</code> to see detailed message.</small></p>";
73 73
         }
74 74
 
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;
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
                         $base = $base->__call($current, array());
415 415
                         continue;
416 416
                     }
417
-                    catch(BadMethodCallException $e) {}
417
+                    catch (BadMethodCallException $e) {}
418 418
                 }
419 419
 
420 420
                 if (is_callable($base)) {
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             // array handling
434 434
             if (is_array($base)) {
435 435
                 // key or index
436
-                if (array_key_exists((string)$current, $base)) {
436
+                if (array_key_exists((string) $current, $base)) {
437 437
                     $base = $base[$current];
438 438
                     continue;
439 439
                 }
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
  * @see PHPTAL_Context::path()
482 482
  * @deprecated
483 483
  */
484
-function phptal_path($base, $path, $nothrow=false)
484
+function phptal_path($base, $path, $nothrow = false)
485 485
 {
486 486
     return PHPTAL_Context::path($base, $path, $nothrow);
487 487
 }
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 function phptal_isempty($var)
497 497
 {
498 498
     return $var === null || $var === false || $var === ''
499
-           || ((is_array($var) || $var instanceof Countable) && count($var)===0);
499
+           || ((is_array($var) || $var instanceof Countable) && count($var) === 0);
500 500
 }
501 501
 
502 502
 /**
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     if (is_string($var)) {
536 536
         return $var;
537 537
     } elseif (is_bool($var)) {
538
-        return (int)$var;
538
+        return (int) $var;
539 539
     } elseif (is_array($var)) {
540 540
         return implode(', ', array_map('phptal_tostring', $var));
541 541
     } elseif ($var instanceof SimpleXMLElement) {
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
             return $xml;
550 550
         }
551 551
     }
552
-    return (string)phptal_unravel_closure($var);
552
+    return (string) phptal_unravel_closure($var);
553 553
 }
554 554
 
555 555
 /**
Please login to merge, or discard this patch.
classes/PHPTAL/Dom/XmlnsState.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
                 $prefix_to_uri[$prefix] = $value;
77 77
             }
78 78
 
79
-            if ($qname == 'xmlns') {$changed=true;$current_default = $value;}
79
+            if ($qname == 'xmlns') {$changed = true; $current_default = $value; }
80 80
         }
81 81
 
82 82
         if ($changed) {
Please login to merge, or discard this patch.
classes/PHPTAL/Dom/DocumentBuilder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
  */
22 22
 abstract class PHPTAL_Dom_DocumentBuilder
23 23
 {
24
-    protected $_stack;   /* array<PHPTAL_Dom_Node> */
24
+    protected $_stack; /* array<PHPTAL_Dom_Node> */
25 25
     protected $_current; /* PHPTAL_Dom_Node */
26 26
 
27 27
     protected $file, $line;
Please login to merge, or discard this patch.
classes/PHPTAL/GetTextTranslator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      *
104 104
      * Encoding must be set before calling addDomain!
105 105
      */
106
-    public function addDomain($domain, $path='./locale/')
106
+    public function addDomain($domain, $path = './locale/')
107 107
     {
108 108
         bindtextdomain($domain, $path);
109 109
         if ($this->_encoding) {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      *
141 141
      * @param bool $htmlencode if true, output will be HTML-escaped.
142 142
      */
143
-    public function translate($key, $htmlencode=true)
143
+    public function translate($key, $htmlencode = true)
144 144
     {
145 145
         if ($this->_canonicalize) $key = self::_canonicalizeKey($key);
146 146
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $key_ = trim($key_);
169 169
         $key_ = str_replace("\n", "", $key_);
170 170
         $key_ = str_replace("\r", "", $key_);
171
-        for ($i = 0; $i<strlen($key_); $i++) {
171
+        for ($i = 0; $i < strlen($key_); $i++) {
172 172
             $c = $key_[$i];
173 173
             $o = ord($c);
174 174
             if ($o < 5 || $o > 127) {
Please login to merge, or discard this patch.
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/TemplateException.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      * @param int       $srcLine
33 33
      * @param Throwable $previous
34 34
      */
35
-    public function __construct($msg, $srcFile='', $srcLine=0, $previous = null)
35
+    public function __construct($msg, $srcFile = '', $srcLine = 0, $previous = null)
36 36
     {
37 37
         parent::__construct($msg, 0, $previous);
38 38
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
         if ($this->is_src_accurate) {
48 48
             $this->file = $this->srcFile;
49
-            $this->line = (int)$this->srcLine;
49
+            $this->line = (int) $this->srcLine;
50 50
         }
51 51
     }
52 52
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
         if ($this->is_src_accurate) {
75 75
             $this->file = $this->srcFile;
76
-            $this->line = (int)$this->srcLine;
76
+            $this->line = (int) $this->srcLine;
77 77
         }
78 78
     }
79 79
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
         $eval_path = NULL;
93 93
 
94 94
         // searches backtrace to find template file
95
-        foreach($this->getTrace() as $tr) {
96
-            if (!isset($tr['file'],$tr['line'])) continue;
95
+        foreach ($this->getTrace() as $tr) {
96
+            if (!isset($tr['file'], $tr['line'])) continue;
97 97
 
98 98
             if ($this->isTemplatePath($tr['file'])) {
99 99
                 return array($tr['file'], $tr['line']);
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
             if (false !== strpos($tr['file'], 'eval()')) {
105 105
                 $eval_line = $tr['line'];
106 106
             }
107
-            else if ($eval_line && isset($tr['function'],$tr['args'],$tr['args'][0]) &&
107
+            else if ($eval_line && isset($tr['function'], $tr['args'], $tr['args'][0]) &&
108 108
                 $this->isTemplatePath("/".$tr['function'].".php") && $tr['args'][0] instanceof PHPTAL) {
109 109
                 return array($tr['args'][0]->getCodePath(), $eval_line);
110 110
             }
111 111
         }
112 112
 
113
-        return array(NULL,NULL);
113
+        return array(NULL, NULL);
114 114
     }
115 115
 
116 116
     /**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         $this->srcFile = $this->file;
126 126
         $this->srcLine = $this->line;
127 127
 
128
-        list($file,$line) = $this->findFileAndLine();
128
+        list($file, $line) = $this->findFileAndLine();
129 129
 
130 130
         if (NULL === $file) {
131 131
             return false;
@@ -140,23 +140,23 @@  discard block
 block discarded – undo
140 140
             return false;
141 141
         }
142 142
 
143
-        $found_line=false;
144
-        $found_file=false;
143
+        $found_line = false;
144
+        $found_file = false;
145 145
 
146 146
         // scan lines backwards looking for "from line" comments
147 147
         $end = min(count($lines), $line)-1;
148
-        for($i=$end; $i >= 0; $i--) {
148
+        for ($i = $end; $i >= 0; $i--) {
149 149
             if (preg_match('/tag "[^"]*" from line (\d+)/', $lines[$i], $m)) {
150 150
                 $this->srcLine = intval($m[1]);
151
-                $found_line=true;
151
+                $found_line = true;
152 152
                 break;
153 153
             }
154 154
         }
155 155
 
156
-        foreach(preg_grep('/Generated by PHPTAL from/',$lines) as $line) {
156
+        foreach (preg_grep('/Generated by PHPTAL from/', $lines) as $line) {
157 157
             if (preg_match('/Generated by PHPTAL from (.*) \(/', $line, $m)) {
158 158
                 $this->srcFile = $m[1];
159
-                $found_file=true;
159
+                $found_file = true;
160 160
                 break;
161 161
             }
162 162
         }
Please login to merge, or discard this patch.