@@ -40,4 +40,4 @@ |
||
40 | 40 | unlink (__FILE__); |
41 | 41 | |
42 | 42 | echo ' Configuration completed'. PHP_EOL . |
43 | - ' Thank for installing KRypt0nn/VoidFramework!'. PHP_EOL . PHP_EOL; |
|
43 | + ' Thank for installing KRypt0nn/VoidFramework!'. PHP_EOL . PHP_EOL; |
@@ -1,43 +1,43 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -echo ' Configuring VoidFramework...'. PHP_EOL; |
|
3 | +echo ' Configuring VoidFramework...'.PHP_EOL; |
|
4 | 4 | |
5 | -function dir_copy (string $from, string $to): bool |
|
5 | +function dir_copy(string $from, string $to): bool |
|
6 | 6 | { |
7 | - if (!is_dir ($from)) |
|
7 | + if (!is_dir($from)) |
|
8 | 8 | return false; |
9 | 9 | |
10 | - if (!is_dir ($to)) |
|
11 | - dir_create ($to); |
|
10 | + if (!is_dir($to)) |
|
11 | + dir_create($to); |
|
12 | 12 | |
13 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
14 | - if (is_dir ($f = $from .'/'. $file)) |
|
15 | - dir_copy ($f, $to .'/'. $file); |
|
13 | + foreach (array_slice(scandir($from), 2) as $file) |
|
14 | + if (is_dir($f = $from.'/'.$file)) |
|
15 | + dir_copy($f, $to.'/'.$file); |
|
16 | 16 | |
17 | - else copy ($f, $to .'/'. $file); |
|
17 | + else copy($f, $to.'/'.$file); |
|
18 | 18 | |
19 | 19 | return true; |
20 | 20 | } |
21 | 21 | |
22 | -$info = file_exists (QERO_DIR .'/qero-info.json') ? |
|
23 | - json_decode (file_get_contents (QERO_DIR .'/qero-info.json'), true) : array (); |
|
22 | +$info = file_exists(QERO_DIR.'/qero-info.json') ? |
|
23 | + json_decode (file_get_contents(QERO_DIR.'/qero-info.json'), true) : array(); |
|
24 | 24 | |
25 | -$info['scripts']['start'] = '"qero-packages'. str_replace (dirname (__DIR__, 3), '', __DIR__) .'/core/VoidCore.exe" "app/start.php"'; |
|
25 | +$info['scripts']['start'] = '"qero-packages'.str_replace(dirname(__DIR__, 3), '', __DIR__).'/core/VoidCore.exe" "app/start.php"'; |
|
26 | 26 | |
27 | -file_put_contents (QERO_DIR .'/qero-info.json', json_encode ($info, defined ('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0)); |
|
28 | -file_put_contents (QERO_DIR .'/start.bat', '@echo off |
|
27 | +file_put_contents(QERO_DIR.'/qero-info.json', json_encode($info, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0)); |
|
28 | +file_put_contents(QERO_DIR.'/start.bat', '@echo off |
|
29 | 29 | '. $info['scripts']['start']); |
30 | 30 | |
31 | -if (!is_dir (QERO_DIR .'/app')) |
|
31 | +if (!is_dir(QERO_DIR.'/app')) |
|
32 | 32 | { |
33 | - echo ' Configuring application...'. PHP_EOL; |
|
33 | + echo ' Configuring application...'.PHP_EOL; |
|
34 | 34 | |
35 | - mkdir (QERO_DIR .'/app'); |
|
36 | - dir_copy (__DIR__ .'/app_bundle', QERO_DIR .'/app'); |
|
35 | + mkdir(QERO_DIR.'/app'); |
|
36 | + dir_copy(__DIR__.'/app_bundle', QERO_DIR.'/app'); |
|
37 | 37 | } |
38 | 38 | |
39 | -Qero\dir_delete (__DIR__ .'/app_bundle'); |
|
40 | -unlink (__FILE__); |
|
39 | +Qero\dir_delete(__DIR__.'/app_bundle'); |
|
40 | +unlink(__FILE__); |
|
41 | 41 | |
42 | -echo ' Configuration completed'. PHP_EOL . |
|
43 | - ' Thank for installing KRypt0nn/VoidFramework!'. PHP_EOL . PHP_EOL; |
|
42 | +echo ' Configuration completed'.PHP_EOL. |
|
43 | + ' Thank for installing KRypt0nn/VoidFramework!'.PHP_EOL.PHP_EOL; |
@@ -4,17 +4,22 @@ |
||
4 | 4 | |
5 | 5 | function dir_copy (string $from, string $to): bool |
6 | 6 | { |
7 | - if (!is_dir ($from)) |
|
8 | - return false; |
|
7 | + if (!is_dir ($from)) { |
|
8 | + return false; |
|
9 | + } |
|
9 | 10 | |
10 | - if (!is_dir ($to)) |
|
11 | - dir_create ($to); |
|
11 | + if (!is_dir ($to)) { |
|
12 | + dir_create ($to); |
|
13 | + } |
|
12 | 14 | |
13 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
14 | - if (is_dir ($f = $from .'/'. $file)) |
|
15 | + foreach (array_slice (scandir ($from), 2) as $file) { |
|
16 | + if (is_dir ($f = $from .'/'. $file)) |
|
15 | 17 | dir_copy ($f, $to .'/'. $file); |
18 | + } |
|
16 | 19 | |
17 | - else copy ($f, $to .'/'. $file); |
|
20 | + else { |
|
21 | + copy ($f, $to .'/'. $file); |
|
22 | + } |
|
18 | 23 | |
19 | 24 | return true; |
20 | 25 | } |
@@ -8,12 +8,12 @@ |
||
8 | 8 | $package = json_decode (@file_get_contents (dirname (__DIR__) .'/qero-packages/packages.json'), true); |
9 | 9 | |
10 | 10 | define ('VoidEngine\CORE_DIR', isset ($package['github:KRypt0nn/VoidFramework']['basefolder']) ? |
11 | - dirname (__DIR__) .'/qero-packages/KRypt0nn/VoidFramework/'. $package['github:KRypt0nn/VoidFramework']['basefolder'] .'/core' : __DIR__); |
|
11 | + dirname (__DIR__) .'/qero-packages/KRypt0nn/VoidFramework/'. $package['github:KRypt0nn/VoidFramework']['basefolder'] .'/core' : __DIR__); |
|
12 | 12 | |
13 | 13 | # Подгружаем PHP расширения |
14 | 14 | foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext) |
15 | - if (!extension_loaded ($ext = substr (basename ($ext), 4, -4))) |
|
16 | - dl ($ext); |
|
15 | + if (!extension_loaded ($ext = substr (basename ($ext), 4, -4))) |
|
16 | + dl ($ext); |
|
17 | 17 | |
18 | 18 | # Подгружаем Qero-пакеты |
19 | 19 | require __DIR__ .'/../qero-packages/autoload.php'; |
@@ -3,25 +3,25 @@ discard block |
||
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | 5 | # Объявление констант |
6 | -const APP_DIR = __DIR__; |
|
6 | +const APP_DIR = __DIR__; |
|
7 | 7 | |
8 | -$package = json_decode (@file_get_contents (dirname (__DIR__) .'/qero-packages/packages.json'), true); |
|
8 | +$package = json_decode(@file_get_contents(dirname(__DIR__).'/qero-packages/packages.json'), true); |
|
9 | 9 | |
10 | -define ('VoidEngine\CORE_DIR', isset ($package['github:KRypt0nn/VoidFramework']['basefolder']) ? |
|
11 | - dirname (__DIR__) .'/qero-packages/KRypt0nn/VoidFramework/'. $package['github:KRypt0nn/VoidFramework']['basefolder'] .'/core' : __DIR__); |
|
10 | +define('VoidEngine\CORE_DIR', isset ($package['github:KRypt0nn/VoidFramework']['basefolder']) ? |
|
11 | + dirname (__DIR__).'/qero-packages/KRypt0nn/VoidFramework/'.$package['github:KRypt0nn/VoidFramework']['basefolder'].'/core' : __DIR__); |
|
12 | 12 | |
13 | 13 | # Подгружаем PHP расширения |
14 | -foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext) |
|
15 | - if (!extension_loaded ($ext = substr (basename ($ext), 4, -4))) |
|
16 | - dl ($ext); |
|
14 | +foreach (glob(CORE_DIR.'/ext/php_*.dll') as $ext) |
|
15 | + if (!extension_loaded($ext = substr(basename($ext), 4, -4))) |
|
16 | + dl($ext); |
|
17 | 17 | |
18 | 18 | # Подгружаем Qero-пакеты |
19 | -require __DIR__ .'/../qero-packages/autoload.php'; |
|
19 | +require __DIR__.'/../qero-packages/autoload.php'; |
|
20 | 20 | |
21 | -chdir (APP_DIR); // Меняем стандартную директорию на директорию приложения |
|
21 | +chdir(APP_DIR); // Меняем стандартную директорию на директорию приложения |
|
22 | 22 | |
23 | 23 | # Парсим app.vlf |
24 | -$parser = new VLFParser (__DIR__. '/app.vlf', [ |
|
24 | +$parser = new VLFParser(__DIR__.'/app.vlf', [ |
|
25 | 25 | 'strong_line_parser' => false, |
26 | 26 | 'ignore_postobject_info' => true, |
27 | 27 | 'ignore_unexpected_method_args' => true, |
@@ -31,5 +31,5 @@ discard block |
||
31 | 31 | ]); |
32 | 32 | |
33 | 33 | # Запускаем приложение |
34 | -$objects = VLFInterpreter::run ($parser); |
|
35 | -$APPLICATION->run ($objects['MainForm']); |
|
34 | +$objects = VLFInterpreter::run($parser); |
|
35 | +$APPLICATION->run($objects['MainForm']); |
@@ -11,9 +11,10 @@ |
||
11 | 11 | dirname (__DIR__) .'/qero-packages/KRypt0nn/VoidFramework/'. $package['github:KRypt0nn/VoidFramework']['basefolder'] .'/core' : __DIR__); |
12 | 12 | |
13 | 13 | # Подгружаем PHP расширения |
14 | -foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext) |
|
14 | +foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext) { |
|
15 | 15 | if (!extension_loaded ($ext = substr (basename ($ext), 4, -4))) |
16 | 16 | dl ($ext); |
17 | +} |
|
17 | 18 | |
18 | 19 | # Подгружаем Qero-пакеты |
19 | 20 | require __DIR__ .'/../qero-packages/autoload.php'; |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | const ENGINE_VERSION = '3.2.5 build-2019/07/30'; |
33 | 33 | const ENGINE_DIR = __DIR__; |
34 | 34 | |
35 | -chdir (ENGINE_DIR); |
|
35 | +chdir(ENGINE_DIR); |
|
36 | 36 | |
37 | 37 | $GLOBALS['error_status'] = true; |
38 | 38 | |
39 | 39 | $GLOBALS['__debug'] = [ |
40 | - 'start_time' => microtime (true) |
|
40 | + 'start_time' => microtime(true) |
|
41 | 41 | ]; |
42 | 42 | |
43 | -$GLOBALS['__ub_write_handler'] = function (...$args) |
|
43 | +$GLOBALS['__ub_write_handler'] = function(...$args) |
|
44 | 44 | { |
45 | - pre (...$args); |
|
45 | + pre(...$args); |
|
46 | 46 | }; |
47 | 47 | |
48 | 48 | require 'common/EngineInterfaces.php'; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | require 'components/Designer.php'; |
102 | 102 | require 'components/EventGrid.php'; |
103 | 103 | |
104 | -if (is_dir ('extensions')) |
|
105 | - foreach (scandir ('extensions') as $ext) |
|
106 | - if (is_dir ('extensions/'. $ext) && file_exists ($ext = 'extensions/'. $ext .'/main.php')) |
|
104 | +if (is_dir('extensions')) |
|
105 | + foreach (scandir('extensions') as $ext) |
|
106 | + if (is_dir('extensions/'.$ext) && file_exists($ext = 'extensions/'.$ext.'/main.php')) |
|
107 | 107 | require $ext; |
@@ -101,7 +101,8 @@ |
||
101 | 101 | require 'components/Designer.php'; |
102 | 102 | require 'components/EventGrid.php'; |
103 | 103 | |
104 | -if (is_dir ('extensions')) |
|
104 | +if (is_dir ('extensions')) { |
|
105 | 105 | foreach (scandir ('extensions') as $ext) |
106 | 106 | if (is_dir ('extensions/'. $ext) && file_exists ($ext = 'extensions/'. $ext .'/main.php')) |
107 | 107 | require $ext; |
108 | +} |
@@ -42,7 +42,7 @@ |
||
42 | 42 | public $name; // Имя объекта |
43 | 43 | public $link; // АСД-ссылка на объект |
44 | 44 | |
45 | - public function __construct (string $name, int $link) |
|
45 | + public function __construct(string $name, int $link) |
|
46 | 46 | { |
47 | 47 | $this->name = $name; |
48 | 48 | $this->link = $link; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | class VLFImporter |
6 | 6 | { |
7 | - static function import (string $vlf, PropertyGrid $propertyGrid, ListBox $eventsList, ComboBox $currentSelectedItem, TabControl $formsList, array $settings = array ( |
|
7 | + static function import(string $vlf, PropertyGrid $propertyGrid, ListBox $eventsList, ComboBox $currentSelectedItem, TabControl $formsList, array $settings = array( |
|
8 | 8 | 'strong_line_parser' => false, |
9 | 9 | 'ignore_postobject_info' => true, |
10 | 10 | 'ignore_unexpected_method_args' => true, |
@@ -13,20 +13,20 @@ discard block |
||
13 | 13 | 'debug_mode' => false |
14 | 14 | )): array |
15 | 15 | { |
16 | - $objects = VLFInterpreter::run (new VLFParser ($vlf, $settings)); |
|
16 | + $objects = VLFInterpreter::run(new VLFParser($vlf, $settings)); |
|
17 | 17 | $designers = []; |
18 | 18 | |
19 | 19 | foreach ($objects as $name => $object) |
20 | 20 | if ($object instanceof Form) |
21 | 21 | { |
22 | - $page = new TabPage ($name); |
|
23 | - $designers[$object->selector] = new VoidDesigner ($page, $name, $propertyGrid, $eventsList, $currentSelectedItem, $formsList, $object); |
|
22 | + $page = new TabPage($name); |
|
23 | + $designers[$object->selector] = new VoidDesigner($page, $name, $propertyGrid, $eventsList, $currentSelectedItem, $formsList, $object); |
|
24 | 24 | |
25 | 25 | $designers[$object->selector]->form->text = $object->text; |
26 | 26 | |
27 | - VoidStudioAPI::addObjects ('main', ['Designer__'. $name .'Designer' => $designers[$object->selector]]); |
|
27 | + VoidStudioAPI::addObjects('main', ['Designer__'.$name.'Designer' => $designers[$object->selector]]); |
|
28 | 28 | |
29 | - $formsList->items->add ($page); |
|
29 | + $formsList->items->add($page); |
|
30 | 30 | $formsList->selectedTab = $page->selector; |
31 | 31 | } |
32 | 32 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $parent = $parent->parent; |
39 | 39 | |
40 | 40 | if (isset ($designers[$parent->selector])) |
41 | - $designers[$parent->selector]->addComponent ($object->selector, $name); |
|
41 | + $designers[$parent->selector]->addComponent($object->selector, $name); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | catch (\Throwable $e) {} |
@@ -16,10 +16,11 @@ discard block |
||
16 | 16 | $objects = VLFInterpreter::run (new VLFParser ($vlf, $settings)); |
17 | 17 | $designers = []; |
18 | 18 | |
19 | - foreach ($objects as $name => $object) |
|
20 | - if ($object instanceof Form) |
|
19 | + foreach ($objects as $name => $object) { |
|
20 | + if ($object instanceof Form) |
|
21 | 21 | { |
22 | 22 | $page = new TabPage ($name); |
23 | + } |
|
23 | 24 | $designers[$object->selector] = new VoidDesigner ($page, $name, $propertyGrid, $eventsList, $currentSelectedItem, $formsList, $object); |
24 | 25 | |
25 | 26 | $designers[$object->selector]->form->text = $object->text; |
@@ -28,20 +29,19 @@ discard block |
||
28 | 29 | |
29 | 30 | $formsList->items->add ($page); |
30 | 31 | $formsList->selectedTab = $page->selector; |
31 | - } |
|
32 | - |
|
33 | - elseif ($object instanceof Control) |
|
34 | - try |
|
32 | + } elseif ($object instanceof Control) { |
|
33 | + try |
|
35 | 34 | { |
36 | 35 | $parent = $object->parent; |
37 | - while (!isset ($designers[$parent->selector]) && $parent->parent) |
|
38 | - $parent = $parent->parent; |
|
39 | - |
|
40 | - if (isset ($designers[$parent->selector])) |
|
41 | - $designers[$parent->selector]->addComponent ($object->selector, $name); |
|
42 | - } |
|
43 | - |
|
44 | - catch (\Throwable $e) {} |
|
36 | + } |
|
37 | + while (!isset ($designers[$parent->selector]) && $parent->parent) { |
|
38 | + $parent = $parent->parent; |
|
39 | + } |
|
40 | + |
|
41 | + if (isset ($designers[$parent->selector])) { |
|
42 | + $designers[$parent->selector]->addComponent ($object->selector, $name); |
|
43 | + } |
|
44 | + } catch (\Throwable $e) {} |
|
45 | 45 | |
46 | 46 | return $designers; |
47 | 47 | } |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | * @return array - возвращает список созданных объектов |
21 | 21 | */ |
22 | 22 | |
23 | - public static function run ($syntaxTree, string $resourcesDir = null, array $parent = null): array |
|
23 | + public static function run($syntaxTree, string $resourcesDir = null, array $parent = null): array |
|
24 | 24 | { |
25 | 25 | if ($syntaxTree instanceof VLFParser) |
26 | 26 | $syntaxTree = $syntaxTree->tree; |
27 | 27 | |
28 | - elseif (!is_array ($syntaxTree) && self::$throw_errors) |
|
29 | - throw new \Exception ('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
28 | + elseif (!is_array($syntaxTree) && self::$throw_errors) |
|
29 | + throw new \Exception('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
30 | 30 | |
31 | 31 | foreach ($syntaxTree as $id => $syntaxInfo) |
32 | 32 | if (isset ($syntaxInfo['type'])) |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | $args = $syntaxInfo['info']['arguments']; |
44 | 44 | |
45 | 45 | foreach ($args as $arg_id => $arg) |
46 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
46 | + if (is_object($arg) && $arg instanceof VLFLink) |
|
47 | 47 | $args[$arg_id] = isset (self::$objects[$arg->name]) ? |
48 | - self::formatLine ($arg->name, self::$objects) : null; |
|
48 | + self::formatLine($arg->name, self::$objects) : null; |
|
49 | 49 | |
50 | - else $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
50 | + else $args[$arg_id] = self::formatLine($arg, self::$objects); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | try |
54 | 54 | { |
55 | - self::$objects[$name] = eval ("namespace VoidEngine; return new $class (". implode (', ', $args) .");"); |
|
55 | + self::$objects[$name] = eval ("namespace VoidEngine; return new $class (".implode(', ', $args).");"); |
|
56 | 56 | |
57 | 57 | try |
58 | 58 | { |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | catch (\Throwable $e) |
66 | 66 | { |
67 | 67 | if (self::$throw_errors) |
68 | - throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
68 | + throw new \Exception('Interpeter couldn\'t create object "'.$class.'" with name "'.$name.'" at line "'.$syntaxInfo['line'].'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
69 | 69 | } |
70 | 70 | break; |
71 | 71 | |
72 | 72 | case VLF_SUBOBJECT_DEFINITION: |
73 | - self::$objects = self::run ((new VLFParser ($syntaxInfo['info']['object_vlf_info']))->tree, null, $syntaxInfo); |
|
73 | + self::$objects = self::run((new VLFParser($syntaxInfo['info']['object_vlf_info']))->tree, null, $syntaxInfo); |
|
74 | 74 | break; |
75 | 75 | |
76 | 76 | case VLF_PROPERTY_SET: |
@@ -80,34 +80,34 @@ discard block |
||
80 | 80 | $propertyValue = $syntaxInfo['info']['property_value']; |
81 | 81 | $preset = ''; |
82 | 82 | |
83 | - if (is_object ($propertyValue) && $propertyValue instanceof VLFLink) |
|
83 | + if (is_object($propertyValue) && $propertyValue instanceof VLFLink) |
|
84 | 84 | $propertyValue = isset (self::$objects[$propertyValue->name]) ? |
85 | - self::formatLine ($propertyValue->name, self::$objects) : null; |
|
85 | + self::formatLine($propertyValue->name, self::$objects) : null; |
|
86 | 86 | |
87 | - elseif (preg_match ('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
87 | + elseif (preg_match('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
88 | 88 | { |
89 | - $use = substr ($propertyValue, strpos ($propertyValue, 'use')); |
|
90 | - $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos); |
|
91 | - $use = explode (' ', $use); |
|
89 | + $use = substr($propertyValue, strpos($propertyValue, 'use')); |
|
90 | + $use = $ouse = substr($use, ($pos = strpos($use, '(') + 1), strpos($use, ')') - $pos); |
|
91 | + $use = explode(' ', $use); |
|
92 | 92 | |
93 | 93 | foreach ($use as $id => $useParam) |
94 | 94 | if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
95 | 95 | { |
96 | 96 | $fname = $use[$id + 1]; |
97 | 97 | |
98 | - if (substr ($fname, strlen ($fname) - 1) == ',') |
|
99 | - $fname = substr ($fname, 0, -1); |
|
98 | + if (substr($fname, strlen($fname) - 1) == ',') |
|
99 | + $fname = substr($fname, 0, -1); |
|
100 | 100 | |
101 | 101 | $preset .= "$fname = $useParam; "; |
102 | 102 | |
103 | 103 | unset ($use[$id]); |
104 | 104 | } |
105 | 105 | |
106 | - $preset = self::formatLine ($preset, self::$objects); |
|
107 | - $propertyValue = self::formatLine (str_replace ($ouse, join (' ', $use), $propertyValue), self::$objects); |
|
106 | + $preset = self::formatLine($preset, self::$objects); |
|
107 | + $propertyValue = self::formatLine(str_replace($ouse, join(' ', $use), $propertyValue), self::$objects); |
|
108 | 108 | } |
109 | 109 | |
110 | - else $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
110 | + else $propertyValue = self::formatLine($propertyValue, self::$objects); |
|
111 | 111 | |
112 | 112 | try |
113 | 113 | { |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | { |
121 | 121 | $propertyValue = $syntaxInfo['info']['property_raw_value']; |
122 | 122 | |
123 | - if (strpos ($propertyName, '->') !== false) |
|
124 | - eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';'); |
|
123 | + if (strpos($propertyName, '->') !== false) |
|
124 | + eval ('namespace VoidEngine; '.$preset.' _c('.self::$objects[$name]->selector.')->'.$propertyName.' = '.$propertyValue.';'); |
|
125 | 125 | |
126 | 126 | else self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
127 | 127 | } |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | catch (\Throwable $e) |
130 | 130 | { |
131 | 131 | if (self::$throw_errors) |
132 | - throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
132 | + throw new \Exception('Interpeter couldn\'t set property "'.$propertyName.'" with value "'.$propertyValue.'" at line "'.$syntaxInfo['line'].'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | 137 | elseif (self::$throw_errors) |
138 | - throw new \Exception ('Setting property to an non-object at line "'. $syntaxInfo['line']); |
|
138 | + throw new \Exception('Setting property to an non-object at line "'.$syntaxInfo['line']); |
|
139 | 139 | break; |
140 | 140 | |
141 | 141 | case VLF_METHOD_CALL: |
@@ -145,58 +145,58 @@ discard block |
||
145 | 145 | $methodArgs = $syntaxInfo['info']['method_arguments']; |
146 | 146 | |
147 | 147 | foreach ($methodArgs as $arg_id => $arg) |
148 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
148 | + if (is_object($arg) && $arg instanceof VLFLink) |
|
149 | 149 | $methodArgs[$arg_id] = isset (self::$objects[$arg->name]) ? |
150 | - self::formatLine ($arg->name, self::$objects) : null; |
|
150 | + self::formatLine($arg->name, self::$objects) : null; |
|
151 | 151 | |
152 | - else $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
152 | + else $methodArgs[$arg_id] = self::formatLine($arg, self::$objects); |
|
153 | 153 | |
154 | 154 | try |
155 | 155 | { |
156 | - if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
157 | - eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
156 | + if (strpos($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
157 | + eval ('namespace VoidEngine; _c('.self::$objects[$name]->selector.')->'.$methodName.' ('.implode(', ', $methodArgs).');'); |
|
158 | 158 | |
159 | - else self::$objects[$name]->$methodName (...$methodArgs); |
|
159 | + else self::$objects[$name]->$methodName(...$methodArgs); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | catch (\Throwable $e) |
163 | 163 | { |
164 | 164 | if (self::$throw_errors) |
165 | - throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
165 | + throw new \Exception('Interpeter couldn\'t call method "'.$methodName.'" with arguments '.json_encode($methodArgs).' at line "'.$syntaxInfo['line'].'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | 169 | elseif (self::$throw_errors) |
170 | - throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
170 | + throw new \Exception('Calling method to an non-object at line "'.$syntaxInfo['line'].'"'); |
|
171 | 171 | break; |
172 | 172 | |
173 | 173 | case VLF_RUNTIME_EXECUTABLE: |
174 | - eval (self::formatLine ($syntaxInfo['info']['code'], self::$objects)); |
|
174 | + eval (self::formatLine($syntaxInfo['info']['code'], self::$objects)); |
|
175 | 175 | break; |
176 | 176 | } |
177 | 177 | |
178 | - if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) |
|
179 | - self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
178 | + if (isset ($syntaxInfo['syntax_nodes']) && sizeof($syntaxInfo['syntax_nodes']) > 0) |
|
179 | + self::$objects = self::run($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
180 | 180 | } |
181 | 181 | |
182 | - else throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
182 | + else throw new \Exception('Catched unknown syntax node: "'.json_encode($syntaxInfo).'"'); |
|
183 | 183 | |
184 | - if (is_dir ($resourcesDir)) |
|
185 | - foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
184 | + if (is_dir($resourcesDir)) |
|
185 | + foreach (glob($resourcesDir.'/*.vrsf') as $id => $dir) |
|
186 | 186 | { |
187 | - $baseName = basenameNoExt ($dir); |
|
188 | - $info = explode ('.', $baseName); |
|
187 | + $baseName = basenameNoExt($dir); |
|
188 | + $info = explode('.', $baseName); |
|
189 | 189 | |
190 | 190 | if (isset (self::$objects[$info[0]])) |
191 | 191 | { |
192 | 192 | if (isset ($info[2])) |
193 | 193 | { |
194 | - $collection = VoidEngine::getProperty (self::$objects[$info[0]]->selector, $info[1]); |
|
194 | + $collection = VoidEngine::getProperty(self::$objects[$info[0]]->selector, $info[1]); |
|
195 | 195 | |
196 | - VoidEngine::callMethod ($collection, 'Add', [VoidEngine::importObject (base64_encode (file_get_contents ($dir))), 'object']); |
|
196 | + VoidEngine::callMethod($collection, 'Add', [VoidEngine::importObject(base64_encode(file_get_contents($dir))), 'object']); |
|
197 | 197 | } |
198 | 198 | |
199 | - else VoidEngine::setProperty (self::$objects[$info[0]]->selector, $info[1], VoidEngine::importObject (base64_encode (file_get_contents ($dir)))); |
|
199 | + else VoidEngine::setProperty(self::$objects[$info[0]]->selector, $info[1], VoidEngine::importObject(base64_encode(file_get_contents($dir)))); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
@@ -213,26 +213,25 @@ discard block |
||
213 | 213 | * @return string - возвращает форматированную строку |
214 | 214 | */ |
215 | 215 | |
216 | - public static function formatLine (string $line, array $objects = []): string |
|
216 | + public static function formatLine(string $line, array $objects = []): string |
|
217 | 217 | { |
218 | - if (sizeof ($objects) > 0) |
|
218 | + if (sizeof($objects) > 0) |
|
219 | 219 | { |
220 | - $len = strlen ($line); |
|
220 | + $len = strlen($line); |
|
221 | 221 | $newLine = ''; |
222 | 222 | |
223 | - $replacement = array_map (function ($object) |
|
223 | + $replacement = array_map(function($object) |
|
224 | 224 | { |
225 | - return Components::componentExists ($object->selector) !== false ? |
|
226 | - '\VoidEngine\_c('. $object->selector .')' : |
|
227 | - 'unserialize (\''. serialize ($object) .'\')'; |
|
225 | + return Components::componentExists($object->selector) !== false ? |
|
226 | + '\VoidEngine\_c('.$object->selector.')' : 'unserialize (\''.serialize($object).'\')'; |
|
228 | 227 | }, $objects); |
229 | 228 | |
230 | - $replacement = array_map (function ($name) |
|
229 | + $replacement = array_map(function($name) |
|
231 | 230 | { |
232 | - return strlen ($name = trim ($name)) + substr_count ($name, '_'); |
|
233 | - }, $omap = array_flip ($replacement)); |
|
231 | + return strlen($name = trim($name)) + substr_count($name, '_'); |
|
232 | + }, $omap = array_flip($replacement)); |
|
234 | 233 | |
235 | - arsort ($replacement); |
|
234 | + arsort($replacement); |
|
236 | 235 | |
237 | 236 | $nReplacement = []; |
238 | 237 | |
@@ -240,14 +239,14 @@ discard block |
||
240 | 239 | $nReplacement[$omap[$replaceTo]] = $replaceTo; |
241 | 240 | |
242 | 241 | $replacement = $nReplacement; |
243 | - $blacklist = array_flip (['\'', '"', '$']); |
|
242 | + $blacklist = array_flip(['\'', '"', '$']); |
|
244 | 243 | |
245 | 244 | for ($i = 0; $i < $len; ++$i) |
246 | 245 | { |
247 | 246 | $replaced = false; |
248 | 247 | |
249 | 248 | foreach ($replacement as $name => $replaceAt) |
250 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
249 | + if (substr($line, $i, ($l = strlen($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
251 | 250 | { |
252 | 251 | $newLine .= $replaceAt; |
253 | 252 |
@@ -22,19 +22,20 @@ discard block |
||
22 | 22 | |
23 | 23 | public static function run ($syntaxTree, string $resourcesDir = null, array $parent = null): array |
24 | 24 | { |
25 | - if ($syntaxTree instanceof VLFParser) |
|
26 | - $syntaxTree = $syntaxTree->tree; |
|
27 | - |
|
28 | - elseif (!is_array ($syntaxTree) && self::$throw_errors) |
|
29 | - throw new \Exception ('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
25 | + if ($syntaxTree instanceof VLFParser) { |
|
26 | + $syntaxTree = $syntaxTree->tree; |
|
27 | + } elseif (!is_array ($syntaxTree) && self::$throw_errors) { |
|
28 | + throw new \Exception ('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
29 | + } |
|
30 | 30 | |
31 | - foreach ($syntaxTree as $id => $syntaxInfo) |
|
32 | - if (isset ($syntaxInfo['type'])) |
|
31 | + foreach ($syntaxTree as $id => $syntaxInfo) { |
|
32 | + if (isset ($syntaxInfo['type'])) |
|
33 | 33 | { |
34 | 34 | switch ($syntaxInfo['type']) |
35 | 35 | { |
36 | 36 | case VLF_OBJECT_DEFINITION: |
37 | 37 | $class = $syntaxInfo['info']['object_class']; |
38 | + } |
|
38 | 39 | $name = $syntaxInfo['info']['object_name']; |
39 | 40 | $args = []; |
40 | 41 | |
@@ -42,12 +43,15 @@ discard block |
||
42 | 43 | { |
43 | 44 | $args = $syntaxInfo['info']['arguments']; |
44 | 45 | |
45 | - foreach ($args as $arg_id => $arg) |
|
46 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
46 | + foreach ($args as $arg_id => $arg) { |
|
47 | + if (is_object ($arg) && $arg instanceof VLFLink) |
|
47 | 48 | $args[$arg_id] = isset (self::$objects[$arg->name]) ? |
48 | 49 | self::formatLine ($arg->name, self::$objects) : null; |
50 | + } |
|
49 | 51 | |
50 | - else $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
52 | + else { |
|
53 | + $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
54 | + } |
|
51 | 55 | } |
52 | 56 | |
53 | 57 | try |
@@ -57,15 +61,12 @@ discard block |
||
57 | 61 | try |
58 | 62 | { |
59 | 63 | self::$objects[$name]->name = $name; |
60 | - } |
|
61 | - |
|
62 | - catch (\Throwable $e) {} |
|
63 | - } |
|
64 | - |
|
65 | - catch (\Throwable $e) |
|
64 | + } catch (\Throwable $e) {} |
|
65 | + } catch (\Throwable $e) |
|
66 | 66 | { |
67 | - if (self::$throw_errors) |
|
68 | - throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
67 | + if (self::$throw_errors) { |
|
68 | + throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
69 | + } |
|
69 | 70 | } |
70 | 71 | break; |
71 | 72 | |
@@ -80,23 +81,24 @@ discard block |
||
80 | 81 | $propertyValue = $syntaxInfo['info']['property_value']; |
81 | 82 | $preset = ''; |
82 | 83 | |
83 | - if (is_object ($propertyValue) && $propertyValue instanceof VLFLink) |
|
84 | - $propertyValue = isset (self::$objects[$propertyValue->name]) ? |
|
84 | + if (is_object ($propertyValue) && $propertyValue instanceof VLFLink) { |
|
85 | + $propertyValue = isset (self::$objects[$propertyValue->name]) ? |
|
85 | 86 | self::formatLine ($propertyValue->name, self::$objects) : null; |
86 | - |
|
87 | - elseif (preg_match ('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
87 | + } elseif (preg_match ('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
88 | 88 | { |
89 | 89 | $use = substr ($propertyValue, strpos ($propertyValue, 'use')); |
90 | 90 | $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos); |
91 | 91 | $use = explode (' ', $use); |
92 | 92 | |
93 | - foreach ($use as $id => $useParam) |
|
94 | - if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
|
93 | + foreach ($use as $id => $useParam) { |
|
94 | + if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
|
95 | 95 | { |
96 | 96 | $fname = $use[$id + 1]; |
97 | + } |
|
97 | 98 | |
98 | - if (substr ($fname, strlen ($fname) - 1) == ',') |
|
99 | - $fname = substr ($fname, 0, -1); |
|
99 | + if (substr ($fname, strlen ($fname) - 1) == ',') { |
|
100 | + $fname = substr ($fname, 0, -1); |
|
101 | + } |
|
100 | 102 | |
101 | 103 | $preset .= "$fname = $useParam; "; |
102 | 104 | |
@@ -105,37 +107,34 @@ discard block |
||
105 | 107 | |
106 | 108 | $preset = self::formatLine ($preset, self::$objects); |
107 | 109 | $propertyValue = self::formatLine (str_replace ($ouse, join (' ', $use), $propertyValue), self::$objects); |
110 | + } else { |
|
111 | + $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
108 | 112 | } |
109 | 113 | |
110 | - else $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
111 | - |
|
112 | 114 | try |
113 | 115 | { |
114 | 116 | self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
115 | - } |
|
116 | - |
|
117 | - catch (\Throwable $e) |
|
117 | + } catch (\Throwable $e) |
|
118 | 118 | { |
119 | 119 | try |
120 | 120 | { |
121 | 121 | $propertyValue = $syntaxInfo['info']['property_raw_value']; |
122 | 122 | |
123 | - if (strpos ($propertyName, '->') !== false) |
|
124 | - eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';'); |
|
125 | - |
|
126 | - else self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
|
127 | - } |
|
128 | - |
|
129 | - catch (\Throwable $e) |
|
123 | + if (strpos ($propertyName, '->') !== false) { |
|
124 | + eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';'); |
|
125 | + } else { |
|
126 | + self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
|
127 | + } |
|
128 | + } catch (\Throwable $e) |
|
130 | 129 | { |
131 | - if (self::$throw_errors) |
|
132 | - throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
130 | + if (self::$throw_errors) { |
|
131 | + throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
132 | + } |
|
133 | 133 | } |
134 | 134 | } |
135 | + } elseif (self::$throw_errors) { |
|
136 | + throw new \Exception ('Setting property to an non-object at line "'. $syntaxInfo['line']); |
|
135 | 137 | } |
136 | - |
|
137 | - elseif (self::$throw_errors) |
|
138 | - throw new \Exception ('Setting property to an non-object at line "'. $syntaxInfo['line']); |
|
139 | 138 | break; |
140 | 139 | |
141 | 140 | case VLF_METHOD_CALL: |
@@ -144,30 +143,32 @@ discard block |
||
144 | 143 | $methodName = $syntaxInfo['info']['method_name']; |
145 | 144 | $methodArgs = $syntaxInfo['info']['method_arguments']; |
146 | 145 | |
147 | - foreach ($methodArgs as $arg_id => $arg) |
|
148 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
146 | + foreach ($methodArgs as $arg_id => $arg) { |
|
147 | + if (is_object ($arg) && $arg instanceof VLFLink) |
|
149 | 148 | $methodArgs[$arg_id] = isset (self::$objects[$arg->name]) ? |
150 | 149 | self::formatLine ($arg->name, self::$objects) : null; |
150 | + } |
|
151 | 151 | |
152 | - else $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
152 | + else { |
|
153 | + $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
154 | + } |
|
153 | 155 | |
154 | 156 | try |
155 | 157 | { |
156 | - if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
157 | - eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
158 | - |
|
159 | - else self::$objects[$name]->$methodName (...$methodArgs); |
|
160 | - } |
|
161 | - |
|
162 | - catch (\Throwable $e) |
|
158 | + if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) { |
|
159 | + eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
160 | + } else { |
|
161 | + self::$objects[$name]->$methodName (...$methodArgs); |
|
162 | + } |
|
163 | + } catch (\Throwable $e) |
|
163 | 164 | { |
164 | - if (self::$throw_errors) |
|
165 | - throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
165 | + if (self::$throw_errors) { |
|
166 | + throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
167 | + } |
|
166 | 168 | } |
169 | + } elseif (self::$throw_errors) { |
|
170 | + throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
167 | 171 | } |
168 | - |
|
169 | - elseif (self::$throw_errors) |
|
170 | - throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
171 | 172 | break; |
172 | 173 | |
173 | 174 | case VLF_RUNTIME_EXECUTABLE: |
@@ -175,16 +176,18 @@ discard block |
||
175 | 176 | break; |
176 | 177 | } |
177 | 178 | |
178 | - if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) |
|
179 | - self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
179 | + if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) { |
|
180 | + self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
181 | + } |
|
182 | + } else { |
|
183 | + throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
180 | 184 | } |
181 | 185 | |
182 | - else throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
183 | - |
|
184 | - if (is_dir ($resourcesDir)) |
|
185 | - foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
186 | + if (is_dir ($resourcesDir)) { |
|
187 | + foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
186 | 188 | { |
187 | 189 | $baseName = basenameNoExt ($dir); |
190 | + } |
|
188 | 191 | $info = explode ('.', $baseName); |
189 | 192 | |
190 | 193 | if (isset (self::$objects[$info[0]])) |
@@ -194,9 +197,9 @@ discard block |
||
194 | 197 | $collection = VoidEngine::getProperty (self::$objects[$info[0]]->selector, $info[1]); |
195 | 198 | |
196 | 199 | VoidEngine::callMethod ($collection, 'Add', [VoidEngine::importObject (base64_encode (file_get_contents ($dir))), 'object']); |
200 | + } else { |
|
201 | + VoidEngine::setProperty (self::$objects[$info[0]]->selector, $info[1], VoidEngine::importObject (base64_encode (file_get_contents ($dir)))); |
|
197 | 202 | } |
198 | - |
|
199 | - else VoidEngine::setProperty (self::$objects[$info[0]]->selector, $info[1], VoidEngine::importObject (base64_encode (file_get_contents ($dir)))); |
|
200 | 203 | } |
201 | 204 | } |
202 | 205 | |
@@ -236,8 +239,9 @@ discard block |
||
236 | 239 | |
237 | 240 | $nReplacement = []; |
238 | 241 | |
239 | - foreach ($replacement as $replaceTo => $nLn) |
|
240 | - $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
242 | + foreach ($replacement as $replaceTo => $nLn) { |
|
243 | + $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
244 | + } |
|
241 | 245 | |
242 | 246 | $replacement = $nReplacement; |
243 | 247 | $blacklist = array_flip (['\'', '"', '$']); |
@@ -246,10 +250,11 @@ discard block |
||
246 | 250 | { |
247 | 251 | $replaced = false; |
248 | 252 | |
249 | - foreach ($replacement as $name => $replaceAt) |
|
250 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
253 | + foreach ($replacement as $name => $replaceAt) { |
|
254 | + if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
251 | 255 | { |
252 | 256 | $newLine .= $replaceAt; |
257 | + } |
|
253 | 258 | |
254 | 259 | $i += $l - 1; |
255 | 260 | $replaced = true; |
@@ -257,8 +262,9 @@ discard block |
||
257 | 262 | break; |
258 | 263 | } |
259 | 264 | |
260 | - if (!$replaced) |
|
261 | - $newLine .= $line[$i]; |
|
265 | + if (!$replaced) { |
|
266 | + $newLine .= $line[$i]; |
|
267 | + } |
|
262 | 268 | } |
263 | 269 | |
264 | 270 | $line = $newLine; |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | * АААААААААААААААААААААААА |
32 | 32 | */ |
33 | 33 | |
34 | - public function __construct (string $content, array $settings = []) |
|
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 | // ДА БАГ ЭТО, НЕ ПИ%ДИ!!! И Я ПОНЯТИЯ НЕ ИМЕЮ КАК И ПОЧЕМУ!!! |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | if (isset ($this->$name)) |
46 | 46 | $this->$name = $setting; |
47 | 47 | |
48 | - else throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
48 | + else throw new \Exception('Trying to setting up undefined property "'.$name.'"'); |
|
49 | 49 | } |
50 | 50 | |
51 | - if ($this->use_caching && file_exists ($file = text (VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache'))) |
|
51 | + if ($this->use_caching && file_exists($file = text(VLF_EXT_DIR.'/cache/'.sha1($content).'.cache'))) |
|
52 | 52 | { |
53 | - $info = unserialize (gzinflate (file_get_contents ($file))); |
|
53 | + $info = unserialize(gzinflate(file_get_contents($file))); |
|
54 | 54 | |
55 | - if ($info[0] == sha1 (file_get_contents (text (__FILE__)))) |
|
55 | + if ($info[0] == sha1(file_get_contents(text(__FILE__)))) |
|
56 | 56 | { |
57 | 57 | $this->tree = $info[1][0]; |
58 | 58 | $this->links = $info[1][1]; |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | - else unlink ($file); |
|
63 | + else unlink($file); |
|
64 | 64 | } |
65 | 65 | |
66 | - $info = $this->generateSyntaxTree ($content); |
|
66 | + $info = $this->generateSyntaxTree($content); |
|
67 | 67 | |
68 | 68 | $this->tree = $info[0]; |
69 | 69 | $this->links = $info[1]; |
70 | 70 | |
71 | 71 | if ($this->use_caching) |
72 | 72 | { |
73 | - if (!is_dir (dirname (__DIR__) .'/cache')) |
|
74 | - mkdir (dirname (__DIR__) .'/cache'); |
|
73 | + if (!is_dir(dirname(__DIR__).'/cache')) |
|
74 | + mkdir(dirname(__DIR__).'/cache'); |
|
75 | 75 | |
76 | - file_put_contents (text (VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache'), gzdeflate (serialize ([sha1 (file_get_contents (text (__FILE__))), $info]))); |
|
76 | + file_put_contents(text(VLF_EXT_DIR.'/cache/'.sha1($content).'.cache'), gzdeflate(serialize([sha1(file_get_contents(text(__FILE__))), $info]))); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return array - возвращает АСД |
87 | 87 | */ |
88 | - protected function generateSyntaxTree (string $content): array |
|
88 | + protected function generateSyntaxTree(string $content): array |
|
89 | 89 | { |
90 | - $lines = $this->linesFilter ($untouched_lines = explode ($this->divider, $content)); |
|
90 | + $lines = $this->linesFilter($untouched_lines = explode($this->divider, $content)); |
|
91 | 91 | $current_object = null; |
92 | 92 | $parent_objects = []; |
93 | 93 | $skip_at = -1; |
@@ -95,18 +95,18 @@ discard block |
||
95 | 95 | $links = []; |
96 | 96 | |
97 | 97 | if ($this->debug_mode) |
98 | - pre ($lines); |
|
98 | + pre($lines); |
|
99 | 99 | |
100 | 100 | foreach ($lines as $id => $line) |
101 | 101 | { |
102 | 102 | if ($skip_at > $id) |
103 | 103 | continue; |
104 | 104 | |
105 | - $height = $this->getLineHeight ($line); |
|
106 | - $words = $this->linesFilter (explode (' ', $line)); |
|
105 | + $height = $this->getLineHeight($line); |
|
106 | + $words = $this->linesFilter(explode(' ', $line)); |
|
107 | 107 | |
108 | 108 | if ($this->debug_mode) |
109 | - pre ($words); |
|
109 | + pre($words); |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Высокоинтеллектуальный фикс |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $updated = false; |
129 | 129 | |
130 | 130 | if ($this->debug_mode) |
131 | - pre ($current_object); |
|
131 | + pre($current_object); |
|
132 | 132 | |
133 | 133 | while (isset ($tree[$current_object]['info']['subparent_link']) && $tree[$link = $tree[$current_object]['info']['subparent_link']->link]['hard'] < $tree[$current_object]['hard']) |
134 | 134 | { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $updated = true; |
137 | 137 | |
138 | 138 | if ($this->debug_mode) |
139 | - pre ($current_object); |
|
139 | + pre($current_object); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if ( |
@@ -151,16 +151,16 @@ discard block |
||
151 | 151 | break; |
152 | 152 | |
153 | 153 | if ($this->debug_mode) |
154 | - pre ($current_object); |
|
154 | + pre($current_object); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Button ... |
159 | 159 | */ |
160 | - if (class_exists ($words[0]) || class_exists ('\VoidEngine\\'. $words[0])) |
|
160 | + if (class_exists($words[0]) || class_exists('\VoidEngine\\'.$words[0])) |
|
161 | 161 | { |
162 | 162 | if (!isset ($words[1])) |
163 | - throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
163 | + throw new \Exception('Object name mustn\'t be empty at line "'.$line.'"'); |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Button NewButton |
@@ -206,39 +206,38 @@ discard block |
||
206 | 206 | 'syntax_nodes' => [] |
207 | 207 | ]; |
208 | 208 | |
209 | - if (($begin = strpos ($line, '(')) !== false) |
|
209 | + if (($begin = strpos($line, '(')) !== false) |
|
210 | 210 | { |
211 | 211 | ++$begin; |
212 | 212 | |
213 | - $end = strrpos ($line, ')'); |
|
213 | + $end = strrpos($line, ')'); |
|
214 | 214 | |
215 | 215 | if ($end === false) |
216 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
216 | + throw new \Exception('Line "'.$line.'" have arguments list initialization, but not have list ending'); |
|
217 | 217 | |
218 | 218 | elseif ($begin < $end) |
219 | 219 | { |
220 | 220 | $arguments = []; |
221 | - $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
|
221 | + $parsed = explode(',', substr($line, $begin, $end - $begin)); |
|
222 | 222 | |
223 | 223 | foreach ($parsed as $argument_id => $argument) |
224 | 224 | { |
225 | - $argument = trim ($argument); |
|
225 | + $argument = trim($argument); |
|
226 | 226 | |
227 | - if (strlen ($argument) > 0) |
|
227 | + if (strlen($argument) > 0) |
|
228 | 228 | $arguments[] = isset ($links[$argument]) ? |
229 | - new VLFLink ($argument, $links[$argument]) : |
|
230 | - $argument; |
|
229 | + new VLFLink($argument, $links[$argument]) : $argument; |
|
231 | 230 | |
232 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
231 | + else throw new \Exception('Argument '.($argument_id + 1).' mustn\'t have zero length at line "'.$line.'"'); |
|
233 | 232 | } |
234 | 233 | |
235 | 234 | $tree[$id]['info']['arguments'] = $arguments; |
236 | 235 | |
237 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
238 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
236 | + if (!$this->ignore_postobject_info && trim(substr($line, $end)) > 0) |
|
237 | + throw new \Exception('You mustn\'t write any chars after arguments definition'); |
|
239 | 238 | } |
240 | 239 | |
241 | - $tree[$id]['info']['subparent_link'] = new VLFLink ($tree[$current_object]['info']['object_name'], $current_object); |
|
240 | + $tree[$id]['info']['subparent_link'] = new VLFLink($tree[$current_object]['info']['object_name'], $current_object); |
|
242 | 241 | } |
243 | 242 | |
244 | 243 | /** |
@@ -248,7 +247,7 @@ discard block |
||
248 | 247 | elseif ($current_object !== null && $tree[$current_object]['hard'] < $height) |
249 | 248 | { |
250 | 249 | $tree[$id]['info']['arguments'] = [ |
251 | - new VLFLink ($tree[$current_object]['info']['object_name'], $current_object) |
|
250 | + new VLFLink($tree[$current_object]['info']['object_name'], $current_object) |
|
252 | 251 | ]; |
253 | 252 | |
254 | 253 | $parent_objects[$id] = $current_object; |
@@ -295,17 +294,17 @@ discard block |
||
295 | 294 | { |
296 | 295 | if ($words[0][1] == '^') |
297 | 296 | { |
298 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
297 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
299 | 298 | |
300 | 299 | $comment .= $parsed[0]; |
301 | 300 | $skip_at = $parsed[1]; |
302 | 301 | } |
303 | 302 | |
304 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
303 | + else throw new \Exception('Unknown char founded after syntax-control symbol at line "'.$line.'"'); |
|
305 | 304 | } |
306 | 305 | |
307 | 306 | if ($this->debug_mode) |
308 | - pre ("Comment:\n\n$comment"); |
|
307 | + pre("Comment:\n\n$comment"); |
|
309 | 308 | } |
310 | 309 | |
311 | 310 | /** |
@@ -317,19 +316,19 @@ discard block |
||
317 | 316 | */ |
318 | 317 | elseif ($words[0][0] == '%') |
319 | 318 | { |
320 | - $code = substr ($line, strlen ($words[0])); |
|
319 | + $code = substr($line, strlen($words[0])); |
|
321 | 320 | |
322 | 321 | if (isset ($words[0][1])) |
323 | 322 | { |
324 | 323 | if ($words[0][1] == '^') |
325 | 324 | { |
326 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
325 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
327 | 326 | |
328 | 327 | $code .= $parsed[0]; |
329 | 328 | $skip_at = $parsed[1]; |
330 | 329 | } |
331 | 330 | |
332 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
331 | + else throw new \Exception('Unknown char founded after syntax-control symbol at line "'.$line.'"'); |
|
333 | 332 | } |
334 | 333 | |
335 | 334 | $tree[$id] = [ |
@@ -354,7 +353,7 @@ discard block |
||
354 | 353 | * Form MyForm |
355 | 354 | * Button MyButton |
356 | 355 | */ |
357 | - elseif (is_int ($current_object) && isset ($tree[$current_object]['hard'])) |
|
356 | + elseif (is_int($current_object) && isset ($tree[$current_object]['hard'])) |
|
358 | 357 | { |
359 | 358 | if ($height <= $tree[$current_object]['hard'] && isset ($parent_objects[$current_object])) |
360 | 359 | { |
@@ -380,16 +379,16 @@ discard block |
||
380 | 379 | /** |
381 | 380 | * property_name: property_value |
382 | 381 | */ |
383 | - $postChar = substr ($words[0], strlen ($words[0]) - 1); |
|
382 | + $postChar = substr($words[0], strlen($words[0]) - 1); |
|
384 | 383 | |
385 | 384 | if ($postChar == ':' || $postChar == '^') |
386 | 385 | { |
387 | 386 | if (!isset ($words[1])) |
388 | - throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
387 | + throw new \Exception('Property value mustn\'t be empty at line "'.$line.'"'); |
|
389 | 388 | |
390 | - $propertyName = substr ($words[0], 0, -1); |
|
391 | - $propertyValue = implode (' ', array_slice ($words, 1)); |
|
392 | - $propertyRawValue = ltrim (substr ($line, strlen ($words[0]))); |
|
389 | + $propertyName = substr($words[0], 0, -1); |
|
390 | + $propertyValue = implode(' ', array_slice($words, 1)); |
|
391 | + $propertyRawValue = ltrim(substr($line, strlen($words[0]))); |
|
393 | 392 | |
394 | 393 | /** |
395 | 394 | * property_name:^ property_value_1 |
@@ -397,10 +396,10 @@ discard block |
||
397 | 396 | */ |
398 | 397 | if ($postChar == '^') |
399 | 398 | { |
400 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
399 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
401 | 400 | |
402 | 401 | $skip_at = $parsed[1]; |
403 | - $propertyName = substr ($propertyName, 0, -1); |
|
402 | + $propertyName = substr($propertyName, 0, -1); |
|
404 | 403 | $propertyRawValue .= $parsed[0]; |
405 | 404 | $propertyValue = $propertyRawValue; |
406 | 405 | } |
@@ -421,7 +420,7 @@ discard block |
||
421 | 420 | ]; |
422 | 421 | |
423 | 422 | if (isset ($links[$info['info']['property_value']])) |
424 | - $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
423 | + $info['info']['property_value'] = new VLFLink($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
425 | 424 | |
426 | 425 | $tree[$current_object]['syntax_nodes'][] = $info; |
427 | 426 | } |
@@ -429,37 +428,36 @@ discard block |
||
429 | 428 | /** |
430 | 429 | * ->method_name ([method_arguments]) |
431 | 430 | */ |
432 | - elseif (substr ($words[0], 0, 2) == '->') |
|
431 | + elseif (substr($words[0], 0, 2) == '->') |
|
433 | 432 | { |
434 | 433 | $arguments = []; |
435 | 434 | |
436 | - if (($begin = strpos ($line, '(')) !== false) |
|
435 | + if (($begin = strpos($line, '(')) !== false) |
|
437 | 436 | { |
438 | 437 | ++$begin; |
439 | 438 | |
440 | - $end = strrpos ($line, ')'); |
|
439 | + $end = strrpos($line, ')'); |
|
441 | 440 | |
442 | 441 | if ($end === false) |
443 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
442 | + throw new \Exception('Line "'.$line.'" have arguments list initialization, but not have list ending'); |
|
444 | 443 | |
445 | 444 | elseif ($begin < $end) |
446 | 445 | { |
447 | - $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
|
446 | + $parsed = explode(',', substr($line, $begin, $end - $begin)); |
|
448 | 447 | |
449 | 448 | foreach ($parsed as $argument_id => $argument) |
450 | 449 | { |
451 | - $argument = trim ($argument); |
|
450 | + $argument = trim($argument); |
|
452 | 451 | |
453 | - if (strlen ($argument) > 0) |
|
452 | + if (strlen($argument) > 0) |
|
454 | 453 | $arguments[] = isset ($links[$argument]) ? |
455 | - new VLFLink ($argument, $links[$argument]) : |
|
456 | - $argument; |
|
454 | + new VLFLink($argument, $links[$argument]) : $argument; |
|
457 | 455 | |
458 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
456 | + else throw new \Exception('Argument '.($argument_id + 1).' mustn\'t have zero length at line "'.$line.'"'); |
|
459 | 457 | } |
460 | 458 | |
461 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
462 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
459 | + if (!$this->ignore_postobject_info && trim(substr($line, $end)) > 0) |
|
460 | + throw new \Exception('You mustn\'t write any chars after arguments definition'); |
|
463 | 461 | } |
464 | 462 | } |
465 | 463 | |
@@ -467,7 +465,7 @@ discard block |
||
467 | 465 | * ->show |
468 | 466 | */ |
469 | 467 | elseif (!$this->ignore_unexpected_method_args) |
470 | - throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
468 | + throw new \Exception('Unexpected method arguments list at line "'.$line.'"'); |
|
471 | 469 | |
472 | 470 | $tree[$current_object]['syntax_nodes'][] = [ |
473 | 471 | 'type' => VLF_METHOD_CALL, |
@@ -476,7 +474,7 @@ discard block |
||
476 | 474 | 'words' => $words, |
477 | 475 | |
478 | 476 | 'info' => [ |
479 | - 'method_name' => substr ($words[0], 2), |
|
477 | + 'method_name' => substr($words[0], 2), |
|
480 | 478 | 'method_arguments' => $arguments |
481 | 479 | ], |
482 | 480 | |
@@ -499,7 +497,7 @@ discard block |
||
499 | 497 | */ |
500 | 498 | else |
501 | 499 | { |
502 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
500 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
503 | 501 | $skip_at = $parsed[1]; |
504 | 502 | |
505 | 503 | $tree[$id] = [ |
@@ -509,7 +507,7 @@ discard block |
||
509 | 507 | 'words' => $words, |
510 | 508 | |
511 | 509 | 'info' => [ |
512 | - 'object_vlf_info' => $line ."\n". $parsed[0] |
|
510 | + 'object_vlf_info' => $line."\n".$parsed[0] |
|
513 | 511 | ], |
514 | 512 | |
515 | 513 | 'syntax_nodes' => [] |
@@ -520,7 +518,7 @@ discard block |
||
520 | 518 | /** |
521 | 519 | * Что-то загадочное, таинственное, неизвестное человечеству |
522 | 520 | */ |
523 | - else throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
521 | + else throw new \Exception('Unknown structures founded at line "'.$line.'"'); |
|
524 | 522 | } |
525 | 523 | |
526 | 524 | return [$tree, $links]; |
@@ -536,7 +534,7 @@ discard block |
||
536 | 534 | * |
537 | 535 | * @return array - возвращает спарсенные подстроки |
538 | 536 | */ |
539 | - protected function parseSubText (array $lines, $begin_id, int $down_height): array |
|
537 | + protected function parseSubText(array $lines, $begin_id, int $down_height): array |
|
540 | 538 | { |
541 | 539 | $parsed = "\n"; |
542 | 540 | |
@@ -545,17 +543,17 @@ discard block |
||
545 | 543 | if ($line_id <= $begin_id) |
546 | 544 | continue; |
547 | 545 | |
548 | - if (!(bool)(trim ($line))) |
|
546 | + if (!(bool) (trim($line))) |
|
549 | 547 | { |
550 | 548 | $parsed .= "\n"; |
551 | 549 | |
552 | 550 | continue; |
553 | 551 | } |
554 | 552 | |
555 | - $height = $this->getLineHeight ($line); |
|
553 | + $height = $this->getLineHeight($line); |
|
556 | 554 | |
557 | 555 | if ($this->debug_mode) |
558 | - pre ("$height, $down_height, $line"); |
|
556 | + pre("$height, $down_height, $line"); |
|
559 | 557 | |
560 | 558 | if ($height > $down_height) |
561 | 559 | $parsed .= "$line\n"; |
@@ -566,7 +564,7 @@ discard block |
||
566 | 564 | return [$parsed, $line_id]; |
567 | 565 | } |
568 | 566 | |
569 | - public function __get ($name) // Возвращалка переменных парсера |
|
567 | + public function __get($name) // Возвращалка переменных парсера |
|
570 | 568 | { |
571 | 569 | return isset ($this->$name) ? |
572 | 570 | $this->$name : false; |
@@ -580,14 +578,14 @@ discard block |
||
580 | 578 | * |
581 | 579 | * @return int - высота строки |
582 | 580 | */ |
583 | - protected function getLineHeight (string &$line): int |
|
581 | + protected function getLineHeight(string &$line): int |
|
584 | 582 | { |
585 | 583 | $i = 0; |
586 | 584 | |
587 | 585 | while (isset ($line[$i]) && $line[$i] == "\t") |
588 | 586 | ++$i; |
589 | 587 | |
590 | - return strlen ($line = str_repeat (' ', $i) . substr ($line, $i)) - strlen ($line = trim ($line)); |
|
588 | + return strlen($line = str_repeat(' ', $i).substr($line, $i)) - strlen($line = trim($line)); |
|
591 | 589 | } |
592 | 590 | |
593 | 591 | /** |
@@ -598,14 +596,14 @@ discard block |
||
598 | 596 | * |
599 | 597 | * @return array - возвращает очищенный массив |
600 | 598 | */ |
601 | - protected function linesFilter (array $segments): array |
|
599 | + protected function linesFilter(array $segments): array |
|
602 | 600 | { |
603 | - return array_filter ($segments, function ($text) |
|
601 | + return array_filter($segments, function($text) |
|
604 | 602 | { |
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'); |
|
603 | + if ($this->strong_line_parser && preg_match('/[^a-z0-9]/i', $text)) |
|
604 | + throw new \Exception('Line "'.$text.'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
607 | 605 | |
608 | - return strlen (trim ($text)) > 0; |
|
606 | + return strlen(trim($text)) > 0; |
|
609 | 607 | }); |
610 | 608 | } |
611 | 609 | } |
@@ -33,8 +33,9 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct (string $content, array $settings = []) |
35 | 35 | { |
36 | - if (file_exists ($content)) |
|
37 | - $content = file_get_contents ($content); |
|
36 | + if (file_exists ($content)) { |
|
37 | + $content = file_get_contents ($content); |
|
38 | + } |
|
38 | 39 | |
39 | 40 | // Зачем? Так надо! |
40 | 41 | // ДА БАГ ЭТО, НЕ ПИ%ДИ!!! И Я ПОНЯТИЯ НЕ ИМЕЮ КАК И ПОЧЕМУ!!! |
@@ -42,10 +43,11 @@ discard block |
||
42 | 43 | |
43 | 44 | foreach ($settings as $name => $setting) |
44 | 45 | { |
45 | - if (isset ($this->$name)) |
|
46 | - $this->$name = $setting; |
|
47 | - |
|
48 | - else throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
46 | + if (isset ($this->$name)) { |
|
47 | + $this->$name = $setting; |
|
48 | + } else { |
|
49 | + throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
50 | + } |
|
49 | 51 | } |
50 | 52 | |
51 | 53 | if ($this->use_caching && file_exists ($file = text (VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache'))) |
@@ -58,9 +60,9 @@ discard block |
||
58 | 60 | $this->links = $info[1][1]; |
59 | 61 | |
60 | 62 | return; |
63 | + } else { |
|
64 | + unlink ($file); |
|
61 | 65 | } |
62 | - |
|
63 | - else unlink ($file); |
|
64 | 66 | } |
65 | 67 | |
66 | 68 | $info = $this->generateSyntaxTree ($content); |
@@ -70,8 +72,9 @@ discard block |
||
70 | 72 | |
71 | 73 | if ($this->use_caching) |
72 | 74 | { |
73 | - if (!is_dir (dirname (__DIR__) .'/cache')) |
|
74 | - mkdir (dirname (__DIR__) .'/cache'); |
|
75 | + if (!is_dir (dirname (__DIR__) .'/cache')) { |
|
76 | + mkdir (dirname (__DIR__) .'/cache'); |
|
77 | + } |
|
75 | 78 | |
76 | 79 | file_put_contents (text (VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache'), gzdeflate (serialize ([sha1 (file_get_contents (text (__FILE__))), $info]))); |
77 | 80 | } |
@@ -94,19 +97,22 @@ discard block |
||
94 | 97 | $tree = []; |
95 | 98 | $links = []; |
96 | 99 | |
97 | - if ($this->debug_mode) |
|
98 | - pre ($lines); |
|
100 | + if ($this->debug_mode) { |
|
101 | + pre ($lines); |
|
102 | + } |
|
99 | 103 | |
100 | 104 | foreach ($lines as $id => $line) |
101 | 105 | { |
102 | - if ($skip_at > $id) |
|
103 | - continue; |
|
106 | + if ($skip_at > $id) { |
|
107 | + continue; |
|
108 | + } |
|
104 | 109 | |
105 | 110 | $height = $this->getLineHeight ($line); |
106 | 111 | $words = $this->linesFilter (explode (' ', $line)); |
107 | 112 | |
108 | - if ($this->debug_mode) |
|
109 | - pre ($words); |
|
113 | + if ($this->debug_mode) { |
|
114 | + pre ($words); |
|
115 | + } |
|
110 | 116 | |
111 | 117 | /** |
112 | 118 | * Высокоинтеллектуальный фикс |
@@ -127,16 +133,18 @@ discard block |
||
127 | 133 | { |
128 | 134 | $updated = false; |
129 | 135 | |
130 | - if ($this->debug_mode) |
|
131 | - pre ($current_object); |
|
136 | + if ($this->debug_mode) { |
|
137 | + pre ($current_object); |
|
138 | + } |
|
132 | 139 | |
133 | 140 | while (isset ($tree[$current_object]['info']['subparent_link']) && $tree[$link = $tree[$current_object]['info']['subparent_link']->link]['hard'] < $tree[$current_object]['hard']) |
134 | 141 | { |
135 | 142 | $current_object = $link; |
136 | 143 | $updated = true; |
137 | 144 | |
138 | - if ($this->debug_mode) |
|
139 | - pre ($current_object); |
|
145 | + if ($this->debug_mode) { |
|
146 | + pre ($current_object); |
|
147 | + } |
|
140 | 148 | } |
141 | 149 | |
142 | 150 | if ( |
@@ -145,13 +153,15 @@ discard block |
||
145 | 153 | isset ($tree[$current_object]['info']['arguments'][0]) && |
146 | 154 | $tree[$current_object]['info']['arguments'][0] instanceof VLFLink && |
147 | 155 | $tree[$tree[$current_object]['info']['arguments'][0]->link]['hard'] < $tree[$current_object]['hard'] |
148 | - ) $current_object = $tree[$current_object]['info']['arguments'][0]->link; |
|
149 | - |
|
150 | - elseif (!$updated) |
|
151 | - break; |
|
156 | + ) { |
|
157 | + $current_object = $tree[$current_object]['info']['arguments'][0]->link; |
|
158 | + } elseif (!$updated) { |
|
159 | + break; |
|
160 | + } |
|
152 | 161 | |
153 | - if ($this->debug_mode) |
|
154 | - pre ($current_object); |
|
162 | + if ($this->debug_mode) { |
|
163 | + pre ($current_object); |
|
164 | + } |
|
155 | 165 | } |
156 | 166 | |
157 | 167 | /** |
@@ -159,8 +169,9 @@ discard block |
||
159 | 169 | */ |
160 | 170 | if (class_exists ($words[0]) || class_exists ('\VoidEngine\\'. $words[0])) |
161 | 171 | { |
162 | - if (!isset ($words[1])) |
|
163 | - throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
172 | + if (!isset ($words[1])) { |
|
173 | + throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
174 | + } |
|
164 | 175 | |
165 | 176 | /** |
166 | 177 | * Button NewButton |
@@ -188,9 +199,7 @@ discard block |
||
188 | 199 | $current_object = $id; |
189 | 200 | |
190 | 201 | continue; |
191 | - } |
|
192 | - |
|
193 | - else |
|
202 | + } else |
|
194 | 203 | { |
195 | 204 | $tree[$id] = [ |
196 | 205 | 'type' => VLF_OBJECT_DEFINITION, |
@@ -212,10 +221,9 @@ discard block |
||
212 | 221 | |
213 | 222 | $end = strrpos ($line, ')'); |
214 | 223 | |
215 | - if ($end === false) |
|
216 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
217 | - |
|
218 | - elseif ($begin < $end) |
|
224 | + if ($end === false) { |
|
225 | + throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
226 | + } elseif ($begin < $end) |
|
219 | 227 | { |
220 | 228 | $arguments = []; |
221 | 229 | $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
@@ -224,18 +232,20 @@ discard block |
||
224 | 232 | { |
225 | 233 | $argument = trim ($argument); |
226 | 234 | |
227 | - if (strlen ($argument) > 0) |
|
228 | - $arguments[] = isset ($links[$argument]) ? |
|
235 | + if (strlen ($argument) > 0) { |
|
236 | + $arguments[] = isset ($links[$argument]) ? |
|
229 | 237 | new VLFLink ($argument, $links[$argument]) : |
230 | 238 | $argument; |
231 | - |
|
232 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
239 | + } else { |
|
240 | + throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
241 | + } |
|
233 | 242 | } |
234 | 243 | |
235 | 244 | $tree[$id]['info']['arguments'] = $arguments; |
236 | 245 | |
237 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
238 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
246 | + if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) { |
|
247 | + throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
248 | + } |
|
239 | 249 | } |
240 | 250 | |
241 | 251 | $tree[$id]['info']['subparent_link'] = new VLFLink ($tree[$current_object]['info']['object_name'], $current_object); |
@@ -299,13 +309,14 @@ discard block |
||
299 | 309 | |
300 | 310 | $comment .= $parsed[0]; |
301 | 311 | $skip_at = $parsed[1]; |
312 | + } else { |
|
313 | + throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
302 | 314 | } |
303 | - |
|
304 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
305 | 315 | } |
306 | 316 | |
307 | - if ($this->debug_mode) |
|
308 | - pre ("Comment:\n\n$comment"); |
|
317 | + if ($this->debug_mode) { |
|
318 | + pre ("Comment:\n\n$comment"); |
|
319 | + } |
|
309 | 320 | } |
310 | 321 | |
311 | 322 | /** |
@@ -327,9 +338,9 @@ discard block |
||
327 | 338 | |
328 | 339 | $code .= $parsed[0]; |
329 | 340 | $skip_at = $parsed[1]; |
341 | + } else { |
|
342 | + throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
330 | 343 | } |
331 | - |
|
332 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
333 | 344 | } |
334 | 345 | |
335 | 346 | $tree[$id] = [ |
@@ -384,8 +395,9 @@ discard block |
||
384 | 395 | |
385 | 396 | if ($postChar == ':' || $postChar == '^') |
386 | 397 | { |
387 | - if (!isset ($words[1])) |
|
388 | - throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
398 | + if (!isset ($words[1])) { |
|
399 | + throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
400 | + } |
|
389 | 401 | |
390 | 402 | $propertyName = substr ($words[0], 0, -1); |
391 | 403 | $propertyValue = implode (' ', array_slice ($words, 1)); |
@@ -420,8 +432,9 @@ discard block |
||
420 | 432 | 'syntax_nodes' => [] |
421 | 433 | ]; |
422 | 434 | |
423 | - if (isset ($links[$info['info']['property_value']])) |
|
424 | - $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
435 | + if (isset ($links[$info['info']['property_value']])) { |
|
436 | + $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
437 | + } |
|
425 | 438 | |
426 | 439 | $tree[$current_object]['syntax_nodes'][] = $info; |
427 | 440 | } |
@@ -439,10 +452,9 @@ discard block |
||
439 | 452 | |
440 | 453 | $end = strrpos ($line, ')'); |
441 | 454 | |
442 | - if ($end === false) |
|
443 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
444 | - |
|
445 | - elseif ($begin < $end) |
|
455 | + if ($end === false) { |
|
456 | + throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
457 | + } elseif ($begin < $end) |
|
446 | 458 | { |
447 | 459 | $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
448 | 460 | |
@@ -450,24 +462,27 @@ discard block |
||
450 | 462 | { |
451 | 463 | $argument = trim ($argument); |
452 | 464 | |
453 | - if (strlen ($argument) > 0) |
|
454 | - $arguments[] = isset ($links[$argument]) ? |
|
465 | + if (strlen ($argument) > 0) { |
|
466 | + $arguments[] = isset ($links[$argument]) ? |
|
455 | 467 | new VLFLink ($argument, $links[$argument]) : |
456 | 468 | $argument; |
457 | - |
|
458 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
469 | + } else { |
|
470 | + throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
471 | + } |
|
459 | 472 | } |
460 | 473 | |
461 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
462 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
474 | + if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) { |
|
475 | + throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
476 | + } |
|
463 | 477 | } |
464 | 478 | } |
465 | 479 | |
466 | 480 | /** |
467 | 481 | * ->show |
468 | 482 | */ |
469 | - elseif (!$this->ignore_unexpected_method_args) |
|
470 | - throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
483 | + elseif (!$this->ignore_unexpected_method_args) { |
|
484 | + throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
485 | + } |
|
471 | 486 | |
472 | 487 | $tree[$current_object]['syntax_nodes'][] = [ |
473 | 488 | 'type' => VLF_METHOD_CALL, |
@@ -520,7 +535,9 @@ discard block |
||
520 | 535 | /** |
521 | 536 | * Что-то загадочное, таинственное, неизвестное человечеству |
522 | 537 | */ |
523 | - else throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
538 | + else { |
|
539 | + throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
540 | + } |
|
524 | 541 | } |
525 | 542 | |
526 | 543 | return [$tree, $links]; |
@@ -542,8 +559,9 @@ discard block |
||
542 | 559 | |
543 | 560 | foreach ($lines as $line_id => $line) |
544 | 561 | { |
545 | - if ($line_id <= $begin_id) |
|
546 | - continue; |
|
562 | + if ($line_id <= $begin_id) { |
|
563 | + continue; |
|
564 | + } |
|
547 | 565 | |
548 | 566 | if (!(bool)(trim ($line))) |
549 | 567 | { |
@@ -554,13 +572,15 @@ discard block |
||
554 | 572 | |
555 | 573 | $height = $this->getLineHeight ($line); |
556 | 574 | |
557 | - if ($this->debug_mode) |
|
558 | - pre ("$height, $down_height, $line"); |
|
559 | - |
|
560 | - if ($height > $down_height) |
|
561 | - $parsed .= "$line\n"; |
|
575 | + if ($this->debug_mode) { |
|
576 | + pre ("$height, $down_height, $line"); |
|
577 | + } |
|
562 | 578 | |
563 | - else break; |
|
579 | + if ($height > $down_height) { |
|
580 | + $parsed .= "$line\n"; |
|
581 | + } else { |
|
582 | + break; |
|
583 | + } |
|
564 | 584 | } |
565 | 585 | |
566 | 586 | return [$parsed, $line_id]; |
@@ -584,8 +604,9 @@ discard block |
||
584 | 604 | { |
585 | 605 | $i = 0; |
586 | 606 | |
587 | - while (isset ($line[$i]) && $line[$i] == "\t") |
|
588 | - ++$i; |
|
607 | + while (isset ($line[$i]) && $line[$i] == "\t") { |
|
608 | + ++$i; |
|
609 | + } |
|
589 | 610 | |
590 | 611 | return strlen ($line = str_repeat (' ', $i) . substr ($line, $i)) - strlen ($line = trim ($line)); |
591 | 612 | } |
@@ -602,8 +623,9 @@ discard block |
||
602 | 623 | { |
603 | 624 | return array_filter ($segments, function ($text) |
604 | 625 | { |
605 | - if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) |
|
606 | - throw new \Exception ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
626 | + if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) { |
|
627 | + throw new \Exception ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
628 | + } |
|
607 | 629 | |
608 | 630 | return strlen (trim ($text)) > 0; |
609 | 631 | }); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | protected $WinAPI; |
31 | 31 | |
32 | - public function __construct () |
|
32 | + public function __construct() |
|
33 | 33 | { |
34 | 34 | /** |
35 | 35 | * Большинство функций было взято из класса "WinAPI" проекта "DevelStudio XL" |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * |
41 | 41 | */ |
42 | 42 | |
43 | - $this->WinAPI = \FFI::cdef (' |
|
43 | + $this->WinAPI = \FFI::cdef(' |
|
44 | 44 | struct LPCTSTR |
45 | 45 | { |
46 | 46 | char string; |
@@ -76,25 +76,25 @@ discard block |
||
76 | 76 | ', 'User32.dll'); |
77 | 77 | } |
78 | 78 | |
79 | - public function __call ($method, $args) |
|
79 | + public function __call($method, $args) |
|
80 | 80 | { |
81 | - if (method_exists ($this, $method)) |
|
82 | - return $this->$method (...$args); |
|
81 | + if (method_exists($this, $method)) |
|
82 | + return $this->$method(...$args); |
|
83 | 83 | |
84 | 84 | else try |
85 | 85 | { |
86 | - return $this->WinAPI->$method (...$args); |
|
86 | + return $this->WinAPI->$method(...$args); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | catch (\Throwable $e) |
90 | 90 | { |
91 | - throw new \Exception ('Method "'. $method .'" not found or return an exception. Exception info: '. "\n\n". (string) $e); |
|
91 | + throw new \Exception('Method "'.$method.'" not found or return an exception. Exception info: '."\n\n".(string) $e); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - public function findWindow (string $caption, string $class = null): ?int |
|
95 | + public function findWindow(string $caption, string $class = null): ?int |
|
96 | 96 | { |
97 | - return $this->FindWindowA ($class, $caption); |
|
97 | + return $this->FindWindowA($class, $caption); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /*public function getWindowCaption (int $handle) |
@@ -78,15 +78,14 @@ |
||
78 | 78 | |
79 | 79 | public function __call ($method, $args) |
80 | 80 | { |
81 | - if (method_exists ($this, $method)) |
|
82 | - return $this->$method (...$args); |
|
83 | - |
|
84 | - else try |
|
81 | + if (method_exists ($this, $method)) { |
|
82 | + return $this->$method (...$args); |
|
83 | + } else { |
|
84 | + try |
|
85 | 85 | { |
86 | 86 | return $this->WinAPI->$method (...$args); |
87 | 87 | } |
88 | - |
|
89 | - catch (\Throwable $e) |
|
88 | + } catch (\Throwable $e) |
|
90 | 89 | { |
91 | 90 | throw new \Exception ('Method "'. $method .'" not found or return an exception. Exception info: '. "\n\n". (string) $e); |
92 | 91 | } |
@@ -7,43 +7,43 @@ discard block |
||
7 | 7 | public $application; |
8 | 8 | public $executablePath; |
9 | 9 | |
10 | - public function __construct () |
|
10 | + public function __construct() |
|
11 | 11 | { |
12 | - $this->application = new WFClass ('System.Windows.Forms.Application'); |
|
12 | + $this->application = new WFClass('System.Windows.Forms.Application'); |
|
13 | 13 | $this->executablePath = $this->application->executablePath; |
14 | 14 | } |
15 | 15 | |
16 | - public function run ($form = null): void |
|
16 | + public function run($form = null): void |
|
17 | 17 | { |
18 | 18 | if ($form instanceof WFObject) |
19 | - $this->application->run ($form->selector); |
|
19 | + $this->application->run($form->selector); |
|
20 | 20 | |
21 | - elseif (is_int ($form) && VoidEngine::objectExists ($form)) |
|
22 | - $this->application->run ($form); |
|
21 | + elseif (is_int($form) && VoidEngine::objectExists($form)) |
|
22 | + $this->application->run($form); |
|
23 | 23 | |
24 | 24 | elseif ($form === null) |
25 | - $this->application->run (); |
|
25 | + $this->application->run(); |
|
26 | 26 | |
27 | - else throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
27 | + else throw new \Exception('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
28 | 28 | } |
29 | 29 | |
30 | - public function restart (): void |
|
30 | + public function restart(): void |
|
31 | 31 | { |
32 | - $this->application->restart (); |
|
33 | - $this->close (); |
|
32 | + $this->application->restart(); |
|
33 | + $this->close(); |
|
34 | 34 | } |
35 | 35 | |
36 | - public function close (): void |
|
36 | + public function close(): void |
|
37 | 37 | { |
38 | - $this->application->exit (); |
|
38 | + $this->application->exit(); |
|
39 | 39 | } |
40 | 40 | |
41 | - public function __call (string $name, array $args) |
|
41 | + public function __call(string $name, array $args) |
|
42 | 42 | { |
43 | - return $this->application->$name (...$args); |
|
43 | + return $this->application->$name(...$args); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function __get (string $name) |
|
46 | + public function __get(string $name) |
|
47 | 47 | { |
48 | 48 | return $this->application->$name; |
49 | 49 | } |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | { |
54 | 54 | public $screen; |
55 | 55 | |
56 | - public function __construct () |
|
56 | + public function __construct() |
|
57 | 57 | { |
58 | - $this->screen = new WFClass ('System.Windows.Forms.Screen'); |
|
58 | + $this->screen = new WFClass('System.Windows.Forms.Screen'); |
|
59 | 59 | } |
60 | 60 | |
61 | - public function __get ($name) |
|
61 | + public function __get($name) |
|
62 | 62 | { |
63 | - switch (strtolower ($name)) |
|
63 | + switch (strtolower($name)) |
|
64 | 64 | { |
65 | 65 | case 'width': |
66 | 66 | case 'w': |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | - public function __debugInfo (): array |
|
81 | + public function __debugInfo(): array |
|
82 | 82 | { |
83 | 83 | return [ |
84 | 84 | $this->w, |
@@ -15,16 +15,15 @@ |
||
15 | 15 | |
16 | 16 | public function run ($form = null): void |
17 | 17 | { |
18 | - if ($form instanceof WFObject) |
|
19 | - $this->application->run ($form->selector); |
|
20 | - |
|
21 | - elseif (is_int ($form) && VoidEngine::objectExists ($form)) |
|
22 | - $this->application->run ($form); |
|
23 | - |
|
24 | - elseif ($form === null) |
|
25 | - $this->application->run (); |
|
26 | - |
|
27 | - else throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
18 | + if ($form instanceof WFObject) { |
|
19 | + $this->application->run ($form->selector); |
|
20 | + } elseif (is_int ($form) && VoidEngine::objectExists ($form)) { |
|
21 | + $this->application->run ($form); |
|
22 | + } elseif ($form === null) { |
|
23 | + $this->application->run (); |
|
24 | + } else { |
|
25 | + throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
26 | + } |
|
28 | 27 | } |
29 | 28 | |
30 | 29 | public function restart (): void |