@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function serialize($value): string |
37 | 37 | { |
38 | - if (is_array($value)) { |
|
38 | + if (is_array($value)){ |
|
39 | 39 | return $this->packArray($value); |
40 | 40 | } |
41 | 41 | |
@@ -50,49 +50,49 @@ discard block |
||
50 | 50 | */ |
51 | 51 | protected function packArray(array $array, int $level = 0): string |
52 | 52 | { |
53 | - if ($array === []) { |
|
53 | + if ($array === []){ |
|
54 | 54 | return '[]'; |
55 | 55 | } |
56 | 56 | //Delimiters between rows and sub-arrays. |
57 | - $subIndent = "\n" . str_repeat(self::INDENT, $level + 2); |
|
58 | - $keyIndent = "\n" . str_repeat(self::INDENT, $level + 1); |
|
57 | + $subIndent = "\n".str_repeat(self::INDENT, $level + 2); |
|
58 | + $keyIndent = "\n".str_repeat(self::INDENT, $level + 1); |
|
59 | 59 | //No keys for associated array |
60 | 60 | $associated = array_diff_key($array, array_keys(array_keys($array))); |
61 | 61 | $result = []; |
62 | 62 | $innerIndent = 0; |
63 | - if (!empty($associated)) { |
|
64 | - foreach ($array as $key => $_) { |
|
63 | + if (!empty($associated)){ |
|
64 | + foreach ($array as $key => $_){ |
|
65 | 65 | //Based on biggest key length |
66 | 66 | $innerIndent = max(strlen(var_export($key, true)), $innerIndent); |
67 | 67 | } |
68 | 68 | } |
69 | - foreach ($array as $key => $value) { |
|
69 | + foreach ($array as $key => $value){ |
|
70 | 70 | $prefix = ''; |
71 | - if (!empty($associated)) { |
|
71 | + if (!empty($associated)){ |
|
72 | 72 | //Key prefix |
73 | 73 | $prefix = str_pad( |
74 | 74 | var_export($key, true), |
75 | 75 | $innerIndent, |
76 | 76 | ' ', |
77 | 77 | STR_PAD_RIGHT |
78 | - ) . ' => '; |
|
78 | + ).' => '; |
|
79 | 79 | } |
80 | - if (!is_array($value)) { |
|
81 | - $result[] = $prefix . $this->packValue($value); |
|
80 | + if (!is_array($value)){ |
|
81 | + $result[] = $prefix.$this->packValue($value); |
|
82 | 82 | continue; |
83 | 83 | } |
84 | - if ($value === []) { |
|
85 | - $result[] = $prefix . '[]'; |
|
84 | + if ($value === []){ |
|
85 | + $result[] = $prefix.'[]'; |
|
86 | 86 | continue; |
87 | 87 | } |
88 | 88 | $subArray = $this->packArray($value, $level + 1); |
89 | - $result[] = $prefix . "[{$subIndent}" . $subArray . "{$keyIndent}]"; |
|
89 | + $result[] = $prefix."[{$subIndent}".$subArray."{$keyIndent}]"; |
|
90 | 90 | } |
91 | - if ($level !== 0) { |
|
91 | + if ($level !== 0){ |
|
92 | 92 | return $result ? implode(",{$keyIndent}", $result) : ''; |
93 | 93 | } |
94 | 94 | |
95 | - return "[{$keyIndent}" . implode(",{$keyIndent}", $result) . "\n]"; |
|
95 | + return "[{$keyIndent}".implode(",{$keyIndent}", $result)."\n]"; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -105,31 +105,31 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function packValue($value): string |
107 | 107 | { |
108 | - if ($value instanceof DeclarationInterface) { |
|
108 | + if ($value instanceof DeclarationInterface){ |
|
109 | 109 | //No indentation here |
110 | 110 | return $value->render(); |
111 | 111 | } |
112 | 112 | |
113 | - if ($value === null) { |
|
113 | + if ($value === null){ |
|
114 | 114 | return 'null'; |
115 | 115 | } |
116 | 116 | |
117 | - if (is_bool($value)) { |
|
117 | + if (is_bool($value)){ |
|
118 | 118 | return ($value ? 'true' : 'false'); |
119 | 119 | } |
120 | 120 | |
121 | - if (is_object($value) && method_exists($value, '__set_state')) { |
|
122 | - return '\\' . var_export($value, true); |
|
121 | + if (is_object($value) && method_exists($value, '__set_state')){ |
|
122 | + return '\\'.var_export($value, true); |
|
123 | 123 | } |
124 | 124 | |
125 | - if (!is_string($value) && !is_numeric($value)) { |
|
125 | + if (!is_string($value) && !is_numeric($value)){ |
|
126 | 126 | throw new SerializeException('Unable to pack non scalar value'); |
127 | 127 | } |
128 | 128 | |
129 | - if (is_string($value) && class_exists($value)) { |
|
129 | + if (is_string($value) && class_exists($value)){ |
|
130 | 130 | $reflection = new ReflectionClass($value); |
131 | - if ($value === $reflection->getName()) { |
|
132 | - return '\\' . $reflection->getName() . '::class'; |
|
131 | + if ($value === $reflection->getName()){ |
|
132 | + return '\\'.$reflection->getName().'::class'; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 |
@@ -35,7 +35,8 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function serialize($value): string |
37 | 37 | { |
38 | - if (is_array($value)) { |
|
38 | + if (is_array($value)) |
|
39 | + { |
|
39 | 40 | return $this->packArray($value); |
40 | 41 | } |
41 | 42 | |
@@ -50,7 +51,8 @@ discard block |
||
50 | 51 | */ |
51 | 52 | protected function packArray(array $array, int $level = 0): string |
52 | 53 | { |
53 | - if ($array === []) { |
|
54 | + if ($array === []) |
|
55 | + { |
|
54 | 56 | return '[]'; |
55 | 57 | } |
56 | 58 | //Delimiters between rows and sub-arrays. |
@@ -60,15 +62,19 @@ discard block |
||
60 | 62 | $associated = array_diff_key($array, array_keys(array_keys($array))); |
61 | 63 | $result = []; |
62 | 64 | $innerIndent = 0; |
63 | - if (!empty($associated)) { |
|
64 | - foreach ($array as $key => $_) { |
|
65 | + if (!empty($associated)) |
|
66 | + { |
|
67 | + foreach ($array as $key => $_) |
|
68 | + { |
|
65 | 69 | //Based on biggest key length |
66 | 70 | $innerIndent = max(strlen(var_export($key, true)), $innerIndent); |
67 | 71 | } |
68 | 72 | } |
69 | - foreach ($array as $key => $value) { |
|
73 | + foreach ($array as $key => $value) |
|
74 | + { |
|
70 | 75 | $prefix = ''; |
71 | - if (!empty($associated)) { |
|
76 | + if (!empty($associated)) |
|
77 | + { |
|
72 | 78 | //Key prefix |
73 | 79 | $prefix = str_pad( |
74 | 80 | var_export($key, true), |
@@ -77,18 +83,21 @@ discard block |
||
77 | 83 | STR_PAD_RIGHT |
78 | 84 | ) . ' => '; |
79 | 85 | } |
80 | - if (!is_array($value)) { |
|
86 | + if (!is_array($value)) |
|
87 | + { |
|
81 | 88 | $result[] = $prefix . $this->packValue($value); |
82 | 89 | continue; |
83 | 90 | } |
84 | - if ($value === []) { |
|
91 | + if ($value === []) |
|
92 | + { |
|
85 | 93 | $result[] = $prefix . '[]'; |
86 | 94 | continue; |
87 | 95 | } |
88 | 96 | $subArray = $this->packArray($value, $level + 1); |
89 | 97 | $result[] = $prefix . "[{$subIndent}" . $subArray . "{$keyIndent}]"; |
90 | 98 | } |
91 | - if ($level !== 0) { |
|
99 | + if ($level !== 0) |
|
100 | + { |
|
92 | 101 | return $result ? implode(",{$keyIndent}", $result) : ''; |
93 | 102 | } |
94 | 103 | |
@@ -105,30 +114,37 @@ discard block |
||
105 | 114 | */ |
106 | 115 | protected function packValue($value): string |
107 | 116 | { |
108 | - if ($value instanceof DeclarationInterface) { |
|
117 | + if ($value instanceof DeclarationInterface) |
|
118 | + { |
|
109 | 119 | //No indentation here |
110 | 120 | return $value->render(); |
111 | 121 | } |
112 | 122 | |
113 | - if ($value === null) { |
|
123 | + if ($value === null) |
|
124 | + { |
|
114 | 125 | return 'null'; |
115 | 126 | } |
116 | 127 | |
117 | - if (is_bool($value)) { |
|
128 | + if (is_bool($value)) |
|
129 | + { |
|
118 | 130 | return ($value ? 'true' : 'false'); |
119 | 131 | } |
120 | 132 | |
121 | - if (is_object($value) && method_exists($value, '__set_state')) { |
|
133 | + if (is_object($value) && method_exists($value, '__set_state')) |
|
134 | + { |
|
122 | 135 | return '\\' . var_export($value, true); |
123 | 136 | } |
124 | 137 | |
125 | - if (!is_string($value) && !is_numeric($value)) { |
|
138 | + if (!is_string($value) && !is_numeric($value)) |
|
139 | + { |
|
126 | 140 | throw new SerializeException('Unable to pack non scalar value'); |
127 | 141 | } |
128 | 142 | |
129 | - if (is_string($value) && class_exists($value)) { |
|
143 | + if (is_string($value) && class_exists($value)) |
|
144 | + { |
|
130 | 145 | $reflection = new ReflectionClass($value); |
131 | - if ($value === $reflection->getName()) { |
|
146 | + if ($value === $reflection->getName()) |
|
147 | + { |
|
132 | 148 | return '\\' . $reflection->getName() . '::class'; |
133 | 149 | } |
134 | 150 | } |
@@ -64,7 +64,8 @@ discard block |
||
64 | 64 | ) { |
65 | 65 | $this->setName($name); |
66 | 66 | |
67 | - if (!empty($extends)) { |
|
67 | + if (!empty($extends)) |
|
68 | + { |
|
68 | 69 | $this->setExtends($extends); |
69 | 70 | } |
70 | 71 | |
@@ -157,7 +158,8 @@ discard block |
||
157 | 158 | public function setInterfaces(array $interfaces): ClassDeclaration |
158 | 159 | { |
159 | 160 | $this->interfaces = []; |
160 | - foreach ($interfaces as $interface) { |
|
161 | + foreach ($interfaces as $interface) |
|
162 | + { |
|
161 | 163 | $this->addInterface($interface); |
162 | 164 | } |
163 | 165 | |
@@ -203,7 +205,8 @@ discard block |
||
203 | 205 | public function setTraits(array $traits): ClassDeclaration |
204 | 206 | { |
205 | 207 | $this->traits = []; |
206 | - foreach ($traits as $trait) { |
|
208 | + foreach ($traits as $trait) |
|
209 | + { |
|
207 | 210 | $this->addTrait($trait); |
208 | 211 | } |
209 | 212 | |
@@ -293,7 +296,8 @@ discard block |
||
293 | 296 | { |
294 | 297 | $result = ''; |
295 | 298 | |
296 | - if (!$this->docComment->isEmpty()) { |
|
299 | + if (!$this->docComment->isEmpty()) |
|
300 | + { |
|
297 | 301 | $result .= $this->docComment->render($indentLevel) . "\n"; |
298 | 302 | } |
299 | 303 | |
@@ -301,11 +305,13 @@ discard block |
||
301 | 305 | $header = "class {$this->getName()}"; |
302 | 306 | |
303 | 307 | //Rendering extends |
304 | - if (!empty($this->extends)) { |
|
308 | + if (!empty($this->extends)) |
|
309 | + { |
|
305 | 310 | $header .= " extends {$this->extends}"; |
306 | 311 | } |
307 | 312 | |
308 | - if (!empty($this->interfaces)) { |
|
313 | + if (!empty($this->interfaces)) |
|
314 | + { |
|
309 | 315 | $interfaces = implode(', ', array_keys($this->interfaces)); |
310 | 316 | $header .= " implements {$interfaces}"; |
311 | 317 | } |
@@ -329,19 +335,23 @@ discard block |
||
329 | 335 | protected function renderBody(int $indentLevel): string |
330 | 336 | { |
331 | 337 | $result = ''; |
332 | - if (!empty($this->traits)) { |
|
338 | + if (!empty($this->traits)) |
|
339 | + { |
|
333 | 340 | $result .= $this->renderTraits($indentLevel + 1) . "\n\n"; |
334 | 341 | } |
335 | 342 | |
336 | - if (!$this->constants->isEmpty()) { |
|
343 | + if (!$this->constants->isEmpty()) |
|
344 | + { |
|
337 | 345 | $result .= $this->constants->render($indentLevel + 1) . "\n\n"; |
338 | 346 | } |
339 | 347 | |
340 | - if (!$this->properties->isEmpty()) { |
|
348 | + if (!$this->properties->isEmpty()) |
|
349 | + { |
|
341 | 350 | $result .= $this->properties->render($indentLevel + 1) . "\n\n"; |
342 | 351 | } |
343 | 352 | |
344 | - if (!$this->methods->isEmpty()) { |
|
353 | + if (!$this->methods->isEmpty()) |
|
354 | + { |
|
345 | 355 | $result .= $this->methods->render($indentLevel + 1) . "\n\n"; |
346 | 356 | } |
347 | 357 | |
@@ -355,7 +365,8 @@ discard block |
||
355 | 365 | private function renderTraits(int $indentLevel = 0): string |
356 | 366 | { |
357 | 367 | $lines = []; |
358 | - foreach ($this->traits as $class => $_) { |
|
368 | + foreach ($this->traits as $class => $_) |
|
369 | + { |
|
359 | 370 | $lines[] = $this->addIndent("use {$class};", $indentLevel); |
360 | 371 | } |
361 | 372 |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | string $extends = '', |
58 | 58 | array $interfaces = [], |
59 | 59 | string $comment = '' |
60 | - ) { |
|
60 | + ){ |
|
61 | 61 | $this->setName($name); |
62 | 62 | |
63 | - if (!empty($extends)) { |
|
63 | + if (!empty($extends)){ |
|
64 | 64 | $this->setExtends($extends); |
65 | 65 | } |
66 | 66 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | public function setInterfaces(array $interfaces): ClassDeclaration |
133 | 133 | { |
134 | 134 | $this->interfaces = []; |
135 | - foreach ($interfaces as $interface) { |
|
135 | + foreach ($interfaces as $interface){ |
|
136 | 136 | $this->addInterface($interface); |
137 | 137 | } |
138 | 138 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | public function setTraits(array $traits): ClassDeclaration |
165 | 165 | { |
166 | 166 | $this->traits = []; |
167 | - foreach ($traits as $trait) { |
|
167 | + foreach ($traits as $trait){ |
|
168 | 168 | $this->addTrait($trait); |
169 | 169 | } |
170 | 170 | |
@@ -233,51 +233,51 @@ discard block |
||
233 | 233 | { |
234 | 234 | $result = ''; |
235 | 235 | |
236 | - if (!$this->docComment->isEmpty()) { |
|
237 | - $result .= $this->docComment->render($indentLevel) . "\n"; |
|
236 | + if (!$this->docComment->isEmpty()){ |
|
237 | + $result .= $this->docComment->render($indentLevel)."\n"; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | //Class header |
241 | 241 | $header = "class {$this->getName()}"; |
242 | 242 | |
243 | 243 | //Rendering extends |
244 | - if (!empty($this->extends)) { |
|
244 | + if (!empty($this->extends)){ |
|
245 | 245 | $header .= " extends {$this->extends}"; |
246 | 246 | } |
247 | 247 | |
248 | - if (!empty($this->interfaces)) { |
|
248 | + if (!empty($this->interfaces)){ |
|
249 | 249 | $interfaces = implode(', ', array_keys($this->interfaces)); |
250 | 250 | $header .= " implements {$interfaces}"; |
251 | 251 | } |
252 | 252 | |
253 | - $result .= $this->addIndent($header, $indentLevel) . "\n"; |
|
254 | - $result .= $this->addIndent('{', $indentLevel) . "\n"; |
|
253 | + $result .= $this->addIndent($header, $indentLevel)."\n"; |
|
254 | + $result .= $this->addIndent('{', $indentLevel)."\n"; |
|
255 | 255 | |
256 | 256 | //Rendering class body |
257 | 257 | $result .= $this->renderBody($indentLevel); |
258 | 258 | |
259 | - $result = rtrim($result, "\n") . "\n"; |
|
259 | + $result = rtrim($result, "\n")."\n"; |
|
260 | 260 | |
261 | - return $result . $this->addIndent('}', $indentLevel); |
|
261 | + return $result.$this->addIndent('}', $indentLevel); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | protected function renderBody(int $indentLevel): string |
265 | 265 | { |
266 | 266 | $result = ''; |
267 | - if (!empty($this->traits)) { |
|
268 | - $result .= $this->renderTraits($indentLevel + 1) . "\n\n"; |
|
267 | + if (!empty($this->traits)){ |
|
268 | + $result .= $this->renderTraits($indentLevel + 1)."\n\n"; |
|
269 | 269 | } |
270 | 270 | |
271 | - if (!$this->constants->isEmpty()) { |
|
272 | - $result .= $this->constants->render($indentLevel + 1) . "\n\n"; |
|
271 | + if (!$this->constants->isEmpty()){ |
|
272 | + $result .= $this->constants->render($indentLevel + 1)."\n\n"; |
|
273 | 273 | } |
274 | 274 | |
275 | - if (!$this->properties->isEmpty()) { |
|
276 | - $result .= $this->properties->render($indentLevel + 1) . "\n\n"; |
|
275 | + if (!$this->properties->isEmpty()){ |
|
276 | + $result .= $this->properties->render($indentLevel + 1)."\n\n"; |
|
277 | 277 | } |
278 | 278 | |
279 | - if (!$this->methods->isEmpty()) { |
|
280 | - $result .= $this->methods->render($indentLevel + 1) . "\n\n"; |
|
279 | + if (!$this->methods->isEmpty()){ |
|
280 | + $result .= $this->methods->render($indentLevel + 1)."\n\n"; |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | return $result; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | private function renderTraits(int $indentLevel = 0): string |
287 | 287 | { |
288 | 288 | $lines = []; |
289 | - foreach ($this->traits as $class => $_) { |
|
289 | + foreach ($this->traits as $class => $_){ |
|
290 | 290 | $lines[] = $this->addIndent("use {$class};", $indentLevel); |
291 | 291 | } |
292 | 292 |
@@ -45,7 +45,7 @@ |
||
45 | 45 | ], |
46 | 46 | ]); |
47 | 47 | |
48 | - foreach ($rules as $rule) { |
|
48 | + foreach ($rules as $rule){ |
|
49 | 49 | return $rule->getConditions(); |
50 | 50 | } |
51 | 51 |
@@ -45,7 +45,8 @@ |
||
45 | 45 | ], |
46 | 46 | ]); |
47 | 47 | |
48 | - foreach ($rules as $rule) { |
|
48 | + foreach ($rules as $rule) |
|
49 | + { |
|
49 | 50 | return $rule->getConditions(); |
50 | 51 | } |
51 | 52 |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function apply($element, string $type, string $context = ''): string |
118 | 118 | { |
119 | - if (!empty($style = $this->getStyle($type, $context))) { |
|
119 | + if (!empty($style = $this->getStyle($type, $context))){ |
|
120 | 120 | return sprintf($this->style['element'], $style, $element); |
121 | 121 | } |
122 | 122 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function indent(int $level): string |
138 | 138 | { |
139 | - if ($level == 0) { |
|
139 | + if ($level == 0){ |
|
140 | 140 | return ''; |
141 | 141 | } |
142 | 142 | |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private function getStyle(string $type, string $context): string |
163 | 163 | { |
164 | - if (isset($this->style[$type][$context])) { |
|
164 | + if (isset($this->style[$type][$context])){ |
|
165 | 165 | return $this->style[$type][$context]; |
166 | 166 | } |
167 | 167 | |
168 | - if (isset($this->style[$type]['common'])) { |
|
168 | + if (isset($this->style[$type]['common'])){ |
|
169 | 169 | return $this->style[$type]['common']; |
170 | 170 | } |
171 | 171 | |
172 | - if (isset($this->style[$type]) && is_string($this->style[$type])) { |
|
172 | + if (isset($this->style[$type]) && is_string($this->style[$type])){ |
|
173 | 173 | return $this->style[$type]; |
174 | 174 | } |
175 | 175 |
@@ -116,7 +116,8 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function apply($element, string $type, string $context = ''): string |
118 | 118 | { |
119 | - if (!empty($style = $this->getStyle($type, $context))) { |
|
119 | + if (!empty($style = $this->getStyle($type, $context))) |
|
120 | + { |
|
120 | 121 | return sprintf($this->style['element'], $style, $element); |
121 | 122 | } |
122 | 123 | |
@@ -136,7 +137,8 @@ discard block |
||
136 | 137 | */ |
137 | 138 | public function indent(int $level): string |
138 | 139 | { |
139 | - if ($level == 0) { |
|
140 | + if ($level == 0) |
|
141 | + { |
|
140 | 142 | return ''; |
141 | 143 | } |
142 | 144 | |
@@ -161,15 +163,18 @@ discard block |
||
161 | 163 | */ |
162 | 164 | private function getStyle(string $type, string $context): string |
163 | 165 | { |
164 | - if (isset($this->style[$type][$context])) { |
|
166 | + if (isset($this->style[$type][$context])) |
|
167 | + { |
|
165 | 168 | return $this->style[$type][$context]; |
166 | 169 | } |
167 | 170 | |
168 | - if (isset($this->style[$type]['common'])) { |
|
171 | + if (isset($this->style[$type]['common'])) |
|
172 | + { |
|
169 | 173 | return $this->style[$type]['common']; |
170 | 174 | } |
171 | 175 | |
172 | - if (isset($this->style[$type]) && is_string($this->style[$type])) { |
|
176 | + if (isset($this->style[$type]) && is_string($this->style[$type])) |
|
177 | + { |
|
173 | 178 | return $this->style[$type]; |
174 | 179 | } |
175 | 180 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * Default coloring schema. |
23 | 23 | */ |
24 | - public const DEFAULT = [ |
|
24 | + public const default = [ |
|
25 | 25 | 'body' => '<pre style="background-color: white; font-family: monospace;">%s</pre>', |
26 | 26 | 'element' => '<span style="%s;">%s</span>', |
27 | 27 | 'indent' => '· ', |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * Set of styles associated with different dumping properties. |
101 | 101 | */ |
102 | - protected array $style = self::DEFAULT; |
|
102 | + protected array $style = self::default; |
|
103 | 103 | |
104 | - public function __construct(array $style = self::DEFAULT) |
|
104 | + public function __construct(array $style = self::default) |
|
105 | 105 | { |
106 | 106 | $this->style = $style; |
107 | 107 | } |
@@ -43,16 +43,16 @@ |
||
43 | 43 | if ( |
44 | 44 | !$node instanceof PHP |
45 | 45 | || strpos($node->content, self::PHP_MARCO_EXISTS_FUNCTION) === false |
46 | - ) { |
|
46 | + ){ |
|
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
50 | - if ($node->getContext()->getPath() !== $this->path) { |
|
50 | + if ($node->getContext()->getPath() !== $this->path){ |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | 54 | $exists = new PHPMixin($node->tokens, self::PHP_MARCO_EXISTS_FUNCTION); |
55 | - foreach ($exists->getBlocks() as $name => $_) { |
|
55 | + foreach ($exists->getBlocks() as $name => $_){ |
|
56 | 56 | // do not leak to parent template |
57 | 57 | $exists->set($name, 'false'); |
58 | 58 | } |
@@ -47,12 +47,14 @@ |
||
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
50 | - if ($node->getContext()->getPath() !== $this->path) { |
|
50 | + if ($node->getContext()->getPath() !== $this->path) |
|
51 | + { |
|
51 | 52 | return; |
52 | 53 | } |
53 | 54 | |
54 | 55 | $exists = new PHPMixin($node->tokens, self::PHP_MARCO_EXISTS_FUNCTION); |
55 | - foreach ($exists->getBlocks() as $name => $_) { |
|
56 | + foreach ($exists->getBlocks() as $name => $_) |
|
57 | + { |
|
56 | 58 | // do not leak to parent template |
57 | 59 | $exists->set($name, 'false'); |
58 | 60 | } |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | public function trimValue(): array |
47 | 47 | { |
48 | 48 | $value = $this->value; |
49 | - if ($value instanceof Nil) { |
|
49 | + if ($value instanceof Nil){ |
|
50 | 50 | return []; |
51 | 51 | } |
52 | 52 | |
53 | - if (is_string($value)) { |
|
53 | + if (is_string($value)){ |
|
54 | 54 | return [new Raw(trim($value, '\'"'))]; |
55 | 55 | } |
56 | 56 | |
57 | - if (!$value instanceof Mixin) { |
|
57 | + if (!$value instanceof Mixin){ |
|
58 | 58 | return [$value]; |
59 | 59 | } |
60 | 60 | |
61 | 61 | // trim mixin quotes |
62 | 62 | $nodes = $value->nodes; |
63 | 63 | |
64 | - if (count($nodes) >= 3 && $nodes[0] instanceof Raw && $nodes[count($nodes) - 1] instanceof Raw) { |
|
64 | + if (count($nodes) >= 3 && $nodes[0] instanceof Raw && $nodes[count($nodes) - 1] instanceof Raw){ |
|
65 | 65 | $quote = $nodes[0]->content[0]; |
66 | - if (!in_array($quote, ['"', '\''])) { |
|
66 | + if (!in_array($quote, ['"', '\''])){ |
|
67 | 67 | return $nodes; |
68 | 68 | } |
69 | 69 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
76 | - foreach ($nodes as $index => $node) { |
|
77 | - if ($node instanceof Raw && $node->content === '') { |
|
76 | + foreach ($nodes as $index => $node){ |
|
77 | + if ($node instanceof Raw && $node->content === ''){ |
|
78 | 78 | unset($nodes[$index]); |
79 | 79 | } |
80 | 80 | } |
@@ -46,24 +46,29 @@ discard block |
||
46 | 46 | public function trimValue(): array |
47 | 47 | { |
48 | 48 | $value = $this->value; |
49 | - if ($value instanceof Nil) { |
|
49 | + if ($value instanceof Nil) |
|
50 | + { |
|
50 | 51 | return []; |
51 | 52 | } |
52 | 53 | |
53 | - if (is_string($value)) { |
|
54 | + if (is_string($value)) |
|
55 | + { |
|
54 | 56 | return [new Raw(trim($value, '\'"'))]; |
55 | 57 | } |
56 | 58 | |
57 | - if (!$value instanceof Mixin) { |
|
59 | + if (!$value instanceof Mixin) |
|
60 | + { |
|
58 | 61 | return [$value]; |
59 | 62 | } |
60 | 63 | |
61 | 64 | // trim mixin quotes |
62 | 65 | $nodes = $value->nodes; |
63 | 66 | |
64 | - if (count($nodes) >= 3 && $nodes[0] instanceof Raw && $nodes[count($nodes) - 1] instanceof Raw) { |
|
67 | + if (count($nodes) >= 3 && $nodes[0] instanceof Raw && $nodes[count($nodes) - 1] instanceof Raw) |
|
68 | + { |
|
65 | 69 | $quote = $nodes[0]->content[0]; |
66 | - if (!in_array($quote, ['"', '\''])) { |
|
70 | + if (!in_array($quote, ['"', '\''])) |
|
71 | + { |
|
67 | 72 | return $nodes; |
68 | 73 | } |
69 | 74 | |
@@ -73,8 +78,10 @@ discard block |
||
73 | 78 | ); |
74 | 79 | } |
75 | 80 | |
76 | - foreach ($nodes as $index => $node) { |
|
77 | - if ($node instanceof Raw && $node->content === '') { |
|
81 | + foreach ($nodes as $index => $node) |
|
82 | + { |
|
83 | + if ($node instanceof Raw && $node->content === '') |
|
84 | + { |
|
78 | 85 | unset($nodes[$index]); |
79 | 86 | } |
80 | 87 | } |
@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | $entities = $this->getDeclaredEntities($controller, $action); |
47 | 47 | |
48 | 48 | $contextCandidates = []; |
49 | - foreach ($entities as $parameter => $role) { |
|
49 | + foreach ($entities as $parameter => $role){ |
|
50 | 50 | $value = $this->getParameter($parameter, $parameters, count($entities) === 1); |
51 | - if ($value === null) { |
|
51 | + if ($value === null){ |
|
52 | 52 | throw new ControllerException( |
53 | 53 | "Entity `{$parameter}` can not be found", |
54 | 54 | ControllerException::NOT_FOUND |
55 | 55 | ); |
56 | 56 | } |
57 | 57 | |
58 | - if (is_object($value)) { |
|
59 | - if ($this->orm->getHeap()->has($value)) { |
|
58 | + if (is_object($value)){ |
|
59 | + if ($this->orm->getHeap()->has($value)){ |
|
60 | 60 | $contextCandidates[] = $value; |
61 | 61 | } |
62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | $entity = $this->resolveEntity($role, $value); |
68 | - if ($entity === null) { |
|
68 | + if ($entity === null){ |
|
69 | 69 | throw new ControllerException( |
70 | 70 | "Entity `{$parameter}` can not be found", |
71 | 71 | ControllerException::NOT_FOUND |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $contextCandidates[] = $entity; |
77 | 77 | } |
78 | 78 | |
79 | - if (!isset($parameters['@context']) && count($contextCandidates) === 1) { |
|
79 | + if (!isset($parameters['@context']) && count($contextCandidates) === 1){ |
|
80 | 80 | $parameters['@context'] = current($contextCandidates); |
81 | 81 | } |
82 | 82 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | protected function getParameter(string $role, array $parameters, bool $useDefault = false) |
93 | 93 | { |
94 | - if (!$useDefault) { |
|
94 | + if (!$useDefault){ |
|
95 | 95 | return $parameters[$role] ?? null; |
96 | 96 | } |
97 | 97 | |
@@ -116,25 +116,25 @@ discard block |
||
116 | 116 | private function getDeclaredEntities(string $controller, string $action): array |
117 | 117 | { |
118 | 118 | $key = sprintf('%s:%s', $controller, $action); |
119 | - if (array_key_exists($key, $this->cache)) { |
|
119 | + if (array_key_exists($key, $this->cache)){ |
|
120 | 120 | return $this->cache[$key]; |
121 | 121 | } |
122 | 122 | |
123 | 123 | $this->cache[$key] = []; |
124 | - try { |
|
124 | + try{ |
|
125 | 125 | $method = new \ReflectionMethod($controller, $action); |
126 | - } catch (\ReflectionException $e) { |
|
126 | + }catch (\ReflectionException $e){ |
|
127 | 127 | return []; |
128 | 128 | } |
129 | 129 | |
130 | - foreach ($method->getParameters() as $parameter) { |
|
130 | + foreach ($method->getParameters() as $parameter){ |
|
131 | 131 | $class = $this->getParameterClass($parameter); |
132 | 132 | |
133 | - if ($class === null) { |
|
133 | + if ($class === null){ |
|
134 | 134 | continue; |
135 | 135 | } |
136 | 136 | |
137 | - if ($this->orm->getSchema()->defines($class->getName())) { |
|
137 | + if ($this->orm->getSchema()->defines($class->getName())){ |
|
138 | 138 | $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($class->getName()); |
139 | 139 | } |
140 | 140 | } |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | { |
151 | 151 | $type = $parameter->getType(); |
152 | 152 | |
153 | - if (!$type instanceof \ReflectionNamedType) { |
|
153 | + if (!$type instanceof \ReflectionNamedType){ |
|
154 | 154 | return null; |
155 | 155 | } |
156 | 156 | |
157 | - if ($type->isBuiltin()) { |
|
157 | + if ($type->isBuiltin()){ |
|
158 | 158 | return null; |
159 | 159 | } |
160 | 160 |
@@ -46,17 +46,21 @@ discard block |
||
46 | 46 | $entities = $this->getDeclaredEntities($controller, $action); |
47 | 47 | |
48 | 48 | $contextCandidates = []; |
49 | - foreach ($entities as $parameter => $role) { |
|
49 | + foreach ($entities as $parameter => $role) |
|
50 | + { |
|
50 | 51 | $value = $this->getParameter($parameter, $parameters, count($entities) === 1); |
51 | - if ($value === null) { |
|
52 | + if ($value === null) |
|
53 | + { |
|
52 | 54 | throw new ControllerException( |
53 | 55 | "Entity `{$parameter}` can not be found", |
54 | 56 | ControllerException::NOT_FOUND |
55 | 57 | ); |
56 | 58 | } |
57 | 59 | |
58 | - if (is_object($value)) { |
|
59 | - if ($this->orm->getHeap()->has($value)) { |
|
60 | + if (is_object($value)) |
|
61 | + { |
|
62 | + if ($this->orm->getHeap()->has($value)) |
|
63 | + { |
|
60 | 64 | $contextCandidates[] = $value; |
61 | 65 | } |
62 | 66 | |
@@ -65,7 +69,8 @@ discard block |
||
65 | 69 | } |
66 | 70 | |
67 | 71 | $entity = $this->resolveEntity($role, $value); |
68 | - if ($entity === null) { |
|
72 | + if ($entity === null) |
|
73 | + { |
|
69 | 74 | throw new ControllerException( |
70 | 75 | "Entity `{$parameter}` can not be found", |
71 | 76 | ControllerException::NOT_FOUND |
@@ -76,7 +81,8 @@ discard block |
||
76 | 81 | $contextCandidates[] = $entity; |
77 | 82 | } |
78 | 83 | |
79 | - if (!isset($parameters['@context']) && count($contextCandidates) === 1) { |
|
84 | + if (!isset($parameters['@context']) && count($contextCandidates) === 1) |
|
85 | + { |
|
80 | 86 | $parameters['@context'] = current($contextCandidates); |
81 | 87 | } |
82 | 88 | |
@@ -91,7 +97,8 @@ discard block |
||
91 | 97 | */ |
92 | 98 | protected function getParameter(string $role, array $parameters, bool $useDefault = false) |
93 | 99 | { |
94 | - if (!$useDefault) { |
|
100 | + if (!$useDefault) |
|
101 | + { |
|
95 | 102 | return $parameters[$role] ?? null; |
96 | 103 | } |
97 | 104 | |
@@ -116,25 +123,32 @@ discard block |
||
116 | 123 | private function getDeclaredEntities(string $controller, string $action): array |
117 | 124 | { |
118 | 125 | $key = sprintf('%s:%s', $controller, $action); |
119 | - if (array_key_exists($key, $this->cache)) { |
|
126 | + if (array_key_exists($key, $this->cache)) |
|
127 | + { |
|
120 | 128 | return $this->cache[$key]; |
121 | 129 | } |
122 | 130 | |
123 | 131 | $this->cache[$key] = []; |
124 | - try { |
|
132 | + try |
|
133 | + { |
|
125 | 134 | $method = new \ReflectionMethod($controller, $action); |
126 | - } catch (\ReflectionException $e) { |
|
135 | + } |
|
136 | + catch (\ReflectionException $e) |
|
137 | + { |
|
127 | 138 | return []; |
128 | 139 | } |
129 | 140 | |
130 | - foreach ($method->getParameters() as $parameter) { |
|
141 | + foreach ($method->getParameters() as $parameter) |
|
142 | + { |
|
131 | 143 | $class = $this->getParameterClass($parameter); |
132 | 144 | |
133 | - if ($class === null) { |
|
145 | + if ($class === null) |
|
146 | + { |
|
134 | 147 | continue; |
135 | 148 | } |
136 | 149 | |
137 | - if ($this->orm->getSchema()->defines($class->getName())) { |
|
150 | + if ($this->orm->getSchema()->defines($class->getName())) |
|
151 | + { |
|
138 | 152 | $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($class->getName()); |
139 | 153 | } |
140 | 154 | } |
@@ -150,11 +164,13 @@ discard block |
||
150 | 164 | { |
151 | 165 | $type = $parameter->getType(); |
152 | 166 | |
153 | - if (!$type instanceof \ReflectionNamedType) { |
|
167 | + if (!$type instanceof \ReflectionNamedType) |
|
168 | + { |
|
154 | 169 | return null; |
155 | 170 | } |
156 | 171 | |
157 | - if ($type->isBuiltin()) { |
|
172 | + if ($type->isBuiltin()) |
|
173 | + { |
|
158 | 174 | return null; |
159 | 175 | } |
160 | 176 |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function process(string $controller, string $action, array $parameters, CoreInterface $core) |
51 | 51 | { |
52 | - foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) { |
|
53 | - if (isset($parameters[$parameter])) { |
|
52 | + foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){ |
|
53 | + if (isset($parameters[$parameter])){ |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** @var FilterInterface $filter */ |
58 | 58 | $filter = $this->container->get($filterClass); |
59 | 59 | |
60 | - if (isset($parameters['@context'])) { |
|
60 | + if (isset($parameters['@context'])){ |
|
61 | 61 | // other interceptors can define the validation contex |
62 | 62 | $filter->setContext($parameters['@context']); |
63 | 63 | } |
64 | 64 | |
65 | - if (!$filter->isValid()) { |
|
65 | + if (!$filter->isValid()){ |
|
66 | 66 | return $this->renderInvalid($filter); |
67 | 67 | } |
68 | 68 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected function renderInvalid(FilterInterface $filter) |
82 | 82 | { |
83 | - switch ($this->strategy) { |
|
83 | + switch ($this->strategy){ |
|
84 | 84 | case self::STRATEGY_JSON_RESPONSE: |
85 | 85 | return [ |
86 | 86 | 'status' => 400, |
@@ -99,25 +99,25 @@ discard block |
||
99 | 99 | private function getDeclaredFilters(string $controller, string $action): array |
100 | 100 | { |
101 | 101 | $key = sprintf('%s:%s', $controller, $action); |
102 | - if (array_key_exists($key, $this->cache)) { |
|
102 | + if (array_key_exists($key, $this->cache)){ |
|
103 | 103 | return $this->cache[$key]; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $this->cache[$key] = []; |
107 | - try { |
|
107 | + try{ |
|
108 | 108 | $method = new \ReflectionMethod($controller, $action); |
109 | - } catch (\ReflectionException $e) { |
|
109 | + }catch (\ReflectionException $e){ |
|
110 | 110 | return []; |
111 | 111 | } |
112 | 112 | |
113 | - foreach ($method->getParameters() as $parameter) { |
|
113 | + foreach ($method->getParameters() as $parameter){ |
|
114 | 114 | $class = $this->getParameterClass($parameter); |
115 | 115 | |
116 | - if ($class === null) { |
|
116 | + if ($class === null){ |
|
117 | 117 | continue; |
118 | 118 | } |
119 | 119 | |
120 | - if ($class->implementsInterface(FilterInterface::class)) { |
|
120 | + if ($class->implementsInterface(FilterInterface::class)){ |
|
121 | 121 | $this->cache[$key][$parameter->getName()] = $class->getName(); |
122 | 122 | } |
123 | 123 | } |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | { |
135 | 135 | $type = $parameter->getType(); |
136 | 136 | |
137 | - if (!$type instanceof \ReflectionNamedType) { |
|
137 | + if (!$type instanceof \ReflectionNamedType){ |
|
138 | 138 | return null; |
139 | 139 | } |
140 | 140 | |
141 | - if ($type->isBuiltin()) { |
|
141 | + if ($type->isBuiltin()){ |
|
142 | 142 | return null; |
143 | 143 | } |
144 | 144 |
@@ -49,20 +49,24 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function process(string $controller, string $action, array $parameters, CoreInterface $core) |
51 | 51 | { |
52 | - foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) { |
|
53 | - if (isset($parameters[$parameter])) { |
|
52 | + foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) |
|
53 | + { |
|
54 | + if (isset($parameters[$parameter])) |
|
55 | + { |
|
54 | 56 | continue; |
55 | 57 | } |
56 | 58 | |
57 | 59 | /** @var FilterInterface $filter */ |
58 | 60 | $filter = $this->container->get($filterClass); |
59 | 61 | |
60 | - if (isset($parameters['@context'])) { |
|
62 | + if (isset($parameters['@context'])) |
|
63 | + { |
|
61 | 64 | // other interceptors can define the validation contex |
62 | 65 | $filter->setContext($parameters['@context']); |
63 | 66 | } |
64 | 67 | |
65 | - if (!$filter->isValid()) { |
|
68 | + if (!$filter->isValid()) |
|
69 | + { |
|
66 | 70 | return $this->renderInvalid($filter); |
67 | 71 | } |
68 | 72 | |
@@ -80,7 +84,8 @@ discard block |
||
80 | 84 | */ |
81 | 85 | protected function renderInvalid(FilterInterface $filter) |
82 | 86 | { |
83 | - switch ($this->strategy) { |
|
87 | + switch ($this->strategy) |
|
88 | + { |
|
84 | 89 | case self::STRATEGY_JSON_RESPONSE: |
85 | 90 | return [ |
86 | 91 | 'status' => 400, |
@@ -99,25 +104,32 @@ discard block |
||
99 | 104 | private function getDeclaredFilters(string $controller, string $action): array |
100 | 105 | { |
101 | 106 | $key = sprintf('%s:%s', $controller, $action); |
102 | - if (array_key_exists($key, $this->cache)) { |
|
107 | + if (array_key_exists($key, $this->cache)) |
|
108 | + { |
|
103 | 109 | return $this->cache[$key]; |
104 | 110 | } |
105 | 111 | |
106 | 112 | $this->cache[$key] = []; |
107 | - try { |
|
113 | + try |
|
114 | + { |
|
108 | 115 | $method = new \ReflectionMethod($controller, $action); |
109 | - } catch (\ReflectionException $e) { |
|
116 | + } |
|
117 | + catch (\ReflectionException $e) |
|
118 | + { |
|
110 | 119 | return []; |
111 | 120 | } |
112 | 121 | |
113 | - foreach ($method->getParameters() as $parameter) { |
|
122 | + foreach ($method->getParameters() as $parameter) |
|
123 | + { |
|
114 | 124 | $class = $this->getParameterClass($parameter); |
115 | 125 | |
116 | - if ($class === null) { |
|
126 | + if ($class === null) |
|
127 | + { |
|
117 | 128 | continue; |
118 | 129 | } |
119 | 130 | |
120 | - if ($class->implementsInterface(FilterInterface::class)) { |
|
131 | + if ($class->implementsInterface(FilterInterface::class)) |
|
132 | + { |
|
121 | 133 | $this->cache[$key][$parameter->getName()] = $class->getName(); |
122 | 134 | } |
123 | 135 | } |
@@ -134,11 +146,13 @@ discard block |
||
134 | 146 | { |
135 | 147 | $type = $parameter->getType(); |
136 | 148 | |
137 | - if (!$type instanceof \ReflectionNamedType) { |
|
149 | + if (!$type instanceof \ReflectionNamedType) |
|
150 | + { |
|
138 | 151 | return null; |
139 | 152 | } |
140 | 153 | |
141 | - if ($type->isBuiltin()) { |
|
154 | + if ($type->isBuiltin()) |
|
155 | + { |
|
142 | 156 | return null; |
143 | 157 | } |
144 | 158 |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | FilesInterface $files, |
53 | 53 | DirectoriesInterface $directories |
54 | 54 | ): void { |
55 | - switch ($this->argument('type')) { |
|
55 | + switch ($this->argument('type')){ |
|
56 | 56 | case 'replace': |
57 | 57 | case 'follow': |
58 | - if ($this->isDirectory()) { |
|
58 | + if ($this->isDirectory()){ |
|
59 | 59 | $this->sprintf( |
60 | 60 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
61 | 61 | $this->getSource($files), |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $this->getMergeMode(), |
69 | 69 | $this->getFileMode() |
70 | 70 | ); |
71 | - } else { |
|
71 | + }else{ |
|
72 | 72 | $this->sprintf( |
73 | 73 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
74 | 74 | $this->getSource($files), |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private function getSource(FilesInterface $files): ?string |
109 | 109 | { |
110 | - if (!$this->isDirectory()) { |
|
110 | + if (!$this->isDirectory()){ |
|
111 | 111 | return $files->normalizePath($this->argument('source')); |
112 | 112 | } |
113 | 113 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
123 | 123 | { |
124 | 124 | $target = $this->argument('target'); |
125 | - foreach ($directories->getAll() as $alias => $value) { |
|
125 | + foreach ($directories->getAll() as $alias => $value){ |
|
126 | 126 | $target = str_replace("@{$alias}", $value, $target); |
127 | 127 | } |
128 | 128 | |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | */ |
135 | 135 | private function isDirectory(): bool |
136 | 136 | { |
137 | - if ($this->argument('type') == 'ensure') { |
|
137 | + if ($this->argument('type') == 'ensure'){ |
|
138 | 138 | return true; |
139 | 139 | } |
140 | 140 | |
141 | - if (strpos($this->argument('source'), '*') !== false) { |
|
141 | + if (strpos($this->argument('source'), '*') !== false){ |
|
142 | 142 | return true; |
143 | 143 | } |
144 | 144 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | private function getMergeMode(): string |
152 | 152 | { |
153 | - switch ($this->argument('type')) { |
|
153 | + switch ($this->argument('type')){ |
|
154 | 154 | case 'follow': |
155 | 155 | return PublisherInterface::FOLLOW; |
156 | 156 | case 'replace': |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | private function getFileMode(): int |
167 | 167 | { |
168 | - switch ($this->argument('mode')) { |
|
168 | + switch ($this->argument('mode')){ |
|
169 | 169 | case 'readonly': |
170 | 170 | return FilesInterface::READONLY; |
171 | 171 | case 'runtime': |
@@ -52,10 +52,12 @@ discard block |
||
52 | 52 | FilesInterface $files, |
53 | 53 | DirectoriesInterface $directories |
54 | 54 | ): void { |
55 | - switch ($this->argument('type')) { |
|
55 | + switch ($this->argument('type')) |
|
56 | + { |
|
56 | 57 | case 'replace': |
57 | 58 | case 'follow': |
58 | - if ($this->isDirectory()) { |
|
59 | + if ($this->isDirectory()) |
|
60 | + { |
|
59 | 61 | $this->sprintf( |
60 | 62 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
61 | 63 | $this->getSource($files), |
@@ -68,7 +70,9 @@ discard block |
||
68 | 70 | $this->getMergeMode(), |
69 | 71 | $this->getFileMode() |
70 | 72 | ); |
71 | - } else { |
|
73 | + } |
|
74 | + else |
|
75 | + { |
|
72 | 76 | $this->sprintf( |
73 | 77 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
74 | 78 | $this->getSource($files), |
@@ -107,7 +111,8 @@ discard block |
||
107 | 111 | */ |
108 | 112 | private function getSource(FilesInterface $files): ?string |
109 | 113 | { |
110 | - if (!$this->isDirectory()) { |
|
114 | + if (!$this->isDirectory()) |
|
115 | + { |
|
111 | 116 | return $files->normalizePath($this->argument('source')); |
112 | 117 | } |
113 | 118 | |
@@ -122,7 +127,8 @@ discard block |
||
122 | 127 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
123 | 128 | { |
124 | 129 | $target = $this->argument('target'); |
125 | - foreach ($directories->getAll() as $alias => $value) { |
|
130 | + foreach ($directories->getAll() as $alias => $value) |
|
131 | + { |
|
126 | 132 | $target = str_replace("@{$alias}", $value, $target); |
127 | 133 | } |
128 | 134 | |
@@ -134,11 +140,13 @@ discard block |
||
134 | 140 | */ |
135 | 141 | private function isDirectory(): bool |
136 | 142 | { |
137 | - if ($this->argument('type') == 'ensure') { |
|
143 | + if ($this->argument('type') == 'ensure') |
|
144 | + { |
|
138 | 145 | return true; |
139 | 146 | } |
140 | 147 | |
141 | - if (strpos($this->argument('source'), '*') !== false) { |
|
148 | + if (strpos($this->argument('source'), '*') !== false) |
|
149 | + { |
|
142 | 150 | return true; |
143 | 151 | } |
144 | 152 | |
@@ -150,7 +158,8 @@ discard block |
||
150 | 158 | */ |
151 | 159 | private function getMergeMode(): string |
152 | 160 | { |
153 | - switch ($this->argument('type')) { |
|
161 | + switch ($this->argument('type')) |
|
162 | + { |
|
154 | 163 | case 'follow': |
155 | 164 | return PublisherInterface::FOLLOW; |
156 | 165 | case 'replace': |
@@ -165,7 +174,8 @@ discard block |
||
165 | 174 | */ |
166 | 175 | private function getFileMode(): int |
167 | 176 | { |
168 | - switch ($this->argument('mode')) { |
|
177 | + switch ($this->argument('mode')) |
|
178 | + { |
|
169 | 179 | case 'readonly': |
170 | 180 | return FilesInterface::READONLY; |
171 | 181 | case 'runtime': |
@@ -167,7 +167,7 @@ |
||
167 | 167 | { |
168 | 168 | switch ($this->argument('mode')) { |
169 | 169 | case 'readonly': |
170 | - return FilesInterface::READONLY; |
|
170 | + return FilesInterface::readonly; |
|
171 | 171 | case 'runtime': |
172 | 172 | return FilesInterface::RUNTIME; |
173 | 173 | default: |