@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | if (($name === '.') || ($name === '..')) continue; |
25 | 25 | |
26 | - if ((null === $type) || (@filetype($dir_name . $name) === $type)) yield $name; |
|
26 | + if ((null === $type) || (@filetype($dir_name.$name) === $type)) yield $name; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | closedir($handler); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | foreach (array_diff($list, ['.', '..']) as $name) { |
117 | 117 | |
118 | - $name = ($dir_name . '/' . $name); |
|
118 | + $name = ($dir_name.'/'.$name); |
|
119 | 119 | |
120 | 120 | if (@is_dir($name)) self::removeDir($name, true); |
121 | 121 |
@@ -21,9 +21,13 @@ discard block |
||
21 | 21 | |
22 | 22 | while (false !== ($name = readdir($handler))) { |
23 | 23 | |
24 | - if (($name === '.') || ($name === '..')) continue; |
|
24 | + if (($name === '.') || ($name === '..')) { |
|
25 | + continue; |
|
26 | + } |
|
25 | 27 | |
26 | - if ((null === $type) || (@filetype($dir_name . $name) === $type)) yield $name; |
|
28 | + if ((null === $type) || (@filetype($dir_name . $name) === $type)) { |
|
29 | + yield $name; |
|
30 | + } |
|
27 | 31 | } |
28 | 32 | |
29 | 33 | closedir($handler); |
@@ -38,7 +42,9 @@ discard block |
||
38 | 42 | |
39 | 43 | private static function getInfo(string $file_name, int $param, bool $check_exists = true) { |
40 | 44 | |
41 | - if ($check_exists && !self::isFile($file_name)) return false; |
|
45 | + if ($check_exists && !self::isFile($file_name)) { |
|
46 | + return false; |
|
47 | + } |
|
42 | 48 | |
43 | 49 | return pathinfo($file_name, $param); |
44 | 50 | } |
@@ -117,9 +123,11 @@ discard block |
||
117 | 123 | |
118 | 124 | $name = ($dir_name . '/' . $name); |
119 | 125 | |
120 | - if (@is_dir($name)) self::removeDir($name, true); |
|
121 | - |
|
122 | - else if (@is_file($name)) self::removeFile($name); |
|
126 | + if (@is_dir($name)) { |
|
127 | + self::removeDir($name, true); |
|
128 | + } else if (@is_file($name)) { |
|
129 | + self::removeFile($name); |
|
130 | + } |
|
123 | 131 | } |
124 | 132 | } |
125 | 133 | |
@@ -145,7 +153,9 @@ discard block |
||
145 | 153 | |
146 | 154 | public static function iterate(string $dir_name) : Generator { |
147 | 155 | |
148 | - foreach (self::getList($dir_name) as $name) yield $name; |
|
156 | + foreach (self::getList($dir_name) as $name) { |
|
157 | + yield $name; |
|
158 | + } |
|
149 | 159 | } |
150 | 160 | |
151 | 161 | /** |
@@ -154,7 +164,9 @@ discard block |
||
154 | 164 | |
155 | 165 | public static function iterateDirs(string $dir_name) : Generator { |
156 | 166 | |
157 | - foreach (self::getList($dir_name, 'dir') as $name) yield $name; |
|
167 | + foreach (self::getList($dir_name, 'dir') as $name) { |
|
168 | + yield $name; |
|
169 | + } |
|
158 | 170 | } |
159 | 171 | |
160 | 172 | /** |
@@ -163,7 +175,9 @@ discard block |
||
163 | 175 | |
164 | 176 | public static function iterateFiles(string $dir_name) : Generator { |
165 | 177 | |
166 | - foreach (self::getList($dir_name, 'file') as $name) yield $name; |
|
178 | + foreach (self::getList($dir_name, 'file') as $name) { |
|
179 | + yield $name; |
|
180 | + } |
|
167 | 181 | } |
168 | 182 | |
169 | 183 | /** |
@@ -334,7 +348,9 @@ discard block |
||
334 | 348 | |
335 | 349 | public static function include(string $file_name) { |
336 | 350 | |
337 | - if ((strtolower(self::getExtension($file_name)) !== 'php')) return false; |
|
351 | + if ((strtolower(self::getExtension($file_name)) !== 'php')) { |
|
352 | + return false; |
|
353 | + } |
|
338 | 354 | |
339 | 355 | return @include $file_name; |
340 | 356 | } |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | |
24 | 24 | private function registerWidget(string $name) { |
25 | 25 | |
26 | - if (false === Template::getWidget($name)) Template::setWidget($name, new Block); |
|
26 | + if (false === Template::getWidget($name)) { |
|
27 | + Template::setWidget($name, new Block); |
|
28 | + } |
|
27 | 29 | } |
28 | 30 | |
29 | 31 | /** |
@@ -40,15 +42,19 @@ discard block |
||
40 | 42 | |
41 | 43 | $type = $matches[2][$key]; $name = $matches[3][$key]; $contents = ($matches[4][$key] ?? ''); |
42 | 44 | |
43 | - if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) continue; |
|
45 | + if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) { |
|
46 | + continue; |
|
47 | + } |
|
44 | 48 | |
45 | 49 | $this->contents = str_replace($match, ('{ ' . $type . ':' . $name . ' / }'), $this->contents); |
46 | 50 | |
47 | - if ($type === 'block') $this->blocks[$name] = (new Block($contents))->$toggle(); |
|
48 | - |
|
49 | - else if ($type === 'for') $this->loops[$name] = new Loop($contents); |
|
50 | - |
|
51 | - else if ($type === 'widget') $this->registerWidget($this->widgets[] = $name); |
|
51 | + if ($type === 'block') { |
|
52 | + $this->blocks[$name] = (new Block($contents))->$toggle(); |
|
53 | + } else if ($type === 'for') { |
|
54 | + $this->loops[$name] = new Loop($contents); |
|
55 | + } else if ($type === 'widget') { |
|
56 | + $this->registerWidget($this->widgets[] = $name); |
|
57 | + } |
|
52 | 58 | } |
53 | 59 | } |
54 | 60 | |
@@ -68,7 +74,9 @@ discard block |
||
68 | 74 | |
69 | 75 | foreach ($matches[1] as $index => $name) { |
70 | 76 | |
71 | - if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) continue; |
|
77 | + if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) { |
|
78 | + continue; |
|
79 | + } |
|
72 | 80 | |
73 | 81 | $elementaries['stack'][$name] = false; |
74 | 82 | } |
@@ -152,11 +160,17 @@ discard block |
||
152 | 160 | |
153 | 161 | public function __clone() { |
154 | 162 | |
155 | - foreach ($this->blocks as $name => $block) $this->blocks[$name] = clone $block; |
|
163 | + foreach ($this->blocks as $name => $block) { |
|
164 | + $this->blocks[$name] = clone $block; |
|
165 | + } |
|
156 | 166 | |
157 | - foreach ($this->loops as $name => $loop) $this->loops[$name] = clone $loop; |
|
167 | + foreach ($this->loops as $name => $loop) { |
|
168 | + $this->loops[$name] = clone $loop; |
|
169 | + } |
|
158 | 170 | |
159 | - foreach ($this->items as $name => $item) $this->items[$name] = clone $item; |
|
171 | + foreach ($this->items as $name => $item) { |
|
172 | + $this->items[$name] = clone $item; |
|
173 | + } |
|
160 | 174 | } |
161 | 175 | |
162 | 176 | /** |
@@ -167,11 +181,13 @@ discard block |
||
167 | 181 | |
168 | 182 | public function set(string $name, $component) : Block { |
169 | 183 | |
170 | - if ($component instanceof Block) $this->setBlock($name, $component); |
|
171 | - |
|
172 | - else if (is_array($component)) $this->setLoop($name, $component); |
|
173 | - |
|
174 | - else if (is_scalar($component)) $this->setVar($name, $component); |
|
184 | + if ($component instanceof Block) { |
|
185 | + $this->setBlock($name, $component); |
|
186 | + } else if (is_array($component)) { |
|
187 | + $this->setLoop($name, $component); |
|
188 | + } else if (is_scalar($component)) { |
|
189 | + $this->setVar($name, $component); |
|
190 | + } |
|
175 | 191 | |
176 | 192 | # ------------------------ |
177 | 193 | |
@@ -186,7 +202,9 @@ discard block |
||
186 | 202 | |
187 | 203 | public function setArray(array $components) : Block { |
188 | 204 | |
189 | - foreach ($components as $name => $component) $this->set($name, $component); |
|
205 | + foreach ($components as $name => $component) { |
|
206 | + $this->set($name, $component); |
|
207 | + } |
|
190 | 208 | |
191 | 209 | return $this; |
192 | 210 | } |
@@ -199,7 +217,9 @@ discard block |
||
199 | 217 | |
200 | 218 | public function setBlock(string $name, Block $block) : Block { |
201 | 219 | |
202 | - if (isset($this->blocks[$name])) $this->blocks[$name] = $block; |
|
220 | + if (isset($this->blocks[$name])) { |
|
221 | + $this->blocks[$name] = $block; |
|
222 | + } |
|
203 | 223 | |
204 | 224 | return $this; |
205 | 225 | } |
@@ -212,7 +232,9 @@ discard block |
||
212 | 232 | |
213 | 233 | public function setLoop(string $name, array $items) : Block { |
214 | 234 | |
215 | - if (isset($this->loops[$name])) $this->loops[$name]->setItems($items); |
|
235 | + if (isset($this->loops[$name])) { |
|
236 | + $this->loops[$name]->setItems($items); |
|
237 | + } |
|
216 | 238 | |
217 | 239 | return $this; |
218 | 240 | } |
@@ -225,7 +247,9 @@ discard block |
||
225 | 247 | |
226 | 248 | public function setVar(string $name, string $value) : Block { |
227 | 249 | |
228 | - if (isset($this->variables[$name])) $this->variables[$name] = $value; |
|
250 | + if (isset($this->variables[$name])) { |
|
251 | + $this->variables[$name] = $value; |
|
252 | + } |
|
229 | 253 | |
230 | 254 | return $this; |
231 | 255 | } |
@@ -307,7 +331,9 @@ discard block |
||
307 | 331 | |
308 | 332 | public function getContents() : string { |
309 | 333 | |
310 | - if (!$this->enabled) return ''; |
|
334 | + if (!$this->enabled) { |
|
335 | + return ''; |
|
336 | + } |
|
311 | 337 | |
312 | 338 | # Lock the block |
313 | 339 |