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