@@ -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'; |
@@ -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; |
@@ -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 |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
111 | - * * Создание экземпляра типа объекта |
|
112 | - * |
|
113 | - * @param mixed $objectName - полное название объекта |
|
114 | - * [@param mixed $objectGroup = null] - полное пространство имён объекта |
|
115 | - * |
|
116 | - * @return mixed - возвращает указатель на объект типа объекта или false в случае ошибки |
|
117 | - * |
|
118 | - */ |
|
111 | + * * Создание экземпляра типа объекта |
|
112 | + * |
|
113 | + * @param mixed $objectName - полное название объекта |
|
114 | + * [@param mixed $objectGroup = null] - полное пространство имён объекта |
|
115 | + * |
|
116 | + * @return mixed - возвращает указатель на объект типа объекта или false в случае ошибки |
|
117 | + * |
|
118 | + */ |
|
119 | 119 | |
120 | 120 | public static function objectType ($objectName, $objectGroup = null) |
121 | 121 | { |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | } |
548 | 548 | |
549 | 549 | public function __get ($name) |
550 | - { |
|
550 | + { |
|
551 | 551 | if (method_exists ($this, $method = "get_$name")) |
552 | 552 | $value = $this->$method (); |
553 | 553 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $size = $this->count; |
577 | 577 | $list = []; |
578 | 578 | |
579 | - for ($i = 0; $i < $size; ++$i) |
|
579 | + for ($i = 0; $i < $size; ++$i) |
|
580 | 580 | $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i)); |
581 | 581 | |
582 | 582 | return $list; |
@@ -606,10 +606,10 @@ discard block |
||
606 | 606 | } |
607 | 607 | |
608 | 608 | return EngineAdditions::coupleSelector ($value, $this->selector); |
609 | - } |
|
609 | + } |
|
610 | 610 | |
611 | - public function __set ($name, $value) |
|
612 | - { |
|
611 | + public function __set ($name, $value) |
|
612 | + { |
|
613 | 613 | if (method_exists ($this, $method = "set_$name")) |
614 | 614 | try |
615 | 615 | { |
@@ -631,8 +631,8 @@ discard block |
||
631 | 631 | else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
632 | 632 | } |
633 | 633 | |
634 | - public function __call ($method, $args) |
|
635 | - { |
|
634 | + public function __call ($method, $args) |
|
635 | + { |
|
636 | 636 | $args = array_map (function ($arg) |
637 | 637 | { |
638 | 638 | return EngineAdditions::uncoupleSelector ($arg); |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | } |
649 | 649 | |
650 | 650 | public function offsetSet ($index, $value) |
651 | - { |
|
651 | + { |
|
652 | 652 | try |
653 | 653 | { |
654 | 654 | return $index === null ? |
@@ -664,14 +664,14 @@ discard block |
||
664 | 664 | } |
665 | 665 | } |
666 | 666 | |
667 | - public function offsetGet ($index) |
|
668 | - { |
|
669 | - return EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $index), $this->selector); |
|
667 | + public function offsetGet ($index) |
|
668 | + { |
|
669 | + return EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $index), $this->selector); |
|
670 | 670 | } |
671 | 671 | |
672 | - public function offsetUnset ($index): void |
|
673 | - { |
|
674 | - $this->callMethod ('RemoveAt', $index); |
|
672 | + public function offsetUnset ($index): void |
|
673 | + { |
|
674 | + $this->callMethod ('RemoveAt', $index); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | public function offsetExists ($index): bool |
@@ -689,19 +689,19 @@ discard block |
||
689 | 689 | return true; |
690 | 690 | } |
691 | 691 | |
692 | - public function indexOf ($value): int |
|
693 | - { |
|
694 | - return $this->callMethod ('IndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
692 | + public function indexOf ($value): int |
|
693 | + { |
|
694 | + return $this->callMethod ('IndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | public function lastIndexOf ($value): int |
698 | - { |
|
699 | - return $this->callMethod ('LastIndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
700 | - } |
|
698 | + { |
|
699 | + return $this->callMethod ('LastIndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
700 | + } |
|
701 | 701 | |
702 | - public function contains ($value): bool |
|
703 | - { |
|
704 | - return $this->callMethod ('Contains', EngineAdditions::uncoupleSelector ($value)); |
|
702 | + public function contains ($value): bool |
|
703 | + { |
|
704 | + return $this->callMethod ('Contains', EngineAdditions::uncoupleSelector ($value)); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | public function foreach (\Closure $callback, string $type = null): void |
@@ -755,45 +755,45 @@ discard block |
||
755 | 755 | return VoidEngine::callMethod ($this->selector, $method, ...$args); |
756 | 756 | } |
757 | 757 | |
758 | - protected function getArrayProperty ($name, string $type = null) |
|
759 | - { |
|
758 | + protected function getArrayProperty ($name, string $type = null) |
|
759 | + { |
|
760 | 760 | $array = $this->getProperty ($name); |
761 | 761 | $size = VoidEngine::getProperty ($array, 'Length'); |
762 | 762 | $return = []; |
763 | 763 | |
764 | - for ($i = 0; $i < $size; ++$i) |
|
764 | + for ($i = 0; $i < $size; ++$i) |
|
765 | 765 | $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
766 | 766 | |
767 | 767 | VoidEngine::removeObjects ($array); |
768 | 768 | |
769 | - return $return; |
|
769 | + return $return; |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | public function get_name () |
773 | - { |
|
774 | - try |
|
775 | - { |
|
776 | - return $this->getProperty ('Name'); |
|
773 | + { |
|
774 | + try |
|
775 | + { |
|
776 | + return $this->getProperty ('Name'); |
|
777 | 777 | } |
778 | 778 | |
779 | - catch (\Throwable $e) |
|
780 | - { |
|
781 | - return $this->name; |
|
782 | - } |
|
783 | - } |
|
779 | + catch (\Throwable $e) |
|
780 | + { |
|
781 | + return $this->name; |
|
782 | + } |
|
783 | + } |
|
784 | 784 | |
785 | - public function set_name (string $name) |
|
786 | - { |
|
787 | - try |
|
788 | - { |
|
789 | - $this->setProperty ('Name', $name); |
|
785 | + public function set_name (string $name) |
|
786 | + { |
|
787 | + try |
|
788 | + { |
|
789 | + $this->setProperty ('Name', $name); |
|
790 | 790 | } |
791 | 791 | |
792 | - catch (\Throwable $e) |
|
793 | - { |
|
794 | - $this->name = $name; |
|
795 | - } |
|
796 | - } |
|
792 | + catch (\Throwable $e) |
|
793 | + { |
|
794 | + $this->name = $name; |
|
795 | + } |
|
796 | + } |
|
797 | 797 | |
798 | 798 | public function __toString (): string |
799 | 799 | { |
@@ -17,9 +17,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,13 +282,13 @@ discard block |
||
282 | 282 | * |
283 | 283 | */ |
284 | 284 | |
285 | - public static function setObjectEvent (int $selector, string $eventName, string $code): void |
|
285 | + public static function setObjectEvent(int $selector, string $eventName, string $code): void |
|
286 | 286 | { |
287 | - if (self::eventExists ($selector, $eventName)) |
|
288 | - self::removeObjectEvent ($selector, $eventName); |
|
287 | + if (self::eventExists($selector, $eventName)) |
|
288 | + self::removeObjectEvent($selector, $eventName); |
|
289 | 289 | |
290 | - \VoidCore::setEvent ($selector, $eventName, $code); |
|
291 | - Components::setComponentEvent ($selector, $eventName, $code); |
|
290 | + \VoidCore::setEvent($selector, $eventName, $code); |
|
291 | + Components::setComponentEvent($selector, $eventName, $code); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | * |
307 | 307 | */ |
308 | 308 | |
309 | - public static function eventExists (int $selector, string $eventName): bool |
|
309 | + public static function eventExists(int $selector, string $eventName): bool |
|
310 | 310 | { |
311 | - return \VoidCore::eventExists ($selector, $eventName); |
|
311 | + return \VoidCore::eventExists($selector, $eventName); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | * |
326 | 326 | */ |
327 | 327 | |
328 | - public static function removeObjectEvent (int $selector, string $eventName): void |
|
328 | + public static function removeObjectEvent(int $selector, string $eventName): void |
|
329 | 329 | { |
330 | - \VoidCore::removeEvent ($selector, $eventName); |
|
331 | - Components::removeComponentEvent ($selector, $eventName); |
|
330 | + \VoidCore::removeEvent($selector, $eventName); |
|
331 | + Components::removeComponentEvent($selector, $eventName); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | * |
341 | 341 | */ |
342 | 342 | |
343 | - public static function importObject (string $data): int |
|
343 | + public static function importObject(string $data): int |
|
344 | 344 | { |
345 | - return \VoidCore::importObject ($data); |
|
345 | + return \VoidCore::importObject($data); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -354,9 +354,9 @@ discard block |
||
354 | 354 | * |
355 | 355 | */ |
356 | 356 | |
357 | - public static function exportObject (int $selector): string |
|
357 | + public static function exportObject(int $selector): string |
|
358 | 358 | { |
359 | - return \VoidCore::exportObject ($selector); |
|
359 | + return \VoidCore::exportObject($selector); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -380,20 +380,20 @@ discard block |
||
380 | 380 | * |
381 | 381 | */ |
382 | 382 | |
383 | - 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 |
|
383 | + public static function compile(string $savePath, string $iconPath, string $phpCode, string $productDescription = null, string $productName = null, string $productVersion = null, string $companyName = null, string $copyright = null, string $callSharpCode = '', string $declareSharpCode = '', WFObject $dictionary = null, WFObject $assemblies = null): array |
|
384 | 384 | { |
385 | 385 | if ($dictionary === null) |
386 | - $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
386 | + $dictionary = new WFObject('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
387 | 387 | |
388 | 388 | if ($assemblies === null) |
389 | - $assemblies = getNetArray ('System.String', [ |
|
389 | + $assemblies = getNetArray('System.String', [ |
|
390 | 390 | // CORE_DIR .'/CefSharp.dll', |
391 | - CORE_DIR .'/FastColoredTextBox.dll', |
|
392 | - CORE_DIR .'/ScintillaNET.dll' |
|
391 | + CORE_DIR.'/FastColoredTextBox.dll', |
|
392 | + CORE_DIR.'/ScintillaNET.dll' |
|
393 | 393 | ]); |
394 | 394 | |
395 | 395 | if ($productName === null) |
396 | - $productName = basenameNoExt ($savePath); |
|
396 | + $productName = basenameNoExt($savePath); |
|
397 | 397 | |
398 | 398 | if ($productDescription === null) |
399 | 399 | $productDescription = $productName; |
@@ -405,19 +405,19 @@ discard block |
||
405 | 405 | $companyName = 'Company N'; |
406 | 406 | |
407 | 407 | if ($copyright === null) |
408 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
408 | + $copyright = $companyName.' copyright (c) '.date('Y'); |
|
409 | 409 | |
410 | - return (new WFClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
410 | + return (new WFClass('WinForms_PHP.WFCompiler', null))->compile($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
414 | 414 | class EngineAdditions |
415 | 415 | { |
416 | - public static function loadModule (string $path): bool |
|
416 | + public static function loadModule(string $path): bool |
|
417 | 417 | { |
418 | 418 | try |
419 | 419 | { |
420 | - (new WFClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
|
420 | + (new WFClass('System.Reflection.Assembly', 'mscorlib'))->loadFrom($path); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | catch (\Throwable $e) |
@@ -428,16 +428,16 @@ discard block |
||
428 | 428 | return true; |
429 | 429 | } |
430 | 430 | |
431 | - public static function getProperty (int $selector, string $name): array |
|
431 | + public static function getProperty(int $selector, string $name): array |
|
432 | 432 | { |
433 | - $property = VoidEngine::callMethod (VoidEngine::callMethod ($selector, 'GetType'), 'GetProperty', $name); |
|
433 | + $property = VoidEngine::callMethod(VoidEngine::callMethod($selector, 'GetType'), 'GetProperty', $name); |
|
434 | 434 | |
435 | - if (!is_int ($property)) |
|
435 | + if (!is_int($property)) |
|
436 | 436 | return false; |
437 | 437 | |
438 | 438 | try |
439 | 439 | { |
440 | - $propertyType = VoidEngine::getProperty ($property, ['PropertyType', 'string']); |
|
440 | + $propertyType = VoidEngine::getProperty($property, ['PropertyType', 'string']); |
|
441 | 441 | |
442 | 442 | switch ($propertyType) |
443 | 443 | { |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | default: |
474 | 474 | try |
475 | 475 | { |
476 | - VoidEngine::getProperty ($selector, [$name, 'int']); |
|
476 | + VoidEngine::getProperty($selector, [$name, 'int']); |
|
477 | 477 | |
478 | 478 | $property = 'int'; |
479 | 479 | } |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | { |
483 | 483 | return [ |
484 | 484 | 'type' => 'vrsf', |
485 | - 'value' => VoidEngine::exportObject (VoidEngine::getProperty ($selector, [$name, 'object'])) |
|
485 | + 'value' => VoidEngine::exportObject(VoidEngine::getProperty($selector, [$name, 'object'])) |
|
486 | 486 | ]; |
487 | 487 | } |
488 | 488 | break; |
@@ -496,30 +496,30 @@ discard block |
||
496 | 496 | |
497 | 497 | return [ |
498 | 498 | 'type' => $property, |
499 | - 'value' => VoidEngine::getProperty ($selector, [$name, $property]) |
|
499 | + 'value' => VoidEngine::getProperty($selector, [$name, $property]) |
|
500 | 500 | ]; |
501 | 501 | } |
502 | 502 | |
503 | - public static function getObjectEvents (int $object): array |
|
503 | + public static function getObjectEvents(int $object): array |
|
504 | 504 | { |
505 | 505 | $events = []; |
506 | 506 | |
507 | - $props = VoidEngine::callMethod (VoidEngine::callMethod ($object, 'GetType'), 'GetEvents'); |
|
508 | - $len = VoidEngine::getProperty ($props, 'Length'); |
|
507 | + $props = VoidEngine::callMethod(VoidEngine::callMethod($object, 'GetType'), 'GetEvents'); |
|
508 | + $len = VoidEngine::getProperty($props, 'Length'); |
|
509 | 509 | |
510 | 510 | for ($i = 0; $i < $len; ++$i) |
511 | - $events[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($props, $i), 'Name'); |
|
511 | + $events[] = VoidEngine::getProperty(VoidEngine::getArrayValue($props, $i), 'Name'); |
|
512 | 512 | |
513 | 513 | return $events; |
514 | 514 | } |
515 | 515 | |
516 | - public static function coupleSelector ($value, int $selfSelector = null) |
|
516 | + public static function coupleSelector($value, int $selfSelector = null) |
|
517 | 517 | { |
518 | - return is_int ($value) && VoidEngine::objectExists ($value) && $value != $selfSelector ? |
|
519 | - new WFObject ($value) : $value; |
|
518 | + return is_int($value) && VoidEngine::objectExists($value) && $value != $selfSelector ? |
|
519 | + new WFObject($value) : $value; |
|
520 | 520 | } |
521 | 521 | |
522 | - public static function uncoupleSelector ($value) |
|
522 | + public static function uncoupleSelector($value) |
|
523 | 523 | { |
524 | 524 | return $value instanceof WFObject ? |
525 | 525 | $value->selector : $value; |
@@ -531,44 +531,44 @@ discard block |
||
531 | 531 | protected $selector; |
532 | 532 | protected $name; |
533 | 533 | |
534 | - public function __construct ($object, ?string $classGroup = 'auto', ...$args) |
|
534 | + public function __construct($object, ?string $classGroup = 'auto', ...$args) |
|
535 | 535 | { |
536 | 536 | foreach ($args as $id => $arg) |
537 | - $args[$id] = ngineAdditions::uncoupleSelector ($arg); |
|
537 | + $args[$id] = ngineAdditions::uncoupleSelector($arg); |
|
538 | 538 | |
539 | - if (is_string ($object)) |
|
540 | - $this->selector = VoidEngine::createObject ($object, $classGroup == 'auto' ? |
|
541 | - substr ($object, 0, strrpos ($object, '.')) : $classGroup, ...$args); |
|
539 | + if (is_string($object)) |
|
540 | + $this->selector = VoidEngine::createObject($object, $classGroup == 'auto' ? |
|
541 | + substr ($object, 0, strrpos($object, '.')) : $classGroup, ...$args); |
|
542 | 542 | |
543 | - elseif (is_int ($object) && VoidEngine::objectExists ($object)) |
|
543 | + elseif (is_int($object) && VoidEngine::objectExists($object)) |
|
544 | 544 | $this->selector = $object; |
545 | 545 | |
546 | - else throw new \Exception ('$object parameter must be string or object selector'); |
|
546 | + else throw new \Exception('$object parameter must be string or object selector'); |
|
547 | 547 | } |
548 | 548 | |
549 | - public function __get ($name) |
|
549 | + public function __get($name) |
|
550 | 550 | { |
551 | - if (method_exists ($this, $method = "get_$name")) |
|
552 | - $value = $this->$method (); |
|
551 | + if (method_exists($this, $method = "get_$name")) |
|
552 | + $value = $this->$method(); |
|
553 | 553 | |
554 | - elseif (substr ($name, -5) == 'Event') |
|
555 | - $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
554 | + elseif (substr($name, -5) == 'Event') |
|
555 | + $value = Events::getObjectEvent($this->selector, substr($name, 0, -5)); |
|
556 | 556 | |
557 | - elseif (property_exists ($this, $name)) |
|
557 | + elseif (property_exists($this, $name)) |
|
558 | 558 | $value = $this->$name; |
559 | 559 | |
560 | - else switch (strtolower ($name)) |
|
560 | + else switch (strtolower($name)) |
|
561 | 561 | { |
562 | 562 | case 'count': |
563 | 563 | case 'length': |
564 | 564 | try |
565 | 565 | { |
566 | - return $this->getProperty ('Count'); |
|
566 | + return $this->getProperty('Count'); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | catch (\Throwable $e) |
570 | 570 | { |
571 | - return $this->getProperty ('Length'); |
|
571 | + return $this->getProperty('Length'); |
|
572 | 572 | } |
573 | 573 | break; |
574 | 574 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | $list = []; |
578 | 578 | |
579 | 579 | for ($i = 0; $i < $size; ++$i) |
580 | - $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i)); |
|
580 | + $list[] = EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $i)); |
|
581 | 581 | |
582 | 582 | return $list; |
583 | 583 | break; |
@@ -589,31 +589,31 @@ discard block |
||
589 | 589 | for ($i = 0; $i < $size; ++$i) |
590 | 590 | try |
591 | 591 | { |
592 | - $names[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($this->selector, [$i, 'object']), 'Text'); |
|
592 | + $names[] = VoidEngine::getProperty(VoidEngine::getArrayValue($this->selector, [$i, 'object']), 'Text'); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | catch (\Throwable $e) |
596 | 596 | { |
597 | - $names[] = VoidEngine::getArrayValue ($this->selector, [$i, 'string']); |
|
597 | + $names[] = VoidEngine::getArrayValue($this->selector, [$i, 'string']); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | return $names; |
601 | 601 | break; |
602 | 602 | |
603 | 603 | default: |
604 | - $value = $this->getProperty ($name); |
|
604 | + $value = $this->getProperty($name); |
|
605 | 605 | break; |
606 | 606 | } |
607 | 607 | |
608 | - return EngineAdditions::coupleSelector ($value, $this->selector); |
|
608 | + return EngineAdditions::coupleSelector($value, $this->selector); |
|
609 | 609 | } |
610 | 610 | |
611 | - public function __set ($name, $value) |
|
611 | + public function __set($name, $value) |
|
612 | 612 | { |
613 | - if (method_exists ($this, $method = "set_$name")) |
|
613 | + if (method_exists($this, $method = "set_$name")) |
|
614 | 614 | try |
615 | 615 | { |
616 | - return $this->$method ($value); |
|
616 | + return $this->$method($value); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | # Метод "set_$name" может принимать в качестве параметра объект WFObject |
@@ -622,63 +622,61 @@ discard block |
||
622 | 622 | catch (\Throwable $e) |
623 | 623 | { |
624 | 624 | return $value instanceof WFObject ? |
625 | - $this->$method ($value->selector) : null; |
|
625 | + $this->$method($value->selector) : null; |
|
626 | 626 | } |
627 | 627 | |
628 | - elseif (substr ($name, -5) == 'Event') |
|
629 | - Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
628 | + elseif (substr($name, -5) == 'Event') |
|
629 | + Events::setObjectEvent($this->selector, substr($name, 0, -5), $value); |
|
630 | 630 | |
631 | - else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
631 | + else $this->setProperty($name, EngineAdditions::uncoupleSelector($value)); |
|
632 | 632 | } |
633 | 633 | |
634 | - public function __call ($method, $args) |
|
634 | + public function __call($method, $args) |
|
635 | 635 | { |
636 | - $args = array_map (function ($arg) |
|
636 | + $args = array_map(function($arg) |
|
637 | 637 | { |
638 | - return EngineAdditions::uncoupleSelector ($arg); |
|
638 | + return EngineAdditions::uncoupleSelector($arg); |
|
639 | 639 | }, $args); |
640 | 640 | |
641 | - return EngineAdditions::coupleSelector ($this->callMethod ($method, ...$args), $this->selector); |
|
641 | + return EngineAdditions::coupleSelector($this->callMethod($method, ...$args), $this->selector); |
|
642 | 642 | } |
643 | 643 | |
644 | - public function addRange (array $values, $assoc = false): void |
|
644 | + public function addRange(array $values, $assoc = false): void |
|
645 | 645 | { |
646 | 646 | foreach ($values as $id => $value) |
647 | - $this->offsetSet ($assoc ? $id : null, $value); |
|
647 | + $this->offsetSet($assoc ? $id : null, $value); |
|
648 | 648 | } |
649 | 649 | |
650 | - public function offsetSet ($index, $value) |
|
650 | + public function offsetSet($index, $value) |
|
651 | 651 | { |
652 | 652 | try |
653 | 653 | { |
654 | 654 | return $index === null ? |
655 | - $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
|
656 | - $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
|
655 | + $this->callMethod('Add', EngineAdditions::uncoupleSelector($value)) : $this->callMethod('Insert', $index, EngineAdditions::uncoupleSelector($value)); |
|
657 | 656 | } |
658 | 657 | |
659 | 658 | catch (\Throwable $e) |
660 | 659 | { |
661 | 660 | return $index === null ? |
662 | - VoidEngine::setArrayValue ($this->selector, $this->count, $value) : |
|
663 | - VoidEngine::setArrayValue ($this->selector, $index, $value); |
|
661 | + VoidEngine::setArrayValue($this->selector, $this->count, $value) : VoidEngine::setArrayValue($this->selector, $index, $value); |
|
664 | 662 | } |
665 | 663 | } |
666 | 664 | |
667 | - public function offsetGet ($index) |
|
665 | + public function offsetGet($index) |
|
668 | 666 | { |
669 | - return EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $index), $this->selector); |
|
667 | + return EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $index), $this->selector); |
|
670 | 668 | } |
671 | 669 | |
672 | - public function offsetUnset ($index): void |
|
670 | + public function offsetUnset($index): void |
|
673 | 671 | { |
674 | - $this->callMethod ('RemoveAt', $index); |
|
672 | + $this->callMethod('RemoveAt', $index); |
|
675 | 673 | } |
676 | 674 | |
677 | - public function offsetExists ($index): bool |
|
675 | + public function offsetExists($index): bool |
|
678 | 676 | { |
679 | 677 | try |
680 | 678 | { |
681 | - $this->offsetGet ($index); |
|
679 | + $this->offsetGet($index); |
|
682 | 680 | } |
683 | 681 | |
684 | 682 | catch (\Exception $e) |
@@ -689,19 +687,19 @@ discard block |
||
689 | 687 | return true; |
690 | 688 | } |
691 | 689 | |
692 | - public function indexOf ($value): int |
|
690 | + public function indexOf($value): int |
|
693 | 691 | { |
694 | - return $this->callMethod ('IndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
692 | + return $this->callMethod('IndexOf', EngineAdditions::uncoupleSelector($value)); |
|
695 | 693 | } |
696 | 694 | |
697 | - public function lastIndexOf ($value): int |
|
695 | + public function lastIndexOf($value): int |
|
698 | 696 | { |
699 | - return $this->callMethod ('LastIndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
697 | + return $this->callMethod('LastIndexOf', EngineAdditions::uncoupleSelector($value)); |
|
700 | 698 | } |
701 | 699 | |
702 | - public function contains ($value): bool |
|
700 | + public function contains($value): bool |
|
703 | 701 | { |
704 | - return $this->callMethod ('Contains', EngineAdditions::uncoupleSelector ($value)); |
|
702 | + return $this->callMethod('Contains', EngineAdditions::uncoupleSelector($value)); |
|
705 | 703 | } |
706 | 704 | |
707 | 705 | public function foreach (\Closure $callback, string $type = null): void |
@@ -709,71 +707,71 @@ discard block |
||
709 | 707 | $size = $this->count; |
710 | 708 | |
711 | 709 | for ($i = 0; $i < $size; ++$i) |
712 | - $callback (EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
710 | + $callback(EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
713 | 711 | } |
714 | 712 | |
715 | - public function where (\Closure $comparator, string $type = null): array |
|
713 | + public function where(\Closure $comparator, string $type = null): array |
|
716 | 714 | { |
717 | 715 | $size = $this->count; |
718 | 716 | $return = []; |
719 | 717 | |
720 | 718 | for ($i = 0; $i < $size; ++$i) |
721 | - if ($comparator ($value = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
719 | + if ($comparator($value = EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
722 | 720 | $return[] = $value; |
723 | 721 | |
724 | 722 | return $return; |
725 | 723 | } |
726 | 724 | |
727 | - protected function getProperty ($name) |
|
725 | + protected function getProperty($name) |
|
728 | 726 | { |
729 | 727 | try |
730 | 728 | { |
731 | - return VoidEngine::getProperty ($this->selector, $name); |
|
729 | + return VoidEngine::getProperty($this->selector, $name); |
|
732 | 730 | } |
733 | 731 | |
734 | 732 | catch (\Throwable $e) |
735 | 733 | { |
736 | - return VoidEngine::getField ($this->selector, $name); |
|
734 | + return VoidEngine::getField($this->selector, $name); |
|
737 | 735 | } |
738 | 736 | } |
739 | 737 | |
740 | - protected function setProperty ($name, $value) |
|
738 | + protected function setProperty($name, $value) |
|
741 | 739 | { |
742 | 740 | try |
743 | 741 | { |
744 | - VoidEngine::setProperty ($this->selector, $name, $value); |
|
742 | + VoidEngine::setProperty($this->selector, $name, $value); |
|
745 | 743 | } |
746 | 744 | |
747 | 745 | catch (\Throwable $e) |
748 | 746 | { |
749 | - VoidEngine::setField ($this->selector, $name, $value); |
|
747 | + VoidEngine::setField($this->selector, $name, $value); |
|
750 | 748 | } |
751 | 749 | } |
752 | 750 | |
753 | - protected function callMethod ($method, ...$args) |
|
751 | + protected function callMethod($method, ...$args) |
|
754 | 752 | { |
755 | - return VoidEngine::callMethod ($this->selector, $method, ...$args); |
|
753 | + return VoidEngine::callMethod($this->selector, $method, ...$args); |
|
756 | 754 | } |
757 | 755 | |
758 | - protected function getArrayProperty ($name, string $type = null) |
|
756 | + protected function getArrayProperty($name, string $type = null) |
|
759 | 757 | { |
760 | - $array = $this->getProperty ($name); |
|
761 | - $size = VoidEngine::getProperty ($array, 'Length'); |
|
758 | + $array = $this->getProperty($name); |
|
759 | + $size = VoidEngine::getProperty($array, 'Length'); |
|
762 | 760 | $return = []; |
763 | 761 | |
764 | 762 | for ($i = 0; $i < $size; ++$i) |
765 | - $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
763 | + $return[] = VoidEngine::getArrayValue($array, $type === null ? $i : [$i, $type]); |
|
766 | 764 | |
767 | - VoidEngine::removeObjects ($array); |
|
765 | + VoidEngine::removeObjects($array); |
|
768 | 766 | |
769 | 767 | return $return; |
770 | 768 | } |
771 | 769 | |
772 | - public function get_name () |
|
770 | + public function get_name() |
|
773 | 771 | { |
774 | 772 | try |
775 | 773 | { |
776 | - return $this->getProperty ('Name'); |
|
774 | + return $this->getProperty('Name'); |
|
777 | 775 | } |
778 | 776 | |
779 | 777 | catch (\Throwable $e) |
@@ -782,11 +780,11 @@ discard block |
||
782 | 780 | } |
783 | 781 | } |
784 | 782 | |
785 | - public function set_name (string $name) |
|
783 | + public function set_name(string $name) |
|
786 | 784 | { |
787 | 785 | try |
788 | 786 | { |
789 | - $this->setProperty ('Name', $name); |
|
787 | + $this->setProperty('Name', $name); |
|
790 | 788 | } |
791 | 789 | |
792 | 790 | catch (\Throwable $e) |
@@ -795,9 +793,9 @@ discard block |
||
795 | 793 | } |
796 | 794 | } |
797 | 795 | |
798 | - public function __toString (): string |
|
796 | + public function __toString(): string |
|
799 | 797 | { |
800 | - return $this->callMethod ('ToString'); |
|
798 | + return $this->callMethod('ToString'); |
|
801 | 799 | } |
802 | 800 | } |
803 | 801 | |
@@ -805,16 +803,16 @@ discard block |
||
805 | 803 | { |
806 | 804 | protected $selector; |
807 | 805 | |
808 | - public function __construct ($class, ?string $classGroup = 'auto') |
|
806 | + public function __construct($class, ?string $classGroup = 'auto') |
|
809 | 807 | { |
810 | - if (is_string ($class)) |
|
811 | - $this->selector = VoidEngine::createClass ($class, $classGroup == 'auto' ? |
|
812 | - substr ($class, 0, strrpos ($class, '.')) : $classGroup |
|
808 | + if (is_string($class)) |
|
809 | + $this->selector = VoidEngine::createClass($class, $classGroup == 'auto' ? |
|
810 | + substr ($class, 0, strrpos($class, '.')) : $classGroup |
|
813 | 811 | ); |
814 | 812 | |
815 | - elseif (is_int ($class) && VoidEngine::objectExists ($class)) |
|
813 | + elseif (is_int($class) && VoidEngine::objectExists($class)) |
|
816 | 814 | $this->selector = $class; |
817 | 815 | |
818 | - else throw new \Exception ('$class parameter must be string or class selector'); |
|
816 | + else throw new \Exception('$class parameter must be string or class selector'); |
|
819 | 817 | } |
820 | 818 | } |
@@ -284,8 +284,9 @@ discard block |
||
284 | 284 | |
285 | 285 | public static function setObjectEvent (int $selector, string $eventName, string $code): void |
286 | 286 | { |
287 | - if (self::eventExists ($selector, $eventName)) |
|
288 | - self::removeObjectEvent ($selector, $eventName); |
|
287 | + if (self::eventExists ($selector, $eventName)) { |
|
288 | + self::removeObjectEvent ($selector, $eventName); |
|
289 | + } |
|
289 | 290 | |
290 | 291 | \VoidCore::setEvent ($selector, $eventName, $code); |
291 | 292 | Components::setComponentEvent ($selector, $eventName, $code); |
@@ -382,30 +383,37 @@ discard block |
||
382 | 383 | |
383 | 384 | public static function compile (string $savePath, string $iconPath, string $phpCode, string $productDescription = null, string $productName = null, string $productVersion = null, string $companyName = null, string $copyright = null, string $callSharpCode = '', string $declareSharpCode = '', WFObject $dictionary = null, WFObject $assemblies = null): array |
384 | 385 | { |
385 | - if ($dictionary === null) |
|
386 | - $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
386 | + if ($dictionary === null) { |
|
387 | + $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
388 | + } |
|
387 | 389 | |
388 | - if ($assemblies === null) |
|
389 | - $assemblies = getNetArray ('System.String', [ |
|
390 | + if ($assemblies === null) { |
|
391 | + $assemblies = getNetArray ('System.String', [ |
|
390 | 392 | // CORE_DIR .'/CefSharp.dll', |
391 | 393 | CORE_DIR .'/FastColoredTextBox.dll', |
392 | 394 | CORE_DIR .'/ScintillaNET.dll' |
393 | 395 | ]); |
396 | + } |
|
394 | 397 | |
395 | - if ($productName === null) |
|
396 | - $productName = basenameNoExt ($savePath); |
|
398 | + if ($productName === null) { |
|
399 | + $productName = basenameNoExt ($savePath); |
|
400 | + } |
|
397 | 401 | |
398 | - if ($productDescription === null) |
|
399 | - $productDescription = $productName; |
|
402 | + if ($productDescription === null) { |
|
403 | + $productDescription = $productName; |
|
404 | + } |
|
400 | 405 | |
401 | - if ($productVersion === null) |
|
402 | - $productVersion = '1.0'; |
|
406 | + if ($productVersion === null) { |
|
407 | + $productVersion = '1.0'; |
|
408 | + } |
|
403 | 409 | |
404 | - if ($companyName === null) |
|
405 | - $companyName = 'Company N'; |
|
410 | + if ($companyName === null) { |
|
411 | + $companyName = 'Company N'; |
|
412 | + } |
|
406 | 413 | |
407 | - if ($copyright === null) |
|
408 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
414 | + if ($copyright === null) { |
|
415 | + $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
416 | + } |
|
409 | 417 | |
410 | 418 | return (new WFClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
411 | 419 | } |
@@ -418,9 +426,7 @@ discard block |
||
418 | 426 | try |
419 | 427 | { |
420 | 428 | (new WFClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
421 | - } |
|
422 | - |
|
423 | - catch (\Throwable $e) |
|
429 | + } catch (\Throwable $e) |
|
424 | 430 | { |
425 | 431 | return false; |
426 | 432 | } |
@@ -432,8 +438,9 @@ discard block |
||
432 | 438 | { |
433 | 439 | $property = VoidEngine::callMethod (VoidEngine::callMethod ($selector, 'GetType'), 'GetProperty', $name); |
434 | 440 | |
435 | - if (!is_int ($property)) |
|
436 | - return false; |
|
441 | + if (!is_int ($property)) { |
|
442 | + return false; |
|
443 | + } |
|
437 | 444 | |
438 | 445 | try |
439 | 446 | { |
@@ -476,9 +483,7 @@ discard block |
||
476 | 483 | VoidEngine::getProperty ($selector, [$name, 'int']); |
477 | 484 | |
478 | 485 | $property = 'int'; |
479 | - } |
|
480 | - |
|
481 | - catch (\Throwable $e) |
|
486 | + } catch (\Throwable $e) |
|
482 | 487 | { |
483 | 488 | return [ |
484 | 489 | 'type' => 'vrsf', |
@@ -487,9 +492,7 @@ discard block |
||
487 | 492 | } |
488 | 493 | break; |
489 | 494 | } |
490 | - } |
|
491 | - |
|
492 | - catch (\Throwable $e) |
|
495 | + } catch (\Throwable $e) |
|
493 | 496 | { |
494 | 497 | $property = 'object'; |
495 | 498 | } |
@@ -507,8 +510,9 @@ discard block |
||
507 | 510 | $props = VoidEngine::callMethod (VoidEngine::callMethod ($object, 'GetType'), 'GetEvents'); |
508 | 511 | $len = VoidEngine::getProperty ($props, 'Length'); |
509 | 512 | |
510 | - for ($i = 0; $i < $len; ++$i) |
|
511 | - $events[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($props, $i), 'Name'); |
|
513 | + for ($i = 0; $i < $len; ++$i) { |
|
514 | + $events[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($props, $i), 'Name'); |
|
515 | + } |
|
512 | 516 | |
513 | 517 | return $events; |
514 | 518 | } |
@@ -533,40 +537,38 @@ discard block |
||
533 | 537 | |
534 | 538 | public function __construct ($object, ?string $classGroup = 'auto', ...$args) |
535 | 539 | { |
536 | - foreach ($args as $id => $arg) |
|
537 | - $args[$id] = ngineAdditions::uncoupleSelector ($arg); |
|
540 | + foreach ($args as $id => $arg) { |
|
541 | + $args[$id] = ngineAdditions::uncoupleSelector ($arg); |
|
542 | + } |
|
538 | 543 | |
539 | - if (is_string ($object)) |
|
540 | - $this->selector = VoidEngine::createObject ($object, $classGroup == 'auto' ? |
|
544 | + if (is_string ($object)) { |
|
545 | + $this->selector = VoidEngine::createObject ($object, $classGroup == 'auto' ? |
|
541 | 546 | substr ($object, 0, strrpos ($object, '.')) : $classGroup, ...$args); |
542 | - |
|
543 | - elseif (is_int ($object) && VoidEngine::objectExists ($object)) |
|
544 | - $this->selector = $object; |
|
545 | - |
|
546 | - else throw new \Exception ('$object parameter must be string or object selector'); |
|
547 | + } elseif (is_int ($object) && VoidEngine::objectExists ($object)) { |
|
548 | + $this->selector = $object; |
|
549 | + } else { |
|
550 | + throw new \Exception ('$object parameter must be string or object selector'); |
|
551 | + } |
|
547 | 552 | } |
548 | 553 | |
549 | 554 | public function __get ($name) |
550 | 555 | { |
551 | - if (method_exists ($this, $method = "get_$name")) |
|
552 | - $value = $this->$method (); |
|
553 | - |
|
554 | - elseif (substr ($name, -5) == 'Event') |
|
555 | - $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
556 | - |
|
557 | - elseif (property_exists ($this, $name)) |
|
558 | - $value = $this->$name; |
|
559 | - |
|
560 | - else switch (strtolower ($name)) |
|
556 | + if (method_exists ($this, $method = "get_$name")) { |
|
557 | + $value = $this->$method (); |
|
558 | + } elseif (substr ($name, -5) == 'Event') { |
|
559 | + $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
560 | + } elseif (property_exists ($this, $name)) { |
|
561 | + $value = $this->$name; |
|
562 | + } else { |
|
563 | + switch (strtolower ($name)) |
|
561 | 564 | { |
562 | 565 | case 'count': |
563 | 566 | case 'length': |
564 | 567 | try |
565 | 568 | { |
566 | 569 | return $this->getProperty ('Count'); |
567 | - } |
|
568 | - |
|
569 | - catch (\Throwable $e) |
|
570 | + } |
|
571 | + } catch (\Throwable $e) |
|
570 | 572 | { |
571 | 573 | return $this->getProperty ('Length'); |
572 | 574 | } |
@@ -576,8 +578,9 @@ discard block |
||
576 | 578 | $size = $this->count; |
577 | 579 | $list = []; |
578 | 580 | |
579 | - for ($i = 0; $i < $size; ++$i) |
|
580 | - $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i)); |
|
581 | + for ($i = 0; $i < $size; ++$i) { |
|
582 | + $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i)); |
|
583 | + } |
|
581 | 584 | |
582 | 585 | return $list; |
583 | 586 | break; |
@@ -586,13 +589,12 @@ discard block |
||
586 | 589 | $size = $this->count; |
587 | 590 | $names = []; |
588 | 591 | |
589 | - for ($i = 0; $i < $size; ++$i) |
|
590 | - try |
|
592 | + for ($i = 0; $i < $size; ++$i) { |
|
593 | + try |
|
591 | 594 | { |
592 | 595 | $names[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($this->selector, [$i, 'object']), 'Text'); |
593 | - } |
|
594 | - |
|
595 | - catch (\Throwable $e) |
|
596 | + } |
|
597 | + } catch (\Throwable $e) |
|
596 | 598 | { |
597 | 599 | $names[] = VoidEngine::getArrayValue ($this->selector, [$i, 'string']); |
598 | 600 | } |
@@ -610,10 +612,11 @@ discard block |
||
610 | 612 | |
611 | 613 | public function __set ($name, $value) |
612 | 614 | { |
613 | - if (method_exists ($this, $method = "set_$name")) |
|
614 | - try |
|
615 | + if (method_exists ($this, $method = "set_$name")) { |
|
616 | + try |
|
615 | 617 | { |
616 | 618 | return $this->$method ($value); |
619 | + } |
|
617 | 620 | } |
618 | 621 | |
619 | 622 | # Метод "set_$name" может принимать в качестве параметра объект WFObject |
@@ -623,12 +626,11 @@ discard block |
||
623 | 626 | { |
624 | 627 | return $value instanceof WFObject ? |
625 | 628 | $this->$method ($value->selector) : null; |
626 | - } |
|
627 | - |
|
628 | - elseif (substr ($name, -5) == 'Event') |
|
629 | - Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
630 | - |
|
631 | - else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
629 | + } elseif (substr ($name, -5) == 'Event') { |
|
630 | + Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
631 | + } else { |
|
632 | + $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
633 | + } |
|
632 | 634 | } |
633 | 635 | |
634 | 636 | public function __call ($method, $args) |
@@ -643,8 +645,9 @@ discard block |
||
643 | 645 | |
644 | 646 | public function addRange (array $values, $assoc = false): void |
645 | 647 | { |
646 | - foreach ($values as $id => $value) |
|
647 | - $this->offsetSet ($assoc ? $id : null, $value); |
|
648 | + foreach ($values as $id => $value) { |
|
649 | + $this->offsetSet ($assoc ? $id : null, $value); |
|
650 | + } |
|
648 | 651 | } |
649 | 652 | |
650 | 653 | public function offsetSet ($index, $value) |
@@ -654,9 +657,7 @@ discard block |
||
654 | 657 | return $index === null ? |
655 | 658 | $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
656 | 659 | $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
657 | - } |
|
658 | - |
|
659 | - catch (\Throwable $e) |
|
660 | + } catch (\Throwable $e) |
|
660 | 661 | { |
661 | 662 | return $index === null ? |
662 | 663 | VoidEngine::setArrayValue ($this->selector, $this->count, $value) : |
@@ -679,9 +680,7 @@ discard block |
||
679 | 680 | try |
680 | 681 | { |
681 | 682 | $this->offsetGet ($index); |
682 | - } |
|
683 | - |
|
684 | - catch (\Exception $e) |
|
683 | + } catch (\Exception $e) |
|
685 | 684 | { |
686 | 685 | return false; |
687 | 686 | } |
@@ -708,8 +707,9 @@ discard block |
||
708 | 707 | { |
709 | 708 | $size = $this->count; |
710 | 709 | |
711 | - for ($i = 0; $i < $size; ++$i) |
|
712 | - $callback (EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
710 | + for ($i = 0; $i < $size; ++$i) { |
|
711 | + $callback (EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
712 | + } |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | public function where (\Closure $comparator, string $type = null): array |
@@ -717,9 +717,10 @@ discard block |
||
717 | 717 | $size = $this->count; |
718 | 718 | $return = []; |
719 | 719 | |
720 | - for ($i = 0; $i < $size; ++$i) |
|
721 | - if ($comparator ($value = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
720 | + for ($i = 0; $i < $size; ++$i) { |
|
721 | + if ($comparator ($value = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
722 | 722 | $return[] = $value; |
723 | + } |
|
723 | 724 | |
724 | 725 | return $return; |
725 | 726 | } |
@@ -729,9 +730,7 @@ discard block |
||
729 | 730 | try |
730 | 731 | { |
731 | 732 | return VoidEngine::getProperty ($this->selector, $name); |
732 | - } |
|
733 | - |
|
734 | - catch (\Throwable $e) |
|
733 | + } catch (\Throwable $e) |
|
735 | 734 | { |
736 | 735 | return VoidEngine::getField ($this->selector, $name); |
737 | 736 | } |
@@ -742,9 +741,7 @@ discard block |
||
742 | 741 | try |
743 | 742 | { |
744 | 743 | VoidEngine::setProperty ($this->selector, $name, $value); |
745 | - } |
|
746 | - |
|
747 | - catch (\Throwable $e) |
|
744 | + } catch (\Throwable $e) |
|
748 | 745 | { |
749 | 746 | VoidEngine::setField ($this->selector, $name, $value); |
750 | 747 | } |
@@ -761,8 +758,9 @@ discard block |
||
761 | 758 | $size = VoidEngine::getProperty ($array, 'Length'); |
762 | 759 | $return = []; |
763 | 760 | |
764 | - for ($i = 0; $i < $size; ++$i) |
|
765 | - $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
761 | + for ($i = 0; $i < $size; ++$i) { |
|
762 | + $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
763 | + } |
|
766 | 764 | |
767 | 765 | VoidEngine::removeObjects ($array); |
768 | 766 | |
@@ -774,9 +772,7 @@ discard block |
||
774 | 772 | try |
775 | 773 | { |
776 | 774 | return $this->getProperty ('Name'); |
777 | - } |
|
778 | - |
|
779 | - catch (\Throwable $e) |
|
775 | + } catch (\Throwable $e) |
|
780 | 776 | { |
781 | 777 | return $this->name; |
782 | 778 | } |
@@ -787,9 +783,7 @@ discard block |
||
787 | 783 | try |
788 | 784 | { |
789 | 785 | $this->setProperty ('Name', $name); |
790 | - } |
|
791 | - |
|
792 | - catch (\Throwable $e) |
|
786 | + } catch (\Throwable $e) |
|
793 | 787 | { |
794 | 788 | $this->name = $name; |
795 | 789 | } |
@@ -807,14 +801,14 @@ discard block |
||
807 | 801 | |
808 | 802 | public function __construct ($class, ?string $classGroup = 'auto') |
809 | 803 | { |
810 | - if (is_string ($class)) |
|
811 | - $this->selector = VoidEngine::createClass ($class, $classGroup == 'auto' ? |
|
804 | + if (is_string ($class)) { |
|
805 | + $this->selector = VoidEngine::createClass ($class, $classGroup == 'auto' ? |
|
812 | 806 | substr ($class, 0, strrpos ($class, '.')) : $classGroup |
813 | 807 | ); |
814 | - |
|
815 | - elseif (is_int ($class) && VoidEngine::objectExists ($class)) |
|
816 | - $this->selector = $class; |
|
817 | - |
|
818 | - else throw new \Exception ('$class parameter must be string or class selector'); |
|
808 | + } elseif (is_int ($class) && VoidEngine::objectExists ($class)) { |
|
809 | + $this->selector = $class; |
|
810 | + } else { |
|
811 | + throw new \Exception ('$class parameter must be string or class selector'); |
|
812 | + } |
|
819 | 813 | } |
820 | 814 | } |
@@ -6,42 +6,42 @@ |
||
6 | 6 | { |
7 | 7 | static $events = []; |
8 | 8 | |
9 | - static function setObjectEvent (int $object, string $eventName, $function) |
|
9 | + static function setObjectEvent(int $object, string $eventName, $function) |
|
10 | 10 | { |
11 | - $eventName = strtolower ($eventName); |
|
11 | + $eventName = strtolower($eventName); |
|
12 | 12 | self::$events[$object][$eventName] = $function; |
13 | 13 | |
14 | - VoidEngine::setObjectEvent ($object, $eventName, " |
|
14 | + VoidEngine::setObjectEvent($object, $eventName, " |
|
15 | 15 | if (VoidEngine\Events::getObjectEvent ('$object', '$eventName') !== false) |
16 | 16 | VoidEngine\Events::getObjectEvent ('$object', '$eventName') (VoidEngine\_c('$object'), |
17 | 17 | isset (\$args) ? (is_int (\$args) && VoidEngine\VoidEngine::objectExists (\$args) && VoidEngine\VoidEngine::objectExists (\$argsSelector = VoidCore::getArrayValue (\$args, 1)) ? |
18 | 18 | new VoidEngine\WFObject (\$argsSelector) : \$args) : null);"); |
19 | 19 | } |
20 | 20 | |
21 | - static function reserveObjectEvent (int $object, string $eventName) |
|
21 | + static function reserveObjectEvent(int $object, string $eventName) |
|
22 | 22 | { |
23 | - $eventName = strtolower ($eventName); |
|
24 | - self::$events[$object][$eventName] = function ($self) {}; |
|
23 | + $eventName = strtolower($eventName); |
|
24 | + self::$events[$object][$eventName] = function($self) {}; |
|
25 | 25 | |
26 | - VoidEngine::setObjectEvent ($object, $eventName, ''); |
|
26 | + VoidEngine::setObjectEvent($object, $eventName, ''); |
|
27 | 27 | } |
28 | 28 | |
29 | - static function removeObjectEvent (int $object, string $eventName) |
|
29 | + static function removeObjectEvent(int $object, string $eventName) |
|
30 | 30 | { |
31 | - $eventName = strtolower ($eventName); |
|
32 | - VoidEngine::removeObjectEvent ($object, $eventName); |
|
31 | + $eventName = strtolower($eventName); |
|
32 | + VoidEngine::removeObjectEvent($object, $eventName); |
|
33 | 33 | |
34 | 34 | unset (self::$events[$object][$eventName]); |
35 | 35 | } |
36 | 36 | |
37 | - static function getObjectEvent (int $object, string $eventName) |
|
37 | + static function getObjectEvent(int $object, string $eventName) |
|
38 | 38 | { |
39 | - $eventName = strtolower ($eventName); |
|
39 | + $eventName = strtolower($eventName); |
|
40 | 40 | |
41 | 41 | return self::$events[$object][$eventName] ?: false; |
42 | 42 | } |
43 | 43 | |
44 | - static function getObjectEvents (int $object) |
|
44 | + static function getObjectEvents(int $object) |
|
45 | 45 | { |
46 | 46 | return self::$events[$object] ?: false; |
47 | 47 | } |