Test Failed
Pull Request — master (#3)
by Chris
02:30
created
php/hamle/Scope.php 1 patch
Braces   +23 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,12 +21,14 @@  discard block
 block discarded – undo
21 21
   static $scopeHook;
22 22
 
23 23
   static function add($model, $name = null) {
24
-    if (!$model instanceOf Model)
25
-      throw new Unsupported("Unsupported Model (".get_class($model)."), Needs to implement hamleModel Interface");
26
-    if ($name)
27
-      self::$namedScopes[$name] = $model;
28
-    else
29
-      self::$scopes[] = $model;
24
+    if (!$model instanceOf Model) {
25
+          throw new Unsupported("Unsupported Model (".get_class($model)."), Needs to implement hamleModel Interface");
26
+    }
27
+    if ($name) {
28
+          self::$namedScopes[$name] = $model;
29
+    } else {
30
+          self::$scopes[] = $model;
31
+    }
30 32
     if(self::$scopeHook) {
31 33
         (self::$scopeHook)($model);
32 34
     }
@@ -47,15 +49,21 @@  discard block
 block discarded – undo
47 49
    */
48 50
   static function get($id = 0) {
49 51
     if (0 == $id) {
50
-      if ($scope = end(self::$scopes))
51
-        return $scope;
52
+      if ($scope = end(self::$scopes)) {
53
+              return $scope;
54
+      }
52 55
       throw new OutOfScope("Unable to find Scope ($id)");
53 56
     }
54 57
     $key = $id - 1;
55
-    if ($id < 0) $key = count(self::$scopes) + $id - 1;
56
-    if ($id == 0) $key = count(self::$scopes) - 1;
57
-    if (!isset(self::$scopes[$key]))
58
-      throw new OutOfScope("Unable to find Scope ($id) or $key");
58
+    if ($id < 0) {
59
+      $key = count(self::$scopes) + $id - 1;
60
+    }
61
+    if ($id == 0) {
62
+      $key = count(self::$scopes) - 1;
63
+    }
64
+    if (!isset(self::$scopes[$key])) {
65
+          throw new OutOfScope("Unable to find Scope ($id) or $key");
66
+    }
59 67
     return self::$scopes[$key];
60 68
   }
61 69
 
@@ -73,8 +81,9 @@  discard block
 block discarded – undo
73 81
       self::$namedScopes[$name]->rewind();
74 82
       return self::$namedScopes[$name];
75 83
     } else
76
-      if(self::$returnZeroOnNoScope)
77
-        return new Model\Zero();
84
+      if(self::$returnZeroOnNoScope) {
85
+              return new Model\Zero();
86
+      }
78 87
       throw new RunTime("Unable to find scope ($name)");
79 88
   }
80 89
 
Please login to merge, or discard this patch.
php/hamle/Tag.php 1 patch
Braces   +33 added lines, -21 removed lines patch added patch discarded remove patch
@@ -76,9 +76,10 @@  discard block
 block discarded – undo
76 76
       }
77 77
       array_shift($path);
78 78
     }
79
-    foreach ($this->tags as $tag)
80
-      if ($found = $tag->find($path))
81
-        $list = array_merge($list, $found);
79
+    foreach ($this->tags as $tag) {
80
+          if ($found = $tag->find($path))
81
+        $list = array_merge($list, $found);
82
+    }
82 83
     return $list;
83 84
   }
84 85
 
@@ -90,7 +91,9 @@  discard block
 block discarded – undo
90 91
    */
91 92
   function replace($path, Tag $newTag) {
92 93
     if ($this->compare($path[0])) {
93
-      if (count($path) == 1) return $newTag;
94
+      if (count($path) == 1) {
95
+        return $newTag;
96
+      }
94 97
       array_shift($path);
95 98
     }
96 99
     foreach ($this->tags as $k => $tag) {
@@ -103,19 +106,23 @@  discard block
 block discarded – undo
103 106
   }
104 107
 
105 108
   function addSnipContent($contentTag, &$tagArray = array(), $key = 0) {
106
-    foreach ($this->tags as $k => $tag)
107
-      $tag->addSnipContent($contentTag, $this->tags, $k);
109
+    foreach ($this->tags as $k => $tag) {
110
+          $tag->addSnipContent($contentTag, $this->tags, $k);
111
+    }
108 112
   }
109 113
 
110 114
   function compare($tic) {
111
-    if (isset($tic['type']) && $this->type != $tic['type'])
112
-      return false;
115
+    if (isset($tic['type']) && $this->type != $tic['type']) {
116
+          return false;
117
+    }
113 118
     if (isset($tic['id']) &&
114 119
         !(isset($this->opt['id']) && $tic['id'] == $this->opt['id'])
115
-    )
116
-      return false;
117
-    if (array_diff($tic['class'] ?? [], $this->opt['class'] ?? []))
118
-      return false;
120
+    ) {
121
+          return false;
122
+    }
123
+    if (array_diff($tic['class'] ?? [], $this->opt['class'] ?? [])) {
124
+          return false;
125
+    }
119 126
     return true;
120 127
   }
121 128
 
@@ -125,10 +132,11 @@  discard block
 block discarded – undo
125 132
    * @param string $mode Mode to add child [append|prepend]
126 133
    */
127 134
   function addChild(Tag $tag, $mode = "append") {
128
-    if ($mode == "prepend")
129
-      array_unshift($this->tags, $tag);
130
-    else
131
-      $this->tags[] = $tag;
135
+    if ($mode == "prepend") {
136
+          array_unshift($this->tags, $tag);
137
+    } else {
138
+          $this->tags[] = $tag;
139
+    }
132 140
   }
133 141
 
134 142
   /**
@@ -142,9 +150,12 @@  discard block
 block discarded – undo
142 150
     $ind = $minify ? '' : str_pad('', $indent);
143 151
     $oneliner = (!(count($this->content) > 1 || $this->tags));
144 152
     $out = $ind . $this->renderStTag() . ($oneliner || $minify ? '' : "\n");
145
-    if ($this->content) $out .= $this->renderContent($ind, $oneliner || $minify);
146
-    foreach ($this->tags as $tag)
147
-      $out .= $tag->render($indent + self::INDENT_SIZE, $minify);
153
+    if ($this->content) {
154
+      $out .= $this->renderContent($ind, $oneliner || $minify);
155
+    }
156
+    foreach ($this->tags as $tag) {
157
+          $out .= $tag->render($indent + self::INDENT_SIZE, $minify);
158
+    }
148 159
     $out .= ($minify || $oneliner ? '' : $ind) . $this->renderEnTag() . ($minify ? '' : "\n");
149 160
     return $out;
150 161
   }
@@ -158,8 +169,9 @@  discard block
 block discarded – undo
158 169
    */
159 170
   function renderContent($pad = "", $oneliner = false) {
160 171
     $out = "";
161
-    foreach ($this->content as $c)
162
-      $out .= ($oneliner ? '' : $pad) . $c . ($oneliner ? '' : "\n");
172
+    foreach ($this->content as $c) {
173
+          $out .= ($oneliner ? '' : $pad) . $c . ($oneliner ? '' : "\n");
174
+    }
163 175
     return $out;
164 176
   }
165 177
 
Please login to merge, or discard this patch.
php/hamle/Tag/Snippet.php 1 patch
Braces   +29 added lines, -18 removed lines patch added patch discarded remove patch
@@ -32,25 +32,33 @@  discard block
 block discarded – undo
32 32
 
33 33
   function __construct($params) {
34 34
     parent::__construct();
35
-    if (!preg_match('/^(append|content|prepend|replace)(?: (.*))?$/', $params, $m))
36
-      throw new Hamle\Exception\ParseError("Unable to parse Snippet($params)");
35
+    if (!preg_match('/^(append|content|prepend|replace)(?: (.*))?$/', $params, $m)) {
36
+          throw new Hamle\Exception\ParseError("Unable to parse Snippet($params)");
37
+    }
37 38
     $this->type = $m[1];
38
-    if (isset($m[2]))
39
-      $this->path = explode(" ", $m[2]);
40
-    else
41
-      $this->path = array();
42
-    foreach ($this->path as $k => $v)
43
-      $this->path[$k] = self::decodeClassId($v);
39
+    if (isset($m[2])) {
40
+          $this->path = explode(" ", $m[2]);
41
+    } else {
42
+          $this->path = array();
43
+    }
44
+    foreach ($this->path as $k => $v) {
45
+          $this->path[$k] = self::decodeClassId($v);
46
+    }
44 47
   }
45 48
 
46 49
   static function decodeClassId($s) {
47 50
     $out = $m = array();
48
-    if(preg_match('/^[a-zA-Z0-9\_]+/', $s, $m))
49
-      $out['type'] = $m[0];
51
+    if(preg_match('/^[a-zA-Z0-9\_]+/', $s, $m)) {
52
+          $out['type'] = $m[0];
53
+    }
50 54
     preg_match_all('/[#\.][a-zA-Z0-9\-\_]+/m', $s, $m);
51
-    if (isset($m[0])) foreach ($m[0] as $ss) {
55
+    if (isset($m[0])) {
56
+      foreach ($m[0] as $ss) {
52 57
       if ($ss[0] === "#") $out['id'] = substr($ss, 1);
53
-      if ($ss[0] === ".") $out['class'][] = substr($ss, 1);
58
+    }
59
+      if ($ss[0] === ".") {
60
+        $out['class'][] = substr($ss, 1);
61
+      }
54 62
     }
55 63
     return $out;
56 64
   }
@@ -62,21 +70,24 @@  discard block
 block discarded – undo
62 70
   function addSnipContent($contentTag, &$tagArray = array(), $key = 0) {
63 71
     if ($this->type == "content") {
64 72
       $tagArray[$key] = $contentTag;
65
-    } else
66
-      parent::addSnipContent($contentTag, $tagArray, $key);
73
+    } else {
74
+          parent::addSnipContent($contentTag, $tagArray, $key);
75
+    }
67 76
   }
68 77
 
69 78
   function apply(Hamle\Tag $rootTag) {
70 79
     if ($this->type == "append" or $this->type == "prepend") {
71 80
       $matchTags = $rootTag->find($this->path);
72
-      foreach ($matchTags as $tag)
73
-        foreach ($this->tags as $t) {
81
+      foreach ($matchTags as $tag) {
82
+              foreach ($this->tags as $t) {
74 83
           $tag->addChild($t, $this->type);
84
+      }
75 85
         }
76 86
     } elseif ($this->type == "replace") {
77 87
       $rootTag->replace($this->path, $this);
78
-    } else
79
-      throw new Hamle\Exception\ParseError("Cant Apply snippet to document '{$this->type}'");
88
+    } else {
89
+          throw new Hamle\Exception\ParseError("Cant Apply snippet to document '{$this->type}'");
90
+    }
80 91
   }
81 92
 
82 93
 }
Please login to merge, or discard this patch.
php/hamle/Parse.php 1 patch
Braces   +56 added lines, -36 removed lines patch added patch discarded remove patch
@@ -109,22 +109,25 @@  discard block
 block discarded – undo
109 109
     $revSnip = array();
110 110
     /** @var Tag[] $roots */
111 111
     $roots = array();
112
-    foreach ($this->root as $snip)
113
-      if ($snip instanceOf Tag\Snippet) {
112
+    foreach ($this->root as $snip) {
113
+          if ($snip instanceOf Tag\Snippet) {
114 114
         if ($snip->getType() == "append") {
115 115
           array_unshift($revSnip, $snip);
116
+    }
116 117
         } else {
117 118
           $fwdSnip[] = $snip;
118 119
         }
119 120
       } else {
120 121
         $roots[] = $snip;
121 122
       }
122
-    foreach ($fwdSnip as $snip)
123
-      foreach ($roots as $root)
123
+    foreach ($fwdSnip as $snip) {
124
+          foreach ($roots as $root)
124 125
         $snip->apply($root);
125
-    foreach ($revSnip as $snip)
126
-      foreach ($roots as $root)
126
+    }
127
+    foreach ($revSnip as $snip) {
128
+          foreach ($roots as $root)
127 129
         $snip->apply($root);
130
+    }
128 131
     $this->root = $roots;
129 132
   }
130 133
 
@@ -143,9 +146,11 @@  discard block
 block discarded – undo
143 146
     $heir = array();
144 147
     while ($this->lineNo < $this->lineCount) {
145 148
       $line = $this->lines[$this->lineNo];
146
-      if (trim($line)) if (preg_match(self::REGEX_PARSE_LINE, $line, $m)) {
149
+      if (trim($line)) {
150
+        if (preg_match(self::REGEX_PARSE_LINE, $line, $m)) {
147 151
         if (FALSE !== strpos($m[1], "\t"))
148 152
           throw new ParseError("Tabs are not supported in templates at this time");
153
+      }
149 154
         $indent = strlen($m[1]);
150 155
         $tag = isset($m[2]) ? $tag = $m[2] : "";
151 156
         $classid = isset($m[3]) ? $m[3] : "";
@@ -157,13 +162,13 @@  discard block
 block discarded – undo
157 162
         unset($m[0]);
158 163
         switch (strlen($code) ? $code[0] : ($textcode ? $textcode : "")) {
159 164
           case "|": //Control Tag
160
-            if ($code == "|snippet")
161
-              $hTag = new Tag\Snippet($text);
162
-            elseif ($code == "|form")
163
-              $hTag = new Tag\Form($text);
164
-            elseif ($code == "|formhint")
165
-              $hTag = new Tag\FormHint();
166
-            elseif ($code == "|else") {
165
+            if ($code == "|snippet") {
166
+                          $hTag = new Tag\Snippet($text);
167
+            } elseif ($code == "|form") {
168
+                          $hTag = new Tag\Form($text);
169
+            } elseif ($code == "|formhint") {
170
+                          $hTag = new Tag\FormHint();
171
+            } elseif ($code == "|else") {
167 172
               $hTag = new Tag\Control(substr($code, 1), $heir[$i - 1]);
168 173
               $hTag->setVar($text);
169 174
             } else {
@@ -174,8 +179,9 @@  discard block
 block discarded – undo
174 179
           case ":": //Filter Tag
175 180
             $hTag = new Tag\Filter(substr($code, 1));
176 181
             $hTag->addContent($text, Text::TOKEN_CODE);
177
-            foreach ($this->consumeBlock($indent) as $l)
178
-              $hTag->addContent($l, Text::TOKEN_CODE);
182
+            foreach ($this->consumeBlock($indent) as $l) {
183
+                          $hTag->addContent($l, Text::TOKEN_CODE);
184
+            }
179 185
             break;
180 186
           case "_": //String Tag
181 187
           case "__": //Unescape String Tag
@@ -191,8 +197,9 @@  discard block
 block discarded – undo
191 197
           case "//": // Non Printed Comment
192 198
             $hTag = new Tag\Comment($textcode);
193 199
             $hTag->addContent($text);
194
-            foreach ($this->consumeBlock($indent) as $l)
195
-              $hTag->addContent($l, Text::TOKEN_CODE);
200
+            foreach ($this->consumeBlock($indent) as $l) {
201
+                          $hTag->addContent($l, Text::TOKEN_CODE);
202
+            }
196 203
             break;
197 204
           default:
198 205
             $attr = array();
@@ -204,25 +211,34 @@  discard block
 block discarded – undo
204 211
             }
205 212
             $class = array(); $id = ""; $ref = "";
206 213
             preg_match_all('/[#\.!][a-zA-Z0-9\-\_]+/m', $classid, $cid);
207
-            if (isset($cid[0])) foreach ($cid[0] as $s) {
214
+            if (isset($cid[0])) {
215
+              foreach ($cid[0] as $s) {
208 216
               if ($s[0] == "#") $id = substr($s, 1);
209
-              if ($s[0] == ".") $class[] = substr($s, 1);
210
-              if ($s[0] == "!") $ref = substr($s, 1);
211 217
             }
212
-            if($ref)
213
-              $hTag = new Tag\DynHtml($tag, $class, $attr, $id, $ref);
214
-            else
215
-              $hTag = new Tag\Html($tag, $class, $attr, $id);
218
+              if ($s[0] == ".") {
219
+                $class[] = substr($s, 1);
220
+              }
221
+              if ($s[0] == "!") {
222
+                $ref = substr($s, 1);
223
+              }
224
+            }
225
+            if($ref) {
226
+                          $hTag = new Tag\DynHtml($tag, $class, $attr, $id, $ref);
227
+            } else {
228
+                          $hTag = new Tag\Html($tag, $class, $attr, $id);
229
+            }
216 230
             $hTag->addContent($text);
217 231
             break;
218 232
         }
219 233
         $heir[$i] = $hTag;
220
-        if ($i > 0)
221
-          $heir[$i - 1]->addChild($hTag);
222
-        else
223
-          $this->root[] = $hTag;
224
-      } else
225
-        throw new ParseError("Unable to parse line {$this->lineNo}\n\"$line\"/" . preg_last_error());
234
+        if ($i > 0) {
235
+                  $heir[$i - 1]->addChild($hTag);
236
+        } else {
237
+                  $this->root[] = $hTag;
238
+        }
239
+      } else {
240
+              throw new ParseError("Unable to parse line {$this->lineNo}\n\"$line\"/" . preg_last_error());
241
+      }
226 242
       $this->lineNo++;
227 243
     }
228 244
   }
@@ -238,8 +254,9 @@  discard block
 block discarded – undo
238 254
 
239 255
   function output($minify = false) {
240 256
     $out = "<?php\nuse Seufert\\Hamle;\n?>";
241
-    foreach ($this->root as $tag)
242
-      $out .= $tag->render(0, $minify);
257
+    foreach ($this->root as $tag) {
258
+          $out .= $tag->render(0, $minify);
259
+    }
243 260
     return $out;
244 261
 
245 262
   }
@@ -251,15 +268,18 @@  discard block
 block discarded – undo
251 268
         (!trim($this->lines[$this->lineNo + 1]) ||
252 269
             preg_match('/^(\s){' . $indent . '}((\s)+[^\s].*)$/',
253 270
                 $this->lines[$this->lineNo + 1], $m))) {
254
-      if (trim($this->lines[$this->lineNo + 1]))
255
-        $out[] = $m[2];
271
+      if (trim($this->lines[$this->lineNo + 1])) {
272
+              $out[] = $m[2];
273
+      }
256 274
       $this->lineNo++;
257 275
     }
258 276
     return $out;
259 277
   }
260 278
 
261 279
   function indentLevel($indent) {
262
-    if (!isset($this->indents)) $this->indents = array();
280
+    if (!isset($this->indents)) {
281
+      $this->indents = array();
282
+    }
263 283
     if (!count($this->indents)) {
264 284
       $this->indents = array(0 => $indent);
265 285
       // Key = indent level, Value = Depth in spaces
Please login to merge, or discard this patch.
php/hamle/Text/Filter.php 1 patch
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -49,8 +49,9 @@  discard block
 block discarded – undo
49 49
     if(preg_match("/^([a-z_]+)(?:\\((?P<vars>.*)\\))?(?:\\|(?P<chained>.+?))?$/", $s, $m)) {
50 50
       $this->filter = $m[1];
51 51
       $this->vars = isset($m['vars']) && strlen($m['vars']) ? explode(',', $m['vars']) : [];
52
-      foreach($this->vars as $k=>$v)
53
-        $this->vars[$k] = str_replace("&comma;",',',$v);
52
+      foreach($this->vars as $k=>$v) {
53
+              $this->vars[$k] = str_replace("&comma;",',',$v);
54
+      }
54 55
       if(isset($m['chained']) && strlen($m['chained'])) {
55 56
         $this->chained = new Filter($m['chained'],$what);
56 57
       }
@@ -71,25 +72,29 @@  discard block
 block discarded – undo
71 72
   }
72 73
 
73 74
   function toHTML($escape = false) {
74
-    if($escape)
75
-      return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
75
+    if($escape) {
76
+          return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
77
+    }
76 78
     return "<?=" . $this->toPHP() . "?>";
77 79
   }
78 80
 
79 81
   function toPHPpre() {
80 82
     $pre = '';
81
-    if($this->chained)
82
-      $pre = $this->chained->toPHPpre();
83
+    if($this->chained) {
84
+          $pre = $this->chained->toPHPpre();
85
+    }
83 86
     return "$pre{$this->filter}(";
84 87
   }
85 88
 
86 89
   function toPHPpost() {
87 90
     $post = '';
88
-    if($this->chained)
89
-      $post = $this->chained->toPHPpost();
91
+    if($this->chained) {
92
+          $post = $this->chained->toPHPpost();
93
+    }
90 94
     $o = '';
91
-    foreach($this->vars as $v)
92
-      $o .= ','.$this->varToCode($v);
95
+    foreach($this->vars as $v) {
96
+          $o .= ','.$this->varToCode($v);
97
+    }
93 98
     return "$o)$post";
94 99
   }
95 100
 
@@ -104,8 +109,9 @@  discard block
 block discarded – undo
104 109
   static function itersplit($v, $sep = ",") {
105 110
     $o = [];
106 111
     foreach(explode($sep, $v) as $k=>$i) {
107
-      if($i)
108
-        $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k];
112
+      if($i) {
113
+              $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k];
114
+      }
109 115
     }
110 116
     return new WrapArray($o);
111 117
   }
Please login to merge, or discard this patch.
php/hamle/Field.php 1 patch
Braces   +21 added lines, -12 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@  discard block
 block discarded – undo
66 66
   }
67 67
 
68 68
   function __call($name, $valarray) {
69
-    if (count($valarray) < 1) return $this->__get($name);
69
+    if (count($valarray) < 1) {
70
+      return $this->__get($name);
71
+    }
70 72
     $val = count($valarray) == 1 ? current($valarray) : $valarray;
71 73
     switch ($name) {
72 74
       case "name":
@@ -111,7 +113,9 @@  discard block
 block discarded – undo
111 113
   }
112 114
 
113 115
   function getValue() {
114
-    if (!is_null($this->setValue)) return $this->setValue;
116
+    if (!is_null($this->setValue)) {
117
+      return $this->setValue;
118
+    }
115 119
     if (isset($_REQUEST[$this->form . "_" . $this->name])) {
116 120
       return $_REQUEST[$this->form . "_" . $this->name];
117 121
     }
@@ -130,12 +134,15 @@  discard block
 block discarded – undo
130 134
     if (!$this->valid) {
131 135
       $atts['class'][] = "hamleFormError";
132 136
     }
133
-    if ($this->opt["disabled"])
134
-      $atts['disabled'] = "disabled";
135
-    if ($this->opt['required'])
136
-      $atts['required'] = "required";
137
-    if ($this->opt['help'])
138
-      $atts['title'] = $this->opt['help'];
137
+    if ($this->opt["disabled"]) {
138
+          $atts['disabled'] = "disabled";
139
+    }
140
+    if ($this->opt['required']) {
141
+          $atts['required'] = "required";
142
+    }
143
+    if ($this->opt['help']) {
144
+          $atts['title'] = $this->opt['help'];
145
+    }
139 146
   }
140 147
 
141 148
   function getLabelAttStatic(&$atts, &$type, &$content) {
@@ -173,10 +180,12 @@  discard block
 block discarded – undo
173 180
   function doProcess($submit) {
174 181
     if ($submit) {
175 182
       $value = $this->getValue();
176
-      if ($this->opt['required'])
177
-        $this->valid = $this->valid && strlen($value);
178
-      if ($this->opt['regex'])
179
-        $this->valid = $this->valid && preg_match($this->opt['regex'], $value);
183
+      if ($this->opt['required']) {
184
+              $this->valid = $this->valid && strlen($value);
185
+      }
186
+      if ($this->opt['regex']) {
187
+              $this->valid = $this->valid && preg_match($this->opt['regex'], $value);
188
+      }
180 189
     }
181 190
   }
182 191
 
Please login to merge, or discard this patch.
php/hamle/Text.php 1 patch
Braces   +21 added lines, -13 removed lines patch added patch discarded remove patch
@@ -126,10 +126,13 @@  discard block
 block discarded – undo
126 126
     $args = join(',', array_map(function($v) {
127 127
       if(is_array($v) && $v['type'] ?? false === 'expr') {
128 128
         return self::renderExpr($v);
129
-      } else
130
-        return self::varToCode($v);
129
+      } else {
130
+              return self::varToCode($v);
131
+      }
131 132
     } , $filter['args']));
132
-    if(strlen($args)) $args = ','.$args;
133
+    if(strlen($args)) {
134
+      $args = ','.$args;
135
+    }
133 136
     $o = "$func($o" . $args . ")";
134 137
     if($filter['chain'] ?? false) {
135 138
       $o = self::addFilter($o, $filter['chain']);
@@ -202,8 +205,9 @@  discard block
 block discarded – undo
202 205
       self::varToCode($limit),
203 206
       self::varToCode($offset)
204 207
     ];
205
-    if ($addGroup)
206
-      $opt[] = self::varToCode($group);
208
+    if ($addGroup) {
209
+          $opt[] = self::varToCode($group);
210
+    }
207 211
     return join(',', $opt);
208 212
   }
209 213
 
@@ -239,10 +243,12 @@  discard block
 block discarded – undo
239 243
     $id = null;
240 244
     $type = [];
241 245
     foreach ($n['query'] ?? [] as $q) {
242
-      if ($q['q'] === 'id')
243
-        $id = $q['id'] ?? null;
244
-      if ($q['q'] === 'type')
245
-        $type = $q['id'];
246
+      if ($q['q'] === 'id') {
247
+              $id = $q['id'] ?? null;
248
+      }
249
+      if ($q['q'] === 'type') {
250
+              $type = $q['id'];
251
+      }
246 252
     }
247 253
     if ($n['query'] === null) {
248 254
       $o = 'Hamle\Scope::get(0)';
@@ -291,8 +297,9 @@  discard block
 block discarded – undo
291 297
     foreach ($this->tree as $node) {
292 298
       switch ($node['type']) {
293 299
         case 'string':
294
-          if ($node['body'] !== '')
295
-            $out .= $node['body'];
300
+          if ($node['body'] !== '') {
301
+                      $out .= $node['body'];
302
+          }
296 303
           break;
297 304
         case 'scopeName':
298 305
           $out .= '<?=' . self::renderScopeName($node) . '?>';
@@ -322,8 +329,9 @@  discard block
 block discarded – undo
322 329
     foreach ($this->tree as $node) {
323 330
       switch ($node['type']) {
324 331
         case 'string':
325
-          if ($node['body'] !== '')
326
-            $out[] = self::varToCode($node['body']);
332
+          if ($node['body'] !== '') {
333
+                      $out[] = self::varToCode($node['body']);
334
+          }
327 335
           break;
328 336
         case 'scopeThis':
329 337
           $out[] = self::renderScopeThis($node);
Please login to merge, or discard this patch.
php/hamle/Tag/Control.php 1 patch
Braces   +23 added lines, -15 removed lines patch added patch discarded remove patch
@@ -82,21 +82,23 @@  discard block
 block discarded – undo
82 82
         $scopeName = $m[1];
83 83
         $lookup = substr($this->var, 0, strlen($this->var) - strlen($m[0]));
84 84
         $hsv = new H\Text(trim($lookup), H\Text::TOKEN_CONTROL);
85
-      } else
86
-        $hsv = new H\Text($this->var, H\Text::TOKEN_CONTROL);
85
+      } else {
86
+              $hsv = new H\Text($this->var, H\Text::TOKEN_CONTROL);
87
+      }
87 88
     }
88 89
     switch ($this->type) {
89 90
       case "each":
90
-        if ($this->var)
91
-          $out .= "foreach(" . $hsv->toPHP() . " as {$this->o}) { \n";
92
-        else
93
-          $out .= "foreach(Hamle\\Scope::get() as {$this->o}) { \n";
91
+        if ($this->var) {
92
+                  $out .= "foreach(" . $hsv->toPHP() . " as {$this->o}) { \n";
93
+        } else {
94
+                  $out .= "foreach(Hamle\\Scope::get() as {$this->o}) { \n";
95
+        }
94 96
         $out .= "Hamle\\Scope::add({$this->o}); ";
95 97
         break;
96 98
       case "with":
97
-        if ($scopeName)
98
-          $out .= "Hamle\\Scope::add(" . $hsv->toPHP() . ", \"$scopeName\");\n;";
99
-        else {
99
+        if ($scopeName) {
100
+                  $out .= "Hamle\\Scope::add(" . $hsv->toPHP() . ", \"$scopeName\");\n;";
101
+        } else {
100 102
           $out .= "if(({$this->o} = " . $hsv->toPHP() . ") && " .
101 103
               "{$this->o}->valid()) {\n";
102 104
           $out .= "Hamle\\Scope::add({$this->o});\n;";
@@ -123,8 +125,9 @@  discard block
 block discarded – undo
123 125
       case "each";
124 126
         $out .= 'Hamle\\Scope::done(); ';
125 127
         $out .= '}';
126
-        if (!$this->var)
127
-          $out .= "Hamle\\Scope::get()->rewind();\n";
128
+        if (!$this->var) {
129
+                  $out .= "Hamle\\Scope::get()->rewind();\n";
130
+        }
128 131
         break;
129 132
       case "if":
130 133
       case "else":
@@ -140,7 +143,9 @@  discard block
 block discarded – undo
140 143
         return "";
141 144
         break;
142 145
     }
143
-    if ($this->else) $out .= "else{";
146
+    if ($this->else) {
147
+      $out .= "else{";
148
+    }
144 149
     return $out . "\n?>";
145 150
   }
146 151
 
@@ -148,9 +153,12 @@  discard block
 block discarded – undo
148 153
     $ind = $minify ? '' : str_pad('', $indent);
149 154
     $oneliner = (!(count($this->content) > 1 || $this->tags));
150 155
     $out = $this->renderStTag();
151
-    if ($this->content) $out .= $this->renderContent($ind, $oneliner || $minify);
152
-    foreach ($this->tags as $tag)
153
-      $out .= $tag->render($indent, $minify);
156
+    if ($this->content) {
157
+      $out .= $this->renderContent($ind, $oneliner || $minify);
158
+    }
159
+    foreach ($this->tags as $tag) {
160
+          $out .= $tag->render($indent, $minify);
161
+    }
154 162
     $out .= $this->renderEnTag();
155 163
     return $out;
156 164
   }
Please login to merge, or discard this patch.
php/hamle/Grammar/Parser.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -306,7 +306,9 @@
 block discarded – undo
306 306
     private function peg_f3($body) { return $body; }
307 307
     private function peg_f4($name) {
308 308
             return new \Seufert\Hamle\TextNode\ScopeId(null, null, new \Seufert\Hamle\TextNode\ModelParam($name)); }
309
-    private function peg_f5($expr, $chain) { if(!$chain) return $expr;
309
+    private function peg_f5($expr, $chain) { if(!$chain) {
310
+      return $expr;
311
+    }
310 312
                            $top = array_pop($chain);
311 313
                            while($chain) { $top = array_pop($chain)->withChain($top); } return $expr->withChain($top); }
312 314
     private function peg_f6($sub) { return $sub; }
Please login to merge, or discard this patch.