@@ -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,216 +12,216 @@ 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 enum_parse (string $baseType, string $value) |
|
65 | +function enum_parse(string $baseType, string $value) |
|
66 | 66 | { |
67 | 67 | try |
68 | 68 | { |
69 | - return \VoidCore::callMethod (\VoidCore::getClass ('System.Enum',''), ['parse', 'object'], \VoidCore::typeof ($baseType), $value, true); |
|
69 | + return \VoidCore::callMethod(\VoidCore::getClass('System.Enum', ''), ['parse', 'object'], \VoidCore::typeof($baseType), $value, true); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | catch (\WinFormsException $e) |
73 | 73 | { |
74 | - return (new WFClass ($baseType))->$value; |
|
74 | + return (new WFClass($baseType))->$value; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | -function getNetArray (string $type, array $items = []): WFObject |
|
78 | +function getNetArray(string $type, array $items = []): WFObject |
|
79 | 79 | { |
80 | - $array = (new WFClass ('System.Array', null)) |
|
81 | - ->createInstance (\VoidCore::typeof ($type), $size = sizeof ($items)); |
|
80 | + $array = (new WFClass('System.Array', null)) |
|
81 | + ->createInstance(\VoidCore::typeof($type), $size = sizeof($items)); |
|
82 | 82 | |
83 | 83 | for ($i = 0; $i < $size; ++$i) |
84 | - $array[$i] = array_shift ($items); |
|
84 | + $array[$i] = array_shift($items); |
|
85 | 85 | |
86 | 86 | return $array; |
87 | 87 | } |
88 | 88 | |
89 | -function dir_create (string $path, int $mode = 0777): void |
|
89 | +function dir_create(string $path, int $mode = 0777): void |
|
90 | 90 | { |
91 | - if (!is_dir ($path)) |
|
92 | - mkdir ($path, $mode, true); |
|
91 | + if (!is_dir($path)) |
|
92 | + mkdir($path, $mode, true); |
|
93 | 93 | } |
94 | 94 | |
95 | -function dir_delete (string $path): bool |
|
95 | +function dir_delete(string $path): bool |
|
96 | 96 | { |
97 | - if (!is_dir ($path)) |
|
97 | + if (!is_dir($path)) |
|
98 | 98 | return false; |
99 | 99 | |
100 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
101 | - if (is_dir ($file = $path .'/'. $file)) |
|
100 | + foreach (array_slice(scandir($path), 2) as $file) |
|
101 | + if (is_dir($file = $path.'/'.$file)) |
|
102 | 102 | { |
103 | - dir_delete ($file); |
|
103 | + dir_delete($file); |
|
104 | 104 | |
105 | - if (is_dir ($file)) |
|
106 | - rmdir ($file); |
|
105 | + if (is_dir($file)) |
|
106 | + rmdir($file); |
|
107 | 107 | } |
108 | 108 | |
109 | - else unlink ($file); |
|
109 | + else unlink($file); |
|
110 | 110 | |
111 | - rmdir ($path); |
|
111 | + rmdir($path); |
|
112 | 112 | |
113 | 113 | return true; |
114 | 114 | } |
115 | 115 | |
116 | -function dir_clean (string $path): void |
|
116 | +function dir_clean(string $path): void |
|
117 | 117 | { |
118 | - dir_delete ($path); |
|
119 | - dir_create ($path); |
|
118 | + dir_delete($path); |
|
119 | + dir_create($path); |
|
120 | 120 | } |
121 | 121 | |
122 | -function dir_copy (string $from, string $to): bool |
|
122 | +function dir_copy(string $from, string $to): bool |
|
123 | 123 | { |
124 | - if (!is_dir ($from)) |
|
124 | + if (!is_dir($from)) |
|
125 | 125 | return false; |
126 | 126 | |
127 | - if (!is_dir ($to)) |
|
128 | - dir_create ($to); |
|
127 | + if (!is_dir($to)) |
|
128 | + dir_create($to); |
|
129 | 129 | |
130 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
131 | - if (is_dir ($f = $from .'/'. $file)) |
|
132 | - dir_copy ($f, $to .'/'. $file); |
|
130 | + foreach (array_slice(scandir($from), 2) as $file) |
|
131 | + if (is_dir($f = $from.'/'.$file)) |
|
132 | + dir_copy($f, $to.'/'.$file); |
|
133 | 133 | |
134 | - else copy ($f, $to .'/'. $file); |
|
134 | + else copy($f, $to.'/'.$file); |
|
135 | 135 | |
136 | 136 | return true; |
137 | 137 | } |
138 | 138 | |
139 | -function getARGBColor (string $color) |
|
139 | +function getARGBColor(string $color) |
|
140 | 140 | { |
141 | - return (new WFClass ('System.Drawing.ColorTranslator'))->fromHtml ($color); |
|
141 | + return (new WFClass('System.Drawing.ColorTranslator'))->fromHtml($color); |
|
142 | 142 | } |
143 | 143 | |
144 | -function replaceSl (string $string): string |
|
144 | +function replaceSl(string $string): string |
|
145 | 145 | { |
146 | - return str_replace ('\\', '/', $string); |
|
146 | + return str_replace('\\', '/', $string); |
|
147 | 147 | } |
148 | 148 | |
149 | -function replaceSr (string $string): string |
|
149 | +function replaceSr(string $string): string |
|
150 | 150 | { |
151 | - return str_replace ('/', '\\', $string); |
|
151 | + return str_replace('/', '\\', $string); |
|
152 | 152 | } |
153 | 153 | |
154 | -function basenameNoExt (string $path): string |
|
154 | +function basenameNoExt(string $path): string |
|
155 | 155 | { |
156 | - return pathinfo ($path, PATHINFO_FILENAME); |
|
156 | + return pathinfo($path, PATHINFO_FILENAME); |
|
157 | 157 | } |
158 | 158 | |
159 | -function file_ext (string $path): string |
|
159 | +function file_ext(string $path): string |
|
160 | 160 | { |
161 | - return strtolower (pathinfo ($path, PATHINFO_EXTENSION)); |
|
161 | + return strtolower(pathinfo($path, PATHINFO_EXTENSION)); |
|
162 | 162 | } |
163 | 163 | |
164 | -function filepathNoExt (string $path): string |
|
164 | +function filepathNoExt(string $path): string |
|
165 | 165 | { |
166 | - return dirname ($path) .'/'. basenameNoExt ($path); |
|
166 | + return dirname($path).'/'.basenameNoExt($path); |
|
167 | 167 | } |
168 | 168 | |
169 | -function array_first (array $array) |
|
169 | +function array_first(array $array) |
|
170 | 170 | { |
171 | - return array_shift ($array); |
|
171 | + return array_shift($array); |
|
172 | 172 | } |
173 | 173 | |
174 | -function array_end (array $array) |
|
174 | +function array_end(array $array) |
|
175 | 175 | { |
176 | - return array_pop ($array); |
|
176 | + return array_pop($array); |
|
177 | 177 | } |
178 | 178 | |
179 | -function substr_icount (string $haystack, string $needle, ...$params): int |
|
179 | +function substr_icount(string $haystack, string $needle, ...$params): int |
|
180 | 180 | { |
181 | - return substr_count (strtolower ($haystack), strtolower ($needle), ...$params); |
|
181 | + return substr_count(strtolower($haystack), strtolower($needle), ...$params); |
|
182 | 182 | } |
183 | 183 | |
184 | -function str_replace_assoc (string $subject, array $replacements): string |
|
184 | +function str_replace_assoc(string $subject, array $replacements): string |
|
185 | 185 | { |
186 | - return str_replace (array_keys ($replacements), array_values ($replacements), $subject); |
|
186 | + return str_replace(array_keys($replacements), array_values($replacements), $subject); |
|
187 | 187 | } |
188 | 188 | |
189 | -function pre (...$args): void |
|
189 | +function pre(...$args): void |
|
190 | 190 | { |
191 | - message (sizeof ($args) < 2 ? current ($args) : $args); |
|
191 | + message(sizeof($args) < 2 ? current ($args) : $args); |
|
192 | 192 | } |
193 | 193 | |
194 | -function messageBox (string $message, string $caption = '', ...$args) |
|
194 | +function messageBox(string $message, string $caption = '', ...$args) |
|
195 | 195 | { |
196 | - return (new MessageBox)->show ($message, $caption, ...$args); |
|
196 | + return (new MessageBox)->show($message, $caption, ...$args); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | class Components |
200 | 200 | { |
201 | 201 | static array $components = []; |
202 | 202 | |
203 | - public static function addComponent (int $selector, object $object): void |
|
203 | + public static function addComponent(int $selector, object $object): void |
|
204 | 204 | { |
205 | 205 | self::$components[$selector] = $object; |
206 | 206 | } |
207 | 207 | |
208 | - public static function getComponent (int $selector) |
|
208 | + public static function getComponent(int $selector) |
|
209 | 209 | { |
210 | 210 | return isset (self::$components[$selector]) ? |
211 | 211 | self::$components[$selector] : false; |
212 | 212 | } |
213 | 213 | |
214 | - public static function componentExists (int $selector): bool |
|
214 | + public static function componentExists(int $selector): bool |
|
215 | 215 | { |
216 | 216 | return isset (self::$components[$selector]); |
217 | 217 | } |
218 | 218 | |
219 | - public static function removeComponent (int $selector): void |
|
219 | + public static function removeComponent(int $selector): void |
|
220 | 220 | { |
221 | 221 | unset (self::$components[$selector]); |
222 | 222 | } |
223 | 223 | |
224 | - public static function cleanJunk (): void |
|
224 | + public static function cleanJunk(): void |
|
225 | 225 | { |
226 | 226 | // TODO: более строгие правила очистки мусорных объектов |
227 | 227 | |
@@ -229,46 +229,46 @@ discard block |
||
229 | 229 | { |
230 | 230 | try |
231 | 231 | { |
232 | - if ($object->getType ()->isSubclassOf (\VoidCore::typeof ('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
232 | + if ($object->getType()->isSubclassOf(\VoidCore::typeof('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
233 | 233 | continue; |
234 | 234 | } |
235 | 235 | |
236 | 236 | catch (\Exception $e) {} |
237 | 237 | |
238 | - \VoidCore::destructObject ($selector); |
|
238 | + \VoidCore::destructObject($selector); |
|
239 | 239 | |
240 | - if (!\VoidCore::objectExists ($selector)) |
|
240 | + if (!\VoidCore::objectExists($selector)) |
|
241 | 241 | unset (self::$components[$selector]); |
242 | 242 | } |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | -function _c (int $selector) |
|
246 | +function _c(int $selector) |
|
247 | 247 | { |
248 | - return Components::getComponent ($selector); |
|
248 | + return Components::getComponent($selector); |
|
249 | 249 | } |
250 | 250 | |
251 | -function c ($name, bool $returnAllSimilarObjects = false) |
|
251 | +function c($name, bool $returnAllSimilarObjects = false) |
|
252 | 252 | { |
253 | - if (is_int ($name) && is_object ($object = _c ($name))) |
|
253 | + if (is_int($name) && is_object($object = _c($name))) |
|
254 | 254 | return $object; |
255 | 255 | |
256 | 256 | else |
257 | 257 | { |
258 | - $path = explode ('->', $name); |
|
258 | + $path = explode('->', $name); |
|
259 | 259 | $similar = []; |
260 | 260 | |
261 | 261 | foreach (Components::$components as $object) |
262 | 262 | try |
263 | 263 | { |
264 | - if ($object->name == end ($path)) |
|
264 | + if ($object->name == end($path)) |
|
265 | 265 | { |
266 | - if (sizeof ($path) > 1) |
|
266 | + if (sizeof($path) > 1) |
|
267 | 267 | try |
268 | 268 | { |
269 | - if (is_object ($parent = _c($object->parent->selector))) |
|
269 | + if (is_object($parent = _c($object->parent->selector))) |
|
270 | 270 | { |
271 | - if (c(join ('->', array_slice ($path, 0, -1))) == $parent) |
|
271 | + if (c(join('->', array_slice($path, 0, -1))) == $parent) |
|
272 | 272 | { |
273 | 273 | if ($returnAllSimilarObjects) |
274 | 274 | $similar[] = $object; |
@@ -302,18 +302,18 @@ discard block |
||
302 | 302 | continue; |
303 | 303 | } |
304 | 304 | |
305 | - if (sizeof ($path) == 2) |
|
305 | + if (sizeof($path) == 2) |
|
306 | 306 | { |
307 | 307 | $objects = c($path[1], true); |
308 | 308 | |
309 | - if (is_array ($objects)) |
|
309 | + if (is_array($objects)) |
|
310 | 310 | { |
311 | 311 | foreach ($objects as $id => $object) |
312 | 312 | try |
313 | 313 | { |
314 | - while (is_object ($parent = _c($object->parent->selector))) |
|
314 | + while (is_object($parent = _c($object->parent->selector))) |
|
315 | 315 | { |
316 | - if ($parent->getType ()->isSubclassOf (\VoidCore::typeof ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
|
316 | + if ($parent->getType()->isSubclassOf(\VoidCore::typeof('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
|
317 | 317 | return $objects[$id]; |
318 | 318 | |
319 | 319 | else $object = $parent; |
@@ -331,70 +331,70 @@ discard block |
||
331 | 331 | else return false; |
332 | 332 | } |
333 | 333 | |
334 | - else return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
334 | + else return $returnAllSimilarObjects && sizeof($similar) > 0 ? |
|
335 | 335 | $similar : false; |
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | -function setTimer (int $interval, callable $function): Timer |
|
339 | +function setTimer(int $interval, callable $function): Timer |
|
340 | 340 | { |
341 | 341 | $timer = new Timer; |
342 | 342 | $timer->interval = $interval; |
343 | 343 | |
344 | - $timer->tickEvent = function ($self) use ($function) |
|
344 | + $timer->tickEvent = function($self) use ($function) |
|
345 | 345 | { |
346 | - call_user_func ($function, $self); |
|
346 | + call_user_func($function, $self); |
|
347 | 347 | }; |
348 | 348 | |
349 | - $timer->start (); |
|
349 | + $timer->start(); |
|
350 | 350 | |
351 | 351 | return $timer; |
352 | 352 | } |
353 | 353 | |
354 | 354 | // FIXME: выполняется несколько раз, а не единожды |
355 | -function setTimeout (int $timeout, callable $function): Timer |
|
355 | +function setTimeout(int $timeout, callable $function): Timer |
|
356 | 356 | { |
357 | 357 | $timer = new Timer; |
358 | 358 | $timer->interval = $timeout; |
359 | 359 | |
360 | - $timer->tickEvent = function ($self) use ($function) |
|
360 | + $timer->tickEvent = function($self) use ($function) |
|
361 | 361 | { |
362 | - call_user_func ($function, $self); |
|
362 | + call_user_func($function, $self); |
|
363 | 363 | |
364 | - $self->stop (); |
|
364 | + $self->stop(); |
|
365 | 365 | }; |
366 | 366 | |
367 | - $timer->start (); |
|
367 | + $timer->start(); |
|
368 | 368 | |
369 | 369 | return $timer; |
370 | 370 | } |
371 | 371 | |
372 | 372 | class Clipboard |
373 | 373 | { |
374 | - public static function getText () |
|
374 | + public static function getText() |
|
375 | 375 | { |
376 | - return (new WFClass ('System.Windows.Forms.Clipboard'))->getText (); |
|
376 | + return (new WFClass('System.Windows.Forms.Clipboard'))->getText(); |
|
377 | 377 | } |
378 | 378 | |
379 | - public static function setText (string $text): void |
|
379 | + public static function setText(string $text): void |
|
380 | 380 | { |
381 | - (new WFClass ('System.Windows.Forms.Clipboard'))->setText ($text); |
|
381 | + (new WFClass('System.Windows.Forms.Clipboard'))->setText($text); |
|
382 | 382 | } |
383 | 383 | |
384 | - public static function getFiles (): array |
|
384 | + public static function getFiles(): array |
|
385 | 385 | { |
386 | - return (new WFClass ('System.Windows.Forms.Clipboard'))->getFileDropList ()->list; |
|
386 | + return (new WFClass('System.Windows.Forms.Clipboard'))->getFileDropList()->list; |
|
387 | 387 | } |
388 | 388 | |
389 | - public static function setFiles (array $files): void |
|
389 | + public static function setFiles(array $files): void |
|
390 | 390 | { |
391 | - $collection = new WFObject ('System.Collections.Specialized.StringCollection'); |
|
391 | + $collection = new WFObject('System.Collections.Specialized.StringCollection'); |
|
392 | 392 | |
393 | 393 | foreach ($files as $file) |
394 | - $collection->add ((string) $file); |
|
394 | + $collection->add((string) $file); |
|
395 | 395 | |
396 | - (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection); |
|
397 | - \VoidCore::removeObjects ($collection->selector); |
|
396 | + (new WFClass('System.Windows.Forms.Clipboard'))->setFileDropList($collection); |
|
397 | + \VoidCore::removeObjects($collection->selector); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
@@ -402,14 +402,13 @@ discard block |
||
402 | 402 | { |
403 | 403 | protected $cursor; |
404 | 404 | |
405 | - public function __construct (int $handle = null) |
|
405 | + public function __construct(int $handle = null) |
|
406 | 406 | { |
407 | 407 | $handle !== null ? |
408 | - $this->cursor = new WFObject ('System.Windows.Forms.Cursor', false, $handle) : |
|
409 | - $this->cursor = new WFClass ('System.Windows.Forms.Cursor'); |
|
408 | + $this->cursor = new WFObject('System.Windows.Forms.Cursor', false, $handle) : $this->cursor = new WFClass('System.Windows.Forms.Cursor'); |
|
410 | 409 | } |
411 | 410 | |
412 | - public function getPosition (): array |
|
411 | + public function getPosition(): array |
|
413 | 412 | { |
414 | 413 | $pos = $this->cursor->position; |
415 | 414 | |
@@ -420,22 +419,22 @@ discard block |
||
420 | 419 | } |
421 | 420 | } |
422 | 421 | |
423 | -function get_cursor_x (int $handle = null): int |
|
422 | +function get_cursor_x(int $handle = null): int |
|
424 | 423 | { |
425 | - return (new Cursor ($handle))->getPosition ()[0]; |
|
424 | + return (new Cursor($handle))->getPosition()[0]; |
|
426 | 425 | } |
427 | 426 | |
428 | -function get_cursor_y (int $handle = null): int |
|
427 | +function get_cursor_y(int $handle = null): int |
|
429 | 428 | { |
430 | - return (new Cursor ($handle))->getPosition ()[1]; |
|
429 | + return (new Cursor($handle))->getPosition()[1]; |
|
431 | 430 | } |
432 | 431 | |
433 | -function get_cursor_pos (int $handle = null): array |
|
432 | +function get_cursor_pos(int $handle = null): array |
|
434 | 433 | { |
435 | - return (new Cursor ($handle))->getPosition (); |
|
434 | + return (new Cursor($handle))->getPosition(); |
|
436 | 435 | } |
437 | 436 | |
438 | -set_error_handler (function ($no, $str, $file, $line) |
|
437 | +set_error_handler(function($no, $str, $file, $line) |
|
439 | 438 | { |
440 | 439 | // Мог ли я здесь сделать более адекватный код с использованием pow/sqrt? Да, мог |
441 | 440 | // Почему не сделал? Скорость важнее |
@@ -458,7 +457,7 @@ discard block |
||
458 | 457 | ]; |
459 | 458 | |
460 | 459 | if ($GLOBALS['__debug']['error_status']) |
461 | - message ([ |
|
460 | + message([ |
|
462 | 461 | 'type' => $errarr[$no], |
463 | 462 | 'text' => $str, |
464 | 463 | 'file' => $file, |
@@ -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,9 +66,7 @@ discard block |
||
67 | 66 | try |
68 | 67 | { |
69 | 68 | return \VoidCore::callMethod (\VoidCore::getClass ('System.Enum',''), ['parse', 'object'], \VoidCore::typeof ($baseType), $value, true); |
70 | - } |
|
71 | - |
|
72 | - catch (\WinFormsException $e) |
|
69 | + } catch (\WinFormsException $e) |
|
73 | 70 | { |
74 | 71 | return (new WFClass ($baseType))->$value; |
75 | 72 | } |
@@ -80,34 +77,39 @@ discard block |
||
80 | 77 | $array = (new WFClass ('System.Array', null)) |
81 | 78 | ->createInstance (\VoidCore::typeof ($type), $size = sizeof ($items)); |
82 | 79 | |
83 | - for ($i = 0; $i < $size; ++$i) |
|
84 | - $array[$i] = array_shift ($items); |
|
80 | + for ($i = 0; $i < $size; ++$i) { |
|
81 | + $array[$i] = array_shift ($items); |
|
82 | + } |
|
85 | 83 | |
86 | 84 | return $array; |
87 | 85 | } |
88 | 86 | |
89 | 87 | function dir_create (string $path, int $mode = 0777): void |
90 | 88 | { |
91 | - if (!is_dir ($path)) |
|
92 | - mkdir ($path, $mode, true); |
|
93 | -} |
|
89 | + if (!is_dir ($path)) { |
|
90 | + mkdir ($path, $mode, true); |
|
91 | + } |
|
92 | + } |
|
94 | 93 | |
95 | 94 | function dir_delete (string $path): bool |
96 | 95 | { |
97 | - if (!is_dir ($path)) |
|
98 | - return false; |
|
96 | + if (!is_dir ($path)) { |
|
97 | + return false; |
|
98 | + } |
|
99 | 99 | |
100 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
101 | - if (is_dir ($file = $path .'/'. $file)) |
|
100 | + foreach (array_slice (scandir ($path), 2) as $file) { |
|
101 | + if (is_dir ($file = $path .'/'. $file)) |
|
102 | 102 | { |
103 | 103 | dir_delete ($file); |
104 | + } |
|
104 | 105 | |
105 | - if (is_dir ($file)) |
|
106 | - rmdir ($file); |
|
106 | + if (is_dir ($file)) { |
|
107 | + rmdir ($file); |
|
108 | + } |
|
109 | + } else { |
|
110 | + unlink ($file); |
|
107 | 111 | } |
108 | 112 | |
109 | - else unlink ($file); |
|
110 | - |
|
111 | 113 | rmdir ($path); |
112 | 114 | |
113 | 115 | return true; |
@@ -121,17 +123,22 @@ discard block |
||
121 | 123 | |
122 | 124 | function dir_copy (string $from, string $to): bool |
123 | 125 | { |
124 | - if (!is_dir ($from)) |
|
125 | - return false; |
|
126 | + if (!is_dir ($from)) { |
|
127 | + return false; |
|
128 | + } |
|
126 | 129 | |
127 | - if (!is_dir ($to)) |
|
128 | - dir_create ($to); |
|
130 | + if (!is_dir ($to)) { |
|
131 | + dir_create ($to); |
|
132 | + } |
|
129 | 133 | |
130 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
131 | - if (is_dir ($f = $from .'/'. $file)) |
|
134 | + foreach (array_slice (scandir ($from), 2) as $file) { |
|
135 | + if (is_dir ($f = $from .'/'. $file)) |
|
132 | 136 | dir_copy ($f, $to .'/'. $file); |
137 | + } |
|
133 | 138 | |
134 | - else copy ($f, $to .'/'. $file); |
|
139 | + else { |
|
140 | + copy ($f, $to .'/'. $file); |
|
141 | + } |
|
135 | 142 | |
136 | 143 | return true; |
137 | 144 | } |
@@ -229,16 +236,16 @@ discard block |
||
229 | 236 | { |
230 | 237 | try |
231 | 238 | { |
232 | - if ($object->getType ()->isSubclassOf (\VoidCore::typeof ('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
233 | - continue; |
|
234 | - } |
|
235 | - |
|
236 | - catch (\Exception $e) {} |
|
239 | + if ($object->getType ()->isSubclassOf (\VoidCore::typeof ('System.Windows.Forms.Form', 'System.Windows.Forms'))) { |
|
240 | + continue; |
|
241 | + } |
|
242 | + } catch (\Exception $e) {} |
|
237 | 243 | |
238 | 244 | \VoidCore::destructObject ($selector); |
239 | 245 | |
240 | - if (!\VoidCore::objectExists ($selector)) |
|
241 | - unset (self::$components[$selector]); |
|
246 | + if (!\VoidCore::objectExists ($selector)) { |
|
247 | + unset (self::$components[$selector]); |
|
248 | + } |
|
242 | 249 | } |
243 | 250 | } |
244 | 251 | } |
@@ -250,16 +257,15 @@ discard block |
||
250 | 257 | |
251 | 258 | function c ($name, bool $returnAllSimilarObjects = false) |
252 | 259 | { |
253 | - if (is_int ($name) && is_object ($object = _c ($name))) |
|
254 | - return $object; |
|
255 | - |
|
256 | - else |
|
260 | + if (is_int ($name) && is_object ($object = _c ($name))) { |
|
261 | + return $object; |
|
262 | + } else |
|
257 | 263 | { |
258 | 264 | $path = explode ('->', $name); |
259 | 265 | $similar = []; |
260 | 266 | |
261 | - foreach (Components::$components as $object) |
|
262 | - try |
|
267 | + foreach (Components::$components as $object) { |
|
268 | + try |
|
263 | 269 | { |
264 | 270 | if ($object->name == end ($path)) |
265 | 271 | { |
@@ -272,32 +278,30 @@ discard block |
||
272 | 278 | { |
273 | 279 | if ($returnAllSimilarObjects) |
274 | 280 | $similar[] = $object; |
281 | + } |
|
275 | 282 | |
276 | - else return $object; |
|
283 | + else { |
|
284 | + return $object; |
|
285 | + } |
|
286 | + } else { |
|
287 | + continue; |
|
277 | 288 | } |
278 | - |
|
279 | - else continue; |
|
289 | + } else { |
|
290 | + continue; |
|
280 | 291 | } |
281 | - |
|
282 | - else continue; |
|
283 | - } |
|
284 | - |
|
285 | - catch (\Throwable $e) |
|
292 | + } catch (\Throwable $e) |
|
286 | 293 | { |
287 | 294 | continue; |
288 | - } |
|
289 | - |
|
290 | - else |
|
295 | + } else |
|
291 | 296 | { |
292 | - if ($returnAllSimilarObjects) |
|
293 | - $similar[] = $object; |
|
294 | - |
|
295 | - else return $object; |
|
297 | + if ($returnAllSimilarObjects) { |
|
298 | + $similar[] = $object; |
|
299 | + } else { |
|
300 | + return $object; |
|
301 | + } |
|
296 | 302 | } |
297 | 303 | } |
298 | - } |
|
299 | - |
|
300 | - catch (\Exception $e) |
|
304 | + } catch (\Exception $e) |
|
301 | 305 | { |
302 | 306 | continue; |
303 | 307 | } |
@@ -308,31 +312,32 @@ discard block |
||
308 | 312 | |
309 | 313 | if (is_array ($objects)) |
310 | 314 | { |
311 | - foreach ($objects as $id => $object) |
|
312 | - try |
|
315 | + foreach ($objects as $id => $object) { |
|
316 | + try |
|
313 | 317 | { |
314 | 318 | while (is_object ($parent = _c($object->parent->selector))) |
315 | 319 | { |
316 | 320 | if ($parent->getType ()->isSubclassOf (\VoidCore::typeof ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
317 | 321 | return $objects[$id]; |
322 | + } |
|
318 | 323 | |
319 | - else $object = $parent; |
|
324 | + else { |
|
325 | + $object = $parent; |
|
326 | + } |
|
320 | 327 | } |
321 | - } |
|
322 | - |
|
323 | - catch (\Throwable $e) |
|
328 | + } catch (\Throwable $e) |
|
324 | 329 | { |
325 | 330 | continue; |
326 | 331 | } |
327 | 332 | |
328 | 333 | return false; |
334 | + } else { |
|
335 | + return false; |
|
329 | 336 | } |
330 | - |
|
331 | - else return false; |
|
332 | - } |
|
333 | - |
|
334 | - else return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
337 | + } else { |
|
338 | + return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
335 | 339 | $similar : false; |
340 | + } |
|
336 | 341 | } |
337 | 342 | } |
338 | 343 | |
@@ -390,8 +395,9 @@ discard block |
||
390 | 395 | { |
391 | 396 | $collection = new WFObject ('System.Collections.Specialized.StringCollection'); |
392 | 397 | |
393 | - foreach ($files as $file) |
|
394 | - $collection->add ((string) $file); |
|
398 | + foreach ($files as $file) { |
|
399 | + $collection->add ((string) $file); |
|
400 | + } |
|
395 | 401 | |
396 | 402 | (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection); |
397 | 403 | \VoidCore::removeObjects ($collection->selector); |
@@ -457,11 +463,12 @@ discard block |
||
457 | 463 | 16384 => 'E_USER_DEPRECATED' |
458 | 464 | ]; |
459 | 465 | |
460 | - if ($GLOBALS['__debug']['error_status']) |
|
461 | - message ([ |
|
466 | + if ($GLOBALS['__debug']['error_status']) { |
|
467 | + message ([ |
|
462 | 468 | 'type' => $errarr[$no], |
463 | 469 | 'text' => $str, |
464 | 470 | 'file' => $file, |
465 | 471 | 'line' => $line |
466 | 472 | ], 'PHP Script Error'); |
467 | -}); |
|
473 | + } |
|
474 | + }); |
@@ -7,9 +7,9 @@ discard block |
||
7 | 7 | public static function setObjectEvent (int $object, string $eventName, callable $function) |
8 | 8 | { |
9 | 9 | \VoidCore::setEvent ($object, $eventName, function ($sender, ...$args) use ($function) |
10 | - { |
|
10 | + { |
|
11 | 11 | try |
12 | - { |
|
12 | + { |
|
13 | 13 | foreach ($args as $id => $arg) |
14 | 14 | $args[$id] = EngineAdditions::coupleSelector ($arg); |
15 | 15 | |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | $e : new WFObject ($sender), ...$args); |
18 | 18 | } |
19 | 19 | |
20 | - catch (\Throwable $e) |
|
21 | - { |
|
20 | + catch (\Throwable $e) |
|
21 | + { |
|
22 | 22 | message ([ |
23 | 23 | 'type' => get_class ($e), |
24 | 24 | 'text' => $e->getMessage (), |
@@ -4,35 +4,35 @@ |
||
4 | 4 | |
5 | 5 | class Events |
6 | 6 | { |
7 | - public static function setObjectEvent (int $object, string $eventName, callable $function) |
|
7 | + public static function setObjectEvent(int $object, string $eventName, callable $function) |
|
8 | 8 | { |
9 | - \VoidCore::setEvent ($object, $eventName, function ($sender, ...$args) use ($function) |
|
9 | + \VoidCore::setEvent($object, $eventName, function($sender, ...$args) use ($function) |
|
10 | 10 | { |
11 | 11 | try |
12 | 12 | { |
13 | 13 | foreach ($args as $id => $arg) |
14 | - $args[$id] = EngineAdditions::coupleSelector ($arg); |
|
14 | + $args[$id] = EngineAdditions::coupleSelector($arg); |
|
15 | 15 | |
16 | - return $function (($e = _c($sender)) !== false ? |
|
17 | - $e : new WFObject ($sender), ...$args); |
|
16 | + return $function(($e = _c($sender)) !== false ? |
|
17 | + $e : new WFObject($sender), ...$args); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | catch (\Throwable $e) |
21 | 21 | { |
22 | - message ([ |
|
23 | - 'type' => get_class ($e), |
|
24 | - 'text' => $e->getMessage (), |
|
25 | - 'file' => $e->getFile (), |
|
26 | - 'line' => $e->getLine (), |
|
27 | - 'code' => $e->getCode (), |
|
28 | - 'trace' => $e->getTraceAsString () |
|
22 | + message([ |
|
23 | + 'type' => get_class($e), |
|
24 | + 'text' => $e->getMessage(), |
|
25 | + 'file' => $e->getFile(), |
|
26 | + 'line' => $e->getLine(), |
|
27 | + 'code' => $e->getCode(), |
|
28 | + 'trace' => $e->getTraceAsString() |
|
29 | 29 | ], 'PHP Critical Error'); |
30 | 30 | } |
31 | 31 | }); |
32 | 32 | } |
33 | 33 | |
34 | - public static function removeObjectEvent (int $object, string $eventName) |
|
34 | + public static function removeObjectEvent(int $object, string $eventName) |
|
35 | 35 | { |
36 | - \VoidCore::removeEvent ($object, $eventName); |
|
36 | + \VoidCore::removeEvent($object, $eventName); |
|
37 | 37 | } |
38 | 38 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | } |
198 | 198 | |
199 | 199 | public function __get ($name) |
200 | - { |
|
200 | + { |
|
201 | 201 | if (method_exists ($this, $method = "get_$name")) |
202 | 202 | $value = $this->$method (); |
203 | 203 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $size = $this->count; |
227 | 227 | $list = []; |
228 | 228 | |
229 | - for ($i = 0; $i < $size; ++$i) |
|
229 | + for ($i = 0; $i < $size; ++$i) |
|
230 | 230 | $list[] = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $i)); |
231 | 231 | |
232 | 232 | return $list; |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | return EngineAdditions::coupleSelector ($value, $this->selector); |
259 | - } |
|
259 | + } |
|
260 | 260 | |
261 | - public function __set ($name, $value) |
|
262 | - { |
|
261 | + public function __set ($name, $value) |
|
262 | + { |
|
263 | 263 | if (method_exists ($this, $method = "set_$name")) |
264 | 264 | try |
265 | 265 | { |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | - public function __call ($method, $args) |
|
291 | - { |
|
290 | + public function __call ($method, $args) |
|
291 | + { |
|
292 | 292 | $args = array_map (function ($arg) |
293 | 293 | { |
294 | 294 | return EngineAdditions::uncoupleSelector ($arg); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | } |
308 | 308 | |
309 | 309 | public function offsetSet ($index, $value) |
310 | - { |
|
310 | + { |
|
311 | 311 | try |
312 | 312 | { |
313 | 313 | return $index === null ? |
@@ -323,14 +323,14 @@ discard block |
||
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
326 | - public function offsetGet ($index) |
|
327 | - { |
|
328 | - return EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $index), $this->selector); |
|
326 | + public function offsetGet ($index) |
|
327 | + { |
|
328 | + return EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $index), $this->selector); |
|
329 | 329 | } |
330 | 330 | |
331 | - public function offsetUnset ($index): void |
|
332 | - { |
|
333 | - $this->callMethod ('RemoveAt', $index); |
|
331 | + public function offsetUnset ($index): void |
|
332 | + { |
|
333 | + $this->callMethod ('RemoveAt', $index); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | public function offsetExists ($index): bool |
@@ -348,19 +348,19 @@ discard block |
||
348 | 348 | return true; |
349 | 349 | } |
350 | 350 | |
351 | - public function indexOf ($value): int |
|
352 | - { |
|
353 | - return $this->callMethod ('IndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
351 | + public function indexOf ($value): int |
|
352 | + { |
|
353 | + return $this->callMethod ('IndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | public function lastIndexOf ($value): int |
357 | - { |
|
358 | - return $this->callMethod ('LastIndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
359 | - } |
|
357 | + { |
|
358 | + return $this->callMethod ('LastIndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
359 | + } |
|
360 | 360 | |
361 | - public function contains ($value): bool |
|
362 | - { |
|
363 | - return $this->callMethod ('Contains', EngineAdditions::uncoupleSelector ($value)); |
|
361 | + public function contains ($value): bool |
|
362 | + { |
|
363 | + return $this->callMethod ('Contains', EngineAdditions::uncoupleSelector ($value)); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | public function foreach (callable $callback, string $type = null): void |
@@ -414,45 +414,45 @@ discard block |
||
414 | 414 | return \VoidCore::callMethod ($this->selector, $method, ...$args); |
415 | 415 | } |
416 | 416 | |
417 | - protected function getArrayProperty ($name, string $type = null) |
|
418 | - { |
|
417 | + protected function getArrayProperty ($name, string $type = null) |
|
418 | + { |
|
419 | 419 | $array = $this->getProperty ($name); |
420 | 420 | $size = \VoidCore::getProperty ($array, 'Length'); |
421 | 421 | $return = []; |
422 | 422 | |
423 | - for ($i = 0; $i < $size; ++$i) |
|
423 | + for ($i = 0; $i < $size; ++$i) |
|
424 | 424 | $return[] = \VoidCore::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
425 | 425 | |
426 | 426 | \VoidCore::removeObjects ($array); |
427 | 427 | |
428 | - return $return; |
|
428 | + return $return; |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | public function get_name () |
432 | - { |
|
433 | - try |
|
434 | - { |
|
435 | - return $this->getProperty ('Name'); |
|
432 | + { |
|
433 | + try |
|
434 | + { |
|
435 | + return $this->getProperty ('Name'); |
|
436 | 436 | } |
437 | 437 | |
438 | - catch (\Throwable $e) |
|
439 | - { |
|
440 | - return $this->name; |
|
441 | - } |
|
442 | - } |
|
438 | + catch (\Throwable $e) |
|
439 | + { |
|
440 | + return $this->name; |
|
441 | + } |
|
442 | + } |
|
443 | 443 | |
444 | - public function set_name (string $name) |
|
445 | - { |
|
446 | - try |
|
447 | - { |
|
448 | - $this->setProperty ('Name', $name); |
|
444 | + public function set_name (string $name) |
|
445 | + { |
|
446 | + try |
|
447 | + { |
|
448 | + $this->setProperty ('Name', $name); |
|
449 | 449 | } |
450 | 450 | |
451 | - catch (\Throwable $e) |
|
452 | - { |
|
453 | - $this->name = $name; |
|
454 | - } |
|
455 | - } |
|
451 | + catch (\Throwable $e) |
|
452 | + { |
|
453 | + $this->name = $name; |
|
454 | + } |
|
455 | + } |
|
456 | 456 | |
457 | 457 | public function __toString (): string |
458 | 458 | { |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | * @return array - возвращает список ошибок компиляции |
25 | 25 | * |
26 | 26 | */ |
27 | - 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 |
|
27 | + 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 |
|
28 | 28 | { |
29 | 29 | if ($dictionary === null) |
30 | - $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
30 | + $dictionary = new WFObject('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
31 | 31 | |
32 | 32 | if ($assemblies === null) |
33 | - $assemblies = getNetArray ('System.String', [ |
|
33 | + $assemblies = getNetArray('System.String', [ |
|
34 | 34 | // CORE_DIR .'/CefSharp.dll', |
35 | - CORE_DIR .'/FastColoredTextBox.dll', |
|
36 | - CORE_DIR .'/ScintillaNET.dll' |
|
35 | + CORE_DIR.'/FastColoredTextBox.dll', |
|
36 | + CORE_DIR.'/ScintillaNET.dll' |
|
37 | 37 | ]); |
38 | 38 | |
39 | 39 | if ($productName === null) |
40 | - $productName = basenameNoExt ($savePath); |
|
40 | + $productName = basenameNoExt($savePath); |
|
41 | 41 | |
42 | 42 | if ($productDescription === null) |
43 | 43 | $productDescription = $productName; |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | $companyName = 'Company N'; |
50 | 50 | |
51 | 51 | if ($copyright === null) |
52 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
52 | + $copyright = $companyName.' copyright (c) '.date('Y'); |
|
53 | 53 | |
54 | - return (new WFClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
54 | + return (new WFClass('WinForms_PHP.WFCompiler', null))->compile($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
55 | 55 | } |
56 | 56 | |
57 | - public static function loadModule (string $path): bool |
|
57 | + public static function loadModule(string $path): bool |
|
58 | 58 | { |
59 | 59 | try |
60 | 60 | { |
61 | - (new WFClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
|
61 | + (new WFClass('System.Reflection.Assembly', 'mscorlib'))->loadFrom($path); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | catch (\WinFormsException $e) |
@@ -69,16 +69,16 @@ discard block |
||
69 | 69 | return true; |
70 | 70 | } |
71 | 71 | |
72 | - public static function getProperty (int $selector, string $name): array |
|
72 | + public static function getProperty(int $selector, string $name): array |
|
73 | 73 | { |
74 | - $property = \VoidCore::callMethod (\VoidCore::callMethod ($selector, 'GetType'), 'GetProperty', $name); |
|
74 | + $property = \VoidCore::callMethod(\VoidCore::callMethod($selector, 'GetType'), 'GetProperty', $name); |
|
75 | 75 | |
76 | - if (!is_int ($property)) |
|
76 | + if (!is_int($property)) |
|
77 | 77 | return false; |
78 | 78 | |
79 | 79 | try |
80 | 80 | { |
81 | - $propertyType = \VoidCore::getProperty ($property, ['PropertyType', 'string']); |
|
81 | + $propertyType = \VoidCore::getProperty($property, ['PropertyType', 'string']); |
|
82 | 82 | |
83 | 83 | switch ($propertyType) |
84 | 84 | { |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | default: |
115 | 115 | try |
116 | 116 | { |
117 | - \VoidCore::getProperty ($selector, [$name, 'int']); |
|
117 | + \VoidCore::getProperty($selector, [$name, 'int']); |
|
118 | 118 | |
119 | 119 | $property = 'int'; |
120 | 120 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | { |
124 | 124 | return [ |
125 | 125 | 'type' => 'vrsf', |
126 | - 'value' => \VoidCore::exportObject (\VoidCore::getProperty ($selector, [$name, 'object'])) |
|
126 | + 'value' => \VoidCore::exportObject(\VoidCore::getProperty($selector, [$name, 'object'])) |
|
127 | 127 | ]; |
128 | 128 | } |
129 | 129 | break; |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | |
138 | 138 | return [ |
139 | 139 | 'type' => $property, |
140 | - 'value' => \VoidCore::getProperty ($selector, [$name, $property]) |
|
140 | + 'value' => \VoidCore::getProperty($selector, [$name, $property]) |
|
141 | 141 | ]; |
142 | 142 | } |
143 | 143 | |
144 | - public static function getObjectEvents (int $object): array |
|
144 | + public static function getObjectEvents(int $object): array |
|
145 | 145 | { |
146 | 146 | $events = []; |
147 | 147 | |
148 | - $props = \VoidCore::callMethod (\VoidCore::callMethod ($object, 'GetType'), 'GetEvents'); |
|
149 | - $len = \VoidCore::getProperty ($props, 'Length'); |
|
148 | + $props = \VoidCore::callMethod(\VoidCore::callMethod($object, 'GetType'), 'GetEvents'); |
|
149 | + $len = \VoidCore::getProperty($props, 'Length'); |
|
150 | 150 | |
151 | 151 | for ($i = 0; $i < $len; ++$i) |
152 | - $events[] = \VoidCore::getProperty (\VoidCore::getArrayValue ($props, $i), 'Name'); |
|
152 | + $events[] = \VoidCore::getProperty(\VoidCore::getArrayValue($props, $i), 'Name'); |
|
153 | 153 | |
154 | 154 | return $events; |
155 | 155 | } |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | * Тогда получается бесконечный цикл вида object->selector->selector->selector->... |
160 | 160 | * Чтобы этого избежать нужно добавить исключение - переменную $selfSelector |
161 | 161 | */ |
162 | - public static function coupleSelector ($value, int $selfSelector = null) |
|
162 | + public static function coupleSelector($value, int $selfSelector = null) |
|
163 | 163 | { |
164 | - return is_int ($value) && \VoidCore::objectExists ($value) && $value != $selfSelector ? |
|
165 | - new WFObject ($value) : $value; |
|
164 | + return is_int($value) && \VoidCore::objectExists($value) && $value != $selfSelector ? |
|
165 | + new WFObject($value) : $value; |
|
166 | 166 | } |
167 | 167 | |
168 | - public static function uncoupleSelector ($value) |
|
168 | + public static function uncoupleSelector($value) |
|
169 | 169 | { |
170 | 170 | return $value instanceof WFObject ? |
171 | 171 | $value->selector : $value; |
@@ -177,48 +177,48 @@ discard block |
||
177 | 177 | protected int $selector = 0; |
178 | 178 | protected $name; |
179 | 179 | |
180 | - public function __construct ($object, $classGroup = false, ...$args) |
|
180 | + public function __construct($object, $classGroup = false, ...$args) |
|
181 | 181 | { |
182 | 182 | foreach ($args as $id => $arg) |
183 | - $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
183 | + $args[$id] = EngineAdditions::uncoupleSelector($arg); |
|
184 | 184 | |
185 | - if (is_string ($object)) |
|
185 | + if (is_string($object)) |
|
186 | 186 | { |
187 | - $this->selector = \VoidCore::createObject ($object, $classGroup, ...$args); |
|
187 | + $this->selector = \VoidCore::createObject($object, $classGroup, ...$args); |
|
188 | 188 | |
189 | 189 | /*$this->selector = \VoidCore::createObject ($object, $classGroup == 'auto' ? |
190 | 190 | substr ($object, 0, strrpos ($object, '.')) : $classGroup, ...$args);*/ |
191 | 191 | } |
192 | 192 | |
193 | - elseif (is_int ($object) && \VoidCore::objectExists ($object)) |
|
193 | + elseif (is_int($object) && \VoidCore::objectExists($object)) |
|
194 | 194 | $this->selector = $object; |
195 | 195 | |
196 | - else throw new \Exception ('$object parameter must be string or object selector'); |
|
196 | + else throw new \Exception('$object parameter must be string or object selector'); |
|
197 | 197 | } |
198 | 198 | |
199 | - public function __get ($name) |
|
199 | + public function __get($name) |
|
200 | 200 | { |
201 | - if (method_exists ($this, $method = "get_$name")) |
|
202 | - $value = $this->$method (); |
|
201 | + if (method_exists($this, $method = "get_$name")) |
|
202 | + $value = $this->$method(); |
|
203 | 203 | |
204 | - elseif (substr ($name, -5) == 'Event') |
|
205 | - $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
204 | + elseif (substr($name, -5) == 'Event') |
|
205 | + $value = Events::getObjectEvent($this->selector, substr($name, 0, -5)); |
|
206 | 206 | |
207 | - elseif (property_exists ($this, $name)) |
|
207 | + elseif (property_exists($this, $name)) |
|
208 | 208 | $value = $this->$name; |
209 | 209 | |
210 | - else switch (strtolower ($name)) |
|
210 | + else switch (strtolower($name)) |
|
211 | 211 | { |
212 | 212 | case 'count': |
213 | 213 | case 'length': |
214 | 214 | try |
215 | 215 | { |
216 | - return $this->getProperty ('Count'); |
|
216 | + return $this->getProperty('Count'); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | catch (\WinFormsException $e) |
220 | 220 | { |
221 | - return $this->getProperty ('Length'); |
|
221 | + return $this->getProperty('Length'); |
|
222 | 222 | } |
223 | 223 | break; |
224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $list = []; |
228 | 228 | |
229 | 229 | for ($i = 0; $i < $size; ++$i) |
230 | - $list[] = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $i)); |
|
230 | + $list[] = EngineAdditions::coupleSelector(\VoidCore::getArrayValue($this->selector, $i)); |
|
231 | 231 | |
232 | 232 | return $list; |
233 | 233 | break; |
@@ -239,31 +239,31 @@ discard block |
||
239 | 239 | for ($i = 0; $i < $size; ++$i) |
240 | 240 | try |
241 | 241 | { |
242 | - $names[] = \VoidCore::getProperty (\VoidCore::getArrayValue ($this->selector, [$i, 'object']), 'Text'); |
|
242 | + $names[] = \VoidCore::getProperty(\VoidCore::getArrayValue($this->selector, [$i, 'object']), 'Text'); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | catch (\WinFormsException $e) |
246 | 246 | { |
247 | - $names[] = \VoidCore::getArrayValue ($this->selector, [$i, 'string']); |
|
247 | + $names[] = \VoidCore::getArrayValue($this->selector, [$i, 'string']); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | return $names; |
251 | 251 | break; |
252 | 252 | |
253 | 253 | default: |
254 | - $value = $this->getProperty ($name); |
|
254 | + $value = $this->getProperty($name); |
|
255 | 255 | break; |
256 | 256 | } |
257 | 257 | |
258 | - return EngineAdditions::coupleSelector ($value, $this->selector); |
|
258 | + return EngineAdditions::coupleSelector($value, $this->selector); |
|
259 | 259 | } |
260 | 260 | |
261 | - public function __set ($name, $value) |
|
261 | + public function __set($name, $value) |
|
262 | 262 | { |
263 | - if (method_exists ($this, $method = "set_$name")) |
|
263 | + if (method_exists($this, $method = "set_$name")) |
|
264 | 264 | try |
265 | 265 | { |
266 | - return $this->$method ($value); |
|
266 | + return $this->$method($value); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | # Метод "set_$name" может принимать в качестве параметра объект WFObject |
@@ -272,72 +272,70 @@ discard block |
||
272 | 272 | catch (\Throwable $e) |
273 | 273 | { |
274 | 274 | return $value instanceof WFObject ? |
275 | - $this->$method ($value->selector) : null; |
|
275 | + $this->$method($value->selector) : null; |
|
276 | 276 | } |
277 | 277 | |
278 | - elseif (substr ($name, -5) == 'Event') |
|
279 | - Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
278 | + elseif (substr($name, -5) == 'Event') |
|
279 | + Events::setObjectEvent($this->selector, substr($name, 0, -5), $value); |
|
280 | 280 | |
281 | 281 | else |
282 | 282 | { |
283 | - if (is_array ($value) && is_string (current ($value))) |
|
284 | - $value = getNetArray ('System.String', $value); |
|
283 | + if (is_array($value) && is_string(current($value))) |
|
284 | + $value = getNetArray('System.String', $value); |
|
285 | 285 | |
286 | - $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
286 | + $this->setProperty($name, EngineAdditions::uncoupleSelector($value)); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | - public function __call ($method, $args) |
|
290 | + public function __call($method, $args) |
|
291 | 291 | { |
292 | - $args = array_map (function ($arg) |
|
292 | + $args = array_map(function($arg) |
|
293 | 293 | { |
294 | - return EngineAdditions::uncoupleSelector ($arg); |
|
294 | + return EngineAdditions::uncoupleSelector($arg); |
|
295 | 295 | }, $args); |
296 | 296 | |
297 | - return EngineAdditions::coupleSelector ($this->callMethod ($method, ...$args), $this->selector); |
|
297 | + return EngineAdditions::coupleSelector($this->callMethod($method, ...$args), $this->selector); |
|
298 | 298 | } |
299 | 299 | |
300 | - public function addRange ($values, $assoc = false): void |
|
300 | + public function addRange($values, $assoc = false): void |
|
301 | 301 | { |
302 | - if (is_array ($values)) |
|
302 | + if (is_array($values)) |
|
303 | 303 | foreach ($values as $id => $value) |
304 | - $this->offsetSet ($assoc ? $id : null, $value); |
|
304 | + $this->offsetSet($assoc ? $id : null, $value); |
|
305 | 305 | |
306 | - else $this->callMethod ('AddRange', EngineAdditions::uncoupleSelector ($values)); |
|
306 | + else $this->callMethod('AddRange', EngineAdditions::uncoupleSelector($values)); |
|
307 | 307 | } |
308 | 308 | |
309 | - public function offsetSet ($index, $value) |
|
309 | + public function offsetSet($index, $value) |
|
310 | 310 | { |
311 | 311 | try |
312 | 312 | { |
313 | 313 | return $index === null ? |
314 | - $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
|
315 | - $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
|
314 | + $this->callMethod('Add', EngineAdditions::uncoupleSelector($value)) : $this->callMethod('Insert', $index, EngineAdditions::uncoupleSelector($value)); |
|
316 | 315 | } |
317 | 316 | |
318 | 317 | catch (\Throwable $e) |
319 | 318 | { |
320 | 319 | return $index === null ? |
321 | - \VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) : |
|
322 | - \VoidCore::setArrayValue ($this->selector, $index, EngineAdditions::uncoupleSelector ($value)); |
|
320 | + \VoidCore::setArrayValue($this->selector, $this->count, EngineAdditions::uncoupleSelector($value)) : \VoidCore::setArrayValue($this->selector, $index, EngineAdditions::uncoupleSelector($value)); |
|
323 | 321 | } |
324 | 322 | } |
325 | 323 | |
326 | - public function offsetGet ($index) |
|
324 | + public function offsetGet($index) |
|
327 | 325 | { |
328 | - return EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $index), $this->selector); |
|
326 | + return EngineAdditions::coupleSelector(\VoidCore::getArrayValue($this->selector, $index), $this->selector); |
|
329 | 327 | } |
330 | 328 | |
331 | - public function offsetUnset ($index): void |
|
329 | + public function offsetUnset($index): void |
|
332 | 330 | { |
333 | - $this->callMethod ('RemoveAt', $index); |
|
331 | + $this->callMethod('RemoveAt', $index); |
|
334 | 332 | } |
335 | 333 | |
336 | - public function offsetExists ($index): bool |
|
334 | + public function offsetExists($index): bool |
|
337 | 335 | { |
338 | 336 | try |
339 | 337 | { |
340 | - $this->offsetGet ($index); |
|
338 | + $this->offsetGet($index); |
|
341 | 339 | } |
342 | 340 | |
343 | 341 | catch (\Exception $e) |
@@ -348,19 +346,19 @@ discard block |
||
348 | 346 | return true; |
349 | 347 | } |
350 | 348 | |
351 | - public function indexOf ($value): int |
|
349 | + public function indexOf($value): int |
|
352 | 350 | { |
353 | - return $this->callMethod ('IndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
351 | + return $this->callMethod('IndexOf', EngineAdditions::uncoupleSelector($value)); |
|
354 | 352 | } |
355 | 353 | |
356 | - public function lastIndexOf ($value): int |
|
354 | + public function lastIndexOf($value): int |
|
357 | 355 | { |
358 | - return $this->callMethod ('LastIndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
356 | + return $this->callMethod('LastIndexOf', EngineAdditions::uncoupleSelector($value)); |
|
359 | 357 | } |
360 | 358 | |
361 | - public function contains ($value): bool |
|
359 | + public function contains($value): bool |
|
362 | 360 | { |
363 | - return $this->callMethod ('Contains', EngineAdditions::uncoupleSelector ($value)); |
|
361 | + return $this->callMethod('Contains', EngineAdditions::uncoupleSelector($value)); |
|
364 | 362 | } |
365 | 363 | |
366 | 364 | public function foreach (callable $callback, string $type = null): void |
@@ -368,71 +366,71 @@ discard block |
||
368 | 366 | $size = $this->count; |
369 | 367 | |
370 | 368 | for ($i = 0; $i < $size; ++$i) |
371 | - $callback (EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
369 | + $callback(EngineAdditions::coupleSelector(\VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
372 | 370 | } |
373 | 371 | |
374 | - public function where (callable $comparator, string $type = null): array |
|
372 | + public function where(callable $comparator, string $type = null): array |
|
375 | 373 | { |
376 | 374 | $size = $this->count; |
377 | 375 | $return = []; |
378 | 376 | |
379 | 377 | for ($i = 0; $i < $size; ++$i) |
380 | - if ($comparator ($value = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
378 | + if ($comparator($value = EngineAdditions::coupleSelector(\VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
381 | 379 | $return[] = $value; |
382 | 380 | |
383 | 381 | return $return; |
384 | 382 | } |
385 | 383 | |
386 | - protected function getProperty ($name) |
|
384 | + protected function getProperty($name) |
|
387 | 385 | { |
388 | 386 | try |
389 | 387 | { |
390 | - return \VoidCore::getProperty ($this->selector, $name); |
|
388 | + return \VoidCore::getProperty($this->selector, $name); |
|
391 | 389 | } |
392 | 390 | |
393 | 391 | catch (\WinFormsException $e) |
394 | 392 | { |
395 | - return \VoidCore::getField ($this->selector, $name); |
|
393 | + return \VoidCore::getField($this->selector, $name); |
|
396 | 394 | } |
397 | 395 | } |
398 | 396 | |
399 | - protected function setProperty ($name, $value) |
|
397 | + protected function setProperty($name, $value) |
|
400 | 398 | { |
401 | 399 | try |
402 | 400 | { |
403 | - \VoidCore::setProperty ($this->selector, $name, $value); |
|
401 | + \VoidCore::setProperty($this->selector, $name, $value); |
|
404 | 402 | } |
405 | 403 | |
406 | 404 | catch (\WinFormsException $e) |
407 | 405 | { |
408 | - \VoidCore::setField ($this->selector, $name, $value); |
|
406 | + \VoidCore::setField($this->selector, $name, $value); |
|
409 | 407 | } |
410 | 408 | } |
411 | 409 | |
412 | - protected function callMethod ($method, ...$args) |
|
410 | + protected function callMethod($method, ...$args) |
|
413 | 411 | { |
414 | - return \VoidCore::callMethod ($this->selector, $method, ...$args); |
|
412 | + return \VoidCore::callMethod($this->selector, $method, ...$args); |
|
415 | 413 | } |
416 | 414 | |
417 | - protected function getArrayProperty ($name, string $type = null) |
|
415 | + protected function getArrayProperty($name, string $type = null) |
|
418 | 416 | { |
419 | - $array = $this->getProperty ($name); |
|
420 | - $size = \VoidCore::getProperty ($array, 'Length'); |
|
417 | + $array = $this->getProperty($name); |
|
418 | + $size = \VoidCore::getProperty($array, 'Length'); |
|
421 | 419 | $return = []; |
422 | 420 | |
423 | 421 | for ($i = 0; $i < $size; ++$i) |
424 | - $return[] = \VoidCore::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
422 | + $return[] = \VoidCore::getArrayValue($array, $type === null ? $i : [$i, $type]); |
|
425 | 423 | |
426 | - \VoidCore::removeObjects ($array); |
|
424 | + \VoidCore::removeObjects($array); |
|
427 | 425 | |
428 | 426 | return $return; |
429 | 427 | } |
430 | 428 | |
431 | - public function get_name () |
|
429 | + public function get_name() |
|
432 | 430 | { |
433 | 431 | try |
434 | 432 | { |
435 | - return $this->getProperty ('Name'); |
|
433 | + return $this->getProperty('Name'); |
|
436 | 434 | } |
437 | 435 | |
438 | 436 | catch (\Throwable $e) |
@@ -441,11 +439,11 @@ discard block |
||
441 | 439 | } |
442 | 440 | } |
443 | 441 | |
444 | - public function set_name (string $name) |
|
442 | + public function set_name(string $name) |
|
445 | 443 | { |
446 | 444 | try |
447 | 445 | { |
448 | - $this->setProperty ('Name', $name); |
|
446 | + $this->setProperty('Name', $name); |
|
449 | 447 | } |
450 | 448 | |
451 | 449 | catch (\Throwable $e) |
@@ -454,22 +452,22 @@ discard block |
||
454 | 452 | } |
455 | 453 | } |
456 | 454 | |
457 | - public function __toString (): string |
|
455 | + public function __toString(): string |
|
458 | 456 | { |
459 | - return $this->callMethod ('ToString'); |
|
457 | + return $this->callMethod('ToString'); |
|
460 | 458 | } |
461 | 459 | } |
462 | 460 | |
463 | 461 | class WFClass extends WFObject |
464 | 462 | { |
465 | - public function __construct ($class, $classGroup = false) |
|
463 | + public function __construct($class, $classGroup = false) |
|
466 | 464 | { |
467 | - if (is_string ($class)) |
|
468 | - $this->selector = \VoidCore::getClass ($class, $classGroup); |
|
465 | + if (is_string($class)) |
|
466 | + $this->selector = \VoidCore::getClass($class, $classGroup); |
|
469 | 467 | |
470 | - elseif (is_int ($class) && \VoidCore::objectExists ($class)) |
|
468 | + elseif (is_int($class) && \VoidCore::objectExists($class)) |
|
471 | 469 | $this->selector = $class; |
472 | 470 | |
473 | - else throw new \Exception ('$class parameter must be string or class selector'); |
|
471 | + else throw new \Exception('$class parameter must be string or class selector'); |
|
474 | 472 | } |
475 | 473 | } |
@@ -26,30 +26,37 @@ discard block |
||
26 | 26 | */ |
27 | 27 | 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 |
28 | 28 | { |
29 | - if ($dictionary === null) |
|
30 | - $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
29 | + if ($dictionary === null) { |
|
30 | + $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
31 | + } |
|
31 | 32 | |
32 | - if ($assemblies === null) |
|
33 | - $assemblies = getNetArray ('System.String', [ |
|
33 | + if ($assemblies === null) { |
|
34 | + $assemblies = getNetArray ('System.String', [ |
|
34 | 35 | // CORE_DIR .'/CefSharp.dll', |
35 | 36 | CORE_DIR .'/FastColoredTextBox.dll', |
36 | 37 | CORE_DIR .'/ScintillaNET.dll' |
37 | 38 | ]); |
39 | + } |
|
38 | 40 | |
39 | - if ($productName === null) |
|
40 | - $productName = basenameNoExt ($savePath); |
|
41 | + if ($productName === null) { |
|
42 | + $productName = basenameNoExt ($savePath); |
|
43 | + } |
|
41 | 44 | |
42 | - if ($productDescription === null) |
|
43 | - $productDescription = $productName; |
|
45 | + if ($productDescription === null) { |
|
46 | + $productDescription = $productName; |
|
47 | + } |
|
44 | 48 | |
45 | - if ($productVersion === null) |
|
46 | - $productVersion = '1.0'; |
|
49 | + if ($productVersion === null) { |
|
50 | + $productVersion = '1.0'; |
|
51 | + } |
|
47 | 52 | |
48 | - if ($companyName === null) |
|
49 | - $companyName = 'Company N'; |
|
53 | + if ($companyName === null) { |
|
54 | + $companyName = 'Company N'; |
|
55 | + } |
|
50 | 56 | |
51 | - if ($copyright === null) |
|
52 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
57 | + if ($copyright === null) { |
|
58 | + $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
59 | + } |
|
53 | 60 | |
54 | 61 | return (new WFClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
55 | 62 | } |
@@ -59,9 +66,7 @@ discard block |
||
59 | 66 | try |
60 | 67 | { |
61 | 68 | (new WFClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
62 | - } |
|
63 | - |
|
64 | - catch (\WinFormsException $e) |
|
69 | + } catch (\WinFormsException $e) |
|
65 | 70 | { |
66 | 71 | return false; |
67 | 72 | } |
@@ -73,8 +78,9 @@ discard block |
||
73 | 78 | { |
74 | 79 | $property = \VoidCore::callMethod (\VoidCore::callMethod ($selector, 'GetType'), 'GetProperty', $name); |
75 | 80 | |
76 | - if (!is_int ($property)) |
|
77 | - return false; |
|
81 | + if (!is_int ($property)) { |
|
82 | + return false; |
|
83 | + } |
|
78 | 84 | |
79 | 85 | try |
80 | 86 | { |
@@ -117,9 +123,7 @@ discard block |
||
117 | 123 | \VoidCore::getProperty ($selector, [$name, 'int']); |
118 | 124 | |
119 | 125 | $property = 'int'; |
120 | - } |
|
121 | - |
|
122 | - catch (\WinFormsException $e) |
|
126 | + } catch (\WinFormsException $e) |
|
123 | 127 | { |
124 | 128 | return [ |
125 | 129 | 'type' => 'vrsf', |
@@ -128,9 +132,7 @@ discard block |
||
128 | 132 | } |
129 | 133 | break; |
130 | 134 | } |
131 | - } |
|
132 | - |
|
133 | - catch (\Throwable $e) |
|
135 | + } catch (\Throwable $e) |
|
134 | 136 | { |
135 | 137 | $property = 'object'; |
136 | 138 | } |
@@ -148,8 +150,9 @@ discard block |
||
148 | 150 | $props = \VoidCore::callMethod (\VoidCore::callMethod ($object, 'GetType'), 'GetEvents'); |
149 | 151 | $len = \VoidCore::getProperty ($props, 'Length'); |
150 | 152 | |
151 | - for ($i = 0; $i < $len; ++$i) |
|
152 | - $events[] = \VoidCore::getProperty (\VoidCore::getArrayValue ($props, $i), 'Name'); |
|
153 | + for ($i = 0; $i < $len; ++$i) { |
|
154 | + $events[] = \VoidCore::getProperty (\VoidCore::getArrayValue ($props, $i), 'Name'); |
|
155 | + } |
|
153 | 156 | |
154 | 157 | return $events; |
155 | 158 | } |
@@ -179,8 +182,9 @@ discard block |
||
179 | 182 | |
180 | 183 | public function __construct ($object, $classGroup = false, ...$args) |
181 | 184 | { |
182 | - foreach ($args as $id => $arg) |
|
183 | - $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
185 | + foreach ($args as $id => $arg) { |
|
186 | + $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
187 | + } |
|
184 | 188 | |
185 | 189 | if (is_string ($object)) |
186 | 190 | { |
@@ -188,35 +192,31 @@ discard block |
||
188 | 192 | |
189 | 193 | /*$this->selector = \VoidCore::createObject ($object, $classGroup == 'auto' ? |
190 | 194 | substr ($object, 0, strrpos ($object, '.')) : $classGroup, ...$args);*/ |
195 | + } elseif (is_int ($object) && \VoidCore::objectExists ($object)) { |
|
196 | + $this->selector = $object; |
|
197 | + } else { |
|
198 | + throw new \Exception ('$object parameter must be string or object selector'); |
|
191 | 199 | } |
192 | - |
|
193 | - elseif (is_int ($object) && \VoidCore::objectExists ($object)) |
|
194 | - $this->selector = $object; |
|
195 | - |
|
196 | - else throw new \Exception ('$object parameter must be string or object selector'); |
|
197 | 200 | } |
198 | 201 | |
199 | 202 | public function __get ($name) |
200 | 203 | { |
201 | - if (method_exists ($this, $method = "get_$name")) |
|
202 | - $value = $this->$method (); |
|
203 | - |
|
204 | - elseif (substr ($name, -5) == 'Event') |
|
205 | - $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
206 | - |
|
207 | - elseif (property_exists ($this, $name)) |
|
208 | - $value = $this->$name; |
|
209 | - |
|
210 | - else switch (strtolower ($name)) |
|
204 | + if (method_exists ($this, $method = "get_$name")) { |
|
205 | + $value = $this->$method (); |
|
206 | + } elseif (substr ($name, -5) == 'Event') { |
|
207 | + $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
208 | + } elseif (property_exists ($this, $name)) { |
|
209 | + $value = $this->$name; |
|
210 | + } else { |
|
211 | + switch (strtolower ($name)) |
|
211 | 212 | { |
212 | 213 | case 'count': |
213 | 214 | case 'length': |
214 | 215 | try |
215 | 216 | { |
216 | 217 | return $this->getProperty ('Count'); |
217 | - } |
|
218 | - |
|
219 | - catch (\WinFormsException $e) |
|
218 | + } |
|
219 | + } catch (\WinFormsException $e) |
|
220 | 220 | { |
221 | 221 | return $this->getProperty ('Length'); |
222 | 222 | } |
@@ -226,8 +226,9 @@ discard block |
||
226 | 226 | $size = $this->count; |
227 | 227 | $list = []; |
228 | 228 | |
229 | - for ($i = 0; $i < $size; ++$i) |
|
230 | - $list[] = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $i)); |
|
229 | + for ($i = 0; $i < $size; ++$i) { |
|
230 | + $list[] = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $i)); |
|
231 | + } |
|
231 | 232 | |
232 | 233 | return $list; |
233 | 234 | break; |
@@ -236,13 +237,12 @@ discard block |
||
236 | 237 | $size = $this->count; |
237 | 238 | $names = []; |
238 | 239 | |
239 | - for ($i = 0; $i < $size; ++$i) |
|
240 | - try |
|
240 | + for ($i = 0; $i < $size; ++$i) { |
|
241 | + try |
|
241 | 242 | { |
242 | 243 | $names[] = \VoidCore::getProperty (\VoidCore::getArrayValue ($this->selector, [$i, 'object']), 'Text'); |
243 | - } |
|
244 | - |
|
245 | - catch (\WinFormsException $e) |
|
244 | + } |
|
245 | + } catch (\WinFormsException $e) |
|
246 | 246 | { |
247 | 247 | $names[] = \VoidCore::getArrayValue ($this->selector, [$i, 'string']); |
248 | 248 | } |
@@ -260,10 +260,11 @@ discard block |
||
260 | 260 | |
261 | 261 | public function __set ($name, $value) |
262 | 262 | { |
263 | - if (method_exists ($this, $method = "set_$name")) |
|
264 | - try |
|
263 | + if (method_exists ($this, $method = "set_$name")) { |
|
264 | + try |
|
265 | 265 | { |
266 | 266 | return $this->$method ($value); |
267 | + } |
|
267 | 268 | } |
268 | 269 | |
269 | 270 | # Метод "set_$name" может принимать в качестве параметра объект WFObject |
@@ -273,15 +274,13 @@ discard block |
||
273 | 274 | { |
274 | 275 | return $value instanceof WFObject ? |
275 | 276 | $this->$method ($value->selector) : null; |
276 | - } |
|
277 | - |
|
278 | - elseif (substr ($name, -5) == 'Event') |
|
279 | - Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
280 | - |
|
281 | - else |
|
277 | + } elseif (substr ($name, -5) == 'Event') { |
|
278 | + Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
279 | + } else |
|
282 | 280 | { |
283 | - if (is_array ($value) && is_string (current ($value))) |
|
284 | - $value = getNetArray ('System.String', $value); |
|
281 | + if (is_array ($value) && is_string (current ($value))) { |
|
282 | + $value = getNetArray ('System.String', $value); |
|
283 | + } |
|
285 | 284 | |
286 | 285 | $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
287 | 286 | } |
@@ -299,11 +298,12 @@ discard block |
||
299 | 298 | |
300 | 299 | public function addRange ($values, $assoc = false): void |
301 | 300 | { |
302 | - if (is_array ($values)) |
|
303 | - foreach ($values as $id => $value) |
|
301 | + if (is_array ($values)) { |
|
302 | + foreach ($values as $id => $value) |
|
304 | 303 | $this->offsetSet ($assoc ? $id : null, $value); |
305 | - |
|
306 | - else $this->callMethod ('AddRange', EngineAdditions::uncoupleSelector ($values)); |
|
304 | + } else { |
|
305 | + $this->callMethod ('AddRange', EngineAdditions::uncoupleSelector ($values)); |
|
306 | + } |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | public function offsetSet ($index, $value) |
@@ -313,9 +313,7 @@ discard block |
||
313 | 313 | return $index === null ? |
314 | 314 | $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
315 | 315 | $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
316 | - } |
|
317 | - |
|
318 | - catch (\Throwable $e) |
|
316 | + } catch (\Throwable $e) |
|
319 | 317 | { |
320 | 318 | return $index === null ? |
321 | 319 | \VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) : |
@@ -338,9 +336,7 @@ discard block |
||
338 | 336 | try |
339 | 337 | { |
340 | 338 | $this->offsetGet ($index); |
341 | - } |
|
342 | - |
|
343 | - catch (\Exception $e) |
|
339 | + } catch (\Exception $e) |
|
344 | 340 | { |
345 | 341 | return false; |
346 | 342 | } |
@@ -367,8 +363,9 @@ discard block |
||
367 | 363 | { |
368 | 364 | $size = $this->count; |
369 | 365 | |
370 | - for ($i = 0; $i < $size; ++$i) |
|
371 | - $callback (EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
366 | + for ($i = 0; $i < $size; ++$i) { |
|
367 | + $callback (EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
368 | + } |
|
372 | 369 | } |
373 | 370 | |
374 | 371 | public function where (callable $comparator, string $type = null): array |
@@ -376,9 +373,10 @@ discard block |
||
376 | 373 | $size = $this->count; |
377 | 374 | $return = []; |
378 | 375 | |
379 | - for ($i = 0; $i < $size; ++$i) |
|
380 | - if ($comparator ($value = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
376 | + for ($i = 0; $i < $size; ++$i) { |
|
377 | + if ($comparator ($value = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
381 | 378 | $return[] = $value; |
379 | + } |
|
382 | 380 | |
383 | 381 | return $return; |
384 | 382 | } |
@@ -388,9 +386,7 @@ discard block |
||
388 | 386 | try |
389 | 387 | { |
390 | 388 | return \VoidCore::getProperty ($this->selector, $name); |
391 | - } |
|
392 | - |
|
393 | - catch (\WinFormsException $e) |
|
389 | + } catch (\WinFormsException $e) |
|
394 | 390 | { |
395 | 391 | return \VoidCore::getField ($this->selector, $name); |
396 | 392 | } |
@@ -401,9 +397,7 @@ discard block |
||
401 | 397 | try |
402 | 398 | { |
403 | 399 | \VoidCore::setProperty ($this->selector, $name, $value); |
404 | - } |
|
405 | - |
|
406 | - catch (\WinFormsException $e) |
|
400 | + } catch (\WinFormsException $e) |
|
407 | 401 | { |
408 | 402 | \VoidCore::setField ($this->selector, $name, $value); |
409 | 403 | } |
@@ -420,8 +414,9 @@ discard block |
||
420 | 414 | $size = \VoidCore::getProperty ($array, 'Length'); |
421 | 415 | $return = []; |
422 | 416 | |
423 | - for ($i = 0; $i < $size; ++$i) |
|
424 | - $return[] = \VoidCore::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
417 | + for ($i = 0; $i < $size; ++$i) { |
|
418 | + $return[] = \VoidCore::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
419 | + } |
|
425 | 420 | |
426 | 421 | \VoidCore::removeObjects ($array); |
427 | 422 | |
@@ -433,9 +428,7 @@ discard block |
||
433 | 428 | try |
434 | 429 | { |
435 | 430 | return $this->getProperty ('Name'); |
436 | - } |
|
437 | - |
|
438 | - catch (\Throwable $e) |
|
431 | + } catch (\Throwable $e) |
|
439 | 432 | { |
440 | 433 | return $this->name; |
441 | 434 | } |
@@ -446,9 +439,7 @@ discard block |
||
446 | 439 | try |
447 | 440 | { |
448 | 441 | $this->setProperty ('Name', $name); |
449 | - } |
|
450 | - |
|
451 | - catch (\Throwable $e) |
|
442 | + } catch (\Throwable $e) |
|
452 | 443 | { |
453 | 444 | $this->name = $name; |
454 | 445 | } |
@@ -464,12 +455,12 @@ discard block |
||
464 | 455 | { |
465 | 456 | public function __construct ($class, $classGroup = false) |
466 | 457 | { |
467 | - if (is_string ($class)) |
|
468 | - $this->selector = \VoidCore::getClass ($class, $classGroup); |
|
469 | - |
|
470 | - elseif (is_int ($class) && \VoidCore::objectExists ($class)) |
|
471 | - $this->selector = $class; |
|
472 | - |
|
473 | - else throw new \Exception ('$class parameter must be string or class selector'); |
|
458 | + if (is_string ($class)) { |
|
459 | + $this->selector = \VoidCore::getClass ($class, $classGroup); |
|
460 | + } elseif (is_int ($class) && \VoidCore::objectExists ($class)) { |
|
461 | + $this->selector = $class; |
|
462 | + } else { |
|
463 | + throw new \Exception ('$class parameter must be string or class selector'); |
|
464 | + } |
|
474 | 465 | } |
475 | 466 | } |
@@ -2,17 +2,17 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -$env = new WFClass ('System.Environment', 'mscorlib'); |
|
6 | -$params = $env->getCommandLineArgs ()->list; |
|
5 | +$env = new WFClass('System.Environment', 'mscorlib'); |
|
6 | +$params = $env->getCommandLineArgs()->list; |
|
7 | 7 | |
8 | -$converter = new WFClass ('System.Drawing.ColorTranslator'); |
|
8 | +$converter = new WFClass('System.Drawing.ColorTranslator'); |
|
9 | 9 | |
10 | 10 | $constants = [ |
11 | 11 | # Информация об окружении |
12 | 12 | |
13 | 13 | 'EXE_NAME' => $APPLICATION->executablePath, |
14 | - 'DOC_ROOT' => dirname ($APPLICATION->executablePath), |
|
15 | - 'IS_ADMIN' => is_writable (getenv ('SystemRoot')), |
|
14 | + 'DOC_ROOT' => dirname($APPLICATION->executablePath), |
|
15 | + 'IS_ADMIN' => is_writable(getenv('SystemRoot')), |
|
16 | 16 | 'START_PARAMS' => $params, |
17 | 17 | 'USERNAME' => $env->username, |
18 | 18 | |
@@ -332,17 +332,17 @@ discard block |
||
332 | 332 | |
333 | 333 | # Моя подборка цветов |
334 | 334 | |
335 | - 'clDark' => $converter->fromHtml ('#0D0F12'), |
|
336 | - 'clDark2' => $converter->fromHtml ('#121416'), |
|
337 | - 'clTurquoise' => $converter->fromHtml ('#00ADB5'), |
|
338 | - 'clLight' => $converter->fromHtml ('#EEEEEE') |
|
335 | + 'clDark' => $converter->fromHtml('#0D0F12'), |
|
336 | + 'clDark2' => $converter->fromHtml('#121416'), |
|
337 | + 'clTurquoise' => $converter->fromHtml('#00ADB5'), |
|
338 | + 'clLight' => $converter->fromHtml('#EEEEEE') |
|
339 | 339 | ]; |
340 | 340 | |
341 | 341 | foreach ($constants as $name => $value) |
342 | - define ($name, $value); |
|
342 | + define($name, $value); |
|
343 | 343 | |
344 | 344 | $argv = START_PARAMS; |
345 | -$argc = sizeof ($argv); |
|
345 | +$argc = sizeof($argv); |
|
346 | 346 | |
347 | -\VoidCore::removeObjects ($converter->selector); |
|
347 | +\VoidCore::removeObjects($converter->selector); |
|
348 | 348 | unset ($constants, $env, $params, $converter); |
@@ -2,50 +2,50 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -register_superglobals ('APPLICATION', 'SCREEN'); |
|
5 | +register_superglobals('APPLICATION', 'SCREEN'); |
|
6 | 6 | |
7 | 7 | $APPLICATION = new class |
8 | 8 | { |
9 | 9 | public WFClass $application; |
10 | 10 | public string $executablePath; |
11 | 11 | |
12 | - public function __construct () |
|
12 | + public function __construct() |
|
13 | 13 | { |
14 | - $this->application = new WFClass ('System.Windows.Forms.Application'); |
|
14 | + $this->application = new WFClass('System.Windows.Forms.Application'); |
|
15 | 15 | $this->executablePath = $this->application->executablePath; |
16 | 16 | } |
17 | 17 | |
18 | - public function run ($form = null): void |
|
18 | + public function run($form = null): void |
|
19 | 19 | { |
20 | 20 | if ($form instanceof WFObject) |
21 | - $this->application->run ($form->selector); |
|
21 | + $this->application->run($form->selector); |
|
22 | 22 | |
23 | - elseif (is_int ($form) && \VoidCore::objectExists ($form)) |
|
24 | - $this->application->run ($form); |
|
23 | + elseif (is_int($form) && \VoidCore::objectExists($form)) |
|
24 | + $this->application->run($form); |
|
25 | 25 | |
26 | 26 | elseif ($form === null) |
27 | - $this->application->run (); |
|
27 | + $this->application->run(); |
|
28 | 28 | |
29 | - else throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
29 | + else throw new \Exception('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
30 | 30 | } |
31 | 31 | |
32 | - public function restart (): void |
|
32 | + public function restart(): void |
|
33 | 33 | { |
34 | - $this->application->restart (); |
|
35 | - $this->close (); |
|
34 | + $this->application->restart(); |
|
35 | + $this->close(); |
|
36 | 36 | } |
37 | 37 | |
38 | - public function close (): void |
|
38 | + public function close(): void |
|
39 | 39 | { |
40 | - $this->application->exit (); |
|
40 | + $this->application->exit(); |
|
41 | 41 | } |
42 | 42 | |
43 | - public function __call (string $name, array $args) |
|
43 | + public function __call(string $name, array $args) |
|
44 | 44 | { |
45 | - return $this->application->$name (...$args); |
|
45 | + return $this->application->$name(...$args); |
|
46 | 46 | } |
47 | 47 | |
48 | - public function __get (string $name) |
|
48 | + public function __get(string $name) |
|
49 | 49 | { |
50 | 50 | return $this->application->$name; |
51 | 51 | } |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | { |
56 | 56 | public WFObject $screen; |
57 | 57 | |
58 | - public function __construct () |
|
58 | + public function __construct() |
|
59 | 59 | { |
60 | - $this->screen = new WFClass ('System.Windows.Forms.Screen'); |
|
60 | + $this->screen = new WFClass('System.Windows.Forms.Screen'); |
|
61 | 61 | } |
62 | 62 | |
63 | - public function __get ($name) |
|
63 | + public function __get($name) |
|
64 | 64 | { |
65 | - switch (strtolower ($name)) |
|
65 | + switch (strtolower($name)) |
|
66 | 66 | { |
67 | 67 | case 'width': |
68 | 68 | case 'w': |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - public function __debugInfo (): array |
|
83 | + public function __debugInfo(): array |
|
84 | 84 | { |
85 | 85 | return [ |
86 | 86 | $this->w, |
@@ -17,16 +17,15 @@ |
||
17 | 17 | |
18 | 18 | public function run ($form = null): void |
19 | 19 | { |
20 | - if ($form instanceof WFObject) |
|
21 | - $this->application->run ($form->selector); |
|
22 | - |
|
23 | - elseif (is_int ($form) && \VoidCore::objectExists ($form)) |
|
24 | - $this->application->run ($form); |
|
25 | - |
|
26 | - elseif ($form === null) |
|
27 | - $this->application->run (); |
|
28 | - |
|
29 | - else throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
20 | + if ($form instanceof WFObject) { |
|
21 | + $this->application->run ($form->selector); |
|
22 | + } elseif (is_int ($form) && \VoidCore::objectExists ($form)) { |
|
23 | + $this->application->run ($form); |
|
24 | + } elseif ($form === null) { |
|
25 | + $this->application->run (); |
|
26 | + } else { |
|
27 | + throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
28 | + } |
|
30 | 29 | } |
31 | 30 | |
32 | 31 | public function restart (): void |
@@ -4,28 +4,28 @@ |
||
4 | 4 | |
5 | 5 | class Process extends Component |
6 | 6 | { |
7 | - public $class = 'System.Diagnostics.Process'; |
|
8 | - public $namespace = 'System'; |
|
7 | + public $class = 'System.Diagnostics.Process'; |
|
8 | + public $namespace = 'System'; |
|
9 | 9 | |
10 | - public function __construct (int $pid = null) |
|
11 | - { |
|
10 | + public function __construct (int $pid = null) |
|
11 | + { |
|
12 | 12 | $this->selector = \VoidCore::getClass ($this->class, $this->namespace); |
13 | 13 | |
14 | - if ($pid !== null) |
|
14 | + if ($pid !== null) |
|
15 | 15 | $this->selector = $pid == getmypid () ? |
16 | 16 | \VoidCore::callMethod ($this->selector, 'GetCurrentProcess') : |
17 | 17 | \VoidCore::callMethod ($this->selector, 'GetProcessById', $pid); |
18 | 18 | |
19 | - Components::addComponent ($this->selector, $this); |
|
20 | - } |
|
19 | + Components::addComponent ($this->selector, $this); |
|
20 | + } |
|
21 | 21 | |
22 | - public static function getProcessById (int $pid) |
|
23 | - { |
|
24 | - return new self ($pid); |
|
25 | - } |
|
22 | + public static function getProcessById (int $pid) |
|
23 | + { |
|
24 | + return new self ($pid); |
|
25 | + } |
|
26 | 26 | |
27 | - public static function getCurrentProcess () |
|
28 | - { |
|
29 | - return new self (getmypid ()); |
|
30 | - } |
|
27 | + public static function getCurrentProcess () |
|
28 | + { |
|
29 | + return new self (getmypid ()); |
|
30 | + } |
|
31 | 31 | } |
@@ -4,28 +4,27 @@ |
||
4 | 4 | |
5 | 5 | class Process extends Component |
6 | 6 | { |
7 | - public $class = 'System.Diagnostics.Process'; |
|
7 | + public $class = 'System.Diagnostics.Process'; |
|
8 | 8 | public $namespace = 'System'; |
9 | 9 | |
10 | - public function __construct (int $pid = null) |
|
10 | + public function __construct(int $pid = null) |
|
11 | 11 | { |
12 | - $this->selector = \VoidCore::getClass ($this->class, $this->namespace); |
|
12 | + $this->selector = \VoidCore::getClass($this->class, $this->namespace); |
|
13 | 13 | |
14 | 14 | if ($pid !== null) |
15 | - $this->selector = $pid == getmypid () ? |
|
16 | - \VoidCore::callMethod ($this->selector, 'GetCurrentProcess') : |
|
17 | - \VoidCore::callMethod ($this->selector, 'GetProcessById', $pid); |
|
15 | + $this->selector = $pid == getmypid() ? |
|
16 | + \VoidCore::callMethod($this->selector, 'GetCurrentProcess') : \VoidCore::callMethod($this->selector, 'GetProcessById', $pid); |
|
18 | 17 | |
19 | - Components::addComponent ($this->selector, $this); |
|
18 | + Components::addComponent($this->selector, $this); |
|
20 | 19 | } |
21 | 20 | |
22 | - public static function getProcessById (int $pid) |
|
21 | + public static function getProcessById(int $pid) |
|
23 | 22 | { |
24 | - return new self ($pid); |
|
23 | + return new self($pid); |
|
25 | 24 | } |
26 | 25 | |
27 | - public static function getCurrentProcess () |
|
26 | + public static function getCurrentProcess() |
|
28 | 27 | { |
29 | - return new self (getmypid ()); |
|
28 | + return new self(getmypid()); |
|
30 | 29 | } |
31 | 30 | } |
@@ -11,10 +11,11 @@ |
||
11 | 11 | { |
12 | 12 | $this->selector = \VoidCore::getClass ($this->class, $this->namespace); |
13 | 13 | |
14 | - if ($pid !== null) |
|
15 | - $this->selector = $pid == getmypid () ? |
|
14 | + if ($pid !== null) { |
|
15 | + $this->selector = $pid == getmypid () ? |
|
16 | 16 | \VoidCore::callMethod ($this->selector, 'GetCurrentProcess') : |
17 | 17 | \VoidCore::callMethod ($this->selector, 'GetProcessById', $pid); |
18 | + } |
|
18 | 19 | |
19 | 20 | Components::addComponent ($this->selector, $this); |
20 | 21 | } |
@@ -31,14 +31,14 @@ |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | public function applyToObject (int $selector): void |
34 | - { |
|
35 | - \VoidCore::setProperty ($selector, 'Icon', $this->selector); |
|
36 | - } |
|
34 | + { |
|
35 | + \VoidCore::setProperty ($selector, 'Icon', $this->selector); |
|
36 | + } |
|
37 | 37 | |
38 | - public function saveToFile (string $file): void |
|
39 | - { |
|
40 | - \VoidCore::callMethod ($this->selector, 'Save', $file); |
|
41 | - } |
|
38 | + public function saveToFile (string $file): void |
|
39 | + { |
|
40 | + \VoidCore::callMethod ($this->selector, 'Save', $file); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | class Bitmap extends WFObject |
@@ -7,14 +7,14 @@ discard block |
||
7 | 7 | public $class = 'System.Drawing.Image'; |
8 | 8 | public $namespace = 'System.Drawing'; |
9 | 9 | |
10 | - public function __construct () |
|
10 | + public function __construct() |
|
11 | 11 | { |
12 | - parent::__construct ($this->class); |
|
12 | + parent::__construct($this->class); |
|
13 | 13 | } |
14 | 14 | |
15 | - public function loadFromFile (string $path) |
|
15 | + public function loadFromFile(string $path) |
|
16 | 16 | { |
17 | - return $this->fromFile ($path); |
|
17 | + return $this->fromFile($path); |
|
18 | 18 | } |
19 | 19 | } |
20 | 20 | |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | public $class = 'System.Drawing.Icon'; |
24 | 24 | public $namespace = 'System.Drawing'; |
25 | 25 | |
26 | - public function __construct (string $file) |
|
26 | + public function __construct(string $file) |
|
27 | 27 | { |
28 | - parent::__construct ($this->class); |
|
28 | + parent::__construct($this->class); |
|
29 | 29 | |
30 | - $this->fromFile ($file); |
|
30 | + $this->fromFile($file); |
|
31 | 31 | } |
32 | 32 | |
33 | - public function applyToObject (int $selector): void |
|
33 | + public function applyToObject(int $selector): void |
|
34 | 34 | { |
35 | - \VoidCore::setProperty ($selector, 'Icon', $this->selector); |
|
35 | + \VoidCore::setProperty($selector, 'Icon', $this->selector); |
|
36 | 36 | } |
37 | 37 | |
38 | - public function saveToFile (string $file): void |
|
38 | + public function saveToFile(string $file): void |
|
39 | 39 | { |
40 | - \VoidCore::callMethod ($this->selector, 'Save', $file); |
|
40 | + \VoidCore::callMethod($this->selector, 'Save', $file); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | public $class = 'System.Drawing.Bitmap'; |
47 | 47 | public $namespace = 'System.Drawing'; |
48 | 48 | |
49 | - public function __construct (string $filename) |
|
49 | + public function __construct(string $filename) |
|
50 | 50 | { |
51 | - parent::__construct ($this->class, $this->namespace, [$filename, 'string']); |
|
51 | + parent::__construct($this->class, $this->namespace, [$filename, 'string']); |
|
52 | 52 | } |
53 | 53 | } |
@@ -4,37 +4,37 @@ discard block |
||
4 | 4 | |
5 | 5 | class Form extends Control |
6 | 6 | { |
7 | - public $class = 'System.Windows.Forms.Form'; |
|
7 | + public $class = 'System.Windows.Forms.Form'; |
|
8 | 8 | |
9 | - public function get_icon () |
|
10 | - { |
|
11 | - return new FormIcon ($this->selector); |
|
12 | - } |
|
9 | + public function get_icon () |
|
10 | + { |
|
11 | + return new FormIcon ($this->selector); |
|
12 | + } |
|
13 | 13 | |
14 | - public function get_clientSize () |
|
15 | - { |
|
16 | - $size = $this->getProperty ('ClientSize'); |
|
14 | + public function get_clientSize () |
|
15 | + { |
|
16 | + $size = $this->getProperty ('ClientSize'); |
|
17 | 17 | |
18 | - return [ |
|
19 | - \VoidCore::getProperty ($size, 'Width'), |
|
20 | - \VoidCore::getProperty ($size, 'Height') |
|
21 | - ]; |
|
22 | - } |
|
18 | + return [ |
|
19 | + \VoidCore::getProperty ($size, 'Width'), |
|
20 | + \VoidCore::getProperty ($size, 'Height') |
|
21 | + ]; |
|
22 | + } |
|
23 | 23 | |
24 | - public function set_clientSize ($size) |
|
25 | - { |
|
26 | - if (is_array ($size)) |
|
27 | - { |
|
28 | - $clientSize = $this->getProperty ('ClientSize'); |
|
24 | + public function set_clientSize ($size) |
|
25 | + { |
|
26 | + if (is_array ($size)) |
|
27 | + { |
|
28 | + $clientSize = $this->getProperty ('ClientSize'); |
|
29 | 29 | |
30 | - \VoidCore::setProperty ($clientSize, 'Width', array_shift ($size)); |
|
31 | - \VoidCore::setProperty ($clientSize, 'Height', array_shift ($size)); |
|
30 | + \VoidCore::setProperty ($clientSize, 'Width', array_shift ($size)); |
|
31 | + \VoidCore::setProperty ($clientSize, 'Height', array_shift ($size)); |
|
32 | 32 | |
33 | - $this->setProperty ('ClientSize', $clientSize); |
|
34 | - } |
|
33 | + $this->setProperty ('ClientSize', $clientSize); |
|
34 | + } |
|
35 | 35 | |
36 | - else $this->setProperty ('ClientSize', EngineAdditions::uncoupleSelector ($size)); |
|
37 | - } |
|
36 | + else $this->setProperty ('ClientSize', EngineAdditions::uncoupleSelector ($size)); |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | class FormIcon extends Icon |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | public function loadFromFile (string $file) |
50 | - { |
|
50 | + { |
|
51 | 51 | $icon = \VoidCore::createObject ('System.Drawing.Icon', 'System.Drawing', $file); |
52 | 52 | |
53 | 53 | \VoidCore::setProperty ($this->formSelector, 'Icon', $icon); |
54 | 54 | |
55 | - if (!isset ($this->selector)) |
|
56 | - $this->selector = $icon; |
|
57 | - } |
|
55 | + if (!isset ($this->selector)) |
|
56 | + $this->selector = $icon; |
|
57 | + } |
|
58 | 58 | } |
@@ -6,34 +6,34 @@ discard block |
||
6 | 6 | { |
7 | 7 | public $class = 'System.Windows.Forms.Form'; |
8 | 8 | |
9 | - public function get_icon () |
|
9 | + public function get_icon() |
|
10 | 10 | { |
11 | - return new FormIcon ($this->selector); |
|
11 | + return new FormIcon($this->selector); |
|
12 | 12 | } |
13 | 13 | |
14 | - public function get_clientSize () |
|
14 | + public function get_clientSize() |
|
15 | 15 | { |
16 | - $size = $this->getProperty ('ClientSize'); |
|
16 | + $size = $this->getProperty('ClientSize'); |
|
17 | 17 | |
18 | 18 | return [ |
19 | - \VoidCore::getProperty ($size, 'Width'), |
|
20 | - \VoidCore::getProperty ($size, 'Height') |
|
19 | + \VoidCore::getProperty($size, 'Width'), |
|
20 | + \VoidCore::getProperty($size, 'Height') |
|
21 | 21 | ]; |
22 | 22 | } |
23 | 23 | |
24 | - public function set_clientSize ($size) |
|
24 | + public function set_clientSize($size) |
|
25 | 25 | { |
26 | - if (is_array ($size)) |
|
26 | + if (is_array($size)) |
|
27 | 27 | { |
28 | - $clientSize = $this->getProperty ('ClientSize'); |
|
28 | + $clientSize = $this->getProperty('ClientSize'); |
|
29 | 29 | |
30 | - \VoidCore::setProperty ($clientSize, 'Width', array_shift ($size)); |
|
31 | - \VoidCore::setProperty ($clientSize, 'Height', array_shift ($size)); |
|
30 | + \VoidCore::setProperty($clientSize, 'Width', array_shift($size)); |
|
31 | + \VoidCore::setProperty($clientSize, 'Height', array_shift($size)); |
|
32 | 32 | |
33 | - $this->setProperty ('ClientSize', $clientSize); |
|
33 | + $this->setProperty('ClientSize', $clientSize); |
|
34 | 34 | } |
35 | 35 | |
36 | - else $this->setProperty ('ClientSize', EngineAdditions::uncoupleSelector ($size)); |
|
36 | + else $this->setProperty('ClientSize', EngineAdditions::uncoupleSelector($size)); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | { |
42 | 42 | protected $formSelector; |
43 | 43 | |
44 | - public function __construct (int $formSelector) |
|
44 | + public function __construct(int $formSelector) |
|
45 | 45 | { |
46 | 46 | $this->formSelector = $formSelector; |
47 | 47 | } |
48 | 48 | |
49 | - public function loadFromFile (string $file) |
|
49 | + public function loadFromFile(string $file) |
|
50 | 50 | { |
51 | - $icon = \VoidCore::createObject ('System.Drawing.Icon', 'System.Drawing', $file); |
|
51 | + $icon = \VoidCore::createObject('System.Drawing.Icon', 'System.Drawing', $file); |
|
52 | 52 | |
53 | - \VoidCore::setProperty ($this->formSelector, 'Icon', $icon); |
|
53 | + \VoidCore::setProperty($this->formSelector, 'Icon', $icon); |
|
54 | 54 | |
55 | 55 | if (!isset ($this->selector)) |
56 | 56 | $this->selector = $icon; |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | \VoidCore::setProperty ($clientSize, 'Height', array_shift ($size)); |
32 | 32 | |
33 | 33 | $this->setProperty ('ClientSize', $clientSize); |
34 | + } else { |
|
35 | + $this->setProperty ('ClientSize', EngineAdditions::uncoupleSelector ($size)); |
|
34 | 36 | } |
35 | - |
|
36 | - else $this->setProperty ('ClientSize', EngineAdditions::uncoupleSelector ($size)); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -52,7 +52,8 @@ discard block |
||
52 | 52 | |
53 | 53 | \VoidCore::setProperty ($this->formSelector, 'Icon', $icon); |
54 | 54 | |
55 | - if (!isset ($this->selector)) |
|
56 | - $this->selector = $icon; |
|
55 | + if (!isset ($this->selector)) { |
|
56 | + $this->selector = $icon; |
|
57 | + } |
|
57 | 58 | } |
58 | 59 | } |
@@ -6,18 +6,18 @@ |
||
6 | 6 | { |
7 | 7 | public $class = 'System.Windows.Forms.ColorDialog'; |
8 | 8 | |
9 | - public function __construct () |
|
9 | + public function __construct() |
|
10 | 10 | { |
11 | - parent::__construct ($this->class); |
|
11 | + parent::__construct($this->class); |
|
12 | 12 | } |
13 | 13 | |
14 | - public function get_color () |
|
14 | + public function get_color() |
|
15 | 15 | { |
16 | - return $this->getProperty (['Color', 'color']); |
|
16 | + return $this->getProperty(['Color', 'color']); |
|
17 | 17 | } |
18 | 18 | |
19 | - public function set_color (int $color) |
|
19 | + public function set_color(int $color) |
|
20 | 20 | { |
21 | - $this->setProperty ('Color', $color); |
|
21 | + $this->setProperty('Color', $color); |
|
22 | 22 | } |
23 | 23 | } |