Completed
Pull Request — master (#59)
by Bram
08:39
created
classes/PHPTAL/Dom/PHPTALDocumentBuilder.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class PHPTAL_Dom_PHPTALDocumentBuilder extends PHPTAL_Dom_DocumentBuilder
24 24
 {
25
-    private $_xmlns;   /* PHPTAL_Dom_XmlnsState */
25
+    private $_xmlns; /* PHPTAL_Dom_XmlnsState */
26 26
     private $encoding;
27 27
 
28 28
     public function __construct()
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
     public function onDocumentEnd()
53 53
     {
54 54
         if (count($this->_stack) > 0) {
55
-            $left='</'.$this->_current->getQualifiedName().'>';
56
-            for ($i = count($this->_stack)-1; $i>0; $i--) $left .= '</'.$this->_stack[$i]->getQualifiedName().'>';
55
+            $left = '</'.$this->_current->getQualifiedName().'>';
56
+            for ($i = count($this->_stack)-1; $i > 0; $i--) $left .= '</'.$this->_stack[$i]->getQualifiedName().'>';
57 57
             throw new PHPTAL_ParserException("Not all elements were closed before end of the document. Missing: ".$left,
58 58
                         $this->file, $this->line);
59 59
         }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
         $node = new PHPTAL_Dom_Element($element_qname, $namespace_uri, $attrnodes, $this->getXmlnsState());
131 131
         $this->pushNode($node);
132
-        $this->_stack[] =  $this->_current;
132
+        $this->_stack[] = $this->_current;
133 133
         $this->_current = $node;
134 134
     }
135 135
 
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/Dom/SaxXmlParser.php 1 patch
Spacing   +15 added lines, -15 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
                 }
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
     {
427 427
         $m = $m[1];
428 428
         $out = "";
429
-        for($i=0; $i < strlen($m); $i++)
429
+        for ($i = 0; $i < strlen($m); $i++)
430 430
         {
431 431
             $out .= '&#X'.strtoupper(dechex(ord($m[$i]))).';';
432 432
         }
Please login to merge, or discard this patch.