@@ -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; |
@@ -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']); |
@@ -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) {} |
@@ -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 |
@@ -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) |
@@ -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, |
@@ -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 | } |
@@ -2,17 +2,17 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -$env = new WFClass ('System.Environment', 'mscorlib'); |
|
6 | -$params = $env->getCommandLineArgs ()->list; |
|
5 | +$env = new WFClass('System.Environment', 'mscorlib'); |
|
6 | +$params = $env->getCommandLineArgs()->list; |
|
7 | 7 | |
8 | -$converter = new WFClass ('System.Drawing.ColorTranslator'); |
|
8 | +$converter = new WFClass('System.Drawing.ColorTranslator'); |
|
9 | 9 | |
10 | 10 | $constants = [ |
11 | 11 | # Информация об окружении |
12 | 12 | |
13 | 13 | 'EXE_NAME' => $APPLICATION->executablePath, |
14 | - 'DOC_ROOT' => dirname ($APPLICATION->executablePath), |
|
15 | - 'IS_ADMIN' => is_writable (getenv ('SystemRoot')), |
|
14 | + 'DOC_ROOT' => dirname($APPLICATION->executablePath), |
|
15 | + 'IS_ADMIN' => is_writable(getenv('SystemRoot')), |
|
16 | 16 | 'START_PARAMS' => $params, |
17 | 17 | 'USERNAME' => $env->username, |
18 | 18 | |
@@ -332,17 +332,17 @@ discard block |
||
332 | 332 | |
333 | 333 | # Моя подборка цветов |
334 | 334 | |
335 | - 'clDark' => $converter->fromHtml ('#0D0F12'), |
|
336 | - 'clDark2' => $converter->fromHtml ('#121416'), |
|
337 | - 'clTurquoise' => $converter->fromHtml ('#00ADB5'), |
|
338 | - 'clLight' => $converter->fromHtml ('#EEEEEE') |
|
335 | + 'clDark' => $converter->fromHtml('#0D0F12'), |
|
336 | + 'clDark2' => $converter->fromHtml('#121416'), |
|
337 | + 'clTurquoise' => $converter->fromHtml('#00ADB5'), |
|
338 | + 'clLight' => $converter->fromHtml('#EEEEEE') |
|
339 | 339 | ]; |
340 | 340 | |
341 | 341 | foreach ($constants as $name => $value) |
342 | - define ($name, $value); |
|
342 | + define($name, $value); |
|
343 | 343 | |
344 | 344 | $argv = START_PARAMS; |
345 | -$argc = sizeof ($argv); |
|
345 | +$argc = sizeof($argv); |
|
346 | 346 | |
347 | -VoidEngine::removeObjects ($converter->selector); |
|
347 | +VoidEngine::removeObjects($converter->selector); |
|
348 | 348 | unset ($constants, $env, $params, $converter); |