Completed
Branch 1.3.x (b833d8)
by Ben
05:10
created
classes/PHPTAL.php 1 patch
Braces   +22 added lines, -13 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(Exception $e) {
837
+                } catch(Exception $e) {
840 838
                     ob_end_clean();
841 839
                     throw $e;
842 840
                 }
@@ -845,7 +843,11 @@  discard block
 block discarded – undo
845 843
                     $msg = str_replace('eval()\'d code', $this->getCodePath(), ob_get_clean());
846 844
 
847 845
                     // greedy .* ensures last match
848
-                    if (preg_match('/.*on line (\d+)$/m', $msg, $m)) $line=$m[1]; else $line=0;
846
+                    if (preg_match('/.*on line (\d+)$/m', $msg, $m)) {
847
+                        $line=$m[1];
848
+                    } else {
849
+                        $line=0;
850
+                    }
849 851
                     throw new PHPTAL_TemplateException(trim($msg), $this->getCodePath(), $line);
850 852
                 }
851 853
                 ob_end_clean();
@@ -939,7 +941,10 @@  discard block
 block discarded – undo
939 941
         $cacheFiles = glob($filename . '?*');
940 942
         if ($cacheFiles) {
941 943
             foreach ($cacheFiles as $file) {
942
-                if (substr($file, 0, strlen($filename)) !== $filename) continue; // safety net
944
+                if (substr($file, 0, strlen($filename)) !== $filename) {
945
+                    continue;
946
+                }
947
+                // safety net
943 948
                 @unlink($file);
944 949
             }
945 950
         }
@@ -956,7 +961,9 @@  discard block
 block discarded – undo
956 961
      */
957 962
     public function getCodePath()
958 963
     {
959
-        if (!$this->_codeFile) $this->setCodeFile();
964
+        if (!$this->_codeFile) {
965
+            $this->setCodeFile();
966
+        }
960 967
         return $this->_codeFile;
961 968
     }
962 969
 
@@ -1187,7 +1194,9 @@  discard block
 block discarded – undo
1187 1194
             $class = strtr($class, '\\', '_');
1188 1195
         }
1189 1196
 
1190
-        if (substr($class, 0, 7) !== 'PHPTAL_') return;
1197
+        if (substr($class, 0, 7) !== 'PHPTAL_') {
1198
+            return;
1199
+        }
1191 1200
 
1192 1201
         $path = dirname(__FILE__) . strtr("_".$class, "_", DIRECTORY_SEPARATOR) . '.php';
1193 1202
 
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Transformer.php 1 patch
Braces   +10 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,8 +63,11 @@  discard block
 block discarded – undo
63 63
 
64 64
 
65 65
         for ($i = 0; $i <= $len; $i++) {
66
-            if ($i == $len) $c = "\0";
67
-            else $c = $str[$i];
66
+            if ($i == $len) {
67
+                $c = "\0";
68
+            } else {
69
+                $c = $str[$i];
70
+            }
68 71
 
69 72
             switch ($state) {
70 73
 
@@ -85,8 +88,7 @@  discard block
 block discarded – undo
85 88
                         $state = self::ST_EVAL;
86 89
                         $mark = $i+1;
87 90
                         $result .= $prefix.'{';
88
-                    }
89
-                    elseif (self::isDigit($c))
91
+                    } elseif (self::isDigit($c))
90 92
                     {
91 93
                         $state = self::ST_NUM;
92 94
                         $mark = $i;
@@ -126,8 +128,7 @@  discard block
 block discarded – undo
126 128
                     elseif ($c === '@') {
127 129
                         $state = self::ST_DEFINE;
128 130
                         $mark = $i+1;
129
-                    }
130
-                    elseif (ctype_space($c)) {
131
+                    } elseif (ctype_space($c)) {
131 132
                         $state = self::ST_WHITE;
132 133
                         $result .= $c;
133 134
                     }
@@ -377,7 +378,9 @@  discard block
 block discarded – undo
377 378
         $result = trim($result);
378 379
 
379 380
         // CodeWriter doesn't like expressions that look like blocks
380
-        if ($result[strlen($result)-1] === '}') return '('.$result.')';
381
+        if ($result[strlen($result)-1] === '}') {
382
+            return '('.$result.')';
383
+        }
381 384
 
382 385
         return $result;
383 386
     }
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
     protected function parseSetExpression($exp)
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute/TAL/Attributes.php 1 patch
Braces   +13 added lines, -9 removed lines patch added patch discarded remove patch
@@ -115,10 +115,11 @@  discard block
 block discarded – undo
115 115
 
116 116
         $codewriter->doIf("null !== ($attkey = ($code))");
117 117
 
118
-        if ($this->_echoType !== PHPTAL_Php_Attribute::ECHO_STRUCTURE)
119
-            $codewriter->doSetVar($attkey, $codewriter->str(" $qname=\"").".".$codewriter->escapeCode($attkey).".'\"'");
120
-        else
121
-            $codewriter->doSetVar($attkey, $codewriter->str(" $qname=\"").".".$codewriter->stringifyCode($attkey).".'\"'");
118
+        if ($this->_echoType !== PHPTAL_Php_Attribute::ECHO_STRUCTURE) {
119
+                    $codewriter->doSetVar($attkey, $codewriter->str(" $qname=\"").".".$codewriter->escapeCode($attkey).".'\"'");
120
+        } else {
121
+                    $codewriter->doSetVar($attkey, $codewriter->str(" $qname=\"").".".$codewriter->stringifyCode($attkey).".'\"'");
122
+        }
122 123
 
123 124
         $codewriter->doElse();
124 125
         $codewriter->doSetVar($attkey, "''");
@@ -166,7 +167,9 @@  discard block
 block discarded – undo
166 167
 
167 168
     public function after(PHPTAL_Php_CodeWriter $codewriter)
168 169
     {
169
-        foreach ($this->vars_to_recycle as $var) $codewriter->recycleTempVariable($var);
170
+        foreach ($this->vars_to_recycle as $var) {
171
+            $codewriter->recycleTempVariable($var);
172
+        }
170 173
     }
171 174
 
172 175
     public function talesChainNothingKeyword(PHPTAL_Php_TalesChainExecutor $executor)
@@ -202,10 +205,11 @@  discard block
 block discarded – undo
202 205
         }
203 206
         $executor->doIf($condition);
204 207
 
205
-        if ($this->_echoType == PHPTAL_Php_Attribute::ECHO_STRUCTURE)
206
-            $value = $codewriter->stringifyCode($this->_attkey);
207
-        else
208
-            $value = $codewriter->escapeCode($this->_attkey);
208
+        if ($this->_echoType == PHPTAL_Php_Attribute::ECHO_STRUCTURE) {
209
+                    $value = $codewriter->stringifyCode($this->_attkey);
210
+        } else {
211
+                    $value = $codewriter->escapeCode($this->_attkey);
212
+        }
209 213
 
210 214
         $codewriter->doSetVar($this->_attkey, $codewriter->str(" {$this->_attribute}=\"").".$value.'\"'");
211 215
     }
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute/TAL/OmitTag.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,9 @@
 block discarded – undo
64 64
 
65 65
     public function after(PHPTAL_Php_CodeWriter $codewriter)
66 66
     {
67
-        if ($this->varname) $codewriter->recycleTempVariable($this->varname);
67
+        if ($this->varname) {
68
+            $codewriter->recycleTempVariable($this->varname);
69
+        }
68 70
     }
69 71
 }
70 72
 
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute/TAL/Define.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,7 +62,9 @@  discard block
 block discarded – undo
62 62
             $this->_defineScope = $defineScope;
63 63
 
64 64
             // <span tal:define="global foo" /> should be invisible, but <img tal:define="bar baz" /> not
65
-            if ($defineScope != 'global') $definesAnyNonGlobalVars = true;
65
+            if ($defineScope != 'global') {
66
+                $definesAnyNonGlobalVars = true;
67
+            }
66 68
 
67 69
             if ($this->_defineScope != 'global' && !$this->_pushedContext) {
68 70
                 $codewriter->pushContext();
@@ -94,7 +96,9 @@  discard block
 block discarded – undo
94 96
 
95 97
     public function after(PHPTAL_Php_CodeWriter $codewriter)
96 98
     {
97
-        if ($this->tmp_content_var) $codewriter->recycleTempVariable($this->tmp_content_var);
99
+        if ($this->tmp_content_var) {
100
+            $codewriter->recycleTempVariable($this->tmp_content_var);
101
+        }
98 102
         if ($this->_pushedContext) {
99 103
             $codewriter->popContext();
100 104
         }
@@ -109,7 +113,9 @@  discard block
 block discarded – undo
109 113
 
110 114
     public function talesChainNothingKeyword(PHPTAL_Php_TalesChainExecutor $executor)
111 115
     {
112
-        if (!$this->_chainPartGenerated) throw new PHPTAL_TemplateException("Invalid expression in tal:define", $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
116
+        if (!$this->_chainPartGenerated) {
117
+            throw new PHPTAL_TemplateException("Invalid expression in tal:define", $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
118
+        }
113 119
 
114 120
         $executor->doElse();
115 121
         $this->doDefineVarWith($executor->getCodeWriter(), 'null');
@@ -118,7 +124,9 @@  discard block
 block discarded – undo
118 124
 
119 125
     public function talesChainDefaultKeyword(PHPTAL_Php_TalesChainExecutor $executor)
120 126
     {
121
-        if (!$this->_chainPartGenerated) throw new PHPTAL_TemplateException("Invalid expression in tal:define", $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
127
+        if (!$this->_chainPartGenerated) {
128
+            throw new PHPTAL_TemplateException("Invalid expression in tal:define", $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
129
+        }
122 130
 
123 131
         $executor->doElse();
124 132
         $this->bufferizeContent($executor->getCodeWriter());
@@ -165,7 +173,9 @@  discard block
 block discarded – undo
165 173
 
166 174
         // extract varname and expression from remaining of expression
167 175
         list($defineVar, $exp) = $this->parseSetExpression($exp);
168
-        if ($exp !== null) $exp = trim($exp);
176
+        if ($exp !== null) {
177
+            $exp = trim($exp);
178
+        }
169 179
         return array($defineScope, $defineVar, $exp);
170 180
     }
171 181
 
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute/I18N/Attributes.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,8 +73,10 @@
 block discarded – undo
73 73
                 $code = $this->_getTranslationCode($codewriter, $key);
74 74
             } else {
75 75
                 $attr = $this->phpelement->getAttributeNode($qname);
76
-                if (!$attr) throw new PHPTAL_TemplateException("Unable to translate attribute $qname, because there is no translation key specified",
76
+                if (!$attr) {
77
+                    throw new PHPTAL_TemplateException("Unable to translate attribute $qname, because there is no translation key specified",
77 78
                                         $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
79
+                }
78 80
 
79 81
                 if ($attr->getReplacedState() === PHPTAL_Dom_Attr::NOT_REPLACED) {
80 82
                     $code = $this->_getTranslationCode($codewriter, $attr->getValue());
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute/I18N/Translate.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,8 +52,9 @@  discard block
 block discarded – undo
52 52
             $code = $codewriter->str($key);
53 53
         } else {
54 54
             $code = $codewriter->evaluateExpression($this->expression);
55
-            if (is_array($code))
56
-                return $this->generateChainedContent($codewriter, $code);
55
+            if (is_array($code)) {
56
+                            return $this->generateChainedContent($codewriter, $code);
57
+            }
57 58
 
58 59
             $code = $codewriter->evaluateExpression($this->expression);
59 60
         }
@@ -100,7 +101,9 @@  discard block
 block discarded – undo
100 101
                     if ($preserve_tags) {
101 102
                         $result .= '<'.$child->getQualifiedName();
102 103
                         foreach ($child->getAttributeNodes() as $attr) {
103
-                            if ($attr->getReplacedState() === PHPTAL_Dom_Attr::HIDDEN) continue;
104
+                            if ($attr->getReplacedState() === PHPTAL_Dom_Attr::HIDDEN) {
105
+                                continue;
106
+                            }
104 107
 
105 108
                             $result .= ' '.$attr->getQualifiedName().'="'.$attr->getValueEscaped().'"';
106 109
                         }
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute/METAL/UseMacro.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,9 +56,10 @@
 block discarded – undo
56 56
 	// [should perhaps be a TemplateException? but I don't know how to set that up...]
57 57
 	if ($defineAttr = $this->phpelement->getAttributeNodeNS(
58 58
 		'http://xml.zope.org/namespaces/metal', 'define-macro')) {
59
-		if ($defineAttr->getValue() == $macroname) 
60
-            		throw new PHPTAL_TemplateException("Cannot simultaneously define and use macro '$macroname'",
61
-                		$this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());			
59
+		if ($defineAttr->getValue() == $macroname) {
60
+		            		throw new PHPTAL_TemplateException("Cannot simultaneously define and use macro '$macroname'",
61
+                		$this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
62
+		}
62 63
 	}
63 64
 
64 65
         // local macro (no filename specified) and non dynamic macro name
Please login to merge, or discard this patch.