@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -function err_status (bool $status = null): bool |
|
5 | +function err_status(bool $status = null): bool |
|
6 | 6 | { |
7 | 7 | $oldStatus = $GLOBALS['__debug']['error_status']; |
8 | 8 | |
@@ -12,203 +12,203 @@ discard block |
||
12 | 12 | return $oldStatus; |
13 | 13 | } |
14 | 14 | |
15 | -function err_no (): bool |
|
15 | +function err_no(): bool |
|
16 | 16 | { |
17 | - return err_status (false); |
|
17 | + return err_status(false); |
|
18 | 18 | } |
19 | 19 | |
20 | -function err_yes (): bool |
|
20 | +function err_yes(): bool |
|
21 | 21 | { |
22 | - return err_status (true); |
|
22 | + return err_status(true); |
|
23 | 23 | } |
24 | 24 | |
25 | -function run (string $path, ...$args) |
|
25 | +function run(string $path, ...$args) |
|
26 | 26 | { |
27 | - return (new Process)->start ($path, ...$args); |
|
27 | + return (new Process)->start($path, ...$args); |
|
28 | 28 | } |
29 | 29 | |
30 | -function vbs_exec (string $code) |
|
30 | +function vbs_exec(string $code) |
|
31 | 31 | { |
32 | - file_put_contents ($path = getenv ('temp') .'/'. crc32 ($code) .'.vbs', $code); |
|
32 | + file_put_contents($path = getenv('temp').'/'.crc32($code).'.vbs', $code); |
|
33 | 33 | |
34 | - (new \COM ('WScript.Shell'))->Run ($path, 0, true); |
|
34 | + (new \COM('WScript.Shell'))->Run($path, 0, true); |
|
35 | 35 | |
36 | - unlink ($path); |
|
36 | + unlink($path); |
|
37 | 37 | } |
38 | 38 | |
39 | -function php_errors_check (string $code): ?array |
|
39 | +function php_errors_check(string $code): ?array |
|
40 | 40 | { |
41 | 41 | try |
42 | 42 | { |
43 | - eval ('return; '. $code); |
|
43 | + eval ('return; '.$code); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | catch (\Throwable $e) |
47 | 47 | { |
48 | 48 | return [ |
49 | - 'text' => $e->getMessage (), |
|
50 | - 'line' => $e->getLine () |
|
49 | + 'text' => $e->getMessage(), |
|
50 | + 'line' => $e->getLine() |
|
51 | 51 | ]; |
52 | 52 | } |
53 | 53 | |
54 | 54 | return null; |
55 | 55 | } |
56 | 56 | |
57 | -function enum (string $name): array |
|
57 | +function enum(string $name): array |
|
58 | 58 | { |
59 | 59 | return [ |
60 | - substr ($name, strrpos ($name, '.') + 1), |
|
61 | - ($name = substr ($name, 0, strrpos ($name, '.'))) .', '. substr ($name, 0, strrpos ($name, '.')) |
|
60 | + substr($name, strrpos($name, '.') + 1), |
|
61 | + ($name = substr($name, 0, strrpos($name, '.'))).', '.substr($name, 0, strrpos($name, '.')) |
|
62 | 62 | ]; |
63 | 63 | } |
64 | 64 | |
65 | -function getNetArray (string $type, array $items = []): WFObject |
|
65 | +function getNetArray(string $type, array $items = []): WFObject |
|
66 | 66 | { |
67 | - $array = (new WFClass ('System.Array', null)) |
|
68 | - ->createInstance (VoidEngine::objectType ($type), $size = sizeof ($items)); |
|
67 | + $array = (new WFClass('System.Array', null)) |
|
68 | + ->createInstance(VoidEngine::objectType($type), $size = sizeof($items)); |
|
69 | 69 | |
70 | 70 | for ($i = 0; $i < $size; ++$i) |
71 | - $array[$i] = array_shift ($items); |
|
71 | + $array[$i] = array_shift($items); |
|
72 | 72 | |
73 | 73 | return $array; |
74 | 74 | } |
75 | 75 | |
76 | -function dir_create (string $path, int $mode = 0777): void |
|
76 | +function dir_create(string $path, int $mode = 0777): void |
|
77 | 77 | { |
78 | - if (!is_dir ($path)) |
|
79 | - mkdir ($path, $mode, true); |
|
78 | + if (!is_dir($path)) |
|
79 | + mkdir($path, $mode, true); |
|
80 | 80 | } |
81 | 81 | |
82 | -function dir_delete (string $path): bool |
|
82 | +function dir_delete(string $path): bool |
|
83 | 83 | { |
84 | - if (!is_dir ($path)) |
|
84 | + if (!is_dir($path)) |
|
85 | 85 | return false; |
86 | 86 | |
87 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
88 | - if (is_dir ($file = $path .'/'. $file)) |
|
87 | + foreach (array_slice(scandir($path), 2) as $file) |
|
88 | + if (is_dir($file = $path.'/'.$file)) |
|
89 | 89 | { |
90 | - dir_delete ($file); |
|
90 | + dir_delete($file); |
|
91 | 91 | |
92 | - if (is_dir ($file)) |
|
93 | - rmdir ($file); |
|
92 | + if (is_dir($file)) |
|
93 | + rmdir($file); |
|
94 | 94 | } |
95 | 95 | |
96 | - else unlink ($file); |
|
96 | + else unlink($file); |
|
97 | 97 | |
98 | - rmdir ($path); |
|
98 | + rmdir($path); |
|
99 | 99 | |
100 | 100 | return true; |
101 | 101 | } |
102 | 102 | |
103 | -function dir_clean (string $path): void |
|
103 | +function dir_clean(string $path): void |
|
104 | 104 | { |
105 | - dir_delete ($path); |
|
106 | - dir_create ($path); |
|
105 | + dir_delete($path); |
|
106 | + dir_create($path); |
|
107 | 107 | } |
108 | 108 | |
109 | -function dir_copy (string $from, string $to): bool |
|
109 | +function dir_copy(string $from, string $to): bool |
|
110 | 110 | { |
111 | - if (!is_dir ($from)) |
|
111 | + if (!is_dir($from)) |
|
112 | 112 | return false; |
113 | 113 | |
114 | - if (!is_dir ($to)) |
|
115 | - dir_create ($to); |
|
114 | + if (!is_dir($to)) |
|
115 | + dir_create($to); |
|
116 | 116 | |
117 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
118 | - if (is_dir ($f = $from .'/'. $file)) |
|
119 | - dir_copy ($f, $to .'/'. $file); |
|
117 | + foreach (array_slice(scandir($from), 2) as $file) |
|
118 | + if (is_dir($f = $from.'/'.$file)) |
|
119 | + dir_copy($f, $to.'/'.$file); |
|
120 | 120 | |
121 | - else copy ($f, $to .'/'. $file); |
|
121 | + else copy($f, $to.'/'.$file); |
|
122 | 122 | |
123 | 123 | return true; |
124 | 124 | } |
125 | 125 | |
126 | -function getARGBColor (string $color) |
|
126 | +function getARGBColor(string $color) |
|
127 | 127 | { |
128 | - return (new WFClass ('System.Drawing.ColorTranslator'))->fromHtml ($color); |
|
128 | + return (new WFClass('System.Drawing.ColorTranslator'))->fromHtml($color); |
|
129 | 129 | } |
130 | 130 | |
131 | -function replaceSl (string $string): string |
|
131 | +function replaceSl(string $string): string |
|
132 | 132 | { |
133 | - return str_replace ('\\', '/', $string); |
|
133 | + return str_replace('\\', '/', $string); |
|
134 | 134 | } |
135 | 135 | |
136 | -function replaceSr (string $string): string |
|
136 | +function replaceSr(string $string): string |
|
137 | 137 | { |
138 | - return str_replace ('/', '\\', $string); |
|
138 | + return str_replace('/', '\\', $string); |
|
139 | 139 | } |
140 | 140 | |
141 | -function basenameNoExt (string $path): string |
|
141 | +function basenameNoExt(string $path): string |
|
142 | 142 | { |
143 | - return pathinfo ($path, PATHINFO_FILENAME); |
|
143 | + return pathinfo($path, PATHINFO_FILENAME); |
|
144 | 144 | } |
145 | 145 | |
146 | -function file_ext (string $path): string |
|
146 | +function file_ext(string $path): string |
|
147 | 147 | { |
148 | - return strtolower (pathinfo ($path, PATHINFO_EXTENSION)); |
|
148 | + return strtolower(pathinfo($path, PATHINFO_EXTENSION)); |
|
149 | 149 | } |
150 | 150 | |
151 | -function filepathNoExt (string $path): string |
|
151 | +function filepathNoExt(string $path): string |
|
152 | 152 | { |
153 | - return dirname ($path) .'/'. basenameNoExt ($path); |
|
153 | + return dirname($path).'/'.basenameNoExt($path); |
|
154 | 154 | } |
155 | 155 | |
156 | -function array_first (array $array) |
|
156 | +function array_first(array $array) |
|
157 | 157 | { |
158 | - return array_shift ($array); |
|
158 | + return array_shift($array); |
|
159 | 159 | } |
160 | 160 | |
161 | -function array_end (array $array) |
|
161 | +function array_end(array $array) |
|
162 | 162 | { |
163 | - return array_pop ($array); |
|
163 | + return array_pop($array); |
|
164 | 164 | } |
165 | 165 | |
166 | -function substr_icount (string $haystack, string $needle, ...$params): int |
|
166 | +function substr_icount(string $haystack, string $needle, ...$params): int |
|
167 | 167 | { |
168 | - return substr_count (strtolower ($haystack), strtolower ($needle), ...$params); |
|
168 | + return substr_count(strtolower($haystack), strtolower($needle), ...$params); |
|
169 | 169 | } |
170 | 170 | |
171 | -function str_replace_assoc (string $subject, array $replacements): string |
|
171 | +function str_replace_assoc(string $subject, array $replacements): string |
|
172 | 172 | { |
173 | - return str_replace (array_keys ($replacements), array_values ($replacements), $subject); |
|
173 | + return str_replace(array_keys($replacements), array_values($replacements), $subject); |
|
174 | 174 | } |
175 | 175 | |
176 | -function pre (...$args): void |
|
176 | +function pre(...$args): void |
|
177 | 177 | { |
178 | - message (sizeof ($args) < 2 ? current ($args) : $args); |
|
178 | + message(sizeof($args) < 2 ? current ($args) : $args); |
|
179 | 179 | } |
180 | 180 | |
181 | -function messageBox (string $message, string $caption = '', ...$args) |
|
181 | +function messageBox(string $message, string $caption = '', ...$args) |
|
182 | 182 | { |
183 | - return (new MessageBox)->show ($message, $caption, ...$args); |
|
183 | + return (new MessageBox)->show($message, $caption, ...$args); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | class Components |
187 | 187 | { |
188 | 188 | static array $components = []; |
189 | 189 | |
190 | - public static function addComponent (int $selector, object $object): void |
|
190 | + public static function addComponent(int $selector, object $object): void |
|
191 | 191 | { |
192 | 192 | self::$components[$selector] = $object; |
193 | 193 | } |
194 | 194 | |
195 | - public static function getComponent (int $selector) |
|
195 | + public static function getComponent(int $selector) |
|
196 | 196 | { |
197 | 197 | return isset (self::$components[$selector]) ? |
198 | 198 | self::$components[$selector] : false; |
199 | 199 | } |
200 | 200 | |
201 | - public static function componentExists (int $selector): bool |
|
201 | + public static function componentExists(int $selector): bool |
|
202 | 202 | { |
203 | 203 | return isset (self::$components[$selector]); |
204 | 204 | } |
205 | 205 | |
206 | - public static function removeComponent (int $selector): void |
|
206 | + public static function removeComponent(int $selector): void |
|
207 | 207 | { |
208 | 208 | unset (self::$components[$selector]); |
209 | 209 | } |
210 | 210 | |
211 | - public static function cleanJunk (): void |
|
211 | + public static function cleanJunk(): void |
|
212 | 212 | { |
213 | 213 | // TODO: более строгие правила очистки мусорных объектов |
214 | 214 | |
@@ -216,46 +216,46 @@ discard block |
||
216 | 216 | { |
217 | 217 | try |
218 | 218 | { |
219 | - if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
219 | + if ($object->getType()->isSubclassOf(VoidEngine::objectType('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
223 | 223 | catch (\Exception $e) {} |
224 | 224 | |
225 | - VoidEngine::destructObject ($selector); |
|
225 | + VoidEngine::destructObject($selector); |
|
226 | 226 | |
227 | - if (!VoidEngine::objectExists ($selector)) |
|
227 | + if (!VoidEngine::objectExists($selector)) |
|
228 | 228 | unset (self::$components[$selector]); |
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | -function _c (int $selector) |
|
233 | +function _c(int $selector) |
|
234 | 234 | { |
235 | - return Components::getComponent ($selector); |
|
235 | + return Components::getComponent($selector); |
|
236 | 236 | } |
237 | 237 | |
238 | -function c ($name, bool $returnAllSimilarObjects = false) |
|
238 | +function c($name, bool $returnAllSimilarObjects = false) |
|
239 | 239 | { |
240 | - if (is_int ($name) && is_object ($object = _c ($name))) |
|
240 | + if (is_int($name) && is_object($object = _c($name))) |
|
241 | 241 | return $object; |
242 | 242 | |
243 | 243 | else |
244 | 244 | { |
245 | - $path = explode ('->', $name); |
|
245 | + $path = explode('->', $name); |
|
246 | 246 | $similar = []; |
247 | 247 | |
248 | 248 | foreach (Components::$components as $object) |
249 | 249 | try |
250 | 250 | { |
251 | - if ($object->name == end ($path)) |
|
251 | + if ($object->name == end($path)) |
|
252 | 252 | { |
253 | - if (sizeof ($path) > 1) |
|
253 | + if (sizeof($path) > 1) |
|
254 | 254 | try |
255 | 255 | { |
256 | - if (is_object ($parent = _c($object->parent->selector))) |
|
256 | + if (is_object($parent = _c($object->parent->selector))) |
|
257 | 257 | { |
258 | - if (c(join ('->', array_slice ($path, 0, -1))) == $parent) |
|
258 | + if (c(join('->', array_slice($path, 0, -1))) == $parent) |
|
259 | 259 | { |
260 | 260 | if ($returnAllSimilarObjects) |
261 | 261 | $similar[] = $object; |
@@ -289,18 +289,18 @@ discard block |
||
289 | 289 | continue; |
290 | 290 | } |
291 | 291 | |
292 | - if (sizeof ($path) == 2) |
|
292 | + if (sizeof($path) == 2) |
|
293 | 293 | { |
294 | 294 | $objects = c($path[1], true); |
295 | 295 | |
296 | - if (is_array ($objects)) |
|
296 | + if (is_array($objects)) |
|
297 | 297 | { |
298 | 298 | foreach ($objects as $id => $object) |
299 | 299 | try |
300 | 300 | { |
301 | - while (is_object ($parent = _c($object->parent->selector))) |
|
301 | + while (is_object($parent = _c($object->parent->selector))) |
|
302 | 302 | { |
303 | - if ($parent->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
|
303 | + if ($parent->getType()->isSubclassOf(VoidEngine::objectType('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
|
304 | 304 | return $objects[$id]; |
305 | 305 | |
306 | 306 | else $object = $parent; |
@@ -318,70 +318,70 @@ discard block |
||
318 | 318 | else return false; |
319 | 319 | } |
320 | 320 | |
321 | - else return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
321 | + else return $returnAllSimilarObjects && sizeof($similar) > 0 ? |
|
322 | 322 | $similar : false; |
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
326 | -function setTimer (int $interval, callable $function): Timer |
|
326 | +function setTimer(int $interval, callable $function): Timer |
|
327 | 327 | { |
328 | 328 | $timer = new Timer; |
329 | 329 | $timer->interval = $interval; |
330 | 330 | |
331 | - $timer->tickEvent = function ($self) use ($function) |
|
331 | + $timer->tickEvent = function($self) use ($function) |
|
332 | 332 | { |
333 | - call_user_func ($function, $self); |
|
333 | + call_user_func($function, $self); |
|
334 | 334 | }; |
335 | 335 | |
336 | - $timer->start (); |
|
336 | + $timer->start(); |
|
337 | 337 | |
338 | 338 | return $timer; |
339 | 339 | } |
340 | 340 | |
341 | 341 | // FIXME: выполняется несколько раз, а не единожды |
342 | -function setTimeout (int $timeout, callable $function): Timer |
|
342 | +function setTimeout(int $timeout, callable $function): Timer |
|
343 | 343 | { |
344 | 344 | $timer = new Timer; |
345 | 345 | $timer->interval = $timeout; |
346 | 346 | |
347 | - $timer->tickEvent = function ($self) use ($function) |
|
347 | + $timer->tickEvent = function($self) use ($function) |
|
348 | 348 | { |
349 | - call_user_func ($function, $self); |
|
349 | + call_user_func($function, $self); |
|
350 | 350 | |
351 | - $self->stop (); |
|
351 | + $self->stop(); |
|
352 | 352 | }; |
353 | 353 | |
354 | - $timer->start (); |
|
354 | + $timer->start(); |
|
355 | 355 | |
356 | 356 | return $timer; |
357 | 357 | } |
358 | 358 | |
359 | 359 | class Clipboard |
360 | 360 | { |
361 | - public static function getText () |
|
361 | + public static function getText() |
|
362 | 362 | { |
363 | - return (new WFClass ('System.Windows.Forms.Clipboard'))->getText (); |
|
363 | + return (new WFClass('System.Windows.Forms.Clipboard'))->getText(); |
|
364 | 364 | } |
365 | 365 | |
366 | - public static function setText (string $text): void |
|
366 | + public static function setText(string $text): void |
|
367 | 367 | { |
368 | - (new WFClass ('System.Windows.Forms.Clipboard'))->setText ($text); |
|
368 | + (new WFClass('System.Windows.Forms.Clipboard'))->setText($text); |
|
369 | 369 | } |
370 | 370 | |
371 | - public static function getFiles (): array |
|
371 | + public static function getFiles(): array |
|
372 | 372 | { |
373 | - return (new WFClass ('System.Windows.Forms.Clipboard'))->getFileDropList ()->list; |
|
373 | + return (new WFClass('System.Windows.Forms.Clipboard'))->getFileDropList()->list; |
|
374 | 374 | } |
375 | 375 | |
376 | - public static function setFiles (array $files): void |
|
376 | + public static function setFiles(array $files): void |
|
377 | 377 | { |
378 | - $collection = new WFObject ('System.Collections.Specialized.StringCollection'); |
|
378 | + $collection = new WFObject('System.Collections.Specialized.StringCollection'); |
|
379 | 379 | |
380 | 380 | foreach ($files as $file) |
381 | - $collection->add ((string) $file); |
|
381 | + $collection->add((string) $file); |
|
382 | 382 | |
383 | - (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection); |
|
384 | - VoidEngine::removeObjects ($collection->selector); |
|
383 | + (new WFClass('System.Windows.Forms.Clipboard'))->setFileDropList($collection); |
|
384 | + VoidEngine::removeObjects($collection->selector); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
@@ -389,14 +389,13 @@ discard block |
||
389 | 389 | { |
390 | 390 | protected $cursor; |
391 | 391 | |
392 | - public function __construct (int $handle = null) |
|
392 | + public function __construct(int $handle = null) |
|
393 | 393 | { |
394 | 394 | $handle !== null ? |
395 | - $this->cursor = new WFObject ('System.Windows.Forms.Cursor', 'auto', $handle) : |
|
396 | - $this->cursor = new WFClass ('System.Windows.Forms.Cursor'); |
|
395 | + $this->cursor = new WFObject('System.Windows.Forms.Cursor', 'auto', $handle) : $this->cursor = new WFClass('System.Windows.Forms.Cursor'); |
|
397 | 396 | } |
398 | 397 | |
399 | - public function getPosition (): array |
|
398 | + public function getPosition(): array |
|
400 | 399 | { |
401 | 400 | $pos = $this->cursor->position; |
402 | 401 | |
@@ -407,22 +406,22 @@ discard block |
||
407 | 406 | } |
408 | 407 | } |
409 | 408 | |
410 | -function get_cursor_x (int $handle = null): int |
|
409 | +function get_cursor_x(int $handle = null): int |
|
411 | 410 | { |
412 | - return (new Cursor ($handle))->getPosition ()[0]; |
|
411 | + return (new Cursor($handle))->getPosition()[0]; |
|
413 | 412 | } |
414 | 413 | |
415 | -function get_cursor_y (int $handle = null): int |
|
414 | +function get_cursor_y(int $handle = null): int |
|
416 | 415 | { |
417 | - return (new Cursor ($handle))->getPosition ()[1]; |
|
416 | + return (new Cursor($handle))->getPosition()[1]; |
|
418 | 417 | } |
419 | 418 | |
420 | -function get_cursor_pos (int $handle = null): array |
|
419 | +function get_cursor_pos(int $handle = null): array |
|
421 | 420 | { |
422 | - return (new Cursor ($handle))->getPosition (); |
|
421 | + return (new Cursor($handle))->getPosition(); |
|
423 | 422 | } |
424 | 423 | |
425 | -set_error_handler (function ($no, $str, $file, $line) |
|
424 | +set_error_handler(function($no, $str, $file, $line) |
|
426 | 425 | { |
427 | 426 | // Мог ли я здесь сделать более адекватный код с использованием pow/sqrt? Да, мог |
428 | 427 | // Почему не сделал? Скорость важнее |
@@ -445,11 +444,11 @@ discard block |
||
445 | 444 | ]; |
446 | 445 | |
447 | 446 | if ($GLOBALS['__debug']['error_status']) |
448 | - message ([ |
|
447 | + message([ |
|
449 | 448 | 'type' => $errarr[$no], |
450 | 449 | 'text' => $str, |
451 | 450 | 'file' => $file, |
452 | 451 | 'line' => $line, |
453 | - 'backtrace' => debug_backtrace () |
|
452 | + 'backtrace' => debug_backtrace() |
|
454 | 453 | ], 'PHP Script Error'); |
455 | 454 | }); |
@@ -6,8 +6,9 @@ discard block |
||
6 | 6 | { |
7 | 7 | $oldStatus = $GLOBALS['__debug']['error_status']; |
8 | 8 | |
9 | - if ($status !== null) |
|
10 | - $GLOBALS['__debug']['error_status'] = $status; |
|
9 | + if ($status !== null) { |
|
10 | + $GLOBALS['__debug']['error_status'] = $status; |
|
11 | + } |
|
11 | 12 | |
12 | 13 | return $oldStatus; |
13 | 14 | } |
@@ -41,9 +42,7 @@ discard block |
||
41 | 42 | try |
42 | 43 | { |
43 | 44 | eval ('return; '. $code); |
44 | - } |
|
45 | - |
|
46 | - catch (\Throwable $e) |
|
45 | + } catch (\Throwable $e) |
|
47 | 46 | { |
48 | 47 | return [ |
49 | 48 | 'text' => $e->getMessage (), |
@@ -67,34 +66,39 @@ discard block |
||
67 | 66 | $array = (new WFClass ('System.Array', null)) |
68 | 67 | ->createInstance (VoidEngine::objectType ($type), $size = sizeof ($items)); |
69 | 68 | |
70 | - for ($i = 0; $i < $size; ++$i) |
|
71 | - $array[$i] = array_shift ($items); |
|
69 | + for ($i = 0; $i < $size; ++$i) { |
|
70 | + $array[$i] = array_shift ($items); |
|
71 | + } |
|
72 | 72 | |
73 | 73 | return $array; |
74 | 74 | } |
75 | 75 | |
76 | 76 | function dir_create (string $path, int $mode = 0777): void |
77 | 77 | { |
78 | - if (!is_dir ($path)) |
|
79 | - mkdir ($path, $mode, true); |
|
80 | -} |
|
78 | + if (!is_dir ($path)) { |
|
79 | + mkdir ($path, $mode, true); |
|
80 | + } |
|
81 | + } |
|
81 | 82 | |
82 | 83 | function dir_delete (string $path): bool |
83 | 84 | { |
84 | - if (!is_dir ($path)) |
|
85 | - return false; |
|
85 | + if (!is_dir ($path)) { |
|
86 | + return false; |
|
87 | + } |
|
86 | 88 | |
87 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
88 | - if (is_dir ($file = $path .'/'. $file)) |
|
89 | + foreach (array_slice (scandir ($path), 2) as $file) { |
|
90 | + if (is_dir ($file = $path .'/'. $file)) |
|
89 | 91 | { |
90 | 92 | dir_delete ($file); |
93 | + } |
|
91 | 94 | |
92 | - if (is_dir ($file)) |
|
93 | - rmdir ($file); |
|
95 | + if (is_dir ($file)) { |
|
96 | + rmdir ($file); |
|
97 | + } |
|
98 | + } else { |
|
99 | + unlink ($file); |
|
94 | 100 | } |
95 | 101 | |
96 | - else unlink ($file); |
|
97 | - |
|
98 | 102 | rmdir ($path); |
99 | 103 | |
100 | 104 | return true; |
@@ -108,17 +112,22 @@ discard block |
||
108 | 112 | |
109 | 113 | function dir_copy (string $from, string $to): bool |
110 | 114 | { |
111 | - if (!is_dir ($from)) |
|
112 | - return false; |
|
115 | + if (!is_dir ($from)) { |
|
116 | + return false; |
|
117 | + } |
|
113 | 118 | |
114 | - if (!is_dir ($to)) |
|
115 | - dir_create ($to); |
|
119 | + if (!is_dir ($to)) { |
|
120 | + dir_create ($to); |
|
121 | + } |
|
116 | 122 | |
117 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
118 | - if (is_dir ($f = $from .'/'. $file)) |
|
123 | + foreach (array_slice (scandir ($from), 2) as $file) { |
|
124 | + if (is_dir ($f = $from .'/'. $file)) |
|
119 | 125 | dir_copy ($f, $to .'/'. $file); |
126 | + } |
|
120 | 127 | |
121 | - else copy ($f, $to .'/'. $file); |
|
128 | + else { |
|
129 | + copy ($f, $to .'/'. $file); |
|
130 | + } |
|
122 | 131 | |
123 | 132 | return true; |
124 | 133 | } |
@@ -216,16 +225,16 @@ discard block |
||
216 | 225 | { |
217 | 226 | try |
218 | 227 | { |
219 | - if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
220 | - continue; |
|
221 | - } |
|
222 | - |
|
223 | - catch (\Exception $e) {} |
|
228 | + if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) { |
|
229 | + continue; |
|
230 | + } |
|
231 | + } catch (\Exception $e) {} |
|
224 | 232 | |
225 | 233 | VoidEngine::destructObject ($selector); |
226 | 234 | |
227 | - if (!VoidEngine::objectExists ($selector)) |
|
228 | - unset (self::$components[$selector]); |
|
235 | + if (!VoidEngine::objectExists ($selector)) { |
|
236 | + unset (self::$components[$selector]); |
|
237 | + } |
|
229 | 238 | } |
230 | 239 | } |
231 | 240 | } |
@@ -237,16 +246,15 @@ discard block |
||
237 | 246 | |
238 | 247 | function c ($name, bool $returnAllSimilarObjects = false) |
239 | 248 | { |
240 | - if (is_int ($name) && is_object ($object = _c ($name))) |
|
241 | - return $object; |
|
242 | - |
|
243 | - else |
|
249 | + if (is_int ($name) && is_object ($object = _c ($name))) { |
|
250 | + return $object; |
|
251 | + } else |
|
244 | 252 | { |
245 | 253 | $path = explode ('->', $name); |
246 | 254 | $similar = []; |
247 | 255 | |
248 | - foreach (Components::$components as $object) |
|
249 | - try |
|
256 | + foreach (Components::$components as $object) { |
|
257 | + try |
|
250 | 258 | { |
251 | 259 | if ($object->name == end ($path)) |
252 | 260 | { |
@@ -259,32 +267,30 @@ discard block |
||
259 | 267 | { |
260 | 268 | if ($returnAllSimilarObjects) |
261 | 269 | $similar[] = $object; |
270 | + } |
|
262 | 271 | |
263 | - else return $object; |
|
272 | + else { |
|
273 | + return $object; |
|
274 | + } |
|
275 | + } else { |
|
276 | + continue; |
|
264 | 277 | } |
265 | - |
|
266 | - else continue; |
|
278 | + } else { |
|
279 | + continue; |
|
267 | 280 | } |
268 | - |
|
269 | - else continue; |
|
270 | - } |
|
271 | - |
|
272 | - catch (\Throwable $e) |
|
281 | + } catch (\Throwable $e) |
|
273 | 282 | { |
274 | 283 | continue; |
275 | - } |
|
276 | - |
|
277 | - else |
|
284 | + } else |
|
278 | 285 | { |
279 | - if ($returnAllSimilarObjects) |
|
280 | - $similar[] = $object; |
|
281 | - |
|
282 | - else return $object; |
|
286 | + if ($returnAllSimilarObjects) { |
|
287 | + $similar[] = $object; |
|
288 | + } else { |
|
289 | + return $object; |
|
290 | + } |
|
283 | 291 | } |
284 | 292 | } |
285 | - } |
|
286 | - |
|
287 | - catch (\Exception $e) |
|
293 | + } catch (\Exception $e) |
|
288 | 294 | { |
289 | 295 | continue; |
290 | 296 | } |
@@ -295,31 +301,32 @@ discard block |
||
295 | 301 | |
296 | 302 | if (is_array ($objects)) |
297 | 303 | { |
298 | - foreach ($objects as $id => $object) |
|
299 | - try |
|
304 | + foreach ($objects as $id => $object) { |
|
305 | + try |
|
300 | 306 | { |
301 | 307 | while (is_object ($parent = _c($object->parent->selector))) |
302 | 308 | { |
303 | 309 | if ($parent->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
304 | 310 | return $objects[$id]; |
311 | + } |
|
305 | 312 | |
306 | - else $object = $parent; |
|
313 | + else { |
|
314 | + $object = $parent; |
|
315 | + } |
|
307 | 316 | } |
308 | - } |
|
309 | - |
|
310 | - catch (\Throwable $e) |
|
317 | + } catch (\Throwable $e) |
|
311 | 318 | { |
312 | 319 | continue; |
313 | 320 | } |
314 | 321 | |
315 | 322 | return false; |
323 | + } else { |
|
324 | + return false; |
|
316 | 325 | } |
317 | - |
|
318 | - else return false; |
|
319 | - } |
|
320 | - |
|
321 | - else return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
326 | + } else { |
|
327 | + return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
322 | 328 | $similar : false; |
329 | + } |
|
323 | 330 | } |
324 | 331 | } |
325 | 332 | |
@@ -377,8 +384,9 @@ discard block |
||
377 | 384 | { |
378 | 385 | $collection = new WFObject ('System.Collections.Specialized.StringCollection'); |
379 | 386 | |
380 | - foreach ($files as $file) |
|
381 | - $collection->add ((string) $file); |
|
387 | + foreach ($files as $file) { |
|
388 | + $collection->add ((string) $file); |
|
389 | + } |
|
382 | 390 | |
383 | 391 | (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection); |
384 | 392 | VoidEngine::removeObjects ($collection->selector); |
@@ -444,12 +452,13 @@ discard block |
||
444 | 452 | 16384 => 'E_USER_DEPRECATED' |
445 | 453 | ]; |
446 | 454 | |
447 | - if ($GLOBALS['__debug']['error_status']) |
|
448 | - message ([ |
|
455 | + if ($GLOBALS['__debug']['error_status']) { |
|
456 | + message ([ |
|
449 | 457 | 'type' => $errarr[$no], |
450 | 458 | 'text' => $str, |
451 | 459 | 'file' => $file, |
452 | 460 | 'line' => $line, |
453 | 461 | 'backtrace' => debug_backtrace () |
454 | 462 | ], 'PHP Script Error'); |
455 | -}); |
|
463 | + } |
|
464 | + }); |
@@ -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,12 +282,12 @@ discard block |
||
282 | 282 | * |
283 | 283 | */ |
284 | 284 | |
285 | - public static function setObjectEvent (int $selector, string $eventName, callable $event): void |
|
285 | + public static function setObjectEvent(int $selector, string $eventName, callable $event): void |
|
286 | 286 | { |
287 | 287 | /*if (self::eventExists ($selector, $eventName)) |
288 | 288 | self::removeObjectEvent ($selector, $eventName);*/ |
289 | 289 | |
290 | - \VoidCore::setEvent ($selector, $eventName, $event); |
|
290 | + \VoidCore::setEvent($selector, $eventName, $event); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | * |
306 | 306 | */ |
307 | 307 | |
308 | - public static function eventExists (int $selector, string $eventName): bool |
|
308 | + public static function eventExists(int $selector, string $eventName): bool |
|
309 | 309 | { |
310 | - return \VoidCore::eventExists ($selector, $eventName); |
|
310 | + return \VoidCore::eventExists($selector, $eventName); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | * |
325 | 325 | */ |
326 | 326 | |
327 | - public static function removeObjectEvent (int $selector, string $eventName): void |
|
327 | + public static function removeObjectEvent(int $selector, string $eventName): void |
|
328 | 328 | { |
329 | - \VoidCore::removeEvent ($selector, $eventName); |
|
329 | + \VoidCore::removeEvent($selector, $eventName); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | * |
339 | 339 | */ |
340 | 340 | |
341 | - public static function importObject (string $data): int |
|
341 | + public static function importObject(string $data): int |
|
342 | 342 | { |
343 | - return \VoidCore::importObject ($data); |
|
343 | + return \VoidCore::importObject($data); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | * |
353 | 353 | */ |
354 | 354 | |
355 | - public static function exportObject (int $selector): string |
|
355 | + public static function exportObject(int $selector): string |
|
356 | 356 | { |
357 | - return \VoidCore::exportObject ($selector); |
|
357 | + return \VoidCore::exportObject($selector); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -378,20 +378,20 @@ discard block |
||
378 | 378 | * |
379 | 379 | */ |
380 | 380 | |
381 | - public static function compile (string $savePath, string $iconPath, string $phpCode, string $productDescription = null, string $productName = null, string $productVersion = null, string $companyName = null, string $copyright = null, string $callSharpCode = '', string $declareSharpCode = '', WFObject $dictionary = null, WFObject $assemblies = null): array |
|
381 | + public static function compile(string $savePath, string $iconPath, string $phpCode, string $productDescription = null, string $productName = null, string $productVersion = null, string $companyName = null, string $copyright = null, string $callSharpCode = '', string $declareSharpCode = '', WFObject $dictionary = null, WFObject $assemblies = null): array |
|
382 | 382 | { |
383 | 383 | if ($dictionary === null) |
384 | - $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
384 | + $dictionary = new WFObject('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
385 | 385 | |
386 | 386 | if ($assemblies === null) |
387 | - $assemblies = getNetArray ('System.String', [ |
|
387 | + $assemblies = getNetArray('System.String', [ |
|
388 | 388 | // CORE_DIR .'/CefSharp.dll', |
389 | - CORE_DIR .'/FastColoredTextBox.dll', |
|
390 | - CORE_DIR .'/ScintillaNET.dll' |
|
389 | + CORE_DIR.'/FastColoredTextBox.dll', |
|
390 | + CORE_DIR.'/ScintillaNET.dll' |
|
391 | 391 | ]); |
392 | 392 | |
393 | 393 | if ($productName === null) |
394 | - $productName = basenameNoExt ($savePath); |
|
394 | + $productName = basenameNoExt($savePath); |
|
395 | 395 | |
396 | 396 | if ($productDescription === null) |
397 | 397 | $productDescription = $productName; |
@@ -403,19 +403,19 @@ discard block |
||
403 | 403 | $companyName = 'Company N'; |
404 | 404 | |
405 | 405 | if ($copyright === null) |
406 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
406 | + $copyright = $companyName.' copyright (c) '.date('Y'); |
|
407 | 407 | |
408 | - return (new WFClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
408 | + return (new WFClass('WinForms_PHP.WFCompiler', null))->compile($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | |
412 | 412 | class EngineAdditions |
413 | 413 | { |
414 | - public static function loadModule (string $path): bool |
|
414 | + public static function loadModule(string $path): bool |
|
415 | 415 | { |
416 | 416 | try |
417 | 417 | { |
418 | - (new WFClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
|
418 | + (new WFClass('System.Reflection.Assembly', 'mscorlib'))->loadFrom($path); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | catch (\Throwable $e) |
@@ -426,16 +426,16 @@ discard block |
||
426 | 426 | return true; |
427 | 427 | } |
428 | 428 | |
429 | - public static function getProperty (int $selector, string $name): array |
|
429 | + public static function getProperty(int $selector, string $name): array |
|
430 | 430 | { |
431 | - $property = VoidEngine::callMethod (VoidEngine::callMethod ($selector, 'GetType'), 'GetProperty', $name); |
|
431 | + $property = VoidEngine::callMethod(VoidEngine::callMethod($selector, 'GetType'), 'GetProperty', $name); |
|
432 | 432 | |
433 | - if (!is_int ($property)) |
|
433 | + if (!is_int($property)) |
|
434 | 434 | return false; |
435 | 435 | |
436 | 436 | try |
437 | 437 | { |
438 | - $propertyType = VoidEngine::getProperty ($property, ['PropertyType', 'string']); |
|
438 | + $propertyType = VoidEngine::getProperty($property, ['PropertyType', 'string']); |
|
439 | 439 | |
440 | 440 | switch ($propertyType) |
441 | 441 | { |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | default: |
472 | 472 | try |
473 | 473 | { |
474 | - VoidEngine::getProperty ($selector, [$name, 'int']); |
|
474 | + VoidEngine::getProperty($selector, [$name, 'int']); |
|
475 | 475 | |
476 | 476 | $property = 'int'; |
477 | 477 | } |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | { |
481 | 481 | return [ |
482 | 482 | 'type' => 'vrsf', |
483 | - 'value' => VoidEngine::exportObject (VoidEngine::getProperty ($selector, [$name, 'object'])) |
|
483 | + 'value' => VoidEngine::exportObject(VoidEngine::getProperty($selector, [$name, 'object'])) |
|
484 | 484 | ]; |
485 | 485 | } |
486 | 486 | break; |
@@ -494,19 +494,19 @@ discard block |
||
494 | 494 | |
495 | 495 | return [ |
496 | 496 | 'type' => $property, |
497 | - 'value' => VoidEngine::getProperty ($selector, [$name, $property]) |
|
497 | + 'value' => VoidEngine::getProperty($selector, [$name, $property]) |
|
498 | 498 | ]; |
499 | 499 | } |
500 | 500 | |
501 | - public static function getObjectEvents (int $object): array |
|
501 | + public static function getObjectEvents(int $object): array |
|
502 | 502 | { |
503 | 503 | $events = []; |
504 | 504 | |
505 | - $props = VoidEngine::callMethod (VoidEngine::callMethod ($object, 'GetType'), 'GetEvents'); |
|
506 | - $len = VoidEngine::getProperty ($props, 'Length'); |
|
505 | + $props = VoidEngine::callMethod(VoidEngine::callMethod($object, 'GetType'), 'GetEvents'); |
|
506 | + $len = VoidEngine::getProperty($props, 'Length'); |
|
507 | 507 | |
508 | 508 | for ($i = 0; $i < $len; ++$i) |
509 | - $events[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($props, $i), 'Name'); |
|
509 | + $events[] = VoidEngine::getProperty(VoidEngine::getArrayValue($props, $i), 'Name'); |
|
510 | 510 | |
511 | 511 | return $events; |
512 | 512 | } |
@@ -516,13 +516,13 @@ discard block |
||
516 | 516 | * Тогда получается бесконечный цикл вида object->selector->selector->selector->... |
517 | 517 | * Чтобы этого избежать нужно добавить исключение - переменную $selfSelector |
518 | 518 | */ |
519 | - public static function coupleSelector ($value, int $selfSelector = null) |
|
519 | + public static function coupleSelector($value, int $selfSelector = null) |
|
520 | 520 | { |
521 | - return is_int ($value) && VoidEngine::objectExists ($value) && $value != $selfSelector ? |
|
522 | - new WFObject ($value) : $value; |
|
521 | + return is_int($value) && VoidEngine::objectExists($value) && $value != $selfSelector ? |
|
522 | + new WFObject($value) : $value; |
|
523 | 523 | } |
524 | 524 | |
525 | - public static function uncoupleSelector ($value) |
|
525 | + public static function uncoupleSelector($value) |
|
526 | 526 | { |
527 | 527 | return $value instanceof WFObject ? |
528 | 528 | $value->selector : $value; |
@@ -534,44 +534,44 @@ discard block |
||
534 | 534 | protected int $selector = 0; |
535 | 535 | protected ?string $name; |
536 | 536 | |
537 | - public function __construct ($object, ?string $classGroup = 'auto', ...$args) |
|
537 | + public function __construct($object, ?string $classGroup = 'auto', ...$args) |
|
538 | 538 | { |
539 | 539 | foreach ($args as $id => $arg) |
540 | - $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
540 | + $args[$id] = EngineAdditions::uncoupleSelector($arg); |
|
541 | 541 | |
542 | - if (is_string ($object)) |
|
543 | - $this->selector = VoidEngine::createObject ($object, $classGroup == 'auto' ? |
|
544 | - substr ($object, 0, strrpos ($object, '.')) : $classGroup, ...$args); |
|
542 | + if (is_string($object)) |
|
543 | + $this->selector = VoidEngine::createObject($object, $classGroup == 'auto' ? |
|
544 | + substr ($object, 0, strrpos($object, '.')) : $classGroup, ...$args); |
|
545 | 545 | |
546 | - elseif (is_int ($object) && VoidEngine::objectExists ($object)) |
|
546 | + elseif (is_int($object) && VoidEngine::objectExists($object)) |
|
547 | 547 | $this->selector = $object; |
548 | 548 | |
549 | - else throw new \Exception ('$object parameter must be string or object selector'); |
|
549 | + else throw new \Exception('$object parameter must be string or object selector'); |
|
550 | 550 | } |
551 | 551 | |
552 | - public function __get ($name) |
|
552 | + public function __get($name) |
|
553 | 553 | { |
554 | - if (method_exists ($this, $method = "get_$name")) |
|
555 | - $value = $this->$method (); |
|
554 | + if (method_exists($this, $method = "get_$name")) |
|
555 | + $value = $this->$method(); |
|
556 | 556 | |
557 | - elseif (substr ($name, -5) == 'Event') |
|
558 | - $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
557 | + elseif (substr($name, -5) == 'Event') |
|
558 | + $value = Events::getObjectEvent($this->selector, substr($name, 0, -5)); |
|
559 | 559 | |
560 | - elseif (property_exists ($this, $name)) |
|
560 | + elseif (property_exists($this, $name)) |
|
561 | 561 | $value = $this->$name; |
562 | 562 | |
563 | - else switch (strtolower ($name)) |
|
563 | + else switch (strtolower($name)) |
|
564 | 564 | { |
565 | 565 | case 'count': |
566 | 566 | case 'length': |
567 | 567 | try |
568 | 568 | { |
569 | - return $this->getProperty ('Count'); |
|
569 | + return $this->getProperty('Count'); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | catch (\Throwable $e) |
573 | 573 | { |
574 | - return $this->getProperty ('Length'); |
|
574 | + return $this->getProperty('Length'); |
|
575 | 575 | } |
576 | 576 | break; |
577 | 577 | |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | $list = []; |
581 | 581 | |
582 | 582 | for ($i = 0; $i < $size; ++$i) |
583 | - $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i)); |
|
583 | + $list[] = EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $i)); |
|
584 | 584 | |
585 | 585 | return $list; |
586 | 586 | break; |
@@ -592,31 +592,31 @@ discard block |
||
592 | 592 | for ($i = 0; $i < $size; ++$i) |
593 | 593 | try |
594 | 594 | { |
595 | - $names[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($this->selector, [$i, 'object']), 'Text'); |
|
595 | + $names[] = VoidEngine::getProperty(VoidEngine::getArrayValue($this->selector, [$i, 'object']), 'Text'); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | catch (\Throwable $e) |
599 | 599 | { |
600 | - $names[] = VoidEngine::getArrayValue ($this->selector, [$i, 'string']); |
|
600 | + $names[] = VoidEngine::getArrayValue($this->selector, [$i, 'string']); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | return $names; |
604 | 604 | break; |
605 | 605 | |
606 | 606 | default: |
607 | - $value = $this->getProperty ($name); |
|
607 | + $value = $this->getProperty($name); |
|
608 | 608 | break; |
609 | 609 | } |
610 | 610 | |
611 | - return EngineAdditions::coupleSelector ($value, $this->selector); |
|
611 | + return EngineAdditions::coupleSelector($value, $this->selector); |
|
612 | 612 | } |
613 | 613 | |
614 | - public function __set ($name, $value) |
|
614 | + public function __set($name, $value) |
|
615 | 615 | { |
616 | - if (method_exists ($this, $method = "set_$name")) |
|
616 | + if (method_exists($this, $method = "set_$name")) |
|
617 | 617 | try |
618 | 618 | { |
619 | - return $this->$method ($value); |
|
619 | + return $this->$method($value); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | # Метод "set_$name" может принимать в качестве параметра объект WFObject |
@@ -625,63 +625,61 @@ discard block |
||
625 | 625 | catch (\Throwable $e) |
626 | 626 | { |
627 | 627 | return $value instanceof WFObject ? |
628 | - $this->$method ($value->selector) : null; |
|
628 | + $this->$method($value->selector) : null; |
|
629 | 629 | } |
630 | 630 | |
631 | - elseif (substr ($name, -5) == 'Event') |
|
632 | - Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
631 | + elseif (substr($name, -5) == 'Event') |
|
632 | + Events::setObjectEvent($this->selector, substr($name, 0, -5), $value); |
|
633 | 633 | |
634 | - else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
634 | + else $this->setProperty($name, EngineAdditions::uncoupleSelector($value)); |
|
635 | 635 | } |
636 | 636 | |
637 | - public function __call ($method, $args) |
|
637 | + public function __call($method, $args) |
|
638 | 638 | { |
639 | - $args = array_map (function ($arg) |
|
639 | + $args = array_map(function($arg) |
|
640 | 640 | { |
641 | - return EngineAdditions::uncoupleSelector ($arg); |
|
641 | + return EngineAdditions::uncoupleSelector($arg); |
|
642 | 642 | }, $args); |
643 | 643 | |
644 | - return EngineAdditions::coupleSelector ($this->callMethod ($method, ...$args), $this->selector); |
|
644 | + return EngineAdditions::coupleSelector($this->callMethod($method, ...$args), $this->selector); |
|
645 | 645 | } |
646 | 646 | |
647 | - public function addRange (array $values, $assoc = false): void |
|
647 | + public function addRange(array $values, $assoc = false): void |
|
648 | 648 | { |
649 | 649 | foreach ($values as $id => $value) |
650 | - $this->offsetSet ($assoc ? $id : null, $value); |
|
650 | + $this->offsetSet($assoc ? $id : null, $value); |
|
651 | 651 | } |
652 | 652 | |
653 | - public function offsetSet ($index, $value) |
|
653 | + public function offsetSet($index, $value) |
|
654 | 654 | { |
655 | 655 | try |
656 | 656 | { |
657 | 657 | return $index === null ? |
658 | - $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
|
659 | - $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
|
658 | + $this->callMethod('Add', EngineAdditions::uncoupleSelector($value)) : $this->callMethod('Insert', $index, EngineAdditions::uncoupleSelector($value)); |
|
660 | 659 | } |
661 | 660 | |
662 | 661 | catch (\Throwable $e) |
663 | 662 | { |
664 | 663 | return $index === null ? |
665 | - VoidEngine::setArrayValue ($this->selector, $this->count, $value) : |
|
666 | - VoidEngine::setArrayValue ($this->selector, $index, $value); |
|
664 | + VoidEngine::setArrayValue($this->selector, $this->count, $value) : VoidEngine::setArrayValue($this->selector, $index, $value); |
|
667 | 665 | } |
668 | 666 | } |
669 | 667 | |
670 | - public function offsetGet ($index) |
|
668 | + public function offsetGet($index) |
|
671 | 669 | { |
672 | - return EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $index), $this->selector); |
|
670 | + return EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $index), $this->selector); |
|
673 | 671 | } |
674 | 672 | |
675 | - public function offsetUnset ($index): void |
|
673 | + public function offsetUnset($index): void |
|
676 | 674 | { |
677 | - $this->callMethod ('RemoveAt', $index); |
|
675 | + $this->callMethod('RemoveAt', $index); |
|
678 | 676 | } |
679 | 677 | |
680 | - public function offsetExists ($index): bool |
|
678 | + public function offsetExists($index): bool |
|
681 | 679 | { |
682 | 680 | try |
683 | 681 | { |
684 | - $this->offsetGet ($index); |
|
682 | + $this->offsetGet($index); |
|
685 | 683 | } |
686 | 684 | |
687 | 685 | catch (\Exception $e) |
@@ -692,19 +690,19 @@ discard block |
||
692 | 690 | return true; |
693 | 691 | } |
694 | 692 | |
695 | - public function indexOf ($value): int |
|
693 | + public function indexOf($value): int |
|
696 | 694 | { |
697 | - return $this->callMethod ('IndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
695 | + return $this->callMethod('IndexOf', EngineAdditions::uncoupleSelector($value)); |
|
698 | 696 | } |
699 | 697 | |
700 | - public function lastIndexOf ($value): int |
|
698 | + public function lastIndexOf($value): int |
|
701 | 699 | { |
702 | - return $this->callMethod ('LastIndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
700 | + return $this->callMethod('LastIndexOf', EngineAdditions::uncoupleSelector($value)); |
|
703 | 701 | } |
704 | 702 | |
705 | - public function contains ($value): bool |
|
703 | + public function contains($value): bool |
|
706 | 704 | { |
707 | - return $this->callMethod ('Contains', EngineAdditions::uncoupleSelector ($value)); |
|
705 | + return $this->callMethod('Contains', EngineAdditions::uncoupleSelector($value)); |
|
708 | 706 | } |
709 | 707 | |
710 | 708 | public function foreach (callable $callback, string $type = null): void |
@@ -712,71 +710,71 @@ discard block |
||
712 | 710 | $size = $this->count; |
713 | 711 | |
714 | 712 | for ($i = 0; $i < $size; ++$i) |
715 | - $callback (EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
713 | + $callback(EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
716 | 714 | } |
717 | 715 | |
718 | - public function where (callable $comparator, string $type = null): array |
|
716 | + public function where(callable $comparator, string $type = null): array |
|
719 | 717 | { |
720 | 718 | $size = $this->count; |
721 | 719 | $return = []; |
722 | 720 | |
723 | 721 | for ($i = 0; $i < $size; ++$i) |
724 | - if ($comparator ($value = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
722 | + if ($comparator($value = EngineAdditions::coupleSelector(VoidEngine::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
725 | 723 | $return[] = $value; |
726 | 724 | |
727 | 725 | return $return; |
728 | 726 | } |
729 | 727 | |
730 | - protected function getProperty ($name) |
|
728 | + protected function getProperty($name) |
|
731 | 729 | { |
732 | 730 | try |
733 | 731 | { |
734 | - return VoidEngine::getProperty ($this->selector, $name); |
|
732 | + return VoidEngine::getProperty($this->selector, $name); |
|
735 | 733 | } |
736 | 734 | |
737 | 735 | catch (\Throwable $e) |
738 | 736 | { |
739 | - return VoidEngine::getField ($this->selector, $name); |
|
737 | + return VoidEngine::getField($this->selector, $name); |
|
740 | 738 | } |
741 | 739 | } |
742 | 740 | |
743 | - protected function setProperty ($name, $value) |
|
741 | + protected function setProperty($name, $value) |
|
744 | 742 | { |
745 | 743 | try |
746 | 744 | { |
747 | - VoidEngine::setProperty ($this->selector, $name, $value); |
|
745 | + VoidEngine::setProperty($this->selector, $name, $value); |
|
748 | 746 | } |
749 | 747 | |
750 | 748 | catch (\Throwable $e) |
751 | 749 | { |
752 | - VoidEngine::setField ($this->selector, $name, $value); |
|
750 | + VoidEngine::setField($this->selector, $name, $value); |
|
753 | 751 | } |
754 | 752 | } |
755 | 753 | |
756 | - protected function callMethod ($method, ...$args) |
|
754 | + protected function callMethod($method, ...$args) |
|
757 | 755 | { |
758 | - return VoidEngine::callMethod ($this->selector, $method, ...$args); |
|
756 | + return VoidEngine::callMethod($this->selector, $method, ...$args); |
|
759 | 757 | } |
760 | 758 | |
761 | - protected function getArrayProperty ($name, string $type = null) |
|
759 | + protected function getArrayProperty($name, string $type = null) |
|
762 | 760 | { |
763 | - $array = $this->getProperty ($name); |
|
764 | - $size = VoidEngine::getProperty ($array, 'Length'); |
|
761 | + $array = $this->getProperty($name); |
|
762 | + $size = VoidEngine::getProperty($array, 'Length'); |
|
765 | 763 | $return = []; |
766 | 764 | |
767 | 765 | for ($i = 0; $i < $size; ++$i) |
768 | - $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
766 | + $return[] = VoidEngine::getArrayValue($array, $type === null ? $i : [$i, $type]); |
|
769 | 767 | |
770 | - VoidEngine::removeObjects ($array); |
|
768 | + VoidEngine::removeObjects($array); |
|
771 | 769 | |
772 | 770 | return $return; |
773 | 771 | } |
774 | 772 | |
775 | - public function get_name () |
|
773 | + public function get_name() |
|
776 | 774 | { |
777 | 775 | try |
778 | 776 | { |
779 | - return $this->getProperty ('Name'); |
|
777 | + return $this->getProperty('Name'); |
|
780 | 778 | } |
781 | 779 | |
782 | 780 | catch (\Throwable $e) |
@@ -785,11 +783,11 @@ discard block |
||
785 | 783 | } |
786 | 784 | } |
787 | 785 | |
788 | - public function set_name (string $name) |
|
786 | + public function set_name(string $name) |
|
789 | 787 | { |
790 | 788 | try |
791 | 789 | { |
792 | - $this->setProperty ('Name', $name); |
|
790 | + $this->setProperty('Name', $name); |
|
793 | 791 | } |
794 | 792 | |
795 | 793 | catch (\Throwable $e) |
@@ -798,24 +796,24 @@ discard block |
||
798 | 796 | } |
799 | 797 | } |
800 | 798 | |
801 | - public function __toString (): string |
|
799 | + public function __toString(): string |
|
802 | 800 | { |
803 | - return $this->callMethod ('ToString'); |
|
801 | + return $this->callMethod('ToString'); |
|
804 | 802 | } |
805 | 803 | } |
806 | 804 | |
807 | 805 | class WFClass extends WFObject |
808 | 806 | { |
809 | - public function __construct ($class, ?string $classGroup = 'auto') |
|
807 | + public function __construct($class, ?string $classGroup = 'auto') |
|
810 | 808 | { |
811 | - if (is_string ($class)) |
|
812 | - $this->selector = VoidEngine::createClass ($class, $classGroup == 'auto' ? |
|
813 | - substr ($class, 0, strrpos ($class, '.')) : $classGroup |
|
809 | + if (is_string($class)) |
|
810 | + $this->selector = VoidEngine::createClass($class, $classGroup == 'auto' ? |
|
811 | + substr ($class, 0, strrpos($class, '.')) : $classGroup |
|
814 | 812 | ); |
815 | 813 | |
816 | - elseif (is_int ($class) && VoidEngine::objectExists ($class)) |
|
814 | + elseif (is_int($class) && VoidEngine::objectExists($class)) |
|
817 | 815 | $this->selector = $class; |
818 | 816 | |
819 | - else throw new \Exception ('$class parameter must be string or class selector'); |
|
817 | + else throw new \Exception('$class parameter must be string or class selector'); |
|
820 | 818 | } |
821 | 819 | } |
@@ -380,30 +380,37 @@ discard block |
||
380 | 380 | |
381 | 381 | public static function compile (string $savePath, string $iconPath, string $phpCode, string $productDescription = null, string $productName = null, string $productVersion = null, string $companyName = null, string $copyright = null, string $callSharpCode = '', string $declareSharpCode = '', WFObject $dictionary = null, WFObject $assemblies = null): array |
382 | 382 | { |
383 | - if ($dictionary === null) |
|
384 | - $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
383 | + if ($dictionary === null) { |
|
384 | + $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
385 | + } |
|
385 | 386 | |
386 | - if ($assemblies === null) |
|
387 | - $assemblies = getNetArray ('System.String', [ |
|
387 | + if ($assemblies === null) { |
|
388 | + $assemblies = getNetArray ('System.String', [ |
|
388 | 389 | // CORE_DIR .'/CefSharp.dll', |
389 | 390 | CORE_DIR .'/FastColoredTextBox.dll', |
390 | 391 | CORE_DIR .'/ScintillaNET.dll' |
391 | 392 | ]); |
393 | + } |
|
392 | 394 | |
393 | - if ($productName === null) |
|
394 | - $productName = basenameNoExt ($savePath); |
|
395 | + if ($productName === null) { |
|
396 | + $productName = basenameNoExt ($savePath); |
|
397 | + } |
|
395 | 398 | |
396 | - if ($productDescription === null) |
|
397 | - $productDescription = $productName; |
|
399 | + if ($productDescription === null) { |
|
400 | + $productDescription = $productName; |
|
401 | + } |
|
398 | 402 | |
399 | - if ($productVersion === null) |
|
400 | - $productVersion = '1.0'; |
|
403 | + if ($productVersion === null) { |
|
404 | + $productVersion = '1.0'; |
|
405 | + } |
|
401 | 406 | |
402 | - if ($companyName === null) |
|
403 | - $companyName = 'Company N'; |
|
407 | + if ($companyName === null) { |
|
408 | + $companyName = 'Company N'; |
|
409 | + } |
|
404 | 410 | |
405 | - if ($copyright === null) |
|
406 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
411 | + if ($copyright === null) { |
|
412 | + $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
413 | + } |
|
407 | 414 | |
408 | 415 | return (new WFClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
409 | 416 | } |
@@ -416,9 +423,7 @@ discard block |
||
416 | 423 | try |
417 | 424 | { |
418 | 425 | (new WFClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
419 | - } |
|
420 | - |
|
421 | - catch (\Throwable $e) |
|
426 | + } catch (\Throwable $e) |
|
422 | 427 | { |
423 | 428 | return false; |
424 | 429 | } |
@@ -430,8 +435,9 @@ discard block |
||
430 | 435 | { |
431 | 436 | $property = VoidEngine::callMethod (VoidEngine::callMethod ($selector, 'GetType'), 'GetProperty', $name); |
432 | 437 | |
433 | - if (!is_int ($property)) |
|
434 | - return false; |
|
438 | + if (!is_int ($property)) { |
|
439 | + return false; |
|
440 | + } |
|
435 | 441 | |
436 | 442 | try |
437 | 443 | { |
@@ -474,9 +480,7 @@ discard block |
||
474 | 480 | VoidEngine::getProperty ($selector, [$name, 'int']); |
475 | 481 | |
476 | 482 | $property = 'int'; |
477 | - } |
|
478 | - |
|
479 | - catch (\Throwable $e) |
|
483 | + } catch (\Throwable $e) |
|
480 | 484 | { |
481 | 485 | return [ |
482 | 486 | 'type' => 'vrsf', |
@@ -485,9 +489,7 @@ discard block |
||
485 | 489 | } |
486 | 490 | break; |
487 | 491 | } |
488 | - } |
|
489 | - |
|
490 | - catch (\Throwable $e) |
|
492 | + } catch (\Throwable $e) |
|
491 | 493 | { |
492 | 494 | $property = 'object'; |
493 | 495 | } |
@@ -505,8 +507,9 @@ discard block |
||
505 | 507 | $props = VoidEngine::callMethod (VoidEngine::callMethod ($object, 'GetType'), 'GetEvents'); |
506 | 508 | $len = VoidEngine::getProperty ($props, 'Length'); |
507 | 509 | |
508 | - for ($i = 0; $i < $len; ++$i) |
|
509 | - $events[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($props, $i), 'Name'); |
|
510 | + for ($i = 0; $i < $len; ++$i) { |
|
511 | + $events[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($props, $i), 'Name'); |
|
512 | + } |
|
510 | 513 | |
511 | 514 | return $events; |
512 | 515 | } |
@@ -536,40 +539,38 @@ discard block |
||
536 | 539 | |
537 | 540 | public function __construct ($object, ?string $classGroup = 'auto', ...$args) |
538 | 541 | { |
539 | - foreach ($args as $id => $arg) |
|
540 | - $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
542 | + foreach ($args as $id => $arg) { |
|
543 | + $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
544 | + } |
|
541 | 545 | |
542 | - if (is_string ($object)) |
|
543 | - $this->selector = VoidEngine::createObject ($object, $classGroup == 'auto' ? |
|
546 | + if (is_string ($object)) { |
|
547 | + $this->selector = VoidEngine::createObject ($object, $classGroup == 'auto' ? |
|
544 | 548 | substr ($object, 0, strrpos ($object, '.')) : $classGroup, ...$args); |
545 | - |
|
546 | - elseif (is_int ($object) && VoidEngine::objectExists ($object)) |
|
547 | - $this->selector = $object; |
|
548 | - |
|
549 | - else throw new \Exception ('$object parameter must be string or object selector'); |
|
549 | + } elseif (is_int ($object) && VoidEngine::objectExists ($object)) { |
|
550 | + $this->selector = $object; |
|
551 | + } else { |
|
552 | + throw new \Exception ('$object parameter must be string or object selector'); |
|
553 | + } |
|
550 | 554 | } |
551 | 555 | |
552 | 556 | public function __get ($name) |
553 | 557 | { |
554 | - if (method_exists ($this, $method = "get_$name")) |
|
555 | - $value = $this->$method (); |
|
556 | - |
|
557 | - elseif (substr ($name, -5) == 'Event') |
|
558 | - $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
559 | - |
|
560 | - elseif (property_exists ($this, $name)) |
|
561 | - $value = $this->$name; |
|
562 | - |
|
563 | - else switch (strtolower ($name)) |
|
558 | + if (method_exists ($this, $method = "get_$name")) { |
|
559 | + $value = $this->$method (); |
|
560 | + } elseif (substr ($name, -5) == 'Event') { |
|
561 | + $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
562 | + } elseif (property_exists ($this, $name)) { |
|
563 | + $value = $this->$name; |
|
564 | + } else { |
|
565 | + switch (strtolower ($name)) |
|
564 | 566 | { |
565 | 567 | case 'count': |
566 | 568 | case 'length': |
567 | 569 | try |
568 | 570 | { |
569 | 571 | return $this->getProperty ('Count'); |
570 | - } |
|
571 | - |
|
572 | - catch (\Throwable $e) |
|
572 | + } |
|
573 | + } catch (\Throwable $e) |
|
573 | 574 | { |
574 | 575 | return $this->getProperty ('Length'); |
575 | 576 | } |
@@ -579,8 +580,9 @@ discard block |
||
579 | 580 | $size = $this->count; |
580 | 581 | $list = []; |
581 | 582 | |
582 | - for ($i = 0; $i < $size; ++$i) |
|
583 | - $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i)); |
|
583 | + for ($i = 0; $i < $size; ++$i) { |
|
584 | + $list[] = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $i)); |
|
585 | + } |
|
584 | 586 | |
585 | 587 | return $list; |
586 | 588 | break; |
@@ -589,13 +591,12 @@ discard block |
||
589 | 591 | $size = $this->count; |
590 | 592 | $names = []; |
591 | 593 | |
592 | - for ($i = 0; $i < $size; ++$i) |
|
593 | - try |
|
594 | + for ($i = 0; $i < $size; ++$i) { |
|
595 | + try |
|
594 | 596 | { |
595 | 597 | $names[] = VoidEngine::getProperty (VoidEngine::getArrayValue ($this->selector, [$i, 'object']), 'Text'); |
596 | - } |
|
597 | - |
|
598 | - catch (\Throwable $e) |
|
598 | + } |
|
599 | + } catch (\Throwable $e) |
|
599 | 600 | { |
600 | 601 | $names[] = VoidEngine::getArrayValue ($this->selector, [$i, 'string']); |
601 | 602 | } |
@@ -613,10 +614,11 @@ discard block |
||
613 | 614 | |
614 | 615 | public function __set ($name, $value) |
615 | 616 | { |
616 | - if (method_exists ($this, $method = "set_$name")) |
|
617 | - try |
|
617 | + if (method_exists ($this, $method = "set_$name")) { |
|
618 | + try |
|
618 | 619 | { |
619 | 620 | return $this->$method ($value); |
621 | + } |
|
620 | 622 | } |
621 | 623 | |
622 | 624 | # Метод "set_$name" может принимать в качестве параметра объект WFObject |
@@ -626,12 +628,11 @@ discard block |
||
626 | 628 | { |
627 | 629 | return $value instanceof WFObject ? |
628 | 630 | $this->$method ($value->selector) : null; |
629 | - } |
|
630 | - |
|
631 | - elseif (substr ($name, -5) == 'Event') |
|
632 | - Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
633 | - |
|
634 | - else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
631 | + } elseif (substr ($name, -5) == 'Event') { |
|
632 | + Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
633 | + } else { |
|
634 | + $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
635 | + } |
|
635 | 636 | } |
636 | 637 | |
637 | 638 | public function __call ($method, $args) |
@@ -646,8 +647,9 @@ discard block |
||
646 | 647 | |
647 | 648 | public function addRange (array $values, $assoc = false): void |
648 | 649 | { |
649 | - foreach ($values as $id => $value) |
|
650 | - $this->offsetSet ($assoc ? $id : null, $value); |
|
650 | + foreach ($values as $id => $value) { |
|
651 | + $this->offsetSet ($assoc ? $id : null, $value); |
|
652 | + } |
|
651 | 653 | } |
652 | 654 | |
653 | 655 | public function offsetSet ($index, $value) |
@@ -657,9 +659,7 @@ discard block |
||
657 | 659 | return $index === null ? |
658 | 660 | $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
659 | 661 | $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
660 | - } |
|
661 | - |
|
662 | - catch (\Throwable $e) |
|
662 | + } catch (\Throwable $e) |
|
663 | 663 | { |
664 | 664 | return $index === null ? |
665 | 665 | VoidEngine::setArrayValue ($this->selector, $this->count, $value) : |
@@ -682,9 +682,7 @@ discard block |
||
682 | 682 | try |
683 | 683 | { |
684 | 684 | $this->offsetGet ($index); |
685 | - } |
|
686 | - |
|
687 | - catch (\Exception $e) |
|
685 | + } catch (\Exception $e) |
|
688 | 686 | { |
689 | 687 | return false; |
690 | 688 | } |
@@ -711,8 +709,9 @@ discard block |
||
711 | 709 | { |
712 | 710 | $size = $this->count; |
713 | 711 | |
714 | - for ($i = 0; $i < $size; ++$i) |
|
715 | - $callback (EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
712 | + for ($i = 0; $i < $size; ++$i) { |
|
713 | + $callback (EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
714 | + } |
|
716 | 715 | } |
717 | 716 | |
718 | 717 | public function where (callable $comparator, string $type = null): array |
@@ -720,9 +719,10 @@ discard block |
||
720 | 719 | $size = $this->count; |
721 | 720 | $return = []; |
722 | 721 | |
723 | - for ($i = 0; $i < $size; ++$i) |
|
724 | - if ($comparator ($value = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
722 | + for ($i = 0; $i < $size; ++$i) { |
|
723 | + if ($comparator ($value = EngineAdditions::coupleSelector (VoidEngine::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
725 | 724 | $return[] = $value; |
725 | + } |
|
726 | 726 | |
727 | 727 | return $return; |
728 | 728 | } |
@@ -732,9 +732,7 @@ discard block |
||
732 | 732 | try |
733 | 733 | { |
734 | 734 | return VoidEngine::getProperty ($this->selector, $name); |
735 | - } |
|
736 | - |
|
737 | - catch (\Throwable $e) |
|
735 | + } catch (\Throwable $e) |
|
738 | 736 | { |
739 | 737 | return VoidEngine::getField ($this->selector, $name); |
740 | 738 | } |
@@ -745,9 +743,7 @@ discard block |
||
745 | 743 | try |
746 | 744 | { |
747 | 745 | VoidEngine::setProperty ($this->selector, $name, $value); |
748 | - } |
|
749 | - |
|
750 | - catch (\Throwable $e) |
|
746 | + } catch (\Throwable $e) |
|
751 | 747 | { |
752 | 748 | VoidEngine::setField ($this->selector, $name, $value); |
753 | 749 | } |
@@ -764,8 +760,9 @@ discard block |
||
764 | 760 | $size = VoidEngine::getProperty ($array, 'Length'); |
765 | 761 | $return = []; |
766 | 762 | |
767 | - for ($i = 0; $i < $size; ++$i) |
|
768 | - $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
763 | + for ($i = 0; $i < $size; ++$i) { |
|
764 | + $return[] = VoidEngine::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
765 | + } |
|
769 | 766 | |
770 | 767 | VoidEngine::removeObjects ($array); |
771 | 768 | |
@@ -777,9 +774,7 @@ discard block |
||
777 | 774 | try |
778 | 775 | { |
779 | 776 | return $this->getProperty ('Name'); |
780 | - } |
|
781 | - |
|
782 | - catch (\Throwable $e) |
|
777 | + } catch (\Throwable $e) |
|
783 | 778 | { |
784 | 779 | return $this->name; |
785 | 780 | } |
@@ -790,9 +785,7 @@ discard block |
||
790 | 785 | try |
791 | 786 | { |
792 | 787 | $this->setProperty ('Name', $name); |
793 | - } |
|
794 | - |
|
795 | - catch (\Throwable $e) |
|
788 | + } catch (\Throwable $e) |
|
796 | 789 | { |
797 | 790 | $this->name = $name; |
798 | 791 | } |
@@ -808,14 +801,14 @@ discard block |
||
808 | 801 | { |
809 | 802 | public function __construct ($class, ?string $classGroup = 'auto') |
810 | 803 | { |
811 | - if (is_string ($class)) |
|
812 | - $this->selector = VoidEngine::createClass ($class, $classGroup == 'auto' ? |
|
804 | + if (is_string ($class)) { |
|
805 | + $this->selector = VoidEngine::createClass ($class, $classGroup == 'auto' ? |
|
813 | 806 | substr ($class, 0, strrpos ($class, '.')) : $classGroup |
814 | 807 | ); |
815 | - |
|
816 | - elseif (is_int ($class) && VoidEngine::objectExists ($class)) |
|
817 | - $this->selector = $class; |
|
818 | - |
|
819 | - 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 | + } |
|
820 | 813 | } |
821 | 814 | } |
@@ -7,43 +7,43 @@ discard block |
||
7 | 7 | public WFClass $application; |
8 | 8 | public string $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 WFObject $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, |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | const ENGINE_VERSION = '3.5.0 build-2019/09/08'; |
37 | 37 | const ENGINE_DIR = __DIR__; |
38 | 38 | |
39 | -chdir (ENGINE_DIR); |
|
39 | +chdir(ENGINE_DIR); |
|
40 | 40 | |
41 | 41 | $GLOBALS['__debug'] = [ |
42 | - 'start_time' => microtime (true), |
|
42 | + 'start_time' => microtime(true), |
|
43 | 43 | 'error_status' => true |
44 | 44 | ]; |
45 | 45 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | require 'common/Others.php'; |
50 | 50 | require 'common/Events.php'; |
51 | 51 | |
52 | -define ('VoidEngine\CORE_VERSION', $APPLICATION->productVersion); |
|
52 | +define('VoidEngine\CORE_VERSION', $APPLICATION->productVersion); |
|
53 | 53 | |
54 | 54 | require 'components/Component.php'; |
55 | 55 | require 'components/Control.php'; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | require 'components/FastColoredTextBox.php'; |
99 | 99 | require 'components/Scintilla.php'; |
100 | 100 | |
101 | -if (is_dir ('extensions')) |
|
102 | - foreach (scandir ('extensions') as $ext) |
|
103 | - if (is_dir ('extensions/'. $ext) && file_exists ($ext = 'extensions/'. $ext .'/main.php')) |
|
101 | +if (is_dir('extensions')) |
|
102 | + foreach (scandir('extensions') as $ext) |
|
103 | + if (is_dir('extensions/'.$ext) && file_exists($ext = 'extensions/'.$ext.'/main.php')) |
|
104 | 104 | require $ext; |
@@ -42,7 +42,7 @@ |
||
42 | 42 | public string $name; // Имя объекта |
43 | 43 | public int $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; |
@@ -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,61 +145,61 @@ 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 | - elseif (sizeof ($methodArgs) > 0) |
|
160 | - self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
159 | + elseif (sizeof($methodArgs) > 0) |
|
160 | + self::$objects[$name]->$methodName(...eval ('namespace VoidEngine; return ['.implode(', ', $methodArgs).'];')); |
|
161 | 161 | |
162 | - else self::$objects[$name]->$methodName (); |
|
162 | + else self::$objects[$name]->$methodName(); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | catch (\Throwable $e) |
166 | 166 | { |
167 | 167 | if (self::$throw_errors) |
168 | - 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); |
|
168 | + 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); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | 172 | elseif (self::$throw_errors) |
173 | - throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
173 | + throw new \Exception('Calling method to an non-object at line "'.$syntaxInfo['line'].'"'); |
|
174 | 174 | break; |
175 | 175 | |
176 | 176 | case VLF_RUNTIME_EXECUTABLE: |
177 | - eval (self::formatLine ($syntaxInfo['info']['code'], self::$objects)); |
|
177 | + eval (self::formatLine($syntaxInfo['info']['code'], self::$objects)); |
|
178 | 178 | break; |
179 | 179 | } |
180 | 180 | |
181 | - if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) |
|
182 | - self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
181 | + if (isset ($syntaxInfo['syntax_nodes']) && sizeof($syntaxInfo['syntax_nodes']) > 0) |
|
182 | + self::$objects = self::run($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
183 | 183 | } |
184 | 184 | |
185 | - else throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
185 | + else throw new \Exception('Catched unknown syntax node: "'.json_encode($syntaxInfo).'"'); |
|
186 | 186 | |
187 | - if (is_dir ($resourcesDir)) |
|
188 | - foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
187 | + if (is_dir($resourcesDir)) |
|
188 | + foreach (glob($resourcesDir.'/*.vrsf') as $id => $dir) |
|
189 | 189 | { |
190 | - $baseName = basenameNoExt ($dir); |
|
191 | - $info = explode ('.', $baseName); |
|
190 | + $baseName = basenameNoExt($dir); |
|
191 | + $info = explode('.', $baseName); |
|
192 | 192 | |
193 | 193 | if (isset (self::$objects[$info[0]])) |
194 | 194 | { |
195 | 195 | if (isset ($info[2])) |
196 | 196 | { |
197 | - $collection = VoidEngine::getProperty (self::$objects[$info[0]]->selector, $info[1]); |
|
197 | + $collection = VoidEngine::getProperty(self::$objects[$info[0]]->selector, $info[1]); |
|
198 | 198 | |
199 | - VoidEngine::callMethod ($collection, 'Add', [VoidEngine::importObject (base64_encode (file_get_contents ($dir))), 'object']); |
|
199 | + VoidEngine::callMethod($collection, 'Add', [VoidEngine::importObject(base64_encode(file_get_contents($dir))), 'object']); |
|
200 | 200 | } |
201 | 201 | |
202 | - else VoidEngine::setProperty (self::$objects[$info[0]]->selector, $info[1], VoidEngine::importObject (base64_encode (file_get_contents ($dir)))); |
|
202 | + else VoidEngine::setProperty(self::$objects[$info[0]]->selector, $info[1], VoidEngine::importObject(base64_encode(file_get_contents($dir)))); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
@@ -216,26 +216,25 @@ discard block |
||
216 | 216 | * @return string - возвращает форматированную строку |
217 | 217 | */ |
218 | 218 | |
219 | - public static function formatLine (string $line, array $objects = []): string |
|
219 | + public static function formatLine(string $line, array $objects = []): string |
|
220 | 220 | { |
221 | - if (sizeof ($objects) > 0) |
|
221 | + if (sizeof($objects) > 0) |
|
222 | 222 | { |
223 | - $len = strlen ($line); |
|
223 | + $len = strlen($line); |
|
224 | 224 | $newLine = ''; |
225 | 225 | |
226 | - $replacement = array_map (function ($object) |
|
226 | + $replacement = array_map(function($object) |
|
227 | 227 | { |
228 | - return Components::componentExists ($object->selector) !== false ? |
|
229 | - '\VoidEngine\_c('. $object->selector .')' : |
|
230 | - 'unserialize (\''. serialize ($object) .'\')'; |
|
228 | + return Components::componentExists($object->selector) !== false ? |
|
229 | + '\VoidEngine\_c('.$object->selector.')' : 'unserialize (\''.serialize($object).'\')'; |
|
231 | 230 | }, $objects); |
232 | 231 | |
233 | - $replacement = array_map (function ($name) |
|
232 | + $replacement = array_map(function($name) |
|
234 | 233 | { |
235 | - return strlen ($name = trim ($name)) + substr_count ($name, '_'); |
|
236 | - }, $omap = array_flip ($replacement)); |
|
234 | + return strlen($name = trim($name)) + substr_count($name, '_'); |
|
235 | + }, $omap = array_flip($replacement)); |
|
237 | 236 | |
238 | - arsort ($replacement); |
|
237 | + arsort($replacement); |
|
239 | 238 | |
240 | 239 | $nReplacement = []; |
241 | 240 | |
@@ -243,14 +242,14 @@ discard block |
||
243 | 242 | $nReplacement[$omap[$replaceTo]] = $replaceTo; |
244 | 243 | |
245 | 244 | $replacement = $nReplacement; |
246 | - $blacklist = array_flip (['\'', '"', '$']); |
|
245 | + $blacklist = array_flip(['\'', '"', '$']); |
|
247 | 246 | |
248 | 247 | for ($i = 0; $i < $len; ++$i) |
249 | 248 | { |
250 | 249 | $replaced = false; |
251 | 250 | |
252 | 251 | foreach ($replacement as $name => $replaceAt) |
253 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
252 | + if (substr($line, $i, ($l = strlen($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
254 | 253 | { |
255 | 254 | $newLine .= $replaceAt; |
256 | 255 |
@@ -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,33 +143,34 @@ 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 | - elseif (sizeof ($methodArgs) > 0) |
|
160 | - self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
161 | - |
|
162 | - else self::$objects[$name]->$methodName (); |
|
163 | - } |
|
164 | - |
|
165 | - 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 | + } elseif (sizeof ($methodArgs) > 0) { |
|
161 | + self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
162 | + } else { |
|
163 | + self::$objects[$name]->$methodName (); |
|
164 | + } |
|
165 | + } catch (\Throwable $e) |
|
166 | 166 | { |
167 | - if (self::$throw_errors) |
|
168 | - 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 | + if (self::$throw_errors) { |
|
168 | + 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); |
|
169 | + } |
|
169 | 170 | } |
171 | + } elseif (self::$throw_errors) { |
|
172 | + throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
170 | 173 | } |
171 | - |
|
172 | - elseif (self::$throw_errors) |
|
173 | - throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
174 | 174 | break; |
175 | 175 | |
176 | 176 | case VLF_RUNTIME_EXECUTABLE: |
@@ -178,16 +178,18 @@ discard block |
||
178 | 178 | break; |
179 | 179 | } |
180 | 180 | |
181 | - if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) |
|
182 | - self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
181 | + if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) { |
|
182 | + self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
183 | + } |
|
184 | + } else { |
|
185 | + throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
183 | 186 | } |
184 | 187 | |
185 | - else throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
186 | - |
|
187 | - if (is_dir ($resourcesDir)) |
|
188 | - foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
188 | + if (is_dir ($resourcesDir)) { |
|
189 | + foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
189 | 190 | { |
190 | 191 | $baseName = basenameNoExt ($dir); |
192 | + } |
|
191 | 193 | $info = explode ('.', $baseName); |
192 | 194 | |
193 | 195 | if (isset (self::$objects[$info[0]])) |
@@ -197,9 +199,9 @@ discard block |
||
197 | 199 | $collection = VoidEngine::getProperty (self::$objects[$info[0]]->selector, $info[1]); |
198 | 200 | |
199 | 201 | VoidEngine::callMethod ($collection, 'Add', [VoidEngine::importObject (base64_encode (file_get_contents ($dir))), 'object']); |
202 | + } else { |
|
203 | + VoidEngine::setProperty (self::$objects[$info[0]]->selector, $info[1], VoidEngine::importObject (base64_encode (file_get_contents ($dir)))); |
|
200 | 204 | } |
201 | - |
|
202 | - else VoidEngine::setProperty (self::$objects[$info[0]]->selector, $info[1], VoidEngine::importObject (base64_encode (file_get_contents ($dir)))); |
|
203 | 205 | } |
204 | 206 | } |
205 | 207 | |
@@ -239,8 +241,9 @@ discard block |
||
239 | 241 | |
240 | 242 | $nReplacement = []; |
241 | 243 | |
242 | - foreach ($replacement as $replaceTo => $nLn) |
|
243 | - $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
244 | + foreach ($replacement as $replaceTo => $nLn) { |
|
245 | + $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
246 | + } |
|
244 | 247 | |
245 | 248 | $replacement = $nReplacement; |
246 | 249 | $blacklist = array_flip (['\'', '"', '$']); |
@@ -249,10 +252,11 @@ discard block |
||
249 | 252 | { |
250 | 253 | $replaced = false; |
251 | 254 | |
252 | - foreach ($replacement as $name => $replaceAt) |
|
253 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
255 | + foreach ($replacement as $name => $replaceAt) { |
|
256 | + if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
254 | 257 | { |
255 | 258 | $newLine .= $replaceAt; |
259 | + } |
|
256 | 260 | |
257 | 261 | $i += $l - 1; |
258 | 262 | $replaced = true; |
@@ -260,8 +264,9 @@ discard block |
||
260 | 264 | break; |
261 | 265 | } |
262 | 266 | |
263 | - if (!$replaced) |
|
264 | - $newLine .= $line[$i]; |
|
267 | + if (!$replaced) { |
|
268 | + $newLine .= $line[$i]; |
|
269 | + } |
|
265 | 270 | } |
266 | 271 | |
267 | 272 | $line = $newLine; |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | * @param string $content - VLF разметка или путь до файла разметки |
24 | 24 | * [@param array $settings = []] - список настроек и их значений (настройка => значение) |
25 | 25 | */ |
26 | - public function __construct (string $content, array $settings = []) |
|
26 | + public function __construct(string $content, array $settings = []) |
|
27 | 27 | { |
28 | - if (file_exists ($content)) |
|
29 | - $content = file_get_contents ($content); |
|
28 | + if (file_exists($content)) |
|
29 | + $content = file_get_contents($content); |
|
30 | 30 | |
31 | 31 | // Зачем? Так надо! |
32 | 32 | $content = "# VLF begin\n\n$content\n\n# VLF end"; |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | if (isset ($this->$name)) |
37 | 37 | $this->$name = $setting; |
38 | 38 | |
39 | - else throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
39 | + else throw new \Exception('Trying to setting up undefined property "'.$name.'"'); |
|
40 | 40 | } |
41 | 41 | |
42 | - if ($this->use_caching && file_exists ($file = VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache')) |
|
42 | + if ($this->use_caching && file_exists($file = VLF_EXT_DIR.'/cache/'.sha1($content).'.cache')) |
|
43 | 43 | { |
44 | - $info = unserialize (gzinflate (file_get_contents ($file))); |
|
44 | + $info = unserialize(gzinflate(file_get_contents($file))); |
|
45 | 45 | |
46 | - if ($info[0] == sha1 (file_get_contents (__FILE__))) |
|
46 | + if ($info[0] == sha1(file_get_contents(__FILE__))) |
|
47 | 47 | { |
48 | 48 | $this->tree = $info[1][0]; |
49 | 49 | $this->links = $info[1][1]; |
@@ -51,20 +51,20 @@ discard block |
||
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | - else unlink ($file); |
|
54 | + else unlink($file); |
|
55 | 55 | } |
56 | 56 | |
57 | - $info = $this->generateSyntaxTree ($content); |
|
57 | + $info = $this->generateSyntaxTree($content); |
|
58 | 58 | |
59 | 59 | $this->tree = $info[0]; |
60 | 60 | $this->links = $info[1]; |
61 | 61 | |
62 | 62 | if ($this->use_caching) |
63 | 63 | { |
64 | - if (!is_dir (dirname (__DIR__) .'/cache')) |
|
65 | - mkdir (dirname (__DIR__) .'/cache'); |
|
64 | + if (!is_dir(dirname(__DIR__).'/cache')) |
|
65 | + mkdir(dirname(__DIR__).'/cache'); |
|
66 | 66 | |
67 | - file_put_contents (VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache', gzdeflate (serialize ([sha1 (file_get_contents (__FILE__)), $info]))); |
|
67 | + file_put_contents(VLF_EXT_DIR.'/cache/'.sha1($content).'.cache', gzdeflate(serialize([sha1(file_get_contents(__FILE__)), $info]))); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return array - возвращает АСД |
78 | 78 | */ |
79 | - protected function generateSyntaxTree (string $content): array |
|
79 | + protected function generateSyntaxTree(string $content): array |
|
80 | 80 | { |
81 | - $lines = $this->linesFilter ($untouched_lines = explode ($this->divider, $content)); |
|
81 | + $lines = $this->linesFilter($untouched_lines = explode($this->divider, $content)); |
|
82 | 82 | $current_object = null; |
83 | 83 | $parent_objects = []; |
84 | 84 | $skip_at = -1; |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | $links = []; |
87 | 87 | |
88 | 88 | if ($this->debug_mode) |
89 | - pre ($lines); |
|
89 | + pre($lines); |
|
90 | 90 | |
91 | 91 | foreach ($lines as $id => $line) |
92 | 92 | { |
93 | 93 | if ($skip_at > $id) |
94 | 94 | continue; |
95 | 95 | |
96 | - $height = $this->getLineHeight ($line); |
|
97 | - $words = $this->linesFilter (explode (' ', $line)); |
|
96 | + $height = $this->getLineHeight($line); |
|
97 | + $words = $this->linesFilter(explode(' ', $line)); |
|
98 | 98 | |
99 | 99 | if ($this->debug_mode) |
100 | - pre ($words); |
|
100 | + pre($words); |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Высокоинтеллектуальный фикс |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $updated = false; |
120 | 120 | |
121 | 121 | if ($this->debug_mode) |
122 | - pre ($current_object); |
|
122 | + pre($current_object); |
|
123 | 123 | |
124 | 124 | while (isset ($tree[$current_object]['info']['subparent_link']) && $tree[$link = $tree[$current_object]['info']['subparent_link']->link]['hard'] < $tree[$current_object]['hard']) |
125 | 125 | { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $updated = true; |
128 | 128 | |
129 | 129 | if ($this->debug_mode) |
130 | - pre ($current_object); |
|
130 | + pre($current_object); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | if ( |
@@ -142,16 +142,16 @@ discard block |
||
142 | 142 | break; |
143 | 143 | |
144 | 144 | if ($this->debug_mode) |
145 | - pre ($current_object); |
|
145 | + pre($current_object); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Button ... |
150 | 150 | */ |
151 | - if (class_exists ($words[0]) || class_exists ('\VoidEngine\\'. $words[0])) |
|
151 | + if (class_exists($words[0]) || class_exists('\VoidEngine\\'.$words[0])) |
|
152 | 152 | { |
153 | 153 | if (!isset ($words[1])) |
154 | - throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
154 | + throw new \Exception('Object name mustn\'t be empty at line "'.$line.'"'); |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Button NewButton |
@@ -197,40 +197,39 @@ discard block |
||
197 | 197 | 'syntax_nodes' => [] |
198 | 198 | ]; |
199 | 199 | |
200 | - if (($begin = strpos ($line, '(')) !== false) |
|
200 | + if (($begin = strpos($line, '(')) !== false) |
|
201 | 201 | { |
202 | 202 | ++$begin; |
203 | 203 | |
204 | - $end = strrpos ($line, ')'); |
|
204 | + $end = strrpos($line, ')'); |
|
205 | 205 | |
206 | 206 | if ($end === false) |
207 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
207 | + throw new \Exception('Line "'.$line.'" have arguments list initialization, but not have list ending'); |
|
208 | 208 | |
209 | 209 | elseif ($begin < $end) |
210 | 210 | { |
211 | 211 | $arguments = []; |
212 | 212 | // $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
213 | - $parsed = $this->parseArguments (substr ($line, $begin, $end - $begin)); |
|
213 | + $parsed = $this->parseArguments(substr($line, $begin, $end - $begin)); |
|
214 | 214 | |
215 | 215 | foreach ($parsed as $argument_id => $argument) |
216 | 216 | { |
217 | - $argument = trim ($argument); |
|
217 | + $argument = trim($argument); |
|
218 | 218 | |
219 | - if (strlen ($argument) > 0) |
|
219 | + if (strlen($argument) > 0) |
|
220 | 220 | $arguments[] = isset ($links[$argument]) ? |
221 | - new VLFLink ($argument, $links[$argument]) : |
|
222 | - $argument; |
|
221 | + new VLFLink($argument, $links[$argument]) : $argument; |
|
223 | 222 | |
224 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
223 | + else throw new \Exception('Argument '.($argument_id + 1).' mustn\'t have zero length at line "'.$line.'"'); |
|
225 | 224 | } |
226 | 225 | |
227 | 226 | $tree[$id]['info']['arguments'] = $arguments; |
228 | 227 | |
229 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
230 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
228 | + if (!$this->ignore_postobject_info && trim(substr($line, $end)) > 0) |
|
229 | + throw new \Exception('You mustn\'t write any chars after arguments definition'); |
|
231 | 230 | } |
232 | 231 | |
233 | - $tree[$id]['info']['subparent_link'] = new VLFLink ($tree[$current_object]['info']['object_name'], $current_object); |
|
232 | + $tree[$id]['info']['subparent_link'] = new VLFLink($tree[$current_object]['info']['object_name'], $current_object); |
|
234 | 233 | } |
235 | 234 | |
236 | 235 | /** |
@@ -240,7 +239,7 @@ discard block |
||
240 | 239 | elseif ($current_object !== null && $tree[$current_object]['hard'] < $height) |
241 | 240 | { |
242 | 241 | $tree[$id]['info']['arguments'] = [ |
243 | - new VLFLink ($tree[$current_object]['info']['object_name'], $current_object) |
|
242 | + new VLFLink($tree[$current_object]['info']['object_name'], $current_object) |
|
244 | 243 | ]; |
245 | 244 | |
246 | 245 | $parent_objects[$id] = $current_object; |
@@ -287,17 +286,17 @@ discard block |
||
287 | 286 | { |
288 | 287 | if ($words[0][1] == '^') |
289 | 288 | { |
290 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
289 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
291 | 290 | |
292 | 291 | $comment .= $parsed[0]; |
293 | 292 | $skip_at = $parsed[1]; |
294 | 293 | } |
295 | 294 | |
296 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
295 | + else throw new \Exception('Unknown char founded after syntax-control symbol at line "'.$line.'"'); |
|
297 | 296 | } |
298 | 297 | |
299 | 298 | if ($this->debug_mode) |
300 | - pre ("Comment:\n\n$comment"); |
|
299 | + pre("Comment:\n\n$comment"); |
|
301 | 300 | } |
302 | 301 | |
303 | 302 | /** |
@@ -309,19 +308,19 @@ discard block |
||
309 | 308 | */ |
310 | 309 | elseif ($words[0][0] == '%') |
311 | 310 | { |
312 | - $code = substr ($line, strlen ($words[0])); |
|
311 | + $code = substr($line, strlen($words[0])); |
|
313 | 312 | |
314 | 313 | if (isset ($words[0][1])) |
315 | 314 | { |
316 | 315 | if ($words[0][1] == '^') |
317 | 316 | { |
318 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
317 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
319 | 318 | |
320 | 319 | $code .= $parsed[0]; |
321 | 320 | $skip_at = $parsed[1]; |
322 | 321 | } |
323 | 322 | |
324 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
323 | + else throw new \Exception('Unknown char founded after syntax-control symbol at line "'.$line.'"'); |
|
325 | 324 | } |
326 | 325 | |
327 | 326 | $tree[$id] = [ |
@@ -346,7 +345,7 @@ discard block |
||
346 | 345 | * Form MyForm |
347 | 346 | * Button MyButton |
348 | 347 | */ |
349 | - elseif (is_int ($current_object) && isset ($tree[$current_object]['hard'])) |
|
348 | + elseif (is_int($current_object) && isset ($tree[$current_object]['hard'])) |
|
350 | 349 | { |
351 | 350 | if ($height <= $tree[$current_object]['hard'] && isset ($parent_objects[$current_object])) |
352 | 351 | { |
@@ -372,16 +371,16 @@ discard block |
||
372 | 371 | /** |
373 | 372 | * property_name: property_value |
374 | 373 | */ |
375 | - $postChar = substr ($words[0], strlen ($words[0]) - 1); |
|
374 | + $postChar = substr($words[0], strlen($words[0]) - 1); |
|
376 | 375 | |
377 | 376 | if ($postChar == ':' || $postChar == '^') |
378 | 377 | { |
379 | 378 | if (!isset ($words[1])) |
380 | - throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
379 | + throw new \Exception('Property value mustn\'t be empty at line "'.$line.'"'); |
|
381 | 380 | |
382 | - $propertyName = substr ($words[0], 0, -1); |
|
383 | - $propertyValue = implode (' ', array_slice ($words, 1)); |
|
384 | - $propertyRawValue = ltrim (substr ($line, strlen ($words[0]))); |
|
381 | + $propertyName = substr($words[0], 0, -1); |
|
382 | + $propertyValue = implode(' ', array_slice($words, 1)); |
|
383 | + $propertyRawValue = ltrim(substr($line, strlen($words[0]))); |
|
385 | 384 | |
386 | 385 | /** |
387 | 386 | * property_name:^ property_value_1 |
@@ -389,10 +388,10 @@ discard block |
||
389 | 388 | */ |
390 | 389 | if ($postChar == '^') |
391 | 390 | { |
392 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
391 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
393 | 392 | |
394 | 393 | $skip_at = $parsed[1]; |
395 | - $propertyName = substr ($propertyName, 0, -1); |
|
394 | + $propertyName = substr($propertyName, 0, -1); |
|
396 | 395 | $propertyRawValue .= $parsed[0]; |
397 | 396 | $propertyValue = $propertyRawValue; |
398 | 397 | } |
@@ -413,7 +412,7 @@ discard block |
||
413 | 412 | ]; |
414 | 413 | |
415 | 414 | if (isset ($links[$info['info']['property_value']])) |
416 | - $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
415 | + $info['info']['property_value'] = new VLFLink($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
417 | 416 | |
418 | 417 | $tree[$current_object]['syntax_nodes'][] = $info; |
419 | 418 | } |
@@ -421,38 +420,37 @@ discard block |
||
421 | 420 | /** |
422 | 421 | * ->method_name ([method_arguments]) |
423 | 422 | */ |
424 | - elseif (substr ($words[0], 0, 2) == '->') |
|
423 | + elseif (substr($words[0], 0, 2) == '->') |
|
425 | 424 | { |
426 | 425 | $arguments = []; |
427 | 426 | |
428 | - if (($begin = strpos ($line, '(')) !== false) |
|
427 | + if (($begin = strpos($line, '(')) !== false) |
|
429 | 428 | { |
430 | 429 | ++$begin; |
431 | 430 | |
432 | - $end = strrpos ($line, ')'); |
|
431 | + $end = strrpos($line, ')'); |
|
433 | 432 | |
434 | 433 | if ($end === false) |
435 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
434 | + throw new \Exception('Line "'.$line.'" have arguments list initialization, but not have list ending'); |
|
436 | 435 | |
437 | 436 | elseif ($begin < $end) |
438 | 437 | { |
439 | 438 | // $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
440 | - $parsed = $this->parseArguments (substr ($line, $begin, $end - $begin)); |
|
439 | + $parsed = $this->parseArguments(substr($line, $begin, $end - $begin)); |
|
441 | 440 | |
442 | 441 | foreach ($parsed as $argument_id => $argument) |
443 | 442 | { |
444 | - $argument = trim ($argument); |
|
443 | + $argument = trim($argument); |
|
445 | 444 | |
446 | - if (strlen ($argument) > 0) |
|
445 | + if (strlen($argument) > 0) |
|
447 | 446 | $arguments[] = isset ($links[$argument]) ? |
448 | - new VLFLink ($argument, $links[$argument]) : |
|
449 | - $argument; |
|
447 | + new VLFLink($argument, $links[$argument]) : $argument; |
|
450 | 448 | |
451 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
449 | + else throw new \Exception('Argument '.($argument_id + 1).' mustn\'t have zero length at line "'.$line.'"'); |
|
452 | 450 | } |
453 | 451 | |
454 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
455 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
452 | + if (!$this->ignore_postobject_info && trim(substr($line, $end)) > 0) |
|
453 | + throw new \Exception('You mustn\'t write any chars after arguments definition'); |
|
456 | 454 | } |
457 | 455 | } |
458 | 456 | |
@@ -460,7 +458,7 @@ discard block |
||
460 | 458 | * ->show |
461 | 459 | */ |
462 | 460 | elseif (!$this->ignore_unexpected_method_args) |
463 | - throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
461 | + throw new \Exception('Unexpected method arguments list at line "'.$line.'"'); |
|
464 | 462 | |
465 | 463 | $tree[$current_object]['syntax_nodes'][] = [ |
466 | 464 | 'type' => VLF_METHOD_CALL, |
@@ -469,7 +467,7 @@ discard block |
||
469 | 467 | 'words' => $words, |
470 | 468 | |
471 | 469 | 'info' => [ |
472 | - 'method_name' => substr ($words[0], 2), |
|
470 | + 'method_name' => substr($words[0], 2), |
|
473 | 471 | 'method_arguments' => $arguments |
474 | 472 | ], |
475 | 473 | |
@@ -492,7 +490,7 @@ discard block |
||
492 | 490 | */ |
493 | 491 | else |
494 | 492 | { |
495 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
493 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
496 | 494 | $skip_at = $parsed[1]; |
497 | 495 | |
498 | 496 | $tree[$id] = [ |
@@ -502,7 +500,7 @@ discard block |
||
502 | 500 | 'words' => $words, |
503 | 501 | |
504 | 502 | 'info' => [ |
505 | - 'object_vlf_info' => $line ."\n". $parsed[0] |
|
503 | + 'object_vlf_info' => $line."\n".$parsed[0] |
|
506 | 504 | ], |
507 | 505 | |
508 | 506 | 'syntax_nodes' => [] |
@@ -513,7 +511,7 @@ discard block |
||
513 | 511 | /** |
514 | 512 | * Что-то загадочное, таинственное, неизвестное человечеству |
515 | 513 | */ |
516 | - else throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
514 | + else throw new \Exception('Unknown structures founded at line "'.$line.'"'); |
|
517 | 515 | } |
518 | 516 | |
519 | 517 | return [$tree, $links]; |
@@ -529,7 +527,7 @@ discard block |
||
529 | 527 | * |
530 | 528 | * @return array - возвращает спарсенные подстроки |
531 | 529 | */ |
532 | - protected function parseSubText (array $lines, $begin_id, int $down_height): array |
|
530 | + protected function parseSubText(array $lines, $begin_id, int $down_height): array |
|
533 | 531 | { |
534 | 532 | $parsed = "\n"; |
535 | 533 | |
@@ -538,17 +536,17 @@ discard block |
||
538 | 536 | if ($line_id <= $begin_id) |
539 | 537 | continue; |
540 | 538 | |
541 | - if (!(bool)(trim ($line))) |
|
539 | + if (!(bool) (trim($line))) |
|
542 | 540 | { |
543 | 541 | $parsed .= "\n"; |
544 | 542 | |
545 | 543 | continue; |
546 | 544 | } |
547 | 545 | |
548 | - $height = $this->getLineHeight ($line); |
|
546 | + $height = $this->getLineHeight($line); |
|
549 | 547 | |
550 | 548 | if ($this->debug_mode) |
551 | - pre ("$height, $down_height, $line"); |
|
549 | + pre("$height, $down_height, $line"); |
|
552 | 550 | |
553 | 551 | if ($height > $down_height) |
554 | 552 | $parsed .= "$line\n"; |
@@ -559,7 +557,7 @@ discard block |
||
559 | 557 | return [$parsed, $line_id]; |
560 | 558 | } |
561 | 559 | |
562 | - public function __get ($name) // Возвращалка переменных парсера |
|
560 | + public function __get($name) // Возвращалка переменных парсера |
|
563 | 561 | { |
564 | 562 | return isset ($this->$name) ? |
565 | 563 | $this->$name : false; |
@@ -573,14 +571,14 @@ discard block |
||
573 | 571 | * |
574 | 572 | * @return int - высота строки |
575 | 573 | */ |
576 | - protected function getLineHeight (string &$line): int |
|
574 | + protected function getLineHeight(string &$line): int |
|
577 | 575 | { |
578 | 576 | $i = 0; |
579 | 577 | |
580 | 578 | while (isset ($line[$i]) && $line[$i] == "\t") |
581 | 579 | ++$i; |
582 | 580 | |
583 | - return strlen ($line = str_repeat (' ', $i) . substr ($line, $i)) - strlen ($line = trim ($line)); |
|
581 | + return strlen($line = str_repeat(' ', $i).substr($line, $i)) - strlen($line = trim($line)); |
|
584 | 582 | } |
585 | 583 | |
586 | 584 | /** |
@@ -591,18 +589,18 @@ discard block |
||
591 | 589 | * |
592 | 590 | * @return array - возвращает очищенный массив |
593 | 591 | */ |
594 | - protected function linesFilter (array $segments): array |
|
592 | + protected function linesFilter(array $segments): array |
|
595 | 593 | { |
596 | - return array_filter ($segments, function ($text) |
|
594 | + return array_filter($segments, function($text) |
|
597 | 595 | { |
598 | - if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) |
|
599 | - throw new \Exception ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
596 | + if ($this->strong_line_parser && preg_match('/[^a-z0-9]/i', $text)) |
|
597 | + throw new \Exception('Line "'.$text.'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
600 | 598 | |
601 | - return strlen (trim ($text)) > 0; |
|
599 | + return strlen(trim($text)) > 0; |
|
602 | 600 | }); |
603 | 601 | } |
604 | 602 | |
605 | - protected function parseArguments (string $arguments): array |
|
603 | + protected function parseArguments(string $arguments): array |
|
606 | 604 | { |
607 | 605 | $args = []; |
608 | 606 | |
@@ -610,7 +608,7 @@ discard block |
||
610 | 608 | $split2 = false; |
611 | 609 | $canSplit = -1; |
612 | 610 | |
613 | - $len = strlen ($arguments); |
|
611 | + $len = strlen($arguments); |
|
614 | 612 | $t = ''; |
615 | 613 | |
616 | 614 | for ($i = 0; $i < $len; ++$i) |
@@ -630,7 +628,7 @@ discard block |
||
630 | 628 | |
631 | 629 | elseif (!$split1 && !$split2 && $arguments[$i] == ',') |
632 | 630 | { |
633 | - $args[] = substr ($t, 0, -1); |
|
631 | + $args[] = substr($t, 0, -1); |
|
634 | 632 | $t = ''; |
635 | 633 | } |
636 | 634 | } |
@@ -25,18 +25,20 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function __construct (string $content, array $settings = []) |
27 | 27 | { |
28 | - if (file_exists ($content)) |
|
29 | - $content = file_get_contents ($content); |
|
28 | + if (file_exists ($content)) { |
|
29 | + $content = file_get_contents ($content); |
|
30 | + } |
|
30 | 31 | |
31 | 32 | // Зачем? Так надо! |
32 | 33 | $content = "# VLF begin\n\n$content\n\n# VLF end"; |
33 | 34 | |
34 | 35 | foreach ($settings as $name => $setting) |
35 | 36 | { |
36 | - if (isset ($this->$name)) |
|
37 | - $this->$name = $setting; |
|
38 | - |
|
39 | - else throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
37 | + if (isset ($this->$name)) { |
|
38 | + $this->$name = $setting; |
|
39 | + } else { |
|
40 | + throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
41 | + } |
|
40 | 42 | } |
41 | 43 | |
42 | 44 | if ($this->use_caching && file_exists ($file = VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache')) |
@@ -49,9 +51,9 @@ discard block |
||
49 | 51 | $this->links = $info[1][1]; |
50 | 52 | |
51 | 53 | return; |
54 | + } else { |
|
55 | + unlink ($file); |
|
52 | 56 | } |
53 | - |
|
54 | - else unlink ($file); |
|
55 | 57 | } |
56 | 58 | |
57 | 59 | $info = $this->generateSyntaxTree ($content); |
@@ -61,8 +63,9 @@ discard block |
||
61 | 63 | |
62 | 64 | if ($this->use_caching) |
63 | 65 | { |
64 | - if (!is_dir (dirname (__DIR__) .'/cache')) |
|
65 | - mkdir (dirname (__DIR__) .'/cache'); |
|
66 | + if (!is_dir (dirname (__DIR__) .'/cache')) { |
|
67 | + mkdir (dirname (__DIR__) .'/cache'); |
|
68 | + } |
|
66 | 69 | |
67 | 70 | file_put_contents (VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache', gzdeflate (serialize ([sha1 (file_get_contents (__FILE__)), $info]))); |
68 | 71 | } |
@@ -85,19 +88,22 @@ discard block |
||
85 | 88 | $tree = []; |
86 | 89 | $links = []; |
87 | 90 | |
88 | - if ($this->debug_mode) |
|
89 | - pre ($lines); |
|
91 | + if ($this->debug_mode) { |
|
92 | + pre ($lines); |
|
93 | + } |
|
90 | 94 | |
91 | 95 | foreach ($lines as $id => $line) |
92 | 96 | { |
93 | - if ($skip_at > $id) |
|
94 | - continue; |
|
97 | + if ($skip_at > $id) { |
|
98 | + continue; |
|
99 | + } |
|
95 | 100 | |
96 | 101 | $height = $this->getLineHeight ($line); |
97 | 102 | $words = $this->linesFilter (explode (' ', $line)); |
98 | 103 | |
99 | - if ($this->debug_mode) |
|
100 | - pre ($words); |
|
104 | + if ($this->debug_mode) { |
|
105 | + pre ($words); |
|
106 | + } |
|
101 | 107 | |
102 | 108 | /** |
103 | 109 | * Высокоинтеллектуальный фикс |
@@ -118,16 +124,18 @@ discard block |
||
118 | 124 | { |
119 | 125 | $updated = false; |
120 | 126 | |
121 | - if ($this->debug_mode) |
|
122 | - pre ($current_object); |
|
127 | + if ($this->debug_mode) { |
|
128 | + pre ($current_object); |
|
129 | + } |
|
123 | 130 | |
124 | 131 | while (isset ($tree[$current_object]['info']['subparent_link']) && $tree[$link = $tree[$current_object]['info']['subparent_link']->link]['hard'] < $tree[$current_object]['hard']) |
125 | 132 | { |
126 | 133 | $current_object = $link; |
127 | 134 | $updated = true; |
128 | 135 | |
129 | - if ($this->debug_mode) |
|
130 | - pre ($current_object); |
|
136 | + if ($this->debug_mode) { |
|
137 | + pre ($current_object); |
|
138 | + } |
|
131 | 139 | } |
132 | 140 | |
133 | 141 | if ( |
@@ -136,13 +144,15 @@ discard block |
||
136 | 144 | isset ($tree[$current_object]['info']['arguments'][0]) && |
137 | 145 | $tree[$current_object]['info']['arguments'][0] instanceof VLFLink && |
138 | 146 | $tree[$tree[$current_object]['info']['arguments'][0]->link]['hard'] < $tree[$current_object]['hard'] |
139 | - ) $current_object = $tree[$current_object]['info']['arguments'][0]->link; |
|
140 | - |
|
141 | - elseif (!$updated) |
|
142 | - break; |
|
147 | + ) { |
|
148 | + $current_object = $tree[$current_object]['info']['arguments'][0]->link; |
|
149 | + } elseif (!$updated) { |
|
150 | + break; |
|
151 | + } |
|
143 | 152 | |
144 | - if ($this->debug_mode) |
|
145 | - pre ($current_object); |
|
153 | + if ($this->debug_mode) { |
|
154 | + pre ($current_object); |
|
155 | + } |
|
146 | 156 | } |
147 | 157 | |
148 | 158 | /** |
@@ -150,8 +160,9 @@ discard block |
||
150 | 160 | */ |
151 | 161 | if (class_exists ($words[0]) || class_exists ('\VoidEngine\\'. $words[0])) |
152 | 162 | { |
153 | - if (!isset ($words[1])) |
|
154 | - throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
163 | + if (!isset ($words[1])) { |
|
164 | + throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
165 | + } |
|
155 | 166 | |
156 | 167 | /** |
157 | 168 | * Button NewButton |
@@ -179,9 +190,7 @@ discard block |
||
179 | 190 | $current_object = $id; |
180 | 191 | |
181 | 192 | continue; |
182 | - } |
|
183 | - |
|
184 | - else |
|
193 | + } else |
|
185 | 194 | { |
186 | 195 | $tree[$id] = [ |
187 | 196 | 'type' => VLF_OBJECT_DEFINITION, |
@@ -203,10 +212,9 @@ discard block |
||
203 | 212 | |
204 | 213 | $end = strrpos ($line, ')'); |
205 | 214 | |
206 | - if ($end === false) |
|
207 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
208 | - |
|
209 | - elseif ($begin < $end) |
|
215 | + if ($end === false) { |
|
216 | + throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
217 | + } elseif ($begin < $end) |
|
210 | 218 | { |
211 | 219 | $arguments = []; |
212 | 220 | // $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
@@ -216,18 +224,20 @@ discard block |
||
216 | 224 | { |
217 | 225 | $argument = trim ($argument); |
218 | 226 | |
219 | - if (strlen ($argument) > 0) |
|
220 | - $arguments[] = isset ($links[$argument]) ? |
|
227 | + if (strlen ($argument) > 0) { |
|
228 | + $arguments[] = isset ($links[$argument]) ? |
|
221 | 229 | new VLFLink ($argument, $links[$argument]) : |
222 | 230 | $argument; |
223 | - |
|
224 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
231 | + } else { |
|
232 | + throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
233 | + } |
|
225 | 234 | } |
226 | 235 | |
227 | 236 | $tree[$id]['info']['arguments'] = $arguments; |
228 | 237 | |
229 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
230 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
238 | + if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) { |
|
239 | + throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
240 | + } |
|
231 | 241 | } |
232 | 242 | |
233 | 243 | $tree[$id]['info']['subparent_link'] = new VLFLink ($tree[$current_object]['info']['object_name'], $current_object); |
@@ -291,13 +301,14 @@ discard block |
||
291 | 301 | |
292 | 302 | $comment .= $parsed[0]; |
293 | 303 | $skip_at = $parsed[1]; |
304 | + } else { |
|
305 | + throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
294 | 306 | } |
295 | - |
|
296 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
297 | 307 | } |
298 | 308 | |
299 | - if ($this->debug_mode) |
|
300 | - pre ("Comment:\n\n$comment"); |
|
309 | + if ($this->debug_mode) { |
|
310 | + pre ("Comment:\n\n$comment"); |
|
311 | + } |
|
301 | 312 | } |
302 | 313 | |
303 | 314 | /** |
@@ -319,9 +330,9 @@ discard block |
||
319 | 330 | |
320 | 331 | $code .= $parsed[0]; |
321 | 332 | $skip_at = $parsed[1]; |
333 | + } else { |
|
334 | + throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
322 | 335 | } |
323 | - |
|
324 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
325 | 336 | } |
326 | 337 | |
327 | 338 | $tree[$id] = [ |
@@ -376,8 +387,9 @@ discard block |
||
376 | 387 | |
377 | 388 | if ($postChar == ':' || $postChar == '^') |
378 | 389 | { |
379 | - if (!isset ($words[1])) |
|
380 | - throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
390 | + if (!isset ($words[1])) { |
|
391 | + throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
392 | + } |
|
381 | 393 | |
382 | 394 | $propertyName = substr ($words[0], 0, -1); |
383 | 395 | $propertyValue = implode (' ', array_slice ($words, 1)); |
@@ -412,8 +424,9 @@ discard block |
||
412 | 424 | 'syntax_nodes' => [] |
413 | 425 | ]; |
414 | 426 | |
415 | - if (isset ($links[$info['info']['property_value']])) |
|
416 | - $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
427 | + if (isset ($links[$info['info']['property_value']])) { |
|
428 | + $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
429 | + } |
|
417 | 430 | |
418 | 431 | $tree[$current_object]['syntax_nodes'][] = $info; |
419 | 432 | } |
@@ -431,10 +444,9 @@ discard block |
||
431 | 444 | |
432 | 445 | $end = strrpos ($line, ')'); |
433 | 446 | |
434 | - if ($end === false) |
|
435 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
436 | - |
|
437 | - elseif ($begin < $end) |
|
447 | + if ($end === false) { |
|
448 | + throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
449 | + } elseif ($begin < $end) |
|
438 | 450 | { |
439 | 451 | // $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
440 | 452 | $parsed = $this->parseArguments (substr ($line, $begin, $end - $begin)); |
@@ -443,24 +455,27 @@ discard block |
||
443 | 455 | { |
444 | 456 | $argument = trim ($argument); |
445 | 457 | |
446 | - if (strlen ($argument) > 0) |
|
447 | - $arguments[] = isset ($links[$argument]) ? |
|
458 | + if (strlen ($argument) > 0) { |
|
459 | + $arguments[] = isset ($links[$argument]) ? |
|
448 | 460 | new VLFLink ($argument, $links[$argument]) : |
449 | 461 | $argument; |
450 | - |
|
451 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
462 | + } else { |
|
463 | + throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
464 | + } |
|
452 | 465 | } |
453 | 466 | |
454 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
455 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
467 | + if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) { |
|
468 | + throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
469 | + } |
|
456 | 470 | } |
457 | 471 | } |
458 | 472 | |
459 | 473 | /** |
460 | 474 | * ->show |
461 | 475 | */ |
462 | - elseif (!$this->ignore_unexpected_method_args) |
|
463 | - throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
476 | + elseif (!$this->ignore_unexpected_method_args) { |
|
477 | + throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
478 | + } |
|
464 | 479 | |
465 | 480 | $tree[$current_object]['syntax_nodes'][] = [ |
466 | 481 | 'type' => VLF_METHOD_CALL, |
@@ -513,7 +528,9 @@ discard block |
||
513 | 528 | /** |
514 | 529 | * Что-то загадочное, таинственное, неизвестное человечеству |
515 | 530 | */ |
516 | - else throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
531 | + else { |
|
532 | + throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
533 | + } |
|
517 | 534 | } |
518 | 535 | |
519 | 536 | return [$tree, $links]; |
@@ -535,8 +552,9 @@ discard block |
||
535 | 552 | |
536 | 553 | foreach ($lines as $line_id => $line) |
537 | 554 | { |
538 | - if ($line_id <= $begin_id) |
|
539 | - continue; |
|
555 | + if ($line_id <= $begin_id) { |
|
556 | + continue; |
|
557 | + } |
|
540 | 558 | |
541 | 559 | if (!(bool)(trim ($line))) |
542 | 560 | { |
@@ -547,13 +565,15 @@ discard block |
||
547 | 565 | |
548 | 566 | $height = $this->getLineHeight ($line); |
549 | 567 | |
550 | - if ($this->debug_mode) |
|
551 | - pre ("$height, $down_height, $line"); |
|
552 | - |
|
553 | - if ($height > $down_height) |
|
554 | - $parsed .= "$line\n"; |
|
568 | + if ($this->debug_mode) { |
|
569 | + pre ("$height, $down_height, $line"); |
|
570 | + } |
|
555 | 571 | |
556 | - else break; |
|
572 | + if ($height > $down_height) { |
|
573 | + $parsed .= "$line\n"; |
|
574 | + } else { |
|
575 | + break; |
|
576 | + } |
|
557 | 577 | } |
558 | 578 | |
559 | 579 | return [$parsed, $line_id]; |
@@ -577,8 +597,9 @@ discard block |
||
577 | 597 | { |
578 | 598 | $i = 0; |
579 | 599 | |
580 | - while (isset ($line[$i]) && $line[$i] == "\t") |
|
581 | - ++$i; |
|
600 | + while (isset ($line[$i]) && $line[$i] == "\t") { |
|
601 | + ++$i; |
|
602 | + } |
|
582 | 603 | |
583 | 604 | return strlen ($line = str_repeat (' ', $i) . substr ($line, $i)) - strlen ($line = trim ($line)); |
584 | 605 | } |
@@ -595,8 +616,9 @@ discard block |
||
595 | 616 | { |
596 | 617 | return array_filter ($segments, function ($text) |
597 | 618 | { |
598 | - if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) |
|
599 | - throw new \Exception ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
619 | + if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) { |
|
620 | + throw new \Exception ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
621 | + } |
|
600 | 622 | |
601 | 623 | return strlen (trim ($text)) > 0; |
602 | 624 | }); |
@@ -617,18 +639,17 @@ discard block |
||
617 | 639 | { |
618 | 640 | $t .= $arguments[$i]; |
619 | 641 | |
620 | - if ($arguments[$i] == '\\') |
|
621 | - $canSplit = $i + 1; |
|
642 | + if ($arguments[$i] == '\\') { |
|
643 | + $canSplit = $i + 1; |
|
644 | + } |
|
622 | 645 | |
623 | 646 | if ($canSplit < $i) |
624 | 647 | { |
625 | - if ($arguments[$i] == '\'' && !$split2) |
|
626 | - $split1 = !$split1; |
|
627 | - |
|
628 | - elseif ($arguments[$i] == '"' && !$split1) |
|
629 | - $split2 = !$split2; |
|
630 | - |
|
631 | - elseif (!$split1 && !$split2 && $arguments[$i] == ',') |
|
648 | + if ($arguments[$i] == '\'' && !$split2) { |
|
649 | + $split1 = !$split1; |
|
650 | + } elseif ($arguments[$i] == '"' && !$split1) { |
|
651 | + $split2 = !$split2; |
|
652 | + } elseif (!$split1 && !$split2 && $arguments[$i] == ',') |
|
632 | 653 | { |
633 | 654 | $args[] = substr ($t, 0, -1); |
634 | 655 | $t = ''; |
@@ -8,20 +8,20 @@ |
||
8 | 8 | chdir (CORE_DIR); |
9 | 9 | |
10 | 10 | foreach (glob ('ext/php_*.dll') as $ext) |
11 | - if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
12 | - load_extension ($ext); |
|
11 | + if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
12 | + load_extension ($ext); |
|
13 | 13 | |
14 | 14 | if (file_exists ('../engine/VoidEngine.php')) |
15 | - require '../engine/VoidEngine.php'; |
|
15 | + require '../engine/VoidEngine.php'; |
|
16 | 16 | |
17 | 17 | elseif (file_exists (FRAMEWORK_DIR .'/engine/VoidEngine.php')) |
18 | - require FRAMEWORK_DIR .'/engine/VoidEngine.php'; |
|
18 | + require FRAMEWORK_DIR .'/engine/VoidEngine.php'; |
|
19 | 19 | |
20 | 20 | else message ('VoidEngine not founded'); |
21 | 21 | |
22 | 22 | $app = '../../app/start.php'; |
23 | 23 | |
24 | 24 | if (file_exists ($app)) |
25 | - require $app; |
|
25 | + require $app; |
|
26 | 26 | |
27 | 27 | else \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm', null), 'ShowDialog'); |
@@ -2,26 +2,26 @@ |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -define ('VoidEngine\FRAMEWORK_DIR', getenv ('AppData') .'\VoidFramework'); |
|
5 | +define('VoidEngine\FRAMEWORK_DIR', getenv('AppData').'\VoidFramework'); |
|
6 | 6 | |
7 | 7 | const CORE_DIR = __DIR__; |
8 | -chdir (CORE_DIR); |
|
8 | +chdir(CORE_DIR); |
|
9 | 9 | |
10 | -foreach (glob ('ext/php_*.dll') as $ext) |
|
11 | - if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
12 | - load_extension ($ext); |
|
10 | +foreach (glob('ext/php_*.dll') as $ext) |
|
11 | + if (!extension_loaded(substr(basename($ext), 4, -4))) |
|
12 | + load_extension($ext); |
|
13 | 13 | |
14 | -if (file_exists ('../engine/VoidEngine.php')) |
|
14 | +if (file_exists('../engine/VoidEngine.php')) |
|
15 | 15 | require '../engine/VoidEngine.php'; |
16 | 16 | |
17 | -elseif (file_exists (FRAMEWORK_DIR .'/engine/VoidEngine.php')) |
|
18 | - require FRAMEWORK_DIR .'/engine/VoidEngine.php'; |
|
17 | +elseif (file_exists(FRAMEWORK_DIR.'/engine/VoidEngine.php')) |
|
18 | + require FRAMEWORK_DIR.'/engine/VoidEngine.php'; |
|
19 | 19 | |
20 | -else message ('VoidEngine not founded'); |
|
20 | +else message('VoidEngine not founded'); |
|
21 | 21 | |
22 | 22 | $app = '../../app/start.php'; |
23 | 23 | |
24 | -if (file_exists ($app)) |
|
24 | +if (file_exists($app)) |
|
25 | 25 | require $app; |
26 | 26 | |
27 | -else \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm', null), 'ShowDialog'); |
|
27 | +else \VoidCore::callMethod(\VoidCore::createObject('WinForms_PHP.DebugForm', null), 'ShowDialog'); |
@@ -7,21 +7,23 @@ |
||
7 | 7 | const CORE_DIR = __DIR__; |
8 | 8 | chdir (CORE_DIR); |
9 | 9 | |
10 | -foreach (glob ('ext/php_*.dll') as $ext) |
|
10 | +foreach (glob ('ext/php_*.dll') as $ext) { |
|
11 | 11 | if (!extension_loaded (substr (basename ($ext), 4, -4))) |
12 | 12 | load_extension ($ext); |
13 | +} |
|
13 | 14 | |
14 | -if (file_exists ('../engine/VoidEngine.php')) |
|
15 | +if (file_exists ('../engine/VoidEngine.php')) { |
|
15 | 16 | require '../engine/VoidEngine.php'; |
16 | - |
|
17 | -elseif (file_exists (FRAMEWORK_DIR .'/engine/VoidEngine.php')) |
|
17 | +} elseif (file_exists (FRAMEWORK_DIR .'/engine/VoidEngine.php')) { |
|
18 | 18 | require FRAMEWORK_DIR .'/engine/VoidEngine.php'; |
19 | - |
|
20 | -else message ('VoidEngine not founded'); |
|
19 | +} else { |
|
20 | + message ('VoidEngine not founded'); |
|
21 | +} |
|
21 | 22 | |
22 | 23 | $app = '../../app/start.php'; |
23 | 24 | |
24 | -if (file_exists ($app)) |
|
25 | +if (file_exists ($app)) { |
|
25 | 26 | require $app; |
26 | - |
|
27 | -else \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm', null), 'ShowDialog'); |
|
27 | +} else { |
|
28 | + \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm', null), 'ShowDialog'); |
|
29 | +} |