Completed
Branch 1.11.x (83359d)
by Ben
18s
created
classes/PHPTAL/Dom/CDATASection.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,10 +34,12 @@
 block discarded – undo
34 34
             $codewriter->pushHTML($codewriter->interpolateCDATA(str_replace('</', '<\/', $value)));
35 35
         } elseif (($mode === PHPTAL::XHTML && $inCDATAelement)  // safe for text/html
36 36
              || ($mode === PHPTAL::XML && preg_match('/[<>&]/', $value))  // non-useless in XML
37
-             || ($mode !== PHPTAL::HTML5 && preg_match('/<\?|\${structure/', $value)))  // hacks with structure (in X[HT]ML) may need it
37
+             || ($mode !== PHPTAL::HTML5 && preg_match('/<\?|\${structure/', $value))) {
38
+            // hacks with structure (in X[HT]ML) may need it
38 39
         {
39 40
             // in text/html "</" is dangerous and the only sensible way to escape is ECMAScript string escapes.
40 41
             if ($mode === PHPTAL::XHTML) $value = str_replace('</', '<\/', $value);
42
+        }
41 43
 
42 44
             $codewriter->pushHTML($codewriter->interpolateCDATA('<![CDATA['.$value.']]>'));
43 45
         } else {
Please login to merge, or discard this patch.
classes/PHPTAL/Dom/PHPTALDocumentBuilder.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@
 block discarded – undo
53 53
     {
54 54
         if (count($this->_stack) > 0) {
55 55
             $left='</'.$this->_current->getQualifiedName().'>';
56
-            for ($i = count($this->_stack)-1; $i>0; $i--) $left .= '</'.$this->_stack[$i]->getQualifiedName().'>';
56
+            for ($i = count($this->_stack)-1; $i>0; $i--) {
57
+                $left .= '</'.$this->_stack[$i]->getQualifiedName().'>';
58
+            }
57 59
             throw new PHPTAL_ParserException("Not all elements were closed before end of the document. Missing: ".$left,
58 60
                         $this->file, $this->line);
59 61
         }
Please login to merge, or discard this patch.
classes/PHPTAL/GetTextTranslator.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,9 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function __construct()
36 36
     {
37
-        if (!function_exists('gettext')) throw new PHPTAL_ConfigurationException("Gettext not installed");
37
+        if (!function_exists('gettext')) {
38
+            throw new PHPTAL_ConfigurationException("Gettext not installed");
39
+        }
38 40
         $this->useDomain("messages"); // PHP bug #21965
39 41
     }
40 42
 
@@ -75,11 +77,15 @@  discard block
 block discarded – undo
75 77
         $langs = func_get_args();
76 78
 
77 79
         $langCode = $this->trySettingLanguages(LC_ALL, $langs);
78
-        if ($langCode) return $langCode;
80
+        if ($langCode) {
81
+            return $langCode;
82
+        }
79 83
 
80 84
         if (defined("LC_MESSAGES")) {
81 85
             $langCode = $this->trySettingLanguages(LC_MESSAGES, $langs);
82
-            if ($langCode) return $langCode;
86
+            if ($langCode) {
87
+                return $langCode;
88
+            }
83 89
         }
84 90
 
85 91
         throw new PHPTAL_ConfigurationException('Language(s) code(s) "'.implode(', ', $langs).'" not supported by your system');
@@ -142,7 +148,9 @@  discard block
 block discarded – undo
142 148
      */
143 149
     public function translate($key, $htmlencode=true)
144 150
     {
145
-        if ($this->_canonicalize) $key = self::_canonicalizeKey($key);
151
+        if ($this->_canonicalize) {
152
+            $key = self::_canonicalizeKey($key);
153
+        }
146 154
 
147 155
         $value = gettext($key);
148 156
 
Please login to merge, or discard this patch.
tools/phptal_lint.php 1 patch
Braces   +9 added lines, -8 removed lines patch added patch discarded remove patch
@@ -94,8 +94,7 @@  discard block
 block discarded – undo
94 94
                 echo "No errors found!\n";
95 95
                 exit($lint->checked ? 0 : 1);
96 96
             }
97
-        }
98
-        catch(Exception $e) {
97
+        } catch(Exception $e) {
99 98
             fwrite(STDERR, $e->getMessage() . "\n");
100 99
             $errcode = $e->getCode();
101 100
             exit($errcode ? $errcode : 1);
@@ -129,7 +128,9 @@  discard block
 block discarded – undo
129 128
 
130 129
     function plural($num, $word)
131 130
     {
132
-        if ($num == 1) return "$num $word";
131
+        if ($num == 1) {
132
+            return "$num $word";
133
+        }
133 134
         return "$num {$word}s";
134 135
     }
135 136
 
@@ -169,7 +170,9 @@  discard block
 block discarded – undo
169 170
 
170 171
     function require_phptal()
171 172
     {
172
-        if (class_exists('PHPTAL', false)) return;
173
+        if (class_exists('PHPTAL', false)) {
174
+            return;
175
+        }
173 176
 
174 177
         $myphptal = dirname(__FILE__) . '/../classes/PHPTAL.php';
175 178
         if (file_exists($myphptal)) {
@@ -263,15 +266,13 @@  discard block
 block discarded – undo
263 266
             $phptal->setForceReparse(true);
264 267
             $phptal->prepare();
265 268
             return self::TEST_OK;
266
-        }
267
-        catch(PHPTAL_UnknownModifierException $e) {
269
+        } catch(PHPTAL_UnknownModifierException $e) {
268 270
             if ($this->skipUnknownModifiers && is_callable(array($e, 'getModifierName'))) {
269 271
                 $this->warnings[] = array(dirname($fullpath), basename($fullpath), "Unknown expression modifier: ".$e->getModifierName()." (use -i to include your custom modifier functions)", $e->getLine());
270 272
                 return self::TEST_SKIPPED;
271 273
             }
272 274
             $log_exception = $e;
273
-        }
274
-        catch(Exception $e) {
275
+        } catch(Exception $e) {
275 276
             $log_exception = $e;
276 277
         }
277 278
 
Please login to merge, or discard this patch.
classes/PHPTAL.php 1 patch
Braces   +23 added lines, -15 removed lines patch added patch discarded remove patch
@@ -379,7 +379,9 @@  discard block
 block discarded – undo
379 379
         $enc = strtoupper($enc);
380 380
         if ($enc != $this->_encoding) {
381 381
             $this->_encoding = $enc;
382
-            if ($this->_translator) $this->_translator->setEncoding($enc);
382
+            if ($this->_translator) {
383
+                $this->_translator->setEncoding($enc);
384
+            }
383 385
 
384 386
             $this->resetPrepared();
385 387
         }
@@ -666,8 +668,7 @@  discard block
 block discarded – undo
666 668
                 ob_start();
667 669
                 $templateFunction($this, $this->_context);
668 670
                 $res = ob_get_clean();
669
-            }
670
-            catch (Exception $e)
671
+            } catch (Exception $e)
671 672
             {
672 673
                 ob_end_clean();
673 674
                 throw $e;
@@ -686,8 +687,7 @@  discard block
 block discarded – undo
686 687
             if ($this->_postfilter) {
687 688
                 return $this->_postfilter->filter($res);
688 689
             }
689
-        }
690
-        catch (Exception $e)
690
+        } catch (Exception $e)
691 691
         {
692 692
             PHPTAL_ExceptionHandler::handleException($e, $this->getEncoding());
693 693
         }
@@ -717,8 +717,7 @@  discard block
 block discarded – undo
717 717
 
718 718
             $templateFunction = $this->getFunctionName();
719 719
             $templateFunction($this, $this->_context);
720
-        }
721
-        catch (Exception $e)
720
+        } catch (Exception $e)
722 721
         {
723 722
             PHPTAL_ExceptionHandler::handleException($e, $this->getEncoding());
724 723
         }
@@ -835,8 +834,7 @@  discard block
 block discarded – undo
835 834
                 ob_start();
836 835
                 try {
837 836
                     eval("?>\n".$result);
838
-                }
839
-                catch(ParseError $parseError) {
837
+                } catch(ParseError $parseError) {
840 838
                     ob_end_clean();
841 839
                     throw new PHPTAL_TemplateException(
842 840
                         'Parse error: ' . $parseError->getMessage(),
@@ -844,8 +842,7 @@  discard block
 block discarded – undo
844 842
                         $parseError->getLine(),
845 843
                         $parseError
846 844
                     );
847
-                }
848
-                catch(Exception $e) {
845
+                } catch(Exception $e) {
849 846
                     ob_end_clean();
850 847
                     throw $e;
851 848
                 }
@@ -854,7 +851,11 @@  discard block
 block discarded – undo
854 851
                     $msg = str_replace('eval()\'d code', $this->getCodePath(), ob_get_clean());
855 852
 
856 853
                     // greedy .* ensures last match
857
-                    if (preg_match('/.*on line (\d+)$/m', $msg, $m)) $line=$m[1]; else $line=0;
854
+                    if (preg_match('/.*on line (\d+)$/m', $msg, $m)) {
855
+                        $line=$m[1];
856
+                    } else {
857
+                        $line=0;
858
+                    }
858 859
                     throw new PHPTAL_TemplateException(trim($msg), $this->getCodePath(), $line);
859 860
                 }
860 861
                 ob_end_clean();
@@ -948,7 +949,10 @@  discard block
 block discarded – undo
948 949
         $cacheFiles = glob($filename . '?*');
949 950
         if ($cacheFiles) {
950 951
             foreach ($cacheFiles as $file) {
951
-                if (substr($file, 0, strlen($filename)) !== $filename) continue; // safety net
952
+                if (substr($file, 0, strlen($filename)) !== $filename) {
953
+                    continue;
954
+                }
955
+                // safety net
952 956
                 @unlink($file);
953 957
             }
954 958
         }
@@ -965,7 +969,9 @@  discard block
 block discarded – undo
965 969
      */
966 970
     public function getCodePath()
967 971
     {
968
-        if (!$this->_codeFile) $this->setCodeFile();
972
+        if (!$this->_codeFile) {
973
+            $this->setCodeFile();
974
+        }
969 975
         return $this->_codeFile;
970 976
     }
971 977
 
@@ -1196,7 +1202,9 @@  discard block
 block discarded – undo
1196 1202
             $class = strtr($class, '\\', '_');
1197 1203
         }
1198 1204
 
1199
-        if (substr($class, 0, 7) !== 'PHPTAL_') return;
1205
+        if (substr($class, 0, 7) !== 'PHPTAL_') {
1206
+            return;
1207
+        }
1200 1208
 
1201 1209
         $path = dirname(__FILE__) . strtr("_".$class, "_", DIRECTORY_SEPARATOR) . '.php';
1202 1210
 
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -76,10 +76,11 @@
 block discarded – undo
76 76
 
77 77
     protected function doEchoAttribute(PHPTAL_Php_CodeWriter $codewriter, $code)
78 78
     {
79
-        if ($this->_echoType === self::ECHO_TEXT)
80
-            $codewriter->doEcho($code);
81
-        else
82
-            $codewriter->doEchoRaw($code);
79
+        if ($this->_echoType === self::ECHO_TEXT) {
80
+                    $codewriter->doEcho($code);
81
+        } else {
82
+                    $codewriter->doEchoRaw($code);
83
+        }
83 84
     }
84 85
 
85 86
     /**
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
@@ -82,10 +82,12 @@
 block discarded – undo
82 82
                 $this->reader->talesChainPart($this, $exp, $lastkey === $key);
83 83
             }
84 84
 
85
-            if ($this->state == self::CHAIN_BREAK)
86
-                break;
87
-            if ($this->state == self::CHAIN_CONT)
88
-                continue;
85
+            if ($this->state == self::CHAIN_BREAK) {
86
+                            break;
87
+            }
88
+            if ($this->state == self::CHAIN_CONT) {
89
+                            continue;
90
+            }
89 91
         }
90 92
 
91 93
         $this->codewriter->doEnd('if');
Please login to merge, or discard this patch.
classes/PHPTAL/Tokenizer.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@
 block discarded – undo
42 42
 
43 43
     function skipSpace()
44 44
     {
45
-        while ($this->current_token === 'SPACE') $this->nextToken();
45
+        while ($this->current_token === 'SPACE') {
46
+            $this->nextToken();
47
+        }
46 48
     }
47 49
 
48 50
     function nextToken()
Please login to merge, or discard this patch.
classes/PHPTAL/Dom/SaxXmlParser.php 1 patch
Braces   +27 added lines, -11 removed lines patch added patch discarded remove patch
@@ -124,7 +124,9 @@  discard block
 block discarded – undo
124 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
-                if ($c === "\n") $builder->setSource($this->_file, ++$this->_line);
127
+                if ($c === "\n") {
128
+                    $builder->setSource($this->_file, ++$this->_line);
129
+                }
128 130
 
129 131
                 switch ($state) {
130 132
                     case self::ST_ROOT:
@@ -174,7 +176,9 @@  discard block
 block discarded – undo
174 176
                     case self::ST_TAG_NAME:
175 177
                         if (self::isWhiteChar($c) || $c === '/' || $c === '>') {
176 178
                             $tagname = substr($src, $mark, $i-$mark);
177
-                            if (!$this->isValidQName($tagname)) $this->raiseError("Invalid tag name '$tagname'");
179
+                            if (!$this->isValidQName($tagname)) {
180
+                                $this->raiseError("Invalid tag name '$tagname'");
181
+                            }
178 182
 
179 183
                             if ($c === '/') {
180 184
                                 $state = self::ST_TAG_SINGLE;
@@ -220,7 +224,9 @@  discard block
 block discarded – undo
220 224
                         } elseif ($state === self::ST_TAG_ATTRIBUTES && $this->isValidQName($c)) {
221 225
                             $mark = $i; // mark attribute key start
222 226
                             $state = self::ST_ATTR_KEY;
223
-                        } else $this->raiseError("Unexpected character '$c' between attributes of < $tagname >");
227
+                        } else {
228
+                            $this->raiseError("Unexpected character '$c' between attributes of < $tagname >");
229
+                        }
224 230
                         break;
225 231
 
226 232
                     case self::ST_COMMENT:
@@ -287,8 +293,11 @@  discard block
 block discarded – undo
287 293
                                 $this->raiseError("Attribute $attribute in < $tagname > is defined more than once");
288 294
                             }
289 295
 
290
-                            if ($c === '=') $state = self::ST_ATTR_VALUE;
291
-                            else /* white char */ $state = self::ST_ATTR_EQ;
296
+                            if ($c === '=') {
297
+                                $state = self::ST_ATTR_VALUE;
298
+                            } else {
299
+                                /* white char */ $state = self::ST_ATTR_EQ;
300
+                            }
292 301
                         } elseif ($c === '/' || $c==='>') {
293 302
                             $attribute = substr($src, $mark, $i-$mark);
294 303
                             if (!$this->isValidQName($attribute)) {
@@ -330,11 +339,15 @@  discard block
 block discarded – undo
330 339
                 }
331 340
             }
332 341
 
333
-            if ($state === self::ST_TEXT) // allows text past root node, which is in violation of XML spec
342
+            if ($state === self::ST_TEXT) {
343
+                // allows text past root node, which is in violation of XML spec
334 344
             {
335 345
                 if ($i > $mark) {
336 346
                     $text = substr($src, $mark, $i-$mark);
337
-                    if (!ctype_space($text)) $this->raiseError("Characters found after end of the root element (wrap document in < tal:block > to avoid this error)");
347
+            }
348
+                    if (!ctype_space($text)) {
349
+                        $this->raiseError("Characters found after end of the root element (wrap document in < tal:block > to avoid this error)");
350
+                    }
338 351
                 }
339 352
             } else {
340 353
                 if ($state === self::ST_ROOT) {
@@ -346,8 +359,7 @@  discard block
 block discarded – undo
346 359
             }
347 360
 
348 361
             $builder->onDocumentEnd();
349
-        }
350
-        catch(PHPTAL_TemplateException $e)
362
+        } catch(PHPTAL_TemplateException $e)
351 363
         {
352 364
             $e->hintSrcPosition($this->_file, $this->_line);
353 365
             throw $e;
@@ -363,7 +375,9 @@  discard block
 block discarded – undo
363 375
 
364 376
     private function checkEncoding($str)
365 377
     {
366
-        if ($str === '') return '';
378
+        if ($str === '') {
379
+            return '';
380
+        }
367 381
 
368 382
         if ($this->input_encoding === 'UTF-8') {
369 383
 
@@ -445,7 +459,9 @@  discard block
 block discarded – undo
445 459
         */
446 460
         $str = preg_replace_callback('/<\?(php|=)(.*?)\?>/', static function ($m) {
447 461
             list(, $type, $code) = $m;
448
-            if ($type === '=') $code = 'echo '.$code;
462
+            if ($type === '=') {
463
+                $code = 'echo '.$code;
464
+            }
449 465
             return '${structure phptal-internal-php-block:'.rawurlencode($code).'}';
450 466
         }, $str);
451 467
 
Please login to merge, or discard this patch.