@@ -90,8 +90,9 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function addAliase (string $name) |
92 | 92 | { |
93 | - if (array_search ($name, $this->names) !== false) |
|
94 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
93 | + if (array_search ($name, $this->names) !== false) { |
|
94 | + throw new \Exception ($this->locale->aliase_exists_exception); |
|
95 | + } |
|
95 | 96 | |
96 | 97 | $this->names[] = $name; |
97 | 98 | |
@@ -109,10 +110,11 @@ discard block |
||
109 | 110 | { |
110 | 111 | $args = array_values ($args); |
111 | 112 | |
112 | - foreach ($this->names as $name) |
|
113 | - if (($key = array_search ($name, $args)) !== false) |
|
113 | + foreach ($this->names as $name) { |
|
114 | + if (($key = array_search ($name, $args)) !== false) |
|
114 | 115 | { |
115 | 116 | unset ($args[$key]); |
117 | + } |
|
116 | 118 | $args = array_values ($args); |
117 | 119 | |
118 | 120 | while ($this->parse ($args) !== false); |
@@ -174,8 +176,9 @@ discard block |
||
174 | 176 | */ |
175 | 177 | public function addAliase (string $name) |
176 | 178 | { |
177 | - if (array_search ($name, $this->names) !== false) |
|
178 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
179 | + if (array_search ($name, $this->names) !== false) { |
|
180 | + throw new \Exception ($this->locale->aliase_exists_exception); |
|
181 | + } |
|
179 | 182 | |
180 | 183 | $this->names[] = $name; |
181 | 184 | |
@@ -193,11 +196,12 @@ discard block |
||
193 | 196 | { |
194 | 197 | $args = array_values ($args); |
195 | 198 | |
196 | - foreach ($this->names as $name) |
|
197 | - if (($key = array_search ($name, $args)) !== false) |
|
199 | + foreach ($this->names as $name) { |
|
200 | + if (($key = array_search ($name, $args)) !== false) |
|
198 | 201 | { |
199 | 202 | if (!isset ($args[$key + 1])) |
200 | 203 | throw new \Exception ($this->locale->unselected_value_exception); |
204 | + } |
|
201 | 205 | |
202 | 206 | $param = [$args[$key + 1]]; |
203 | 207 | |
@@ -208,21 +212,21 @@ discard block |
||
208 | 212 | { |
209 | 213 | while (($altParam = $this->parse ($args)) !== $this->defaultValue) |
210 | 214 | { |
211 | - if (is_array ($altParam)) |
|
212 | - $param = array_merge ($param, $altParam); |
|
213 | - |
|
214 | - else $param[] = $altParam; |
|
215 | + if (is_array ($altParam)) { |
|
216 | + $param = array_merge ($param, $altParam); |
|
217 | + } else { |
|
218 | + $param[] = $altParam; |
|
219 | + } |
|
215 | 220 | } |
216 | - } |
|
217 | - |
|
218 | - catch (\Throwable $e) {} |
|
221 | + } catch (\Throwable $e) {} |
|
219 | 222 | |
220 | 223 | return sizeof ($param) == 1 ? |
221 | 224 | $param[0] : $param; |
222 | 225 | } |
223 | 226 | |
224 | - if ($this->required) |
|
225 | - throw new \Exception ($this->locale->undefined_param_exception); |
|
227 | + if ($this->required) { |
|
228 | + throw new \Exception ($this->locale->undefined_param_exception); |
|
229 | + } |
|
226 | 230 | |
227 | 231 | return $this->defaultValue; |
228 | 232 | } |
@@ -281,8 +285,9 @@ discard block |
||
281 | 285 | */ |
282 | 286 | public function addAliase (string $name) |
283 | 287 | { |
284 | - if (array_search ($name, $this->names) !== false) |
|
285 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
288 | + if (array_search ($name, $this->names) !== false) { |
|
289 | + throw new \Exception ($this->locale->aliase_exists_exception); |
|
290 | + } |
|
286 | 291 | |
287 | 292 | $this->names[] = $name; |
288 | 293 | |
@@ -301,11 +306,12 @@ discard block |
||
301 | 306 | $args = array_values ($args); |
302 | 307 | $l = strlen ($this->separator); |
303 | 308 | |
304 | - foreach ($this->names as $name) |
|
305 | - foreach ($args as $id => $arg) |
|
309 | + foreach ($this->names as $name) { |
|
310 | + foreach ($args as $id => $arg) |
|
306 | 311 | if (substr ($arg, 0, ($pos = strlen ($name) + $l)) == $name . $this->separator) |
307 | 312 | { |
308 | 313 | $param = [substr ($arg, $pos)]; |
314 | + } |
|
309 | 315 | |
310 | 316 | unset ($args[$id]); |
311 | 317 | $args = array_values ($args); |
@@ -314,21 +320,21 @@ discard block |
||
314 | 320 | { |
315 | 321 | while (($altParam = $this->parse ($args)) !== $this->defaultValue) |
316 | 322 | { |
317 | - if (is_array ($altParam)) |
|
318 | - $param = array_merge ($param, $altParam); |
|
319 | - |
|
320 | - else $param[] = $altParam; |
|
323 | + if (is_array ($altParam)) { |
|
324 | + $param = array_merge ($param, $altParam); |
|
325 | + } else { |
|
326 | + $param[] = $altParam; |
|
327 | + } |
|
321 | 328 | } |
322 | - } |
|
323 | - |
|
324 | - catch (\Throwable $e) {} |
|
329 | + } catch (\Throwable $e) {} |
|
325 | 330 | |
326 | 331 | return sizeof ($param) == 1 ? |
327 | 332 | $param[0] : $param; |
328 | 333 | } |
329 | 334 | |
330 | - if ($this->required) |
|
331 | - throw new \Exception ($this->locale->undefined_param_exception); |
|
335 | + if ($this->required) { |
|
336 | + throw new \Exception ($this->locale->undefined_param_exception); |
|
337 | + } |
|
332 | 338 | |
333 | 339 | return $this->defaultValue; |
334 | 340 | } |
@@ -357,8 +363,9 @@ discard block |
||
357 | 363 | $this->name = $name; |
358 | 364 | $this->locale = new Locale; |
359 | 365 | |
360 | - if ($callable !== null) |
|
361 | - $this->callable = $callable; |
|
366 | + if ($callable !== null) { |
|
367 | + $this->callable = $callable; |
|
368 | + } |
|
362 | 369 | } |
363 | 370 | |
364 | 371 | /** |
@@ -384,11 +391,14 @@ discard block |
||
384 | 391 | */ |
385 | 392 | public function addParams (array $params): Command |
386 | 393 | { |
387 | - foreach ($params as $param) |
|
388 | - if ($param instanceof Parameter) |
|
394 | + foreach ($params as $param) { |
|
395 | + if ($param instanceof Parameter) |
|
389 | 396 | $this->params[current ($param->names)] = $param; |
397 | + } |
|
390 | 398 | |
391 | - else throw new \Exception ($this->locale->param_type_exception); |
|
399 | + else { |
|
400 | + throw new \Exception ($this->locale->param_type_exception); |
|
401 | + } |
|
392 | 402 | |
393 | 403 | return $this; |
394 | 404 | } |
@@ -404,8 +414,9 @@ discard block |
||
404 | 414 | { |
405 | 415 | $params = array_combine (array_keys ($this->params), array_fill (0, sizeof ($this->params), null)); |
406 | 416 | |
407 | - foreach ($this->params as $name => $param) |
|
408 | - $params[$name] = $param->parse ($args); |
|
417 | + foreach ($this->params as $name => $param) { |
|
418 | + $params[$name] = $param->parse ($args); |
|
419 | + } |
|
409 | 420 | |
410 | 421 | return $params; |
411 | 422 | } |
@@ -441,8 +452,9 @@ discard block |
||
441 | 452 | */ |
442 | 453 | public function __construct (\Closure $callable = null) |
443 | 454 | { |
444 | - if ($callable !== null) |
|
445 | - $this->callable = $callable; |
|
455 | + if ($callable !== null) { |
|
456 | + $this->callable = $callable; |
|
457 | + } |
|
446 | 458 | } |
447 | 459 | } |
448 | 460 | |
@@ -467,11 +479,14 @@ discard block |
||
467 | 479 | $this->locale = new Locale; |
468 | 480 | $this->defaultCommand = $defaultCommand; |
469 | 481 | |
470 | - foreach ($commands as $command) |
|
471 | - if ($command instanceof Command) |
|
482 | + foreach ($commands as $command) { |
|
483 | + if ($command instanceof Command) |
|
472 | 484 | $this->commands[$command->name] = $command; |
485 | + } |
|
473 | 486 | |
474 | - else throw new \Exception ($this->locale->command_type_exception); |
|
487 | + else { |
|
488 | + throw new \Exception ($this->locale->command_type_exception); |
|
489 | + } |
|
475 | 490 | } |
476 | 491 | |
477 | 492 | /** |
@@ -513,18 +528,20 @@ discard block |
||
513 | 528 | |
514 | 529 | if (!isset ($args[0])) |
515 | 530 | { |
516 | - if ($this->defaultCommand !== null) |
|
517 | - return $this->defaultCommand->execute ($args); |
|
518 | - |
|
519 | - else throw new \Exception ($this->locale->command_undefined_error); |
|
531 | + if ($this->defaultCommand !== null) { |
|
532 | + return $this->defaultCommand->execute ($args); |
|
533 | + } else { |
|
534 | + throw new \Exception ($this->locale->command_undefined_error); |
|
535 | + } |
|
520 | 536 | } |
521 | 537 | |
522 | 538 | $name = $args[0]; |
523 | 539 | $args = array_slice ($args, 1); |
524 | 540 | |
525 | - if (!isset ($this->commands[$name])) |
|
526 | - return $this->defaultCommand !== null ? |
|
541 | + if (!isset ($this->commands[$name])) { |
|
542 | + return $this->defaultCommand !== null ? |
|
527 | 543 | $this->defaultCommand->execute ($args) : false; |
544 | + } |
|
528 | 545 | |
529 | 546 | return $this->commands[$name]->execute ($args); |
530 | 547 | } |
@@ -7,19 +7,21 @@ |
||
7 | 7 | const CORE_DIR = __DIR__; |
8 | 8 | chdir (CORE_DIR); |
9 | 9 | |
10 | -foreach (glob ('ext/php_*.dll') as $ext) |
|
10 | +foreach (glob ('ext/php_*.dll') as $ext) { |
|
11 | 11 | if (!extension_loaded (substr (basename ($ext), 4, -4))) |
12 | 12 | load_extension ($ext); |
13 | +} |
|
13 | 14 | |
14 | -if (file_exists ('../engine/VoidEngine.php')) |
|
15 | +if (file_exists ('../engine/VoidEngine.php')) { |
|
15 | 16 | require '../engine/VoidEngine.php'; |
16 | - |
|
17 | -elseif (file_exists (FRAMEWORK_DIR .'/engine/VoidEngine.php')) |
|
17 | +} elseif (file_exists (FRAMEWORK_DIR .'/engine/VoidEngine.php')) { |
|
18 | 18 | require FRAMEWORK_DIR .'/engine/VoidEngine.php'; |
19 | - |
|
20 | -else message ('VoidEngine not founded'); |
|
19 | +} else { |
|
20 | + message ('VoidEngine not founded'); |
|
21 | +} |
|
21 | 22 | |
22 | 23 | $app = '../../app/start.php'; |
23 | 24 | |
24 | -if (file_exists ($app)) |
|
25 | +if (file_exists ($app)) { |
|
25 | 26 | require $app; |
27 | +} |
@@ -338,8 +338,9 @@ |
||
338 | 338 | 'clLight' => $converter->fromHtml ('#EEEEEE') |
339 | 339 | ]; |
340 | 340 | |
341 | -foreach ($constants as $name => $value) |
|
341 | +foreach ($constants as $name => $value) { |
|
342 | 342 | define ($name, $value); |
343 | +} |
|
343 | 344 | |
344 | 345 | $argv = START_PARAMS; |
345 | 346 | $argc = sizeof ($argv); |
@@ -10,14 +10,13 @@ |
||
10 | 10 | { |
11 | 11 | try |
12 | 12 | { |
13 | - foreach ($args as $id => $arg) |
|
14 | - $args[$id] = EngineAdditions::coupleSelector ($arg); |
|
13 | + foreach ($args as $id => $arg) { |
|
14 | + $args[$id] = EngineAdditions::coupleSelector ($arg); |
|
15 | + } |
|
15 | 16 | |
16 | 17 | return $function (($e = _c($sender)) !== false ? |
17 | 18 | $e : new WFObject ($sender), ...$args); |
18 | - } |
|
19 | - |
|
20 | - catch (\Throwable $e) |
|
19 | + } catch (\Throwable $e) |
|
21 | 20 | { |
22 | 21 | message ([ |
23 | 22 | 'type' => get_class ($e), |
@@ -15,16 +15,15 @@ |
||
15 | 15 | |
16 | 16 | public function run ($form = null): void |
17 | 17 | { |
18 | - if ($form instanceof WFObject) |
|
19 | - $this->application->run ($form->selector); |
|
20 | - |
|
21 | - elseif (is_int ($form) && VoidEngine::objectExists ($form)) |
|
22 | - $this->application->run ($form); |
|
23 | - |
|
24 | - elseif ($form === null) |
|
25 | - $this->application->run (); |
|
26 | - |
|
27 | - else throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
18 | + if ($form instanceof WFObject) { |
|
19 | + $this->application->run ($form->selector); |
|
20 | + } elseif (is_int ($form) && VoidEngine::objectExists ($form)) { |
|
21 | + $this->application->run ($form); |
|
22 | + } elseif ($form === null) { |
|
23 | + $this->application->run (); |
|
24 | + } else { |
|
25 | + throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
26 | + } |
|
28 | 27 | } |
29 | 28 | |
30 | 29 | public function restart (): void |
@@ -6,8 +6,9 @@ discard block |
||
6 | 6 | { |
7 | 7 | $oldStatus = $GLOBALS['error_status']; |
8 | 8 | |
9 | - if ($status !== null) |
|
10 | - $GLOBALS['error_status'] = $status; |
|
9 | + if ($status !== null) { |
|
10 | + $GLOBALS['error_status'] = $status; |
|
11 | + } |
|
11 | 12 | |
12 | 13 | return $oldStatus; |
13 | 14 | } |
@@ -41,9 +42,7 @@ discard block |
||
41 | 42 | try |
42 | 43 | { |
43 | 44 | eval ('return; '. $code); |
44 | - } |
|
45 | - |
|
46 | - catch (\Throwable $e) |
|
45 | + } catch (\Throwable $e) |
|
47 | 46 | { |
48 | 47 | return [ |
49 | 48 | 'text' => $e->getMessage (), |
@@ -67,34 +66,39 @@ discard block |
||
67 | 66 | $array = (new WFClass ('System.Array', null)) |
68 | 67 | ->createInstance (VoidEngine::objectType ($type), $size = sizeof ($items)); |
69 | 68 | |
70 | - for ($i = 0; $i < $size; ++$i) |
|
71 | - $array[$i] = array_shift ($items); |
|
69 | + for ($i = 0; $i < $size; ++$i) { |
|
70 | + $array[$i] = array_shift ($items); |
|
71 | + } |
|
72 | 72 | |
73 | 73 | return $array; |
74 | 74 | } |
75 | 75 | |
76 | 76 | function dir_create (string $path, int $mode = 0777): void |
77 | 77 | { |
78 | - if (!is_dir ($path)) |
|
79 | - mkdir ($path, $mode, true); |
|
80 | -} |
|
78 | + if (!is_dir ($path)) { |
|
79 | + mkdir ($path, $mode, true); |
|
80 | + } |
|
81 | + } |
|
81 | 82 | |
82 | 83 | function dir_delete (string $path): bool |
83 | 84 | { |
84 | - if (!is_dir ($path)) |
|
85 | - return false; |
|
85 | + if (!is_dir ($path)) { |
|
86 | + return false; |
|
87 | + } |
|
86 | 88 | |
87 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
88 | - if (is_dir ($file = $path .'/'. $file)) |
|
89 | + foreach (array_slice (scandir ($path), 2) as $file) { |
|
90 | + if (is_dir ($file = $path .'/'. $file)) |
|
89 | 91 | { |
90 | 92 | dir_delete ($file); |
93 | + } |
|
91 | 94 | |
92 | - if (is_dir ($file)) |
|
93 | - rmdir ($file); |
|
95 | + if (is_dir ($file)) { |
|
96 | + rmdir ($file); |
|
97 | + } |
|
98 | + } else { |
|
99 | + unlink ($file); |
|
94 | 100 | } |
95 | 101 | |
96 | - else unlink ($file); |
|
97 | - |
|
98 | 102 | rmdir ($path); |
99 | 103 | |
100 | 104 | return true; |
@@ -108,17 +112,22 @@ discard block |
||
108 | 112 | |
109 | 113 | function dir_copy (string $from, string $to): bool |
110 | 114 | { |
111 | - if (!is_dir ($from)) |
|
112 | - return false; |
|
115 | + if (!is_dir ($from)) { |
|
116 | + return false; |
|
117 | + } |
|
113 | 118 | |
114 | - if (!is_dir ($to)) |
|
115 | - dir_create ($to); |
|
119 | + if (!is_dir ($to)) { |
|
120 | + dir_create ($to); |
|
121 | + } |
|
116 | 122 | |
117 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
118 | - if (is_dir ($f = $from .'/'. $file)) |
|
123 | + foreach (array_slice (scandir ($from), 2) as $file) { |
|
124 | + if (is_dir ($f = $from .'/'. $file)) |
|
119 | 125 | dir_copy ($f, $to .'/'. $file); |
126 | + } |
|
120 | 127 | |
121 | - else copy ($f, $to .'/'. $file); |
|
128 | + else { |
|
129 | + copy ($f, $to .'/'. $file); |
|
130 | + } |
|
122 | 131 | |
123 | 132 | return true; |
124 | 133 | } |
@@ -216,16 +225,16 @@ discard block |
||
216 | 225 | { |
217 | 226 | try |
218 | 227 | { |
219 | - if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
220 | - continue; |
|
221 | - } |
|
222 | - |
|
223 | - catch (\Exception $e) {} |
|
228 | + if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) { |
|
229 | + continue; |
|
230 | + } |
|
231 | + } catch (\Exception $e) {} |
|
224 | 232 | |
225 | 233 | VoidEngine::destructObject ($selector); |
226 | 234 | |
227 | - if (!VoidEngine::objectExists ($selector)) |
|
228 | - unset (self::$components[$selector]); |
|
235 | + if (!VoidEngine::objectExists ($selector)) { |
|
236 | + unset (self::$components[$selector]); |
|
237 | + } |
|
229 | 238 | } |
230 | 239 | } |
231 | 240 | } |
@@ -237,16 +246,15 @@ discard block |
||
237 | 246 | |
238 | 247 | function c ($name, bool $returnAllSimilarObjects = false) |
239 | 248 | { |
240 | - if (is_int ($name) && is_object ($object = _c ($name))) |
|
241 | - return $object; |
|
242 | - |
|
243 | - else |
|
249 | + if (is_int ($name) && is_object ($object = _c ($name))) { |
|
250 | + return $object; |
|
251 | + } else |
|
244 | 252 | { |
245 | 253 | $path = explode ('->', $name); |
246 | 254 | $similar = []; |
247 | 255 | |
248 | - foreach (Components::$components as $object) |
|
249 | - try |
|
256 | + foreach (Components::$components as $object) { |
|
257 | + try |
|
250 | 258 | { |
251 | 259 | if ($object->name == end ($path)) |
252 | 260 | { |
@@ -259,32 +267,30 @@ discard block |
||
259 | 267 | { |
260 | 268 | if ($returnAllSimilarObjects) |
261 | 269 | $similar[] = $object; |
270 | + } |
|
262 | 271 | |
263 | - else return $object; |
|
272 | + else { |
|
273 | + return $object; |
|
274 | + } |
|
275 | + } else { |
|
276 | + continue; |
|
264 | 277 | } |
265 | - |
|
266 | - else continue; |
|
278 | + } else { |
|
279 | + continue; |
|
267 | 280 | } |
268 | - |
|
269 | - else continue; |
|
270 | - } |
|
271 | - |
|
272 | - catch (\Throwable $e) |
|
281 | + } catch (\Throwable $e) |
|
273 | 282 | { |
274 | 283 | continue; |
275 | - } |
|
276 | - |
|
277 | - else |
|
284 | + } else |
|
278 | 285 | { |
279 | - if ($returnAllSimilarObjects) |
|
280 | - $similar[] = $object; |
|
281 | - |
|
282 | - else return $object; |
|
286 | + if ($returnAllSimilarObjects) { |
|
287 | + $similar[] = $object; |
|
288 | + } else { |
|
289 | + return $object; |
|
290 | + } |
|
283 | 291 | } |
284 | 292 | } |
285 | - } |
|
286 | - |
|
287 | - catch (\Exception $e) |
|
293 | + } catch (\Exception $e) |
|
288 | 294 | { |
289 | 295 | continue; |
290 | 296 | } |
@@ -295,31 +301,32 @@ discard block |
||
295 | 301 | |
296 | 302 | if (is_array ($objects)) |
297 | 303 | { |
298 | - foreach ($objects as $id => $object) |
|
299 | - try |
|
304 | + foreach ($objects as $id => $object) { |
|
305 | + try |
|
300 | 306 | { |
301 | 307 | while (is_object ($parent = _c($object->parent->selector))) |
302 | 308 | { |
303 | 309 | if ($parent->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
304 | 310 | return $objects[$id]; |
311 | + } |
|
305 | 312 | |
306 | - else $object = $parent; |
|
313 | + else { |
|
314 | + $object = $parent; |
|
315 | + } |
|
307 | 316 | } |
308 | - } |
|
309 | - |
|
310 | - catch (\Throwable $e) |
|
317 | + } catch (\Throwable $e) |
|
311 | 318 | { |
312 | 319 | continue; |
313 | 320 | } |
314 | 321 | |
315 | 322 | return false; |
323 | + } else { |
|
324 | + return false; |
|
316 | 325 | } |
317 | - |
|
318 | - else return false; |
|
319 | - } |
|
320 | - |
|
321 | - else return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
326 | + } else { |
|
327 | + return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
322 | 328 | $similar : false; |
329 | + } |
|
323 | 330 | } |
324 | 331 | } |
325 | 332 | |
@@ -377,8 +384,9 @@ discard block |
||
377 | 384 | { |
378 | 385 | $collection = new WFObject ('System.Collections.Specialized.StringCollection'); |
379 | 386 | |
380 | - foreach ($files as $file) |
|
381 | - $collection->add ((string) $file); |
|
387 | + foreach ($files as $file) { |
|
388 | + $collection->add ((string) $file); |
|
389 | + } |
|
382 | 390 | |
383 | 391 | (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection); |
384 | 392 | VoidEngine::removeObjects ($collection->selector); |
@@ -444,12 +452,13 @@ discard block |
||
444 | 452 | 16384 => 'E_USER_DEPRECATED' |
445 | 453 | ]; |
446 | 454 | |
447 | - if ($GLOBALS['error_status']) |
|
448 | - message ([ |
|
455 | + if ($GLOBALS['error_status']) { |
|
456 | + message ([ |
|
449 | 457 | 'type' => $errarr[$no], |
450 | 458 | 'text' => $str, |
451 | 459 | 'file' => $file, |
452 | 460 | 'line' => $line, |
453 | 461 | 'backtrace' => debug_backtrace () |
454 | 462 | ], 'PHP Script Error'); |
455 | -}); |
|
463 | + } |
|
464 | + }); |
@@ -380,30 +380,37 @@ discard block |
||
380 | 380 | |
381 | 381 | public static function compile (string $savePath, string $iconPath, string $phpCode, string $productDescription = null, string $productName = null, string $productVersion = null, string $companyName = null, string $copyright = null, string $callSharpCode = '', string $declareSharpCode = '', WFObject $dictionary = null, WFObject $assemblies = null): array |
382 | 382 | { |
383 | - if ($dictionary === null) |
|
384 | - $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
383 | + if ($dictionary === null) { |
|
384 | + $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
385 | + } |
|
385 | 386 | |
386 | - if ($assemblies === null) |
|
387 | - $assemblies = getNetArray ('System.String', [ |
|
387 | + if ($assemblies === null) { |
|
388 | + $assemblies = getNetArray ('System.String', [ |
|
388 | 389 | // CORE_DIR .'/CefSharp.dll', |
389 | 390 | CORE_DIR .'/FastColoredTextBox.dll', |
390 | 391 | CORE_DIR .'/ScintillaNET.dll' |
391 | 392 | ]); |
393 | + } |
|
392 | 394 | |
393 | - if ($productName === null) |
|
394 | - $productName = basenameNoExt ($savePath); |
|
395 | + if ($productName === null) { |
|
396 | + $productName = basenameNoExt ($savePath); |
|
397 | + } |
|
395 | 398 | |
396 | - if ($productDescription === null) |
|
397 | - $productDescription = $productName; |
|
399 | + if ($productDescription === null) { |
|
400 | + $productDescription = $productName; |
|
401 | + } |
|
398 | 402 | |
399 | - if ($productVersion === null) |
|
400 | - $productVersion = '1.0'; |
|
403 | + if ($productVersion === null) { |
|
404 | + $productVersion = '1.0'; |
|
405 | + } |
|
401 | 406 | |
402 | - if ($companyName === null) |
|
403 | - $companyName = 'Company N'; |
|
407 | + if ($companyName === null) { |
|
408 | + $companyName = 'Company N'; |
|
409 | + } |
|
404 | 410 | |
405 | - if ($copyright === null) |
|
406 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
411 | + if ($copyright === null) { |
|
412 | + $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
413 | + } |
|
407 | 414 | |
408 | 415 | return (new WFClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
409 | 416 | } |
@@ -416,9 +423,7 @@ discard block |
||
416 | 423 | try |
417 | 424 | { |
418 | 425 | (new WFClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
419 | - } |
|
420 | - |
|
421 | - catch (\Throwable $e) |
|
426 | + } catch (\Throwable $e) |
|
422 | 427 | { |
423 | 428 | return false; |
424 | 429 | } |
@@ -430,8 +435,9 @@ discard block |
||
430 | 435 | { |
431 | 436 | $property = VoidEngine::callMethod (VoidEngine::callMethod ($selector, 'GetType'), 'GetProperty', $name); |
432 | 437 | |
433 | - if (!is_int ($property)) |
|
434 | - return false; |
|
438 | + if (!is_int ($property)) { |
|
439 | + return false; |
|
440 | + } |
|
435 | 441 | |
436 | 442 | try |
437 | 443 | { |
@@ -474,9 +480,7 @@ discard block |
||
474 | 480 | VoidEngine::getProperty ($selector, [$name, 'int']); |
475 | 481 | |
476 | 482 | $property = 'int'; |
477 | - } |
|
478 | - |
|
479 | - catch (\Throwable $e) |
|
483 | + } catch (\Throwable $e) |
|
480 | 484 | { |
481 | 485 | return [ |
482 | 486 | 'type' => 'vrsf', |
@@ -485,9 +489,7 @@ discard block |
||
485 | 489 | } |
486 | 490 | break; |
487 | 491 | } |
488 | - } |
|
489 | - |
|
490 | - catch (\Throwable $e) |
|
492 | + } catch (\Throwable $e) |
|
491 | 493 | { |
492 | 494 | $property = 'object'; |
493 | 495 | } |
@@ -505,8 +507,9 @@ discard block |
||
505 | 507 | $props = VoidEngine::callMethod (VoidEngine::callMethod ($object, 'GetType'), 'GetEvents'); |
506 | 508 | $len = VoidEngine::getProperty ($props, 'Length'); |
507 | 509 | |
508 | - for ($i = 0; $i < $len; ++$i) |
|
509 | - $events[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($props, $i), 'Name'); |
|
510 | + for ($i = 0; $i < $len; ++$i) { |
|
511 | + $events[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($props, $i), 'Name'); |
|
512 | + } |
|
510 | 513 | |
511 | 514 | return $events; |
512 | 515 | } |
@@ -536,40 +539,38 @@ discard block |
||
536 | 539 | |
537 | 540 | public function __construct ($object, ?string $classGroup = 'auto', ...$args) |
538 | 541 | { |
539 | - foreach ($args as $id => $arg) |
|
540 | - $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
542 | + foreach ($args as $id => $arg) { |
|
543 | + $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
544 | + } |
|
541 | 545 | |
542 | - if (is_string ($object)) |
|
543 | - $this->selector = VoidEngine::createObject ($object, $classGroup == 'auto' ? |
|
546 | + if (is_string ($object)) { |
|
547 | + $this->selector = VoidEngine::createObject ($object, $classGroup == 'auto' ? |
|
544 | 548 | substr ($object, 0, strrpos ($object, '.')) : $classGroup, ...$args); |
545 | - |
|
546 | - elseif (is_int ($object) && VoidEngine::objectExists ($object)) |
|
547 | - $this->selector = $object; |
|
548 | - |
|
549 | - else throw new \Exception ('$object parameter must be string or object selector'); |
|
549 | + } elseif (is_int ($object) && VoidEngine::objectExists ($object)) { |
|
550 | + $this->selector = $object; |
|
551 | + } else { |
|
552 | + throw new \Exception ('$object parameter must be string or object selector'); |
|
553 | + } |
|
550 | 554 | } |
551 | 555 | |
552 | 556 | public function __get ($name) |
553 | 557 | { |
554 | - if (method_exists ($this, $method = "get_$name")) |
|
555 | - $value = $this->$method (); |
|
556 | - |
|
557 | - elseif (substr ($name, -5) == 'Event') |
|
558 | - $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
559 | - |
|
560 | - elseif (property_exists ($this, $name)) |
|
561 | - $value = $this->$name; |
|
562 | - |
|
563 | - else switch (strtolower ($name)) |
|
558 | + if (method_exists ($this, $method = "get_$name")) { |
|
559 | + $value = $this->$method (); |
|
560 | + } elseif (substr ($name, -5) == 'Event') { |
|
561 | + $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
562 | + } elseif (property_exists ($this, $name)) { |
|
563 | + $value = $this->$name; |
|
564 | + } else { |
|
565 | + switch (strtolower ($name)) |
|
564 | 566 | { |
565 | 567 | case 'count': |
566 | 568 | case 'length': |
567 | 569 | try |
568 | 570 | { |
569 | 571 | return $this->getProperty ('Count'); |
570 | - } |
|
571 | - |
|
572 | - catch (\Throwable $e) |
|
572 | + } |
|
573 | + } catch (\Throwable $e) |
|
573 | 574 | { |
574 | 575 | return $this->getProperty ('Length'); |
575 | 576 | } |
@@ -579,8 +580,9 @@ discard block |
||
579 | 580 | $size = $this->count; |
580 | 581 | $list = []; |
581 | 582 | |
582 | - for ($i = 0; $i < $size; ++$i) |
|
583 | - $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i)); |
|
583 | + for ($i = 0; $i < $size; ++$i) { |
|
584 | + $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i)); |
|
585 | + } |
|
584 | 586 | |
585 | 587 | return $list; |
586 | 588 | break; |
@@ -589,13 +591,12 @@ discard block |
||
589 | 591 | $size = $this->count; |
590 | 592 | $names = []; |
591 | 593 | |
592 | - for ($i = 0; $i < $size; ++$i) |
|
593 | - try |
|
594 | + for ($i = 0; $i < $size; ++$i) { |
|
595 | + try |
|
594 | 596 | { |
595 | 597 | $names[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($this->selector, [$i, 'object']), 'Text'); |
596 | - } |
|
597 | - |
|
598 | - catch (\Throwable $e) |
|
598 | + } |
|
599 | + } catch (\Throwable $e) |
|
599 | 600 | { |
600 | 601 | $names[] = VoidEngine::getArrayValue ($this->selector, [$i, 'string']); |
601 | 602 | } |
@@ -613,10 +614,11 @@ discard block |
||
613 | 614 | |
614 | 615 | public function __set ($name, $value) |
615 | 616 | { |
616 | - if (method_exists ($this, $method = "set_$name")) |
|
617 | - try |
|
617 | + if (method_exists ($this, $method = "set_$name")) { |
|
618 | + try |
|
618 | 619 | { |
619 | 620 | return $this->$method ($value); |
621 | + } |
|
620 | 622 | } |
621 | 623 | |
622 | 624 | # Метод "set_$name" может принимать в качестве параметра объект WFObject |
@@ -626,12 +628,11 @@ discard block |
||
626 | 628 | { |
627 | 629 | return $value instanceof WFObject ? |
628 | 630 | $this->$method ($value->selector) : null; |
629 | - } |
|
630 | - |
|
631 | - elseif (substr ($name, -5) == 'Event') |
|
632 | - Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
633 | - |
|
634 | - else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
631 | + } elseif (substr ($name, -5) == 'Event') { |
|
632 | + Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
633 | + } else { |
|
634 | + $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
635 | + } |
|
635 | 636 | } |
636 | 637 | |
637 | 638 | public function __call ($method, $args) |
@@ -646,8 +647,9 @@ discard block |
||
646 | 647 | |
647 | 648 | public function addRange (array $values, $assoc = false): void |
648 | 649 | { |
649 | - foreach ($values as $id => $value) |
|
650 | - $this->offsetSet ($assoc ? $id : null, $value); |
|
650 | + foreach ($values as $id => $value) { |
|
651 | + $this->offsetSet ($assoc ? $id : null, $value); |
|
652 | + } |
|
651 | 653 | } |
652 | 654 | |
653 | 655 | public function offsetSet ($index, $value) |
@@ -657,9 +659,7 @@ discard block |
||
657 | 659 | return $index === null ? |
658 | 660 | $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
659 | 661 | $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
660 | - } |
|
661 | - |
|
662 | - catch (\Throwable $e) |
|
662 | + } catch (\Throwable $e) |
|
663 | 663 | { |
664 | 664 | return $index === null ? |
665 | 665 | VoidEngine::setArrayValue ($this->selector, $this->count, $value) : |
@@ -682,9 +682,7 @@ discard block |
||
682 | 682 | try |
683 | 683 | { |
684 | 684 | $this->offsetGet ($index); |
685 | - } |
|
686 | - |
|
687 | - catch (\Exception $e) |
|
685 | + } catch (\Exception $e) |
|
688 | 686 | { |
689 | 687 | return false; |
690 | 688 | } |
@@ -711,8 +709,9 @@ discard block |
||
711 | 709 | { |
712 | 710 | $size = $this->count; |
713 | 711 | |
714 | - for ($i = 0; $i < $size; ++$i) |
|
715 | - $callback (EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
712 | + for ($i = 0; $i < $size; ++$i) { |
|
713 | + $callback (EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
714 | + } |
|
716 | 715 | } |
717 | 716 | |
718 | 717 | public function where (callable $comparator, string $type = null): array |
@@ -720,9 +719,10 @@ discard block |
||
720 | 719 | $size = $this->count; |
721 | 720 | $return = []; |
722 | 721 | |
723 | - for ($i = 0; $i < $size; ++$i) |
|
724 | - if ($comparator ($value = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
722 | + for ($i = 0; $i < $size; ++$i) { |
|
723 | + if ($comparator ($value = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
725 | 724 | $return[] = $value; |
725 | + } |
|
726 | 726 | |
727 | 727 | return $return; |
728 | 728 | } |
@@ -732,9 +732,7 @@ discard block |
||
732 | 732 | try |
733 | 733 | { |
734 | 734 | return VoidEngine::getProperty ($this->selector, $name); |
735 | - } |
|
736 | - |
|
737 | - catch (\Throwable $e) |
|
735 | + } catch (\Throwable $e) |
|
738 | 736 | { |
739 | 737 | return VoidEngine::getField ($this->selector, $name); |
740 | 738 | } |
@@ -745,9 +743,7 @@ discard block |
||
745 | 743 | try |
746 | 744 | { |
747 | 745 | VoidEngine::setProperty ($this->selector, $name, $value); |
748 | - } |
|
749 | - |
|
750 | - catch (\Throwable $e) |
|
746 | + } catch (\Throwable $e) |
|
751 | 747 | { |
752 | 748 | VoidEngine::setField ($this->selector, $name, $value); |
753 | 749 | } |
@@ -764,8 +760,9 @@ discard block |
||
764 | 760 | $size = VoidEngine::getProperty ($array, 'Length'); |
765 | 761 | $return = []; |
766 | 762 | |
767 | - for ($i = 0; $i < $size; ++$i) |
|
768 | - $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
763 | + for ($i = 0; $i < $size; ++$i) { |
|
764 | + $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
765 | + } |
|
769 | 766 | |
770 | 767 | VoidEngine::removeObjects ($array); |
771 | 768 | |
@@ -777,9 +774,7 @@ discard block |
||
777 | 774 | try |
778 | 775 | { |
779 | 776 | return $this->getProperty ('Name'); |
780 | - } |
|
781 | - |
|
782 | - catch (\Throwable $e) |
|
777 | + } catch (\Throwable $e) |
|
783 | 778 | { |
784 | 779 | return $this->name; |
785 | 780 | } |
@@ -790,9 +785,7 @@ discard block |
||
790 | 785 | try |
791 | 786 | { |
792 | 787 | $this->setProperty ('Name', $name); |
793 | - } |
|
794 | - |
|
795 | - catch (\Throwable $e) |
|
788 | + } catch (\Throwable $e) |
|
796 | 789 | { |
797 | 790 | $this->name = $name; |
798 | 791 | } |
@@ -810,14 +803,14 @@ discard block |
||
810 | 803 | |
811 | 804 | public function __construct ($class, ?string $classGroup = 'auto') |
812 | 805 | { |
813 | - if (is_string ($class)) |
|
814 | - $this->selector = VoidEngine::createClass ($class, $classGroup == 'auto' ? |
|
806 | + if (is_string ($class)) { |
|
807 | + $this->selector = VoidEngine::createClass ($class, $classGroup == 'auto' ? |
|
815 | 808 | substr ($class, 0, strrpos ($class, '.')) : $classGroup |
816 | 809 | ); |
817 | - |
|
818 | - elseif (is_int ($class) && VoidEngine::objectExists ($class)) |
|
819 | - $this->selector = $class; |
|
820 | - |
|
821 | - else throw new \Exception ('$class parameter must be string or class selector'); |
|
810 | + } elseif (is_int ($class) && VoidEngine::objectExists ($class)) { |
|
811 | + $this->selector = $class; |
|
812 | + } else { |
|
813 | + throw new \Exception ('$class parameter must be string or class selector'); |
|
814 | + } |
|
822 | 815 | } |
823 | 816 | } |
@@ -78,15 +78,14 @@ |
||
78 | 78 | |
79 | 79 | public function __call ($method, $args) |
80 | 80 | { |
81 | - if (method_exists ($this, $method)) |
|
82 | - return $this->$method (...$args); |
|
83 | - |
|
84 | - else try |
|
81 | + if (method_exists ($this, $method)) { |
|
82 | + return $this->$method (...$args); |
|
83 | + } else { |
|
84 | + try |
|
85 | 85 | { |
86 | 86 | return $this->WinAPI->$method (...$args); |
87 | 87 | } |
88 | - |
|
89 | - catch (\Throwable $e) |
|
88 | + } catch (\Throwable $e) |
|
90 | 89 | { |
91 | 90 | throw new \Exception ('Method "'. $method .'" not found or return an exception. Exception info: '. "\n\n". (string) $e); |
92 | 91 | } |
@@ -33,8 +33,9 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct (string $content, array $settings = []) |
35 | 35 | { |
36 | - if (file_exists ($content)) |
|
37 | - $content = file_get_contents ($content); |
|
36 | + if (file_exists ($content)) { |
|
37 | + $content = file_get_contents ($content); |
|
38 | + } |
|
38 | 39 | |
39 | 40 | // Зачем? Так надо! |
40 | 41 | // ДА БАГ ЭТО, НЕ ПИ%ДИ!!! И Я ПОНЯТИЯ НЕ ИМЕЮ КАК И ПОЧЕМУ!!! |
@@ -42,10 +43,11 @@ discard block |
||
42 | 43 | |
43 | 44 | foreach ($settings as $name => $setting) |
44 | 45 | { |
45 | - if (isset ($this->$name)) |
|
46 | - $this->$name = $setting; |
|
47 | - |
|
48 | - else throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
46 | + if (isset ($this->$name)) { |
|
47 | + $this->$name = $setting; |
|
48 | + } else { |
|
49 | + throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
50 | + } |
|
49 | 51 | } |
50 | 52 | |
51 | 53 | if ($this->use_caching && file_exists ($file = VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache')) |
@@ -58,9 +60,9 @@ discard block |
||
58 | 60 | $this->links = $info[1][1]; |
59 | 61 | |
60 | 62 | return; |
63 | + } else { |
|
64 | + unlink ($file); |
|
61 | 65 | } |
62 | - |
|
63 | - else unlink ($file); |
|
64 | 66 | } |
65 | 67 | |
66 | 68 | $info = $this->generateSyntaxTree ($content); |
@@ -70,8 +72,9 @@ discard block |
||
70 | 72 | |
71 | 73 | if ($this->use_caching) |
72 | 74 | { |
73 | - if (!is_dir (dirname (__DIR__) .'/cache')) |
|
74 | - mkdir (dirname (__DIR__) .'/cache'); |
|
75 | + if (!is_dir (dirname (__DIR__) .'/cache')) { |
|
76 | + mkdir (dirname (__DIR__) .'/cache'); |
|
77 | + } |
|
75 | 78 | |
76 | 79 | file_put_contents (VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache', gzdeflate (serialize ([sha1 (file_get_contents (__FILE__)), $info]))); |
77 | 80 | } |
@@ -94,19 +97,22 @@ discard block |
||
94 | 97 | $tree = []; |
95 | 98 | $links = []; |
96 | 99 | |
97 | - if ($this->debug_mode) |
|
98 | - pre ($lines); |
|
100 | + if ($this->debug_mode) { |
|
101 | + pre ($lines); |
|
102 | + } |
|
99 | 103 | |
100 | 104 | foreach ($lines as $id => $line) |
101 | 105 | { |
102 | - if ($skip_at > $id) |
|
103 | - continue; |
|
106 | + if ($skip_at > $id) { |
|
107 | + continue; |
|
108 | + } |
|
104 | 109 | |
105 | 110 | $height = $this->getLineHeight ($line); |
106 | 111 | $words = $this->linesFilter (explode (' ', $line)); |
107 | 112 | |
108 | - if ($this->debug_mode) |
|
109 | - pre ($words); |
|
113 | + if ($this->debug_mode) { |
|
114 | + pre ($words); |
|
115 | + } |
|
110 | 116 | |
111 | 117 | /** |
112 | 118 | * Высокоинтеллектуальный фикс |
@@ -127,16 +133,18 @@ discard block |
||
127 | 133 | { |
128 | 134 | $updated = false; |
129 | 135 | |
130 | - if ($this->debug_mode) |
|
131 | - pre ($current_object); |
|
136 | + if ($this->debug_mode) { |
|
137 | + pre ($current_object); |
|
138 | + } |
|
132 | 139 | |
133 | 140 | while (isset ($tree[$current_object]['info']['subparent_link']) && $tree[$link = $tree[$current_object]['info']['subparent_link']->link]['hard'] < $tree[$current_object]['hard']) |
134 | 141 | { |
135 | 142 | $current_object = $link; |
136 | 143 | $updated = true; |
137 | 144 | |
138 | - if ($this->debug_mode) |
|
139 | - pre ($current_object); |
|
145 | + if ($this->debug_mode) { |
|
146 | + pre ($current_object); |
|
147 | + } |
|
140 | 148 | } |
141 | 149 | |
142 | 150 | if ( |
@@ -145,13 +153,15 @@ discard block |
||
145 | 153 | isset ($tree[$current_object]['info']['arguments'][0]) && |
146 | 154 | $tree[$current_object]['info']['arguments'][0] instanceof VLFLink && |
147 | 155 | $tree[$tree[$current_object]['info']['arguments'][0]->link]['hard'] < $tree[$current_object]['hard'] |
148 | - ) $current_object = $tree[$current_object]['info']['arguments'][0]->link; |
|
149 | - |
|
150 | - elseif (!$updated) |
|
151 | - break; |
|
156 | + ) { |
|
157 | + $current_object = $tree[$current_object]['info']['arguments'][0]->link; |
|
158 | + } elseif (!$updated) { |
|
159 | + break; |
|
160 | + } |
|
152 | 161 | |
153 | - if ($this->debug_mode) |
|
154 | - pre ($current_object); |
|
162 | + if ($this->debug_mode) { |
|
163 | + pre ($current_object); |
|
164 | + } |
|
155 | 165 | } |
156 | 166 | |
157 | 167 | /** |
@@ -159,8 +169,9 @@ discard block |
||
159 | 169 | */ |
160 | 170 | if (class_exists ($words[0]) || class_exists ('\VoidEngine\\'. $words[0])) |
161 | 171 | { |
162 | - if (!isset ($words[1])) |
|
163 | - throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
172 | + if (!isset ($words[1])) { |
|
173 | + throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
174 | + } |
|
164 | 175 | |
165 | 176 | /** |
166 | 177 | * Button NewButton |
@@ -188,9 +199,7 @@ discard block |
||
188 | 199 | $current_object = $id; |
189 | 200 | |
190 | 201 | continue; |
191 | - } |
|
192 | - |
|
193 | - else |
|
202 | + } else |
|
194 | 203 | { |
195 | 204 | $tree[$id] = [ |
196 | 205 | 'type' => VLF_OBJECT_DEFINITION, |
@@ -212,10 +221,9 @@ discard block |
||
212 | 221 | |
213 | 222 | $end = strrpos ($line, ')'); |
214 | 223 | |
215 | - if ($end === false) |
|
216 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
217 | - |
|
218 | - elseif ($begin < $end) |
|
224 | + if ($end === false) { |
|
225 | + throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
226 | + } elseif ($begin < $end) |
|
219 | 227 | { |
220 | 228 | $arguments = []; |
221 | 229 | $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
@@ -224,18 +232,20 @@ discard block |
||
224 | 232 | { |
225 | 233 | $argument = trim ($argument); |
226 | 234 | |
227 | - if (strlen ($argument) > 0) |
|
228 | - $arguments[] = isset ($links[$argument]) ? |
|
235 | + if (strlen ($argument) > 0) { |
|
236 | + $arguments[] = isset ($links[$argument]) ? |
|
229 | 237 | new VLFLink ($argument, $links[$argument]) : |
230 | 238 | $argument; |
231 | - |
|
232 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
239 | + } else { |
|
240 | + throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
241 | + } |
|
233 | 242 | } |
234 | 243 | |
235 | 244 | $tree[$id]['info']['arguments'] = $arguments; |
236 | 245 | |
237 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
238 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
246 | + if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) { |
|
247 | + throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
248 | + } |
|
239 | 249 | } |
240 | 250 | |
241 | 251 | $tree[$id]['info']['subparent_link'] = new VLFLink ($tree[$current_object]['info']['object_name'], $current_object); |
@@ -299,13 +309,14 @@ discard block |
||
299 | 309 | |
300 | 310 | $comment .= $parsed[0]; |
301 | 311 | $skip_at = $parsed[1]; |
312 | + } else { |
|
313 | + throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
302 | 314 | } |
303 | - |
|
304 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
305 | 315 | } |
306 | 316 | |
307 | - if ($this->debug_mode) |
|
308 | - pre ("Comment:\n\n$comment"); |
|
317 | + if ($this->debug_mode) { |
|
318 | + pre ("Comment:\n\n$comment"); |
|
319 | + } |
|
309 | 320 | } |
310 | 321 | |
311 | 322 | /** |
@@ -327,9 +338,9 @@ discard block |
||
327 | 338 | |
328 | 339 | $code .= $parsed[0]; |
329 | 340 | $skip_at = $parsed[1]; |
341 | + } else { |
|
342 | + throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
330 | 343 | } |
331 | - |
|
332 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
333 | 344 | } |
334 | 345 | |
335 | 346 | $tree[$id] = [ |
@@ -384,8 +395,9 @@ discard block |
||
384 | 395 | |
385 | 396 | if ($postChar == ':' || $postChar == '^') |
386 | 397 | { |
387 | - if (!isset ($words[1])) |
|
388 | - throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
398 | + if (!isset ($words[1])) { |
|
399 | + throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
400 | + } |
|
389 | 401 | |
390 | 402 | $propertyName = substr ($words[0], 0, -1); |
391 | 403 | $propertyValue = implode (' ', array_slice ($words, 1)); |
@@ -420,8 +432,9 @@ discard block |
||
420 | 432 | 'syntax_nodes' => [] |
421 | 433 | ]; |
422 | 434 | |
423 | - if (isset ($links[$info['info']['property_value']])) |
|
424 | - $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
435 | + if (isset ($links[$info['info']['property_value']])) { |
|
436 | + $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
437 | + } |
|
425 | 438 | |
426 | 439 | $tree[$current_object]['syntax_nodes'][] = $info; |
427 | 440 | } |
@@ -439,10 +452,9 @@ discard block |
||
439 | 452 | |
440 | 453 | $end = strrpos ($line, ')'); |
441 | 454 | |
442 | - if ($end === false) |
|
443 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
444 | - |
|
445 | - elseif ($begin < $end) |
|
455 | + if ($end === false) { |
|
456 | + throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
457 | + } elseif ($begin < $end) |
|
446 | 458 | { |
447 | 459 | $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
448 | 460 | |
@@ -450,24 +462,27 @@ discard block |
||
450 | 462 | { |
451 | 463 | $argument = trim ($argument); |
452 | 464 | |
453 | - if (strlen ($argument) > 0) |
|
454 | - $arguments[] = isset ($links[$argument]) ? |
|
465 | + if (strlen ($argument) > 0) { |
|
466 | + $arguments[] = isset ($links[$argument]) ? |
|
455 | 467 | new VLFLink ($argument, $links[$argument]) : |
456 | 468 | $argument; |
457 | - |
|
458 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
469 | + } else { |
|
470 | + throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
471 | + } |
|
459 | 472 | } |
460 | 473 | |
461 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
462 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
474 | + if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) { |
|
475 | + throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
476 | + } |
|
463 | 477 | } |
464 | 478 | } |
465 | 479 | |
466 | 480 | /** |
467 | 481 | * ->show |
468 | 482 | */ |
469 | - elseif (!$this->ignore_unexpected_method_args) |
|
470 | - throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
483 | + elseif (!$this->ignore_unexpected_method_args) { |
|
484 | + throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
485 | + } |
|
471 | 486 | |
472 | 487 | $tree[$current_object]['syntax_nodes'][] = [ |
473 | 488 | 'type' => VLF_METHOD_CALL, |
@@ -520,7 +535,9 @@ discard block |
||
520 | 535 | /** |
521 | 536 | * Что-то загадочное, таинственное, неизвестное человечеству |
522 | 537 | */ |
523 | - else throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
538 | + else { |
|
539 | + throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
540 | + } |
|
524 | 541 | } |
525 | 542 | |
526 | 543 | return [$tree, $links]; |
@@ -542,8 +559,9 @@ discard block |
||
542 | 559 | |
543 | 560 | foreach ($lines as $line_id => $line) |
544 | 561 | { |
545 | - if ($line_id <= $begin_id) |
|
546 | - continue; |
|
562 | + if ($line_id <= $begin_id) { |
|
563 | + continue; |
|
564 | + } |
|
547 | 565 | |
548 | 566 | if (!(bool)(trim ($line))) |
549 | 567 | { |
@@ -554,13 +572,15 @@ discard block |
||
554 | 572 | |
555 | 573 | $height = $this->getLineHeight ($line); |
556 | 574 | |
557 | - if ($this->debug_mode) |
|
558 | - pre ("$height, $down_height, $line"); |
|
559 | - |
|
560 | - if ($height > $down_height) |
|
561 | - $parsed .= "$line\n"; |
|
575 | + if ($this->debug_mode) { |
|
576 | + pre ("$height, $down_height, $line"); |
|
577 | + } |
|
562 | 578 | |
563 | - else break; |
|
579 | + if ($height > $down_height) { |
|
580 | + $parsed .= "$line\n"; |
|
581 | + } else { |
|
582 | + break; |
|
583 | + } |
|
564 | 584 | } |
565 | 585 | |
566 | 586 | return [$parsed, $line_id]; |
@@ -584,8 +604,9 @@ discard block |
||
584 | 604 | { |
585 | 605 | $i = 0; |
586 | 606 | |
587 | - while (isset ($line[$i]) && $line[$i] == "\t") |
|
588 | - ++$i; |
|
607 | + while (isset ($line[$i]) && $line[$i] == "\t") { |
|
608 | + ++$i; |
|
609 | + } |
|
589 | 610 | |
590 | 611 | return strlen ($line = str_repeat (' ', $i) . substr ($line, $i)) - strlen ($line = trim ($line)); |
591 | 612 | } |
@@ -602,8 +623,9 @@ discard block |
||
602 | 623 | { |
603 | 624 | return array_filter ($segments, function ($text) |
604 | 625 | { |
605 | - if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) |
|
606 | - throw new \Exception ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
626 | + if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) { |
|
627 | + throw new \Exception ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
628 | + } |
|
607 | 629 | |
608 | 630 | return strlen (trim ($text)) > 0; |
609 | 631 | }); |