Passed
Pull Request — master (#3)
by Chris
01:53
created
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/TextNode/ScopeName.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,8 +31,12 @@
 block discarded – undo
31 31
 
32 32
   public function toPHP():string {
33 33
     $o = "Hamle\\Scope::getName(" . Text::varToCode($this->name) . ")";
34
-    if ($this->immediate) $o = $this->immediate->apply($o);
35
-    if($this->chain) $o = $this->chain->apply($o);
34
+    if ($this->immediate) {
35
+      $o = $this->immediate->apply($o);
36
+    }
37
+    if($this->chain) {
38
+      $o = $this->chain->apply($o);
39
+    }
36 40
     return $o;
37 41
   }
38 42
 
Please login to merge, or discard this patch.
php/hamle/TextNode/ModelParam.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,9 @@
 block discarded – undo
24 24
   public function apply(string $out): string
25 25
   {
26 26
     $o = "{$out}->hamleGet(" . Text::varToCode($this->name) . ")";
27
-    if($this->chain)
28
-      $o = $this->chain->apply($o);
27
+    if($this->chain) {
28
+          $o = $this->chain->apply($o);
29
+    }
29 30
     return $o;
30 31
   }
31 32
 }
Please login to merge, or discard this patch.
php/hamle/TextNode/FilterFunc.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,9 @@
 block discarded – undo
39 39
     $args = array_map(fn($v) => $v instanceof Literal ? Text::varToCode($v->string()) : $v->toPHP(), $this->args);
40 40
     array_unshift($args, $out);
41 41
     $o = "{$this->func}(" . join(',', $args) . ")";
42
-    if ($this->chain) $o = $this->chain->apply($o);
42
+    if ($this->chain) {
43
+      $o = $this->chain->apply($o);
44
+    }
43 45
     return $o;
44 46
   }
45 47
 }
Please login to merge, or discard this patch.
php/hamle/TextNode/Doc.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
           $code = false;
54 54
         }
55 55
         $s = $n->string();
56
-        if($escFixed) $s = htmlspecialchars($s);
56
+        if($escFixed) {
57
+          $s = htmlspecialchars($s);
58
+        }
57 59
         $out[] = $s;
58 60
       } else {
59 61
         if (!$code) {
@@ -63,7 +65,9 @@  discard block
 block discarded – undo
63 65
         $out[] = $n->toPHP();
64 66
       }
65 67
     }
66
-    if ($code) $out[] = $closeTag;
68
+    if ($code) {
69
+      $out[] = $closeTag;
70
+    }
67 71
     return join('', $out);
68 72
   }
69 73
 }
Please login to merge, or discard this patch.
php/hamle/TextNode/ScopeId.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,12 @@
 block discarded – undo
36 36
     } else {
37 37
       $o = "Hamle\\Scope::get({$this->id})";
38 38
     }
39
-    if ($this->immediate) $o = $this->immediate->apply($o);
40
-    if ($this->chain) $o = $this->chain->apply($o);
39
+    if ($this->immediate) {
40
+      $o = $this->immediate->apply($o);
41
+    }
42
+    if ($this->chain) {
43
+      $o = $this->chain->apply($o);
44
+    }
41 45
     return $o;
42 46
   }
43 47
 
Please login to merge, or discard this patch.
php/hamle/TextNode/RelQuery.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@
 block discarded – undo
30 30
   public function apply(string $s):string {
31 31
 
32 32
     $s=  $s."->hamleRel({$this->rel}," . Query::queryParams($this->filters, true) . ')';
33
-    if($this->chain) $s = $this->chain->apply($s);
33
+    if($this->chain) {
34
+      $s = $this->chain->apply($s);
35
+    }
34 36
     return $s;
35 37
   }
36 38
 
Please login to merge, or discard this patch.
php/hamle/TextNode/Query.php 1 patch
Braces   +16 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,10 +28,12 @@  discard block
 block discarded – undo
28 28
     $id = null;
29 29
     $type = [];
30 30
     foreach ($this->filters ?? [] as $q) {
31
-      if ($q['q'] === 'id')
32
-        $id = $q['id'] ?? null;
33
-      if ($q['q'] === 'type')
34
-        $type = $q['id'];
31
+      if ($q['q'] === 'id') {
32
+              $id = $q['id'] ?? null;
33
+      }
34
+      if ($q['q'] === 'type') {
35
+              $type = $q['id'];
36
+      }
35 37
     }
36 38
     if (!$this->filters) {
37 39
       $o = 'Hamle\Scope::get(0)';
@@ -40,8 +42,12 @@  discard block
 block discarded – undo
40 42
     } else {
41 43
       $o = 'Hamle\Run::modelTypeTags(' . self::queryParams($this->filters) . ')';
42 44
     }
43
-    if($this->immediate) $o = $this->immediate->apply($o);
44
-    if($this->chain) $o = $this->chain->apply($o);
45
+    if($this->immediate) {
46
+      $o = $this->immediate->apply($o);
47
+    }
48
+    if($this->chain) {
49
+      $o = $this->chain->apply($o);
50
+    }
45 51
     return $o;
46 52
   }
47 53
 
@@ -75,7 +81,7 @@  discard block
 block discarded – undo
75 81
             $sort[''] = Hamle::SORT_RANDOM;
76 82
           } elseif($sd[0] === '-') {
77 83
             $sort[substr($sd, 1)] = Hamle::SORT_DESCENDING;
78
-          }else {
84
+          } else {
79 85
             $sort[$sd] = Hamle::SORT_ASCENDING;
80 86
           }
81 87
       }
@@ -86,8 +92,9 @@  discard block
 block discarded – undo
86 92
       Text::varToCode($limit),
87 93
       Text::varToCode($offset)
88 94
     ];
89
-    if ($addGroup)
90
-      $opt[] = Text::varToCode($group);
95
+    if ($addGroup) {
96
+          $opt[] = Text::varToCode($group);
97
+    }
91 98
     return join(',', $opt);
92 99
   }
93 100
 
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.