Passed
Push — master ( 4b7a9f...0f5812 )
by Observer
01:18
created
engine/VoidEngine.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,9 +105,10 @@
 block discarded – undo
105 105
 require 'components/Designer.php';
106 106
 require 'components/EventGrid.php';
107 107
 
108
-if (is_dir ('extensions'))
108
+if (is_dir ('extensions')) {
109 109
     foreach (scandir ('extensions') as $ext)
110 110
         if (is_dir ('extensions/'. $ext) && file_exists ($ext = 'extensions/'. $ext .'/main.php'))
111 111
             require $ext;
112
+}
112 113
 
113 114
 gc_collect_cycles ();
Please login to merge, or discard this patch.
engine/extensions/VLF/bin/parser.php 1 patch
Braces   +98 added lines, -76 removed lines patch added patch discarded remove patch
@@ -33,8 +33,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         });
Please login to merge, or discard this patch.
engine/common/EngineInterfaces.php 1 patch
Braces   +93 added lines, -99 removed lines patch added patch discarded remove patch
@@ -284,8 +284,9 @@  discard block
 block discarded – undo
284 284
 
285 285
     public static function setObjectEvent (int $selector, string $eventName, string $code): void
286 286
     {
287
-        if (self::eventExists ($selector, $eventName))
288
-            self::removeObjectEvent ($selector, $eventName);
287
+        if (self::eventExists ($selector, $eventName)) {
288
+                    self::removeObjectEvent ($selector, $eventName);
289
+        }
289 290
 
290 291
         \VoidCore::setEvent ($selector, $eventName, $code);
291 292
         Components::setComponentEvent ($selector, $eventName, $code);
@@ -382,30 +383,37 @@  discard block
 block discarded – undo
382 383
 
383 384
     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
384 385
     {
385
-        if ($dictionary === null)
386
-            $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null);
386
+        if ($dictionary === null) {
387
+                    $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null);
388
+        }
387 389
 
388
-        if ($assemblies === null)
389
-            $assemblies = getNetArray ('System.String', [
390
+        if ($assemblies === null) {
391
+                    $assemblies = getNetArray ('System.String', [
390 392
                 // CORE_DIR .'/CefSharp.dll',
391 393
                 CORE_DIR .'/FastColoredTextBox.dll',
392 394
                 CORE_DIR .'/ScintillaNET.dll'
393 395
             ]);
396
+        }
394 397
 
395
-        if ($productName === null)
396
-            $productName = basenameNoExt ($savePath);
398
+        if ($productName === null) {
399
+                    $productName = basenameNoExt ($savePath);
400
+        }
397 401
 
398
-        if ($productDescription === null)
399
-            $productDescription = $productName;
402
+        if ($productDescription === null) {
403
+                    $productDescription = $productName;
404
+        }
400 405
 
401
-        if ($productVersion === null)
402
-            $productVersion = '1.0';
406
+        if ($productVersion === null) {
407
+                    $productVersion = '1.0';
408
+        }
403 409
 
404
-        if ($companyName === null)
405
-            $companyName = 'Company N';
410
+        if ($companyName === null) {
411
+                    $companyName = 'Company N';
412
+        }
406 413
 
407
-        if ($copyright === null)
408
-            $copyright = $companyName .' copyright (c) '. date ('Y');
414
+        if ($copyright === null) {
415
+                    $copyright = $companyName .' copyright (c) '. date ('Y');
416
+        }
409 417
 
410 418
         return (new WFClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names;
411 419
     }
@@ -418,9 +426,7 @@  discard block
 block discarded – undo
418 426
         try
419 427
         {
420 428
             (new WFClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path);
421
-        }
422
-
423
-        catch (\Throwable $e)
429
+        } catch (\Throwable $e)
424 430
         {
425 431
             return false;
426 432
         }
@@ -432,8 +438,9 @@  discard block
 block discarded – undo
432 438
     {
433 439
         $property = VoidEngine::callMethod (VoidEngine::callMethod ($selector, 'GetType'), 'GetProperty', $name);
434 440
 
435
-        if (!is_int ($property))
436
-            return false;
441
+        if (!is_int ($property)) {
442
+                    return false;
443
+        }
437 444
 
438 445
         try
439 446
         {
@@ -476,9 +483,7 @@  discard block
 block discarded – undo
476 483
                         VoidEngine::getProperty ($selector, [$name, 'int']);
477 484
 
478 485
                         $property = 'int';
479
-                    }
480
-
481
-                    catch (\Throwable $e)
486
+                    } catch (\Throwable $e)
482 487
                     {
483 488
                         return [
484 489
                             'type'  => 'vrsf',
@@ -487,9 +492,7 @@  discard block
 block discarded – undo
487 492
                     }
488 493
                 break;
489 494
             }
490
-        }
491
-
492
-        catch (\Throwable $e)
495
+        } catch (\Throwable $e)
493 496
         {
494 497
             $property = 'object';
495 498
         }
@@ -507,8 +510,9 @@  discard block
 block discarded – undo
507 510
         $props = VoidEngine::callMethod (VoidEngine::callMethod ($object, 'GetType'), 'GetEvents');
508 511
         $len   = VoidEngine::getProperty ($props, 'Length');
509 512
 
510
-        for ($i = 0; $i < $len; ++$i)
511
-            $events[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($props, $i), 'Name');
513
+        for ($i = 0; $i < $len; ++$i) {
514
+                    $events[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($props, $i), 'Name');
515
+        }
512 516
 
513 517
         return $events;
514 518
     }
@@ -533,40 +537,38 @@  discard block
 block discarded – undo
533 537
 
534 538
     public function __construct ($object, ?string $classGroup = 'auto', ...$args)
535 539
     {
536
-        foreach ($args as $id => $arg)
537
-            $args[$id] = ngineAdditions::uncoupleSelector ($arg);
540
+        foreach ($args as $id => $arg) {
541
+                    $args[$id] = ngineAdditions::uncoupleSelector ($arg);
542
+        }
538 543
 
539
-        if (is_string ($object))
540
-            $this->selector = VoidEngine::createObject ($object, $classGroup == 'auto' ?
544
+        if (is_string ($object)) {
545
+                    $this->selector = VoidEngine::createObject ($object, $classGroup == 'auto' ?
541 546
                 substr ($object, 0, strrpos ($object, '.')) : $classGroup, ...$args);
542
-
543
-        elseif (is_int ($object) && VoidEngine::objectExists ($object))
544
-            $this->selector = $object;
545
-
546
-        else throw new \Exception ('$object parameter must be string or object selector');
547
+        } elseif (is_int ($object) && VoidEngine::objectExists ($object)) {
548
+                    $this->selector = $object;
549
+        } else {
550
+            throw new \Exception ('$object parameter must be string or object selector');
551
+        }
547 552
     }
548 553
     
549 554
     public function __get ($name)
550 555
 	{
551
-        if (method_exists ($this, $method = "get_$name"))
552
-            $value = $this->$method ();
553
-
554
-        elseif (substr ($name, -5) == 'Event')
555
-            $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5));
556
-
557
-        elseif (property_exists ($this, $name))
558
-            $value = $this->$name;
559
-
560
-        else switch (strtolower ($name))
556
+        if (method_exists ($this, $method = "get_$name")) {
557
+                    $value = $this->$method ();
558
+        } elseif (substr ($name, -5) == 'Event') {
559
+                    $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5));
560
+        } elseif (property_exists ($this, $name)) {
561
+                    $value = $this->$name;
562
+        } else {
563
+            switch (strtolower ($name))
561 564
         {
562 565
             case 'count':
563 566
             case 'length':
564 567
                 try
565 568
                 {
566 569
                     return $this->getProperty ('Count');
567
-                }
568
-
569
-                catch (\Throwable $e)
570
+        }
571
+                } catch (\Throwable $e)
570 572
                 {
571 573
                     return $this->getProperty ('Length');
572 574
                 }
@@ -576,8 +578,9 @@  discard block
 block discarded – undo
576 578
                 $size = $this->count;
577 579
                 $list = [];
578 580
                 
579
-				for ($i = 0; $i < $size; ++$i)
580
-                    $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i));
581
+				for ($i = 0; $i < $size; ++$i) {
582
+				                    $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i));
583
+				}
581 584
                 
582 585
                 return $list;
583 586
             break;
@@ -586,13 +589,12 @@  discard block
 block discarded – undo
586 589
                 $size = $this->count;
587 590
                 $names = [];
588 591
                 
589
-                for ($i = 0; $i < $size; ++$i)
590
-                    try
592
+                for ($i = 0; $i < $size; ++$i) {
593
+                                    try
591 594
                     {
592 595
                         $names[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($this->selector, [$i, 'object']), 'Text');
593
-                    }
594
-
595
-                    catch (\Throwable $e)
596
+                }
597
+                    } catch (\Throwable $e)
596 598
                     {
597 599
                         $names[] = VoidEngine::getArrayValue ($this->selector, [$i, 'string']);
598 600
                     }
@@ -610,10 +612,11 @@  discard block
 block discarded – undo
610 612
 	
611 613
 	public function __set ($name, $value)
612 614
 	{
613
-        if (method_exists ($this, $method = "set_$name"))
614
-            try
615
+        if (method_exists ($this, $method = "set_$name")) {
616
+                    try
615 617
             {
616 618
                 return $this->$method ($value);
619
+        }
617 620
             }
618 621
 
619 622
             # Метод "set_$name" может принимать в качестве параметра объект WFObject
@@ -623,12 +626,11 @@  discard block
 block discarded – undo
623 626
             {
624 627
                 return $value instanceof WFObject ?
625 628
                     $this->$method ($value->selector) : null;
626
-            }
627
-
628
-        elseif (substr ($name, -5) == 'Event')
629
-            Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value);
630
-        
631
-        else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value));
629
+            } elseif (substr ($name, -5) == 'Event') {
630
+                    Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value);
631
+        } else {
632
+            $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value));
633
+        }
632 634
     }
633 635
 	
634 636
 	public function __call ($method, $args)
@@ -643,8 +645,9 @@  discard block
 block discarded – undo
643 645
 
644 646
     public function addRange (array $values, $assoc = false): void
645 647
     {
646
-        foreach ($values as $id => $value)
647
-            $this->offsetSet ($assoc ? $id : null, $value);
648
+        foreach ($values as $id => $value) {
649
+                    $this->offsetSet ($assoc ? $id : null, $value);
650
+        }
648 651
     }
649 652
     
650 653
     public function offsetSet ($index, $value)
@@ -654,9 +657,7 @@  discard block
 block discarded – undo
654 657
             return $index === null ?
655 658
                 $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) :
656 659
                 $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value));
657
-        }
658
-
659
-        catch (\Throwable $e)
660
+        } catch (\Throwable $e)
660 661
         {
661 662
             return $index === null ?
662 663
                 VoidEngine::setArrayValue ($this->selector, $this->count, $value) :
@@ -679,9 +680,7 @@  discard block
 block discarded – undo
679 680
         try
680 681
         {
681 682
             $this->offsetGet ($index);
682
-        }
683
-
684
-        catch (\Exception $e)
683
+        } catch (\Exception $e)
685 684
         {
686 685
             return false;
687 686
         }
@@ -708,8 +707,9 @@  discard block
 block discarded – undo
708 707
     {
709 708
         $size = $this->count;
710 709
 
711
-        for ($i = 0; $i < $size; ++$i)
712
-            $callback (EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i);
710
+        for ($i = 0; $i < $size; ++$i) {
711
+                    $callback (EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i);
712
+        }
713 713
     }
714 714
 
715 715
     public function where (\Closure $comparator, string $type = null): array
@@ -717,9 +717,10 @@  discard block
 block discarded – undo
717 717
         $size   = $this->count;
718 718
         $return = [];
719 719
 
720
-        for ($i = 0; $i < $size; ++$i)
721
-            if ($comparator ($value = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i))
720
+        for ($i = 0; $i < $size; ++$i) {
721
+                    if ($comparator ($value = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i))
722 722
                 $return[] = $value;
723
+        }
723 724
 
724 725
         return $return;
725 726
     }
@@ -729,9 +730,7 @@  discard block
 block discarded – undo
729 730
         try
730 731
         {
731 732
             return VoidEngine::getProperty ($this->selector, $name);
732
-        }
733
-
734
-        catch (\Throwable $e)
733
+        } catch (\Throwable $e)
735 734
         {
736 735
             return VoidEngine::getField ($this->selector, $name);
737 736
         }
@@ -742,9 +741,7 @@  discard block
 block discarded – undo
742 741
         try
743 742
         {
744 743
             VoidEngine::setProperty ($this->selector, $name, $value);
745
-        }
746
-
747
-        catch (\Throwable $e)
744
+        } catch (\Throwable $e)
748 745
         {
749 746
             VoidEngine::setField ($this->selector, $name, $value);
750 747
         }
@@ -761,8 +758,9 @@  discard block
 block discarded – undo
761 758
         $size   = VoidEngine::getProperty ($array, 'Length');
762 759
         $return = [];
763 760
 
764
-		for ($i = 0; $i < $size; ++$i)
765
-            $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]);
761
+		for ($i = 0; $i < $size; ++$i) {
762
+		            $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]);
763
+		}
766 764
         
767 765
         VoidEngine::removeObjects ($array);
768 766
         
@@ -774,9 +772,7 @@  discard block
 block discarded – undo
774 772
 		try
775 773
 		{
776 774
 			return $this->getProperty ('Name');
777
-        }
778
-        
779
-		catch (\Throwable $e)
775
+        } catch (\Throwable $e)
780 776
 		{
781 777
 			return $this->name;
782 778
 		}
@@ -787,9 +783,7 @@  discard block
 block discarded – undo
787 783
 		try
788 784
 		{
789 785
 			$this->setProperty ('Name', $name);
790
-        }
791
-        
792
-		catch (\Throwable $e)
786
+        } catch (\Throwable $e)
793 787
 		{
794 788
 			$this->name = $name;
795 789
 		}
@@ -807,14 +801,14 @@  discard block
 block discarded – undo
807 801
 
808 802
     public function __construct ($class, ?string $classGroup = 'auto')
809 803
     {
810
-        if (is_string ($class))
811
-            $this->selector = VoidEngine::createClass ($class, $classGroup == 'auto' ?
804
+        if (is_string ($class)) {
805
+                    $this->selector = VoidEngine::createClass ($class, $classGroup == 'auto' ?
812 806
                 substr ($class, 0, strrpos ($class, '.')) : $classGroup
813 807
             );
814
-
815
-        elseif (is_int ($class) && VoidEngine::objectExists ($class))
816
-            $this->selector = $class;
817
-
818
-        else throw new \Exception ('$class parameter must be string or class selector');
808
+        } elseif (is_int ($class) && VoidEngine::objectExists ($class)) {
809
+                    $this->selector = $class;
810
+        } else {
811
+            throw new \Exception ('$class parameter must be string or class selector');
812
+        }
819 813
     }
820 814
 }
Please login to merge, or discard this patch.
engine/common/Others.php 1 patch
Braces   +85 added lines, -75 removed lines patch added patch discarded remove patch
@@ -6,8 +6,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
@@ -236,11 +245,10 @@  discard block
 block discarded – undo
236 245
         {
237 246
             try
238 247
             {
239
-                if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms')))
240
-                    continue;
241
-            }
242
-
243
-            catch (\Exception $e) {}
248
+                if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) {
249
+                                    continue;
250
+                }
251
+            } catch (\Exception $e) {}
244 252
             
245 253
             VoidEngine::destructObject ($selector);
246 254
 
@@ -248,8 +256,9 @@  discard block
 block discarded – undo
248 256
             {
249 257
                 unset (self::$components[$selector]);
250 258
 
251
-                if (isset (self::$events[$selector]))
252
-                    unset (self::$events[$selector]);
259
+                if (isset (self::$events[$selector])) {
260
+                                    unset (self::$events[$selector]);
261
+                }
253 262
             }
254 263
         }
255 264
     }
@@ -262,16 +271,15 @@  discard block
 block discarded – undo
262 271
 
263 272
 function c ($name, bool $returnAllSimilarObjects = false)
264 273
 {
265
-    if (is_int ($name) && is_object ($object = _c ($name)))
266
-        return $object;
267
-
268
-    else
274
+    if (is_int ($name) && is_object ($object = _c ($name))) {
275
+            return $object;
276
+    } else
269 277
     {
270 278
         $path    = explode ('->', $name);
271 279
         $similar = [];
272 280
 
273
-        foreach (Components::$components as $object)
274
-            try
281
+        foreach (Components::$components as $object) {
282
+                    try
275 283
             {
276 284
                 if ($object->name == end ($path))
277 285
                 {
@@ -284,32 +292,30 @@  discard block
 block discarded – undo
284 292
                                 {
285 293
                                     if ($returnAllSimilarObjects)
286 294
                                         $similar[] = $object;
295
+        }
287 296
 
288
-                                    else return $object;
297
+                                    else {
298
+                                        return $object;
299
+                                    }
300
+                                } else {
301
+                                    continue;
289 302
                                 }
290
-
291
-                                else continue;
303
+                            } else {
304
+                                continue;
292 305
                             }
293
-
294
-                            else continue;
295
-                        }
296
-
297
-                        catch (\Throwable $e)
306
+                        } catch (\Throwable $e)
298 307
                         {
299 308
                             continue;
300
-                        }
301
-
302
-                    else
309
+                        } else
303 310
                     {
304
-                        if ($returnAllSimilarObjects)
305
-                            $similar[] = $object;
306
-
307
-                        else return $object;
311
+                        if ($returnAllSimilarObjects) {
312
+                                                    $similar[] = $object;
313
+                        } else {
314
+                            return $object;
315
+                        }
308 316
                     }
309 317
                 }
310
-            }
311
-
312
-            catch (\Exception $e)
318
+            } catch (\Exception $e)
313 319
             {
314 320
                 continue;
315 321
             }
@@ -320,31 +326,32 @@  discard block
 block discarded – undo
320 326
 
321 327
             if (is_array ($objects))
322 328
             {
323
-                foreach ($objects as $id => $object)
324
-                    try
329
+                foreach ($objects as $id => $object) {
330
+                                    try
325 331
                     {
326 332
                         while (is_object ($parent = _c($object->parent->selector)))
327 333
                         {
328 334
                             if ($parent->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0])
329 335
                                 return $objects[$id];
336
+                }
330 337
 
331
-                            else $object = $parent;
338
+                            else {
339
+                                $object = $parent;
340
+                            }
332 341
                         }
333
-                    }
334
-
335
-                    catch (\Throwable $e)
342
+                    } catch (\Throwable $e)
336 343
 					{
337 344
 						continue;
338 345
 					}
339 346
 
340 347
                 return false;
348
+            } else {
349
+                return false;
341 350
             }
342
-
343
-            else return false;
344
-        }
345
-
346
-        else return $returnAllSimilarObjects && sizeof ($similar) > 0 ?
351
+        } else {
352
+            return $returnAllSimilarObjects && sizeof ($similar) > 0 ?
347 353
             $similar : false;
354
+        }
348 355
     }
349 356
 }
350 357
 
@@ -402,8 +409,9 @@  discard block
 block discarded – undo
402 409
     {
403 410
         $collection = new WFObject ('System.Collections.Specialized.StringCollection');
404 411
 
405
-        foreach ($files as $file)
406
-            $collection->add ((string) $file);
412
+        foreach ($files as $file) {
413
+                    $collection->add ((string) $file);
414
+        }
407 415
 
408 416
         (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection);
409 417
         VoidEngine::removeObjects ($collection->selector);
@@ -455,12 +463,14 @@  discard block
 block discarded – undo
455 463
 
456 464
 set_error_handler (function (...$args)
457 465
 {
458
-    if ($GLOBALS['error_status'])
459
-        pre ($args);
460
-});
466
+    if ($GLOBALS['error_status']) {
467
+            pre ($args);
468
+    }
469
+    });
461 470
 
462 471
 set_exception_handler (function (...$args)
463 472
 {
464
-    if ($GLOBALS['error_status'])
465
-        pre ($args);
466
-});
473
+    if ($GLOBALS['error_status']) {
474
+            pre ($args);
475
+    }
476
+    });
Please login to merge, or discard this patch.
engine/components/Designer.php 1 patch
Braces   +19 added lines, -17 removed lines patch added patch discarded remove patch
@@ -25,8 +25,9 @@  discard block
 block discarded – undo
25 25
         $this->form = $form === null ? new Form :
26 26
             EngineAdditions::coupleSelector ($form);
27 27
 
28
-        if (!is_object ($this->form))
29
-            throw new \Exception ('$form param in "VoidEngine\VoidDesigner" constructor must be instance of "VoidEngine\WFObject" ("VoidEngine\Form") or be object selector');
28
+        if (!is_object ($this->form)) {
29
+                    throw new \Exception ('$form param in "VoidEngine\VoidDesigner" constructor must be instance of "VoidEngine\WFObject" ("VoidEngine\Form") or be object selector');
30
+        }
30 31
 
31 32
         $this->propertyGrid        = $propertyGrid;
32 33
         $this->eventsList          = $eventsList;
@@ -199,17 +200,17 @@  discard block
 block discarded – undo
199 200
 
200 201
         foreach ($this->getSelectedComponents ()->list as $object)
201 202
         {
202
-            if ($object->getType ()->toString () != 'System.Windows.Forms.Form')
203
-                $toUnset[] = $this->getComponentName ($object->selector);
204
-
205
-            else
203
+            if ($object->getType ()->toString () != 'System.Windows.Forms.Form') {
204
+                            $toUnset[] = $this->getComponentName ($object->selector);
205
+            } else
206 206
             {
207 207
                 if ($this->formsList->items->count > 1)
208 208
                 {
209 209
                     if (messageBox ('Вы действительно хотите удалить форму "'. $this->form->name .'"?', 'Подтвердите действие', enum ('System.Windows.Forms.MessageBoxButtons.YesNo'), enum ('System.Windows.Forms.MessageBoxIcon.Question')) == 6)
210 210
                     {
211
-                        foreach ($this->objects as $name => $obj)
212
-                            unset ($this->objects[$name]);
211
+                        foreach ($this->objects as $name => $obj) {
212
+                                                    unset ($this->objects[$name]);
213
+                        }
213 214
 
214 215
                         unset ($this->formsList->items[array_flip ($this->formsList->items->names)[$form = $this->getComponentName ($object->selector)]]);
215 216
 
@@ -226,9 +227,7 @@  discard block
 block discarded – undo
226 227
 
227 228
                         return;
228 229
                     }
229
-                }
230
-
231
-                else
230
+                } else
232 231
                 {
233 232
                     messageBox ('Нельзя удалить единственную форму проекта', 'Ошибка удаления', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Error'));
234 233
 
@@ -237,14 +236,16 @@  discard block
 block discarded – undo
237 236
             }
238 237
         }
239 238
 
240
-        foreach ($toUnset as $name)
241
-            unset ($this->objects[$name]);
239
+        foreach ($toUnset as $name) {
240
+                    unset ($this->objects[$name]);
241
+        }
242 242
 
243 243
         $this->callMethod ('DeleteSelected');
244 244
 
245
-        foreach ($this->objects as $objectName => $object)
246
-            if (!is_int ($this->getComponentByName ($objectName)))
245
+        foreach ($this->objects as $objectName => $object) {
246
+                    if (!is_int ($this->getComponentByName ($objectName)))
247 247
                 unset ($this->objects[$objectName]);
248
+        }
248 249
 
249 250
         $this->currentSelectedItem->items->clear ();
250 251
         $this->currentSelectedItem->items->addRange (array_keys ($this->objects));
@@ -253,8 +254,9 @@  discard block
 block discarded – undo
253 254
 
254 255
     public function renameComponent (int $component, string $name, string $fromName = null): void
255 256
     {
256
-        if ($fromName === null)
257
-            $fromName = $this->getComponentName ($component);
257
+        if ($fromName === null) {
258
+                    $fromName = $this->getComponentName ($component);
259
+        }
258 260
 
259 261
         $info = $this->objects[$fromName];
260 262
         unset ($this->objects[$fromName]);
Please login to merge, or discard this patch.
engine/components/Process.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,10 +11,11 @@
 block discarded – undo
11 11
 	{
12 12
         $this->selector = VoidEngine::createClass ($this->class, $this->namespace);
13 13
 
14
-		if ($pid !== null)
15
-            $this->selector = $pid == getmypid () ?
14
+		if ($pid !== null) {
15
+		            $this->selector = $pid == getmypid () ?
16 16
                 VoidEngine::callMethod ($this->selector, 'GetCurrentProcess') :
17 17
                 VoidEngine::callMethod ($this->selector, 'GetProcessById', $pid);
18
+		}
18 19
 
19 20
 		Components::addComponent ($this->selector, $this);
20 21
 	}
Please login to merge, or discard this patch.