Passed
Push — master ( 89a9e2...8bb4e8 )
by Observer
01:15
created
engine/common/EngineInterfaces.php 1 patch
Spacing   +140 added lines, -142 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
      * 
18 18
      */
19 19
 
20
-    public static function createObject ($objectName, $objectGroup = null, ...$args): int
20
+    public static function createObject($objectName, $objectGroup = null, ...$args): int
21 21
     {
22
-        return \VoidCore::createObject ($objectName, $objectGroup, ...$args);
22
+        return \VoidCore::createObject($objectName, $objectGroup, ...$args);
23 23
     }
24 24
 
25 25
     /**
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
      * 
35 35
      */
36 36
 
37
-    public static function removeObjects (int ...$selectors): void
37
+    public static function removeObjects(int ...$selectors): void
38 38
     {
39
-        \VoidCore::removeObjects (...$selectors);
39
+        \VoidCore::removeObjects(...$selectors);
40 40
     }
41 41
 
42 42
     /**
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
      * 
52 52
      */
53 53
 
54
-    public static function destructObject (int $selector): bool
54
+    public static function destructObject(int $selector): bool
55 55
     {
56
-        return \VoidCore::destructObject ($selector);
56
+        return \VoidCore::destructObject($selector);
57 57
     }
58 58
 
59 59
     /**
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
      * 
69 69
      */
70 70
 
71
-    public static function createClass ($className, $classGroup = null): int
71
+    public static function createClass($className, $classGroup = null): int
72 72
     {
73
-        return \VoidCore::getClass ($className, $classGroup);
73
+        return \VoidCore::getClass($className, $classGroup);
74 74
     }
75 75
 
76 76
     /**
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
      * 
84 84
      */
85 85
 
86
-    public static function createDelegate (string $type, string $code): int
86
+    public static function createDelegate(string $type, string $code): int
87 87
     {
88
-        return \VoidCore::createDelegate ($type, $code);
88
+        return \VoidCore::createDelegate($type, $code);
89 89
     }
90 90
 
91 91
     /**
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
      * 
103 103
      */
104 104
 
105
-    public static function objectExists (int $selector): bool
105
+    public static function objectExists(int $selector): bool
106 106
     {
107
-        return \VoidCore::objectExists ($selector);
107
+        return \VoidCore::objectExists($selector);
108 108
     }
109 109
 
110 110
     /**
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
     * 
118 118
     */
119 119
 
120
-    public static function objectType ($objectName, $objectGroup = null)
120
+    public static function objectType($objectName, $objectGroup = null)
121 121
     {
122
-        return \VoidCore::typeof ($objectName, $objectGroup);
122
+        return \VoidCore::typeof($objectName, $objectGroup);
123 123
     }
124 124
 
125 125
     /**
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
      * 
141 141
      */
142 142
 
143
-    public static function getProperty (int $selector, $propertyName)
143
+    public static function getProperty(int $selector, $propertyName)
144 144
     {
145
-        return \VoidCore::getProp ($selector, $propertyName);
145
+        return \VoidCore::getProp($selector, $propertyName);
146 146
     }
147 147
 
148 148
     /**
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
      * 
163 163
      */
164 164
 
165
-    public static function setProperty (int $selector, string $propertyName, $value): void
165
+    public static function setProperty(int $selector, string $propertyName, $value): void
166 166
     {
167
-        \VoidCore::setProp ($selector, $propertyName, $value);
167
+        \VoidCore::setProp($selector, $propertyName, $value);
168 168
     }
169 169
 
170 170
     /**
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
      * 
185 185
      */
186 186
 
187
-    public static function getField (int $selector, $fieldName)
187
+    public static function getField(int $selector, $fieldName)
188 188
     {
189
-        return \VoidCore::getField ($selector, $fieldName);
189
+        return \VoidCore::getField($selector, $fieldName);
190 190
     }
191 191
 
192 192
     /**
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
      * 
202 202
      */
203 203
 
204
-    public static function setField (int $selector, string $fieldName, $value): void
204
+    public static function setField(int $selector, string $fieldName, $value): void
205 205
     {
206
-        \VoidCore::setField ($selector, $fieldName, $value);
206
+        \VoidCore::setField($selector, $fieldName, $value);
207 207
     }
208 208
 
209 209
     /**
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
      * 
228 228
      */
229 229
 
230
-    public static function callMethod (int $selector, $methodName, ...$args)
230
+    public static function callMethod(int $selector, $methodName, ...$args)
231 231
     {
232
-        return \VoidCore::callMethod ($selector, $methodName, ...$args);
232
+        return \VoidCore::callMethod($selector, $methodName, ...$args);
233 233
     }
234 234
 
235 235
     /**
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
      * 
246 246
      */
247 247
 
248
-    public static function getArrayValue (int $selector, $index)
248
+    public static function getArrayValue(int $selector, $index)
249 249
     {
250
-        return \VoidCore::getArrayValue ($selector, $index);
250
+        return \VoidCore::getArrayValue($selector, $index);
251 251
     }
252 252
 
253 253
     /**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
      * 
266 266
      */
267 267
 
268
-    public static function setArrayValue (int $selector, $index, $value): void
268
+    public static function setArrayValue(int $selector, $index, $value): void
269 269
     {
270
-        \VoidCore::setArrayValue ($selector, $index, $value);
270
+        \VoidCore::setArrayValue($selector, $index, $value);
271 271
     }
272 272
 
273 273
     /**
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
      * 
283 283
      */
284 284
 
285
-    public static function setObjectEvent (int $selector, string $eventName, callable $event): void
285
+    public static function setObjectEvent(int $selector, string $eventName, callable $event): void
286 286
     {
287 287
         /*if (self::eventExists ($selector, $eventName))
288 288
             self::removeObjectEvent ($selector, $eventName);*/
289 289
 
290
-        \VoidCore::setEvent ($selector, $eventName, $event);
290
+        \VoidCore::setEvent($selector, $eventName, $event);
291 291
     }
292 292
 
293 293
     /**
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
      * 
306 306
      */
307 307
 
308
-    public static function eventExists (int $selector, string $eventName): bool
308
+    public static function eventExists(int $selector, string $eventName): bool
309 309
     {
310
-        return \VoidCore::eventExists ($selector, $eventName);
310
+        return \VoidCore::eventExists($selector, $eventName);
311 311
     }
312 312
 
313 313
     /**
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
      * 
325 325
      */
326 326
 
327
-    public static function removeObjectEvent (int $selector, string $eventName): void
327
+    public static function removeObjectEvent(int $selector, string $eventName): void
328 328
     {
329
-        \VoidCore::removeEvent ($selector, $eventName);
329
+        \VoidCore::removeEvent($selector, $eventName);
330 330
     }
331 331
 
332 332
     /**
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
      * 
339 339
      */
340 340
 
341
-    public static function importObject (string $data): int
341
+    public static function importObject(string $data): int
342 342
     {
343
-        return \VoidCore::importObject ($data);
343
+        return \VoidCore::importObject($data);
344 344
     }
345 345
 
346 346
     /**
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
      * 
353 353
      */
354 354
 
355
-    public static function exportObject (int $selector): string
355
+    public static function exportObject(int $selector): string
356 356
     {
357
-        return \VoidCore::exportObject ($selector);
357
+        return \VoidCore::exportObject($selector);
358 358
     }
359 359
 
360 360
     /**
@@ -378,20 +378,20 @@  discard block
 block discarded – undo
378 378
      * 
379 379
      */
380 380
 
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
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 383
         if ($dictionary === null)
384
-            $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', 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
+            $assemblies = getNetArray('System.String', [
388 388
                 // CORE_DIR .'/CefSharp.dll',
389
-                CORE_DIR .'/FastColoredTextBox.dll',
390
-                CORE_DIR .'/ScintillaNET.dll'
389
+                CORE_DIR.'/FastColoredTextBox.dll',
390
+                CORE_DIR.'/ScintillaNET.dll'
391 391
             ]);
392 392
 
393 393
         if ($productName === null)
394
-            $productName = basenameNoExt ($savePath);
394
+            $productName = basenameNoExt($savePath);
395 395
 
396 396
         if ($productDescription === null)
397 397
             $productDescription = $productName;
@@ -403,19 +403,19 @@  discard block
 block discarded – undo
403 403
             $companyName = 'Company N';
404 404
 
405 405
         if ($copyright === null)
406
-            $copyright = $companyName .' copyright (c) '. date ('Y');
406
+            $copyright = $companyName.' copyright (c) '.date('Y');
407 407
 
408
-        return (new WFClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names;
408
+        return (new WFClass('WinForms_PHP.WFCompiler', null))->compile($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names;
409 409
     }
410 410
 }
411 411
 
412 412
 class EngineAdditions
413 413
 {
414
-    public static function loadModule (string $path): bool
414
+    public static function loadModule(string $path): bool
415 415
     {
416 416
         try
417 417
         {
418
-            (new WFClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path);
418
+            (new WFClass('System.Reflection.Assembly', 'mscorlib'))->loadFrom($path);
419 419
         }
420 420
 
421 421
         catch (\Throwable $e)
@@ -426,16 +426,16 @@  discard block
 block discarded – undo
426 426
         return true;
427 427
     }
428 428
 
429
-    public static function getProperty (int $selector, string $name): array
429
+    public static function getProperty(int $selector, string $name): array
430 430
     {
431
-        $property = VoidEngine::callMethod (VoidEngine::callMethod ($selector, 'GetType'), 'GetProperty', $name);
431
+        $property = VoidEngine::callMethod(VoidEngine::callMethod($selector, 'GetType'), 'GetProperty', $name);
432 432
 
433
-        if (!is_int ($property))
433
+        if (!is_int($property))
434 434
             return false;
435 435
 
436 436
         try
437 437
         {
438
-            $propertyType = VoidEngine::getProperty ($property, ['PropertyType', 'string']);
438
+            $propertyType = VoidEngine::getProperty($property, ['PropertyType', 'string']);
439 439
 
440 440
             switch ($propertyType)
441 441
             {
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
                 default:
472 472
                     try
473 473
                     {
474
-                        VoidEngine::getProperty ($selector, [$name, 'int']);
474
+                        VoidEngine::getProperty($selector, [$name, 'int']);
475 475
 
476 476
                         $property = 'int';
477 477
                     }
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
                     {
481 481
                         return [
482 482
                             'type'  => 'vrsf',
483
-                            'value' => VoidEngine::exportObject (VoidEngine::getProperty ($selector, [$name, 'object']))
483
+                            'value' => VoidEngine::exportObject(VoidEngine::getProperty($selector, [$name, 'object']))
484 484
                         ];
485 485
                     }
486 486
                 break;
@@ -494,19 +494,19 @@  discard block
 block discarded – undo
494 494
 
495 495
         return [
496 496
             'type'  => $property,
497
-            'value' => VoidEngine::getProperty ($selector, [$name, $property])
497
+            'value' => VoidEngine::getProperty($selector, [$name, $property])
498 498
         ];
499 499
     }
500 500
 
501
-    public static function getObjectEvents (int $object): array
501
+    public static function getObjectEvents(int $object): array
502 502
     {
503 503
         $events = [];
504 504
 
505
-        $props = VoidEngine::callMethod (VoidEngine::callMethod ($object, 'GetType'), 'GetEvents');
506
-        $len   = VoidEngine::getProperty ($props, 'Length');
505
+        $props = VoidEngine::callMethod(VoidEngine::callMethod($object, 'GetType'), 'GetEvents');
506
+        $len   = VoidEngine::getProperty($props, 'Length');
507 507
 
508 508
         for ($i = 0; $i < $len; ++$i)
509
-            $events[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($props, $i), 'Name');
509
+            $events[] = VoidEngine::getProperty(VoidEngine::getArrayValue($props, $i), 'Name');
510 510
 
511 511
         return $events;
512 512
     }
@@ -516,13 +516,13 @@  discard block
 block discarded – undo
516 516
      * Тогда получается бесконечный цикл вида object->selector->selector->selector->...
517 517
      * Чтобы этого избежать нужно добавить исключение - переменную $selfSelector
518 518
      */
519
-    public static function coupleSelector ($value, int $selfSelector = null)
519
+    public static function coupleSelector($value, int $selfSelector = null)
520 520
     {
521
-        return is_int ($value) && VoidEngine::objectExists ($value) && $value != $selfSelector ?
522
-            new WFObject ($value) : $value;
521
+        return is_int($value) && VoidEngine::objectExists($value) && $value != $selfSelector ?
522
+            new WFObject($value) : $value;
523 523
     }
524 524
 
525
-    public static function uncoupleSelector ($value)
525
+    public static function uncoupleSelector($value)
526 526
     {
527 527
         return $value instanceof WFObject ?
528 528
             $value->selector : $value;
@@ -534,44 +534,44 @@  discard block
 block discarded – undo
534 534
     protected int $selector = 0;
535 535
     protected $name;
536 536
 
537
-    public function __construct ($object, ?string $classGroup = 'auto', ...$args)
537
+    public function __construct($object, ?string $classGroup = 'auto', ...$args)
538 538
     {
539 539
         foreach ($args as $id => $arg)
540
-            $args[$id] = EngineAdditions::uncoupleSelector ($arg);
540
+            $args[$id] = EngineAdditions::uncoupleSelector($arg);
541 541
 
542
-        if (is_string ($object))
543
-            $this->selector = VoidEngine::createObject ($object, $classGroup == 'auto' ?
544
-                substr ($object, 0, strrpos ($object, '.')) : $classGroup, ...$args);
542
+        if (is_string($object))
543
+            $this->selector = VoidEngine::createObject($object, $classGroup == 'auto' ?
544
+                substr ($object, 0, strrpos($object, '.')) : $classGroup, ...$args);
545 545
 
546
-        elseif (is_int ($object) && VoidEngine::objectExists ($object))
546
+        elseif (is_int($object) && VoidEngine::objectExists($object))
547 547
             $this->selector = $object;
548 548
 
549
-        else throw new \Exception ('$object parameter must be string or object selector');
549
+        else throw new \Exception('$object parameter must be string or object selector');
550 550
     }
551 551
     
552
-    public function __get ($name)
552
+    public function __get($name)
553 553
 	{
554
-        if (method_exists ($this, $method = "get_$name"))
555
-            $value = $this->$method ();
554
+        if (method_exists($this, $method = "get_$name"))
555
+            $value = $this->$method();
556 556
 
557
-        elseif (substr ($name, -5) == 'Event')
558
-            $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5));
557
+        elseif (substr($name, -5) == 'Event')
558
+            $value = Events::getObjectEvent($this->selector, substr($name, 0, -5));
559 559
 
560
-        elseif (property_exists ($this, $name))
560
+        elseif (property_exists($this, $name))
561 561
             $value = $this->$name;
562 562
 
563
-        else switch (strtolower ($name))
563
+        else switch (strtolower($name))
564 564
         {
565 565
             case 'count':
566 566
             case 'length':
567 567
                 try
568 568
                 {
569
-                    return $this->getProperty ('Count');
569
+                    return $this->getProperty('Count');
570 570
                 }
571 571
 
572 572
                 catch (\Throwable $e)
573 573
                 {
574
-                    return $this->getProperty ('Length');
574
+                    return $this->getProperty('Length');
575 575
                 }
576 576
             break;
577 577
 
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
                 $list = [];
581 581
                 
582 582
 				for ($i = 0; $i < $size; ++$i)
583
-                    $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i));
583
+                    $list[] = EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $i));
584 584
                 
585 585
                 return $list;
586 586
             break;
@@ -592,31 +592,31 @@  discard block
 block discarded – undo
592 592
                 for ($i = 0; $i < $size; ++$i)
593 593
                     try
594 594
                     {
595
-                        $names[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($this->selector, [$i, 'object']), 'Text');
595
+                        $names[] = VoidEngine::getProperty(VoidEngine::getArrayValue($this->selector, [$i, 'object']), 'Text');
596 596
                     }
597 597
 
598 598
                     catch (\Throwable $e)
599 599
                     {
600
-                        $names[] = VoidEngine::getArrayValue ($this->selector, [$i, 'string']);
600
+                        $names[] = VoidEngine::getArrayValue($this->selector, [$i, 'string']);
601 601
                     }
602 602
                 
603 603
                 return $names;
604 604
             break;
605 605
 
606 606
             default:
607
-                $value = $this->getProperty ($name);
607
+                $value = $this->getProperty($name);
608 608
             break;
609 609
         }
610 610
 
611
-        return EngineAdditions::coupleSelector ($value, $this->selector);
611
+        return EngineAdditions::coupleSelector($value, $this->selector);
612 612
 	}
613 613
 	
614
-	public function __set ($name, $value)
614
+	public function __set($name, $value)
615 615
 	{
616
-        if (method_exists ($this, $method = "set_$name"))
616
+        if (method_exists($this, $method = "set_$name"))
617 617
             try
618 618
             {
619
-                return $this->$method ($value);
619
+                return $this->$method($value);
620 620
             }
621 621
 
622 622
             # Метод "set_$name" может принимать в качестве параметра объект WFObject
@@ -625,63 +625,61 @@  discard block
 block discarded – undo
625 625
             catch (\Throwable $e)
626 626
             {
627 627
                 return $value instanceof WFObject ?
628
-                    $this->$method ($value->selector) : null;
628
+                    $this->$method($value->selector) : null;
629 629
             }
630 630
 
631
-        elseif (substr ($name, -5) == 'Event')
632
-            Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value);
631
+        elseif (substr($name, -5) == 'Event')
632
+            Events::setObjectEvent($this->selector, substr($name, 0, -5), $value);
633 633
         
634
-        else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value));
634
+        else $this->setProperty($name, EngineAdditions::uncoupleSelector($value));
635 635
     }
636 636
 	
637
-	public function __call ($method, $args)
637
+	public function __call($method, $args)
638 638
 	{
639
-        $args = array_map (function ($arg)
639
+        $args = array_map(function($arg)
640 640
         {
641
-            return EngineAdditions::uncoupleSelector ($arg);
641
+            return EngineAdditions::uncoupleSelector($arg);
642 642
         }, $args);
643 643
 
644
-        return EngineAdditions::coupleSelector ($this->callMethod ($method, ...$args), $this->selector);
644
+        return EngineAdditions::coupleSelector($this->callMethod($method, ...$args), $this->selector);
645 645
     }
646 646
 
647
-    public function addRange (array $values, $assoc = false): void
647
+    public function addRange(array $values, $assoc = false): void
648 648
     {
649 649
         foreach ($values as $id => $value)
650
-            $this->offsetSet ($assoc ? $id : null, $value);
650
+            $this->offsetSet($assoc ? $id : null, $value);
651 651
     }
652 652
     
653
-    public function offsetSet ($index, $value)
653
+    public function offsetSet($index, $value)
654 654
 	{
655 655
         try
656 656
         {
657 657
             return $index === null ?
658
-                $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) :
659
-                $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value));
658
+                $this->callMethod('Add', EngineAdditions::uncoupleSelector($value)) : $this->callMethod('Insert', $index, EngineAdditions::uncoupleSelector($value));
660 659
         }
661 660
 
662 661
         catch (\Throwable $e)
663 662
         {
664 663
             return $index === null ?
665
-                VoidEngine::setArrayValue ($this->selector, $this->count, $value) :
666
-                VoidEngine::setArrayValue ($this->selector, $index, $value);
664
+                VoidEngine::setArrayValue($this->selector, $this->count, $value) : VoidEngine::setArrayValue($this->selector, $index, $value);
667 665
         }
668 666
     }
669 667
 	
670
-	public function offsetGet ($index)
668
+	public function offsetGet($index)
671 669
 	{
672
-		return EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $index), $this->selector);
670
+		return EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $index), $this->selector);
673 671
     }
674 672
 	
675
-	public function offsetUnset ($index): void
673
+	public function offsetUnset($index): void
676 674
 	{
677
-		$this->callMethod ('RemoveAt', $index);
675
+		$this->callMethod('RemoveAt', $index);
678 676
     }
679 677
     
680
-    public function offsetExists ($index): bool
678
+    public function offsetExists($index): bool
681 679
     {
682 680
         try
683 681
         {
684
-            $this->offsetGet ($index);
682
+            $this->offsetGet($index);
685 683
         }
686 684
 
687 685
         catch (\Exception $e)
@@ -692,19 +690,19 @@  discard block
 block discarded – undo
692 690
         return true;
693 691
     }
694 692
 	
695
-	public function indexOf ($value): int
693
+	public function indexOf($value): int
696 694
 	{
697
-		return $this->callMethod ('IndexOf', EngineAdditions::uncoupleSelector ($value));
695
+		return $this->callMethod('IndexOf', EngineAdditions::uncoupleSelector($value));
698 696
     }
699 697
     
700
-    public function lastIndexOf ($value): int
698
+    public function lastIndexOf($value): int
701 699
 	{
702
-		return $this->callMethod ('LastIndexOf', EngineAdditions::uncoupleSelector ($value));
700
+		return $this->callMethod('LastIndexOf', EngineAdditions::uncoupleSelector($value));
703 701
 	}
704 702
 	
705
-	public function contains ($value): bool
703
+	public function contains($value): bool
706 704
 	{
707
-		return $this->callMethod ('Contains', EngineAdditions::uncoupleSelector ($value));
705
+		return $this->callMethod('Contains', EngineAdditions::uncoupleSelector($value));
708 706
     }
709 707
 
710 708
     public function foreach (callable $callback, string $type = null): void
@@ -712,71 +710,71 @@  discard block
 block discarded – undo
712 710
         $size = $this->count;
713 711
 
714 712
         for ($i = 0; $i < $size; ++$i)
715
-            $callback (EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i);
713
+            $callback(EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i);
716 714
     }
717 715
 
718
-    public function where (callable $comparator, string $type = null): array
716
+    public function where(callable $comparator, string $type = null): array
719 717
     {
720 718
         $size   = $this->count;
721 719
         $return = [];
722 720
 
723 721
         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
+            if ($comparator($value = EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i))
725 723
                 $return[] = $value;
726 724
 
727 725
         return $return;
728 726
     }
729 727
 	
730
-    protected function getProperty ($name)
728
+    protected function getProperty($name)
731 729
     {
732 730
         try
733 731
         {
734
-            return VoidEngine::getProperty ($this->selector, $name);
732
+            return VoidEngine::getProperty($this->selector, $name);
735 733
         }
736 734
 
737 735
         catch (\Throwable $e)
738 736
         {
739
-            return VoidEngine::getField ($this->selector, $name);
737
+            return VoidEngine::getField($this->selector, $name);
740 738
         }
741 739
     }
742 740
 
743
-    protected function setProperty ($name, $value)
741
+    protected function setProperty($name, $value)
744 742
     {
745 743
         try
746 744
         {
747
-            VoidEngine::setProperty ($this->selector, $name, $value);
745
+            VoidEngine::setProperty($this->selector, $name, $value);
748 746
         }
749 747
 
750 748
         catch (\Throwable $e)
751 749
         {
752
-            VoidEngine::setField ($this->selector, $name, $value);
750
+            VoidEngine::setField($this->selector, $name, $value);
753 751
         }
754 752
     }
755 753
 	
756
-    protected function callMethod ($method, ...$args)
754
+    protected function callMethod($method, ...$args)
757 755
     {
758
-        return VoidEngine::callMethod ($this->selector, $method, ...$args);
756
+        return VoidEngine::callMethod($this->selector, $method, ...$args);
759 757
     }
760 758
 	
761
-	protected function getArrayProperty ($name, string $type = null)
759
+	protected function getArrayProperty($name, string $type = null)
762 760
 	{
763
-        $array  = $this->getProperty ($name);
764
-        $size   = VoidEngine::getProperty ($array, 'Length');
761
+        $array  = $this->getProperty($name);
762
+        $size   = VoidEngine::getProperty($array, 'Length');
765 763
         $return = [];
766 764
 
767 765
 		for ($i = 0; $i < $size; ++$i)
768
-            $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]);
766
+            $return[] = VoidEngine::getArrayValue($array, $type === null ? $i : [$i, $type]);
769 767
         
770
-        VoidEngine::removeObjects ($array);
768
+        VoidEngine::removeObjects($array);
771 769
         
772 770
 		return $return;
773 771
     }
774 772
 
775
-    public function get_name ()
773
+    public function get_name()
776 774
 	{
777 775
 		try
778 776
 		{
779
-			return $this->getProperty ('Name');
777
+			return $this->getProperty('Name');
780 778
         }
781 779
         
782 780
 		catch (\Throwable $e)
@@ -785,11 +783,11 @@  discard block
 block discarded – undo
785 783
 		}
786 784
 	}
787 785
 	
788
-	public function set_name (string $name)
786
+	public function set_name(string $name)
789 787
 	{
790 788
 		try
791 789
 		{
792
-			$this->setProperty ('Name', $name);
790
+			$this->setProperty('Name', $name);
793 791
         }
794 792
         
795 793
 		catch (\Throwable $e)
@@ -798,24 +796,24 @@  discard block
 block discarded – undo
798 796
 		}
799 797
 	}
800 798
 
801
-    public function __toString (): string
799
+    public function __toString(): string
802 800
     {
803
-        return $this->callMethod ('ToString');
801
+        return $this->callMethod('ToString');
804 802
     }
805 803
 }
806 804
 
807 805
 class WFClass extends WFObject
808 806
 {
809
-    public function __construct ($class, ?string $classGroup = 'auto')
807
+    public function __construct($class, ?string $classGroup = 'auto')
810 808
     {
811
-        if (is_string ($class))
812
-            $this->selector = VoidEngine::createClass ($class, $classGroup == 'auto' ?
813
-                substr ($class, 0, strrpos ($class, '.')) : $classGroup
809
+        if (is_string($class))
810
+            $this->selector = VoidEngine::createClass($class, $classGroup == 'auto' ?
811
+                substr ($class, 0, strrpos($class, '.')) : $classGroup
814 812
             );
815 813
 
816
-        elseif (is_int ($class) && VoidEngine::objectExists ($class))
814
+        elseif (is_int($class) && VoidEngine::objectExists($class))
817 815
             $this->selector = $class;
818 816
 
819
-        else throw new \Exception ('$class parameter must be string or class selector');
817
+        else throw new \Exception('$class parameter must be string or class selector');
820 818
     }
821 819
 }
Please login to merge, or discard this patch.
engine/VoidEngine.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 const ENGINE_VERSION = '3.5.1 build-2019/09/08';
37 37
 const ENGINE_DIR = __DIR__;
38 38
 
39
-chdir (ENGINE_DIR);
39
+chdir(ENGINE_DIR);
40 40
 
41 41
 $GLOBALS['__debug'] = [
42
-    'start_time'   => microtime (true),
42
+    'start_time'   => microtime(true),
43 43
     'error_status' => true
44 44
 ];
45 45
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 require 'common/Others.php';
50 50
 require 'common/Events.php';
51 51
 
52
-define ('VoidEngine\CORE_VERSION', $APPLICATION->productVersion);
52
+define('VoidEngine\CORE_VERSION', $APPLICATION->productVersion);
53 53
 
54 54
 require 'components/Component.php';
55 55
 require 'components/Control.php';
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 require 'components/FastColoredTextBox.php';
99 99
 require 'components/Scintilla.php';
100 100
 
101
-if (is_dir ('extensions'))
102
-    foreach (scandir ('extensions') as $ext)
103
-        if (is_dir ('extensions/'. $ext) && file_exists ($ext = 'extensions/'. $ext .'/main.php'))
101
+if (is_dir('extensions'))
102
+    foreach (scandir('extensions') as $ext)
103
+        if (is_dir('extensions/'.$ext) && file_exists($ext = 'extensions/'.$ext.'/main.php'))
104 104
             require $ext;
Please login to merge, or discard this patch.
engine/extensions/VLF/bin/parser.php 1 patch
Braces   +106 added lines, -87 removed lines patch added patch discarded remove patch
@@ -25,18 +25,20 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function __construct (string $content, array $settings = [])
27 27
     {
28
-        if (file_exists ($content))
29
-            $content = file_get_contents ($content);
28
+        if (file_exists ($content)) {
29
+                    $content = file_get_contents ($content);
30
+        }
30 31
 
31 32
         // Зачем? Так надо!
32 33
         $content = "# VLF begin\n\n$content\n\n# VLF end";
33 34
 
34 35
         foreach ($settings as $name => $setting)
35 36
         {
36
-            if (isset ($this->$name))
37
-                $this->$name = $setting;
38
-
39
-            else throw new \Exception ('Trying to setting up undefined property "'. $name .'"');
37
+            if (isset ($this->$name)) {
38
+                            $this->$name = $setting;
39
+            } else {
40
+                throw new \Exception ('Trying to setting up undefined property "'. $name .'"');
41
+            }
40 42
         }
41 43
 
42 44
         if ($this->use_caching && file_exists ($file = VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache'))
@@ -49,9 +51,9 @@  discard block
 block discarded – undo
49 51
                 $this->links = $info[1][1];
50 52
 
51 53
                 return;
54
+            } else {
55
+                unlink ($file);
52 56
             }
53
-
54
-            else unlink ($file);
55 57
         }
56 58
 
57 59
         $info = $this->generateSyntaxTree ($content);
@@ -61,8 +63,9 @@  discard block
 block discarded – undo
61 63
 
62 64
         if ($this->use_caching)
63 65
         {
64
-            if (!is_dir (dirname (__DIR__) .'/cache'))
65
-                mkdir (dirname (__DIR__) .'/cache');
66
+            if (!is_dir (dirname (__DIR__) .'/cache')) {
67
+                            mkdir (dirname (__DIR__) .'/cache');
68
+            }
66 69
 
67 70
             file_put_contents (VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache', gzdeflate (serialize ([sha1 (file_get_contents (__FILE__)), $info])));
68 71
         }
@@ -85,19 +88,22 @@  discard block
 block discarded – undo
85 88
         $tree           = [];
86 89
         $links          = [];
87 90
 
88
-        if ($this->debug_mode)
89
-            pre ($lines);
91
+        if ($this->debug_mode) {
92
+                    pre ($lines);
93
+        }
90 94
 
91 95
         foreach ($lines as $id => $line)
92 96
         {
93
-            if ($skip_at > $id)
94
-                continue;
97
+            if ($skip_at > $id) {
98
+                            continue;
99
+            }
95 100
 
96 101
             $height = $this->getLineHeight ($line);
97 102
             $words  = $this->linesFilter (explode (' ', $line));
98 103
 
99
-            if ($this->debug_mode)
100
-                pre ($words);
104
+            if ($this->debug_mode) {
105
+                            pre ($words);
106
+            }
101 107
 
102 108
             /**
103 109
              * Высокоинтеллектуальный фикс
@@ -118,16 +124,18 @@  discard block
 block discarded – undo
118 124
             {
119 125
                 $updated = false;
120 126
 
121
-                if ($this->debug_mode)
122
-                    pre ($current_object);
127
+                if ($this->debug_mode) {
128
+                                    pre ($current_object);
129
+                }
123 130
 
124 131
                 while (isset ($tree[$current_object]['info']['subparent_link']) && $tree[$link = $tree[$current_object]['info']['subparent_link']->link]['hard'] < $tree[$current_object]['hard'])
125 132
                 {
126 133
                     $current_object = $link;
127 134
                     $updated        = true;
128 135
 
129
-                    if ($this->debug_mode)
130
-                        pre ($current_object);
136
+                    if ($this->debug_mode) {
137
+                                            pre ($current_object);
138
+                    }
131 139
                 }
132 140
 
133 141
                 if (
@@ -136,13 +144,15 @@  discard block
 block discarded – undo
136 144
                     isset ($tree[$current_object]['info']['arguments'][0]) &&
137 145
                     $tree[$current_object]['info']['arguments'][0] instanceof VLFLink &&
138 146
                     $tree[$tree[$current_object]['info']['arguments'][0]->link]['hard'] < $tree[$current_object]['hard']
139
-                ) $current_object = $tree[$current_object]['info']['arguments'][0]->link;
140
-
141
-                elseif (!$updated)
142
-                    break;
147
+                ) {
148
+                    $current_object = $tree[$current_object]['info']['arguments'][0]->link;
149
+                } elseif (!$updated) {
150
+                                    break;
151
+                }
143 152
 
144
-                if ($this->debug_mode)
145
-                    pre ($current_object);
153
+                if ($this->debug_mode) {
154
+                                    pre ($current_object);
155
+                }
146 156
             }
147 157
 
148 158
             /**
@@ -150,8 +160,9 @@  discard block
 block discarded – undo
150 160
              */
151 161
             if (class_exists ($words[0]) || class_exists ('\VoidEngine\\'. $words[0]))
152 162
             {
153
-                if (!isset ($words[1]))
154
-                    throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"');
163
+                if (!isset ($words[1])) {
164
+                                    throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"');
165
+                }
155 166
 
156 167
                 /**
157 168
                  * Button NewButton
@@ -179,9 +190,7 @@  discard block
 block discarded – undo
179 190
                     $current_object = $id;
180 191
 
181 192
                     continue;
182
-                }
183
-
184
-                else
193
+                } else
185 194
                 {
186 195
                     $tree[$id] = [
187 196
                         'type'  => VLF_OBJECT_DEFINITION,
@@ -203,10 +212,9 @@  discard block
 block discarded – undo
203 212
                         
204 213
                         $end = strrpos ($line, ')');
205 214
 
206
-                        if ($end === false)
207
-                            throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending');
208
-
209
-                        elseif ($begin < $end)
215
+                        if ($end === false) {
216
+                                                    throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending');
217
+                        } elseif ($begin < $end)
210 218
                         {
211 219
                             $arguments = [];
212 220
                             // $parsed    = explode (',', substr ($line, $begin, $end - $begin));
@@ -216,18 +224,20 @@  discard block
 block discarded – undo
216 224
                             {
217 225
                                 $argument = trim ($argument);
218 226
 
219
-                                if (strlen ($argument) > 0)
220
-                                    $arguments[] = isset ($links[$argument]) ?
227
+                                if (strlen ($argument) > 0) {
228
+                                                                    $arguments[] = isset ($links[$argument]) ?
221 229
                                         new VLFLink ($argument, $links[$argument]) :
222 230
                                         $argument;
223
-
224
-                                else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"');
231
+                                } else {
232
+                                    throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"');
233
+                                }
225 234
                             }
226 235
 
227 236
                             $tree[$id]['info']['arguments'] = $arguments;
228 237
 
229
-                            if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0)
230
-                                throw new \Exception ('You mustn\'t write any chars after arguments definition');
238
+                            if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) {
239
+                                                            throw new \Exception ('You mustn\'t write any chars after arguments definition');
240
+                            }
231 241
                         }
232 242
 
233 243
                         $tree[$id]['info']['subparent_link'] = new VLFLink ($tree[$current_object]['info']['object_name'], $current_object);
@@ -291,13 +301,14 @@  discard block
 block discarded – undo
291 301
 
292 302
                         $comment .= $parsed[0];
293 303
                         $skip_at  = $parsed[1];
304
+                    } else {
305
+                        throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"');
294 306
                     }
295
-
296
-                    else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"');
297 307
                 }
298 308
                 
299
-                if ($this->debug_mode)
300
-                    pre ("Comment:\n\n$comment");
309
+                if ($this->debug_mode) {
310
+                                    pre ("Comment:\n\n$comment");
311
+                }
301 312
             }
302 313
 
303 314
             /**
@@ -319,9 +330,9 @@  discard block
 block discarded – undo
319 330
 
320 331
                         $code   .= $parsed[0];
321 332
                         $skip_at = $parsed[1];
333
+                    } else {
334
+                        throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"');
322 335
                     }
323
-
324
-                    else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"');
325 336
                 }
326 337
                 
327 338
                 $tree[$id] = [
@@ -376,8 +387,9 @@  discard block
 block discarded – undo
376 387
 
377 388
                 if ($postChar == ':' || $postChar == '^')
378 389
                 {
379
-                    if (!isset ($words[1]))
380
-                        throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"');
390
+                    if (!isset ($words[1])) {
391
+                                            throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"');
392
+                    }
381 393
 
382 394
                     $propertyName     = substr ($words[0], 0, -1);
383 395
                     $propertyValue    = implode (' ', array_slice ($words, 1));
@@ -412,8 +424,9 @@  discard block
 block discarded – undo
412 424
                         'syntax_nodes' => []
413 425
                     ];
414 426
 
415
-                    if (isset ($links[$info['info']['property_value']]))
416
-                        $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]);
427
+                    if (isset ($links[$info['info']['property_value']])) {
428
+                                            $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]);
429
+                    }
417 430
 
418 431
                     $tree[$current_object]['syntax_nodes'][] = $info;
419 432
                 }
@@ -431,10 +444,9 @@  discard block
 block discarded – undo
431 444
                         
432 445
                         $end = strrpos ($line, ')');
433 446
 
434
-                        if ($end === false)
435
-                            throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending');
436
-
437
-                        elseif ($begin < $end)
447
+                        if ($end === false) {
448
+                                                    throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending');
449
+                        } elseif ($begin < $end)
438 450
                         {
439 451
                             // $parsed = explode (',', substr ($line, $begin, $end - $begin));
440 452
                             $parsed = $this->parseArguments (substr ($line, $begin, $end - $begin));
@@ -443,24 +455,27 @@  discard block
 block discarded – undo
443 455
                             {
444 456
                                 $argument = trim ($argument);
445 457
 
446
-                                if (strlen ($argument) > 0)
447
-                                    $arguments[] = isset ($links[$argument]) ?
458
+                                if (strlen ($argument) > 0) {
459
+                                                                    $arguments[] = isset ($links[$argument]) ?
448 460
                                         new VLFLink ($argument, $links[$argument]) :
449 461
                                         $argument;
450
-
451
-                                else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"');
462
+                                } else {
463
+                                    throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"');
464
+                                }
452 465
                             }
453 466
 
454
-                            if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0)
455
-                                throw new \Exception ('You mustn\'t write any chars after arguments definition');
467
+                            if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) {
468
+                                                            throw new \Exception ('You mustn\'t write any chars after arguments definition');
469
+                            }
456 470
                         }
457 471
                     }
458 472
 
459 473
                     /**
460 474
                      * ->show
461 475
                      */
462
-                    elseif (!$this->ignore_unexpected_method_args)
463
-                        throw new \Exception ('Unexpected method arguments list at line "'. $line .'"');
476
+                    elseif (!$this->ignore_unexpected_method_args) {
477
+                                            throw new \Exception ('Unexpected method arguments list at line "'. $line .'"');
478
+                    }
464 479
 
465 480
                     $tree[$current_object]['syntax_nodes'][] = [
466 481
                         'type'  => VLF_METHOD_CALL,
@@ -513,7 +528,9 @@  discard block
 block discarded – undo
513 528
             /**
514 529
              * Что-то загадочное, таинственное, неизвестное человечеству
515 530
              */
516
-            else throw new \Exception ('Unknown structures founded at line "'. $line .'"');
531
+            else {
532
+                throw new \Exception ('Unknown structures founded at line "'. $line .'"');
533
+            }
517 534
         }
518 535
 
519 536
         return [$tree, $links];
@@ -535,8 +552,9 @@  discard block
 block discarded – undo
535 552
 
536 553
         foreach ($lines as $line_id => $line)
537 554
         {
538
-            if ($line_id <= $begin_id)
539
-                continue;
555
+            if ($line_id <= $begin_id) {
556
+                            continue;
557
+            }
540 558
 
541 559
             if (!(bool)(trim ($line)))
542 560
             {
@@ -547,13 +565,15 @@  discard block
 block discarded – undo
547 565
 
548 566
             $height = $this->getLineHeight ($line);
549 567
 
550
-            if ($this->debug_mode)
551
-                pre ("$height, $down_height, $line");
552
-
553
-            if ($height > $down_height)
554
-                $parsed .= "$line\n";
568
+            if ($this->debug_mode) {
569
+                            pre ("$height, $down_height, $line");
570
+            }
555 571
 
556
-            else break;
572
+            if ($height > $down_height) {
573
+                            $parsed .= "$line\n";
574
+            } else {
575
+                break;
576
+            }
557 577
         }
558 578
 
559 579
         return [$parsed, $line_id];
@@ -577,8 +597,9 @@  discard block
 block discarded – undo
577 597
     {
578 598
         $i = 0;
579 599
 
580
-        while (isset ($line[$i]) && $line[$i] == "\t")
581
-            ++$i;
600
+        while (isset ($line[$i]) && $line[$i] == "\t") {
601
+                    ++$i;
602
+        }
582 603
         
583 604
         return strlen ($line = str_repeat ('    ', $i) . substr ($line, $i)) - strlen ($line = trim ($line));
584 605
     }
@@ -595,8 +616,9 @@  discard block
 block discarded – undo
595 616
     {
596 617
         return array_filter ($segments, function ($text)
597 618
         {
598
-            if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text))
599
-                throw new \Exception  ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters');
619
+            if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) {
620
+                            throw new \Exception  ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters');
621
+            }
600 622
             
601 623
             return strlen (trim ($text)) > 0;
602 624
         });
@@ -617,18 +639,15 @@  discard block
 block discarded – undo
617 639
         {
618 640
             $t .= $arguments[$i];
619 641
 
620
-            if ($arguments[$i] == '\\')
621
-                $canSplit = $i + 1;
622
-
623
-            elseif ($canSplit < $i)
642
+            if ($arguments[$i] == '\\') {
643
+                            $canSplit = $i + 1;
644
+            } elseif ($canSplit < $i)
624 645
             {
625
-                if ($arguments[$i] == '\'' && !$split2)
626
-                    $split1 = !$split1;
627
-
628
-                elseif ($arguments[$i] == '"' && !$split1)
629
-                    $split2 = !$split2;
630
-
631
-                elseif (!$split1 && !$split2 && $arguments[$i] == ',')
646
+                if ($arguments[$i] == '\'' && !$split2) {
647
+                                    $split1 = !$split1;
648
+                } elseif ($arguments[$i] == '"' && !$split1) {
649
+                                    $split2 = !$split2;
650
+                } elseif (!$split1 && !$split2 && $arguments[$i] == ',')
632 651
                 {
633 652
                     $args[] = substr ($t, 0, -1);
634 653
                     $t = '';
Please login to merge, or discard this patch.