@@ -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 = \VoidCore::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 = \VoidCore::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 | \VoidCore::setProperty ($this->pictureBoxSelector, 'Image', (new Image ())->loadFromFile ($file)->selector); |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function saveToFile (string $file) |
|
| 38 | - { |
|
| 39 | - \VoidCore::callMethod ($this->selector, 'Save', $file); |
|
| 40 | - } |
|
| 37 | + public function saveToFile (string $file) |
|
| 38 | + { |
|
| 39 | + \VoidCore::callMethod ($this->selector, 'Save', $file); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function loadFromClipboard () |
|
| 43 | - { |
|
| 44 | - \VoidCore::setProperty ($this->pictureBoxSelector, 'Image', $this->clipboard->getImage ()); |
|
| 45 | - } |
|
| 42 | + public function loadFromClipboard () |
|
| 43 | + { |
|
| 44 | + \VoidCore::setProperty ($this->pictureBoxSelector, 'Image', $this->clipboard->getImage ()); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public function saveToClipboard () |
|
| 48 | - { |
|
| 49 | - $this->clipboard->setImage (\VoidCore::getProperty ($this->pictureBoxSelector, 'Image')); |
|
| 50 | - } |
|
| 47 | + public function saveToClipboard () |
|
| 48 | + { |
|
| 49 | + $this->clipboard->setImage (\VoidCore::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 = \VoidCore::getProperty ($pictureBoxSelector, 'Image'); |
|
| 29 | - $this->clipboard = new WFClass ('System.Windows.Forms.Clipboard'); |
|
| 28 | + $this->selector = \VoidCore::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 | - \VoidCore::setProperty ($this->pictureBoxSelector, 'Image', (new Image ())->loadFromFile ($file)->selector); |
|
| 34 | + \VoidCore::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 | - \VoidCore::callMethod ($this->selector, 'Save', $file); |
|
| 39 | + \VoidCore::callMethod($this->selector, 'Save', $file); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function loadFromClipboard () |
|
| 42 | + public function loadFromClipboard() |
|
| 43 | 43 | { |
| 44 | - \VoidCore::setProperty ($this->pictureBoxSelector, 'Image', $this->clipboard->getImage ()); |
|
| 44 | + \VoidCore::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 (\VoidCore::getProperty ($this->pictureBoxSelector, 'Image')); |
|
| 49 | + $this->clipboard->setImage(\VoidCore::getProperty($this->pictureBoxSelector, 'Image')); |
|
| 50 | 50 | } |
| 51 | 51 | } |
@@ -4,37 +4,37 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Form extends Control |
| 6 | 6 | { |
| 7 | - public $class = 'System.Windows.Forms.Form'; |
|
| 7 | + public $class = 'System.Windows.Forms.Form'; |
|
| 8 | 8 | |
| 9 | - public function get_icon () |
|
| 10 | - { |
|
| 11 | - return new FormIcon ($this->selector); |
|
| 12 | - } |
|
| 9 | + public function get_icon () |
|
| 10 | + { |
|
| 11 | + return new FormIcon ($this->selector); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - public function get_clientSize () |
|
| 15 | - { |
|
| 16 | - $size = $this->getProperty ('ClientSize'); |
|
| 14 | + public function get_clientSize () |
|
| 15 | + { |
|
| 16 | + $size = $this->getProperty ('ClientSize'); |
|
| 17 | 17 | |
| 18 | - return [ |
|
| 19 | - \VoidCore::getProperty ($size, 'Width'), |
|
| 20 | - \VoidCore::getProperty ($size, 'Height') |
|
| 21 | - ]; |
|
| 22 | - } |
|
| 18 | + return [ |
|
| 19 | + \VoidCore::getProperty ($size, 'Width'), |
|
| 20 | + \VoidCore::getProperty ($size, 'Height') |
|
| 21 | + ]; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function set_clientSize ($size) |
|
| 25 | - { |
|
| 26 | - if (is_array ($size)) |
|
| 27 | - { |
|
| 28 | - $clientSize = $this->getProperty ('ClientSize'); |
|
| 24 | + public function set_clientSize ($size) |
|
| 25 | + { |
|
| 26 | + if (is_array ($size)) |
|
| 27 | + { |
|
| 28 | + $clientSize = $this->getProperty ('ClientSize'); |
|
| 29 | 29 | |
| 30 | - \VoidCore::setProperty ($clientSize, 'Width', array_shift ($size)); |
|
| 31 | - \VoidCore::setProperty ($clientSize, 'Height', array_shift ($size)); |
|
| 30 | + \VoidCore::setProperty ($clientSize, 'Width', array_shift ($size)); |
|
| 31 | + \VoidCore::setProperty ($clientSize, 'Height', array_shift ($size)); |
|
| 32 | 32 | |
| 33 | - $this->setProperty ('ClientSize', $clientSize); |
|
| 34 | - } |
|
| 33 | + $this->setProperty ('ClientSize', $clientSize); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - else $this->setProperty ('ClientSize', EngineAdditions::uncoupleSelector ($size)); |
|
| 37 | - } |
|
| 36 | + else $this->setProperty ('ClientSize', EngineAdditions::uncoupleSelector ($size)); |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | class FormIcon extends Icon |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function loadFromFile (string $file) |
| 50 | - { |
|
| 50 | + { |
|
| 51 | 51 | $icon = \VoidCore::createObject ('System.Drawing.Icon', 'System.Drawing', $file); |
| 52 | 52 | |
| 53 | 53 | \VoidCore::setProperty ($this->formSelector, 'Icon', $icon); |
| 54 | 54 | |
| 55 | - if (!isset ($this->selector)) |
|
| 56 | - $this->selector = $icon; |
|
| 57 | - } |
|
| 55 | + if (!isset ($this->selector)) |
|
| 56 | + $this->selector = $icon; |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -6,34 +6,34 @@ discard block |
||
| 6 | 6 | { |
| 7 | 7 | public $class = 'System.Windows.Forms.Form'; |
| 8 | 8 | |
| 9 | - public function get_icon () |
|
| 9 | + public function get_icon() |
|
| 10 | 10 | { |
| 11 | - return new FormIcon ($this->selector); |
|
| 11 | + return new FormIcon($this->selector); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public function get_clientSize () |
|
| 14 | + public function get_clientSize() |
|
| 15 | 15 | { |
| 16 | - $size = $this->getProperty ('ClientSize'); |
|
| 16 | + $size = $this->getProperty('ClientSize'); |
|
| 17 | 17 | |
| 18 | 18 | return [ |
| 19 | - \VoidCore::getProperty ($size, 'Width'), |
|
| 20 | - \VoidCore::getProperty ($size, 'Height') |
|
| 19 | + \VoidCore::getProperty($size, 'Width'), |
|
| 20 | + \VoidCore::getProperty($size, 'Height') |
|
| 21 | 21 | ]; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function set_clientSize ($size) |
|
| 24 | + public function set_clientSize($size) |
|
| 25 | 25 | { |
| 26 | - if (is_array ($size)) |
|
| 26 | + if (is_array($size)) |
|
| 27 | 27 | { |
| 28 | - $clientSize = $this->getProperty ('ClientSize'); |
|
| 28 | + $clientSize = $this->getProperty('ClientSize'); |
|
| 29 | 29 | |
| 30 | - \VoidCore::setProperty ($clientSize, 'Width', array_shift ($size)); |
|
| 31 | - \VoidCore::setProperty ($clientSize, 'Height', array_shift ($size)); |
|
| 30 | + \VoidCore::setProperty($clientSize, 'Width', array_shift($size)); |
|
| 31 | + \VoidCore::setProperty($clientSize, 'Height', array_shift($size)); |
|
| 32 | 32 | |
| 33 | - $this->setProperty ('ClientSize', $clientSize); |
|
| 33 | + $this->setProperty('ClientSize', $clientSize); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - else $this->setProperty ('ClientSize', EngineAdditions::uncoupleSelector ($size)); |
|
| 36 | + else $this->setProperty('ClientSize', EngineAdditions::uncoupleSelector($size)); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -41,16 +41,16 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | protected $formSelector; |
| 43 | 43 | |
| 44 | - public function __construct (int $formSelector) |
|
| 44 | + public function __construct(int $formSelector) |
|
| 45 | 45 | { |
| 46 | 46 | $this->formSelector = $formSelector; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function loadFromFile (string $file) |
|
| 49 | + public function loadFromFile(string $file) |
|
| 50 | 50 | { |
| 51 | - $icon = \VoidCore::createObject ('System.Drawing.Icon', 'System.Drawing', $file); |
|
| 51 | + $icon = \VoidCore::createObject('System.Drawing.Icon', 'System.Drawing', $file); |
|
| 52 | 52 | |
| 53 | - \VoidCore::setProperty ($this->formSelector, 'Icon', $icon); |
|
| 53 | + \VoidCore::setProperty($this->formSelector, 'Icon', $icon); |
|
| 54 | 54 | |
| 55 | 55 | if (!isset ($this->selector)) |
| 56 | 56 | $this->selector = $icon; |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | \VoidCore::setProperty ($clientSize, 'Height', array_shift ($size)); |
| 32 | 32 | |
| 33 | 33 | $this->setProperty ('ClientSize', $clientSize); |
| 34 | + } else { |
|
| 35 | + $this->setProperty ('ClientSize', EngineAdditions::uncoupleSelector ($size)); |
|
| 34 | 36 | } |
| 35 | - |
|
| 36 | - else $this->setProperty ('ClientSize', EngineAdditions::uncoupleSelector ($size)); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -52,7 +52,8 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | \VoidCore::setProperty ($this->formSelector, 'Icon', $icon); |
| 54 | 54 | |
| 55 | - if (!isset ($this->selector)) |
|
| 56 | - $this->selector = $icon; |
|
| 55 | + if (!isset ($this->selector)) { |
|
| 56 | + $this->selector = $icon; |
|
| 57 | + } |
|
| 57 | 58 | } |
| 58 | 59 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | public function __get ($name) |
| 200 | - { |
|
| 200 | + { |
|
| 201 | 201 | if (method_exists ($this, $method = "get_$name")) |
| 202 | 202 | $value = $this->$method (); |
| 203 | 203 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $size = $this->count; |
| 227 | 227 | $list = []; |
| 228 | 228 | |
| 229 | - for ($i = 0; $i < $size; ++$i) |
|
| 229 | + for ($i = 0; $i < $size; ++$i) |
|
| 230 | 230 | $list[] = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $i)); |
| 231 | 231 | |
| 232 | 232 | return $list; |
@@ -256,10 +256,10 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | return EngineAdditions::coupleSelector ($value, $this->selector); |
| 259 | - } |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - public function __set ($name, $value) |
|
| 262 | - { |
|
| 261 | + public function __set ($name, $value) |
|
| 262 | + { |
|
| 263 | 263 | if (method_exists ($this, $method = "set_$name")) |
| 264 | 264 | try |
| 265 | 265 | { |
@@ -287,8 +287,8 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - public function __call ($method, $args) |
|
| 291 | - { |
|
| 290 | + public function __call ($method, $args) |
|
| 291 | + { |
|
| 292 | 292 | $args = array_map (function ($arg) |
| 293 | 293 | { |
| 294 | 294 | return EngineAdditions::uncoupleSelector ($arg); |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | public function offsetSet ($index, $value) |
| 310 | - { |
|
| 310 | + { |
|
| 311 | 311 | try |
| 312 | 312 | { |
| 313 | 313 | return $index === null ? |
@@ -323,14 +323,14 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - public function offsetGet ($index) |
|
| 327 | - { |
|
| 328 | - return EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $index), $this->selector); |
|
| 326 | + public function offsetGet ($index) |
|
| 327 | + { |
|
| 328 | + return EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $index), $this->selector); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - public function offsetUnset ($index): void |
|
| 332 | - { |
|
| 333 | - $this->callMethod ('RemoveAt', $index); |
|
| 331 | + public function offsetUnset ($index): void |
|
| 332 | + { |
|
| 333 | + $this->callMethod ('RemoveAt', $index); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | public function offsetExists ($index): bool |
@@ -348,19 +348,19 @@ discard block |
||
| 348 | 348 | return true; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - public function indexOf ($value): int |
|
| 352 | - { |
|
| 353 | - return $this->callMethod ('IndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
| 351 | + public function indexOf ($value): int |
|
| 352 | + { |
|
| 353 | + return $this->callMethod ('IndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | public function lastIndexOf ($value): int |
| 357 | - { |
|
| 358 | - return $this->callMethod ('LastIndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
| 359 | - } |
|
| 357 | + { |
|
| 358 | + return $this->callMethod ('LastIndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - public function contains ($value): bool |
|
| 362 | - { |
|
| 363 | - return $this->callMethod ('Contains', EngineAdditions::uncoupleSelector ($value)); |
|
| 361 | + public function contains ($value): bool |
|
| 362 | + { |
|
| 363 | + return $this->callMethod ('Contains', EngineAdditions::uncoupleSelector ($value)); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | public function foreach (callable $callback, string $type = null): void |
@@ -414,45 +414,45 @@ discard block |
||
| 414 | 414 | return \VoidCore::callMethod ($this->selector, $method, ...$args); |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - protected function getArrayProperty ($name, string $type = null) |
|
| 418 | - { |
|
| 417 | + protected function getArrayProperty ($name, string $type = null) |
|
| 418 | + { |
|
| 419 | 419 | $array = $this->getProperty ($name); |
| 420 | 420 | $size = \VoidCore::getProperty ($array, 'Length'); |
| 421 | 421 | $return = []; |
| 422 | 422 | |
| 423 | - for ($i = 0; $i < $size; ++$i) |
|
| 423 | + for ($i = 0; $i < $size; ++$i) |
|
| 424 | 424 | $return[] = \VoidCore::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
| 425 | 425 | |
| 426 | 426 | \VoidCore::removeObjects ($array); |
| 427 | 427 | |
| 428 | - return $return; |
|
| 428 | + return $return; |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | public function get_name () |
| 432 | - { |
|
| 433 | - try |
|
| 434 | - { |
|
| 435 | - return $this->getProperty ('Name'); |
|
| 432 | + { |
|
| 433 | + try |
|
| 434 | + { |
|
| 435 | + return $this->getProperty ('Name'); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - catch (\Throwable $e) |
|
| 439 | - { |
|
| 440 | - return $this->name; |
|
| 441 | - } |
|
| 442 | - } |
|
| 438 | + catch (\Throwable $e) |
|
| 439 | + { |
|
| 440 | + return $this->name; |
|
| 441 | + } |
|
| 442 | + } |
|
| 443 | 443 | |
| 444 | - public function set_name (string $name) |
|
| 445 | - { |
|
| 446 | - try |
|
| 447 | - { |
|
| 448 | - $this->setProperty ('Name', $name); |
|
| 444 | + public function set_name (string $name) |
|
| 445 | + { |
|
| 446 | + try |
|
| 447 | + { |
|
| 448 | + $this->setProperty ('Name', $name); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - catch (\Throwable $e) |
|
| 452 | - { |
|
| 453 | - $this->name = $name; |
|
| 454 | - } |
|
| 455 | - } |
|
| 451 | + catch (\Throwable $e) |
|
| 452 | + { |
|
| 453 | + $this->name = $name; |
|
| 454 | + } |
|
| 455 | + } |
|
| 456 | 456 | |
| 457 | 457 | public function __toString (): string |
| 458 | 458 | { |
@@ -24,20 +24,20 @@ discard block |
||
| 24 | 24 | * @return array - возвращает список ошибок компиляции |
| 25 | 25 | * |
| 26 | 26 | */ |
| 27 | - public static function compile (string $savePath, string $iconPath, string $phpCode, string $productDescription = null, string $productName = null, string $productVersion = null, string $companyName = null, string $copyright = null, string $callSharpCode = '', string $declareSharpCode = '', WFObject $dictionary = null, WFObject $assemblies = null): array |
|
| 27 | + public static function compile(string $savePath, string $iconPath, string $phpCode, string $productDescription = null, string $productName = null, string $productVersion = null, string $companyName = null, string $copyright = null, string $callSharpCode = '', string $declareSharpCode = '', WFObject $dictionary = null, WFObject $assemblies = null): array |
|
| 28 | 28 | { |
| 29 | 29 | if ($dictionary === null) |
| 30 | - $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
| 30 | + $dictionary = new WFObject('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
| 31 | 31 | |
| 32 | 32 | if ($assemblies === null) |
| 33 | - $assemblies = getNetArray ('System.String', [ |
|
| 33 | + $assemblies = getNetArray('System.String', [ |
|
| 34 | 34 | // CORE_DIR .'/CefSharp.dll', |
| 35 | - CORE_DIR .'/FastColoredTextBox.dll', |
|
| 36 | - CORE_DIR .'/ScintillaNET.dll' |
|
| 35 | + CORE_DIR.'/FastColoredTextBox.dll', |
|
| 36 | + CORE_DIR.'/ScintillaNET.dll' |
|
| 37 | 37 | ]); |
| 38 | 38 | |
| 39 | 39 | if ($productName === null) |
| 40 | - $productName = basenameNoExt ($savePath); |
|
| 40 | + $productName = basenameNoExt($savePath); |
|
| 41 | 41 | |
| 42 | 42 | if ($productDescription === null) |
| 43 | 43 | $productDescription = $productName; |
@@ -49,16 +49,16 @@ discard block |
||
| 49 | 49 | $companyName = 'Company N'; |
| 50 | 50 | |
| 51 | 51 | if ($copyright === null) |
| 52 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
| 52 | + $copyright = $companyName.' copyright (c) '.date('Y'); |
|
| 53 | 53 | |
| 54 | - return (new WFClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
| 54 | + return (new WFClass('WinForms_PHP.WFCompiler', null))->compile($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public static function loadModule (string $path): bool |
|
| 57 | + public static function loadModule(string $path): bool |
|
| 58 | 58 | { |
| 59 | 59 | try |
| 60 | 60 | { |
| 61 | - (new WFClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
|
| 61 | + (new WFClass('System.Reflection.Assembly', 'mscorlib'))->loadFrom($path); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | catch (\WinFormsException $e) |
@@ -69,16 +69,16 @@ discard block |
||
| 69 | 69 | return true; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public static function getProperty (int $selector, string $name): array |
|
| 72 | + public static function getProperty(int $selector, string $name): array |
|
| 73 | 73 | { |
| 74 | - $property = \VoidCore::callMethod (\VoidCore::callMethod ($selector, 'GetType'), 'GetProperty', $name); |
|
| 74 | + $property = \VoidCore::callMethod(\VoidCore::callMethod($selector, 'GetType'), 'GetProperty', $name); |
|
| 75 | 75 | |
| 76 | - if (!is_int ($property)) |
|
| 76 | + if (!is_int($property)) |
|
| 77 | 77 | return false; |
| 78 | 78 | |
| 79 | 79 | try |
| 80 | 80 | { |
| 81 | - $propertyType = \VoidCore::getProperty ($property, ['PropertyType', 'string']); |
|
| 81 | + $propertyType = \VoidCore::getProperty($property, ['PropertyType', 'string']); |
|
| 82 | 82 | |
| 83 | 83 | switch ($propertyType) |
| 84 | 84 | { |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | default: |
| 115 | 115 | try |
| 116 | 116 | { |
| 117 | - \VoidCore::getProperty ($selector, [$name, 'int']); |
|
| 117 | + \VoidCore::getProperty($selector, [$name, 'int']); |
|
| 118 | 118 | |
| 119 | 119 | $property = 'int'; |
| 120 | 120 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | { |
| 124 | 124 | return [ |
| 125 | 125 | 'type' => 'vrsf', |
| 126 | - 'value' => \VoidCore::exportObject (\VoidCore::getProperty ($selector, [$name, 'object'])) |
|
| 126 | + 'value' => \VoidCore::exportObject(\VoidCore::getProperty($selector, [$name, 'object'])) |
|
| 127 | 127 | ]; |
| 128 | 128 | } |
| 129 | 129 | break; |
@@ -137,19 +137,19 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | return [ |
| 139 | 139 | 'type' => $property, |
| 140 | - 'value' => \VoidCore::getProperty ($selector, [$name, $property]) |
|
| 140 | + 'value' => \VoidCore::getProperty($selector, [$name, $property]) |
|
| 141 | 141 | ]; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public static function getObjectEvents (int $object): array |
|
| 144 | + public static function getObjectEvents(int $object): array |
|
| 145 | 145 | { |
| 146 | 146 | $events = []; |
| 147 | 147 | |
| 148 | - $props = \VoidCore::callMethod (\VoidCore::callMethod ($object, 'GetType'), 'GetEvents'); |
|
| 149 | - $len = \VoidCore::getProperty ($props, 'Length'); |
|
| 148 | + $props = \VoidCore::callMethod(\VoidCore::callMethod($object, 'GetType'), 'GetEvents'); |
|
| 149 | + $len = \VoidCore::getProperty($props, 'Length'); |
|
| 150 | 150 | |
| 151 | 151 | for ($i = 0; $i < $len; ++$i) |
| 152 | - $events[] = \VoidCore::getProperty (\VoidCore::getArrayValue ($props, $i), 'Name'); |
|
| 152 | + $events[] = \VoidCore::getProperty(\VoidCore::getArrayValue($props, $i), 'Name'); |
|
| 153 | 153 | |
| 154 | 154 | return $events; |
| 155 | 155 | } |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | * Тогда получается бесконечный цикл вида object->selector->selector->selector->... |
| 160 | 160 | * Чтобы этого избежать нужно добавить исключение - переменную $selfSelector |
| 161 | 161 | */ |
| 162 | - public static function coupleSelector ($value, int $selfSelector = null) |
|
| 162 | + public static function coupleSelector($value, int $selfSelector = null) |
|
| 163 | 163 | { |
| 164 | - return is_int ($value) && \VoidCore::objectExists ($value) && $value != $selfSelector ? |
|
| 165 | - new WFObject ($value) : $value; |
|
| 164 | + return is_int($value) && \VoidCore::objectExists($value) && $value != $selfSelector ? |
|
| 165 | + new WFObject($value) : $value; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - public static function uncoupleSelector ($value) |
|
| 168 | + public static function uncoupleSelector($value) |
|
| 169 | 169 | { |
| 170 | 170 | return $value instanceof WFObject ? |
| 171 | 171 | $value->selector : $value; |
@@ -177,48 +177,48 @@ discard block |
||
| 177 | 177 | protected int $selector = 0; |
| 178 | 178 | protected $name; |
| 179 | 179 | |
| 180 | - public function __construct ($object, $classGroup = false, ...$args) |
|
| 180 | + public function __construct($object, $classGroup = false, ...$args) |
|
| 181 | 181 | { |
| 182 | 182 | foreach ($args as $id => $arg) |
| 183 | - $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
| 183 | + $args[$id] = EngineAdditions::uncoupleSelector($arg); |
|
| 184 | 184 | |
| 185 | - if (is_string ($object)) |
|
| 185 | + if (is_string($object)) |
|
| 186 | 186 | { |
| 187 | - $this->selector = \VoidCore::createObject ($object, $classGroup, ...$args); |
|
| 187 | + $this->selector = \VoidCore::createObject($object, $classGroup, ...$args); |
|
| 188 | 188 | |
| 189 | 189 | /*$this->selector = \VoidCore::createObject ($object, $classGroup == 'auto' ? |
| 190 | 190 | substr ($object, 0, strrpos ($object, '.')) : $classGroup, ...$args);*/ |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - elseif (is_int ($object) && \VoidCore::objectExists ($object)) |
|
| 193 | + elseif (is_int($object) && \VoidCore::objectExists($object)) |
|
| 194 | 194 | $this->selector = $object; |
| 195 | 195 | |
| 196 | - else throw new \Exception ('$object parameter must be string or object selector'); |
|
| 196 | + else throw new \Exception('$object parameter must be string or object selector'); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - public function __get ($name) |
|
| 199 | + public function __get($name) |
|
| 200 | 200 | { |
| 201 | - if (method_exists ($this, $method = "get_$name")) |
|
| 202 | - $value = $this->$method (); |
|
| 201 | + if (method_exists($this, $method = "get_$name")) |
|
| 202 | + $value = $this->$method(); |
|
| 203 | 203 | |
| 204 | - elseif (substr ($name, -5) == 'Event') |
|
| 205 | - $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
| 204 | + elseif (substr($name, -5) == 'Event') |
|
| 205 | + $value = Events::getObjectEvent($this->selector, substr($name, 0, -5)); |
|
| 206 | 206 | |
| 207 | - elseif (property_exists ($this, $name)) |
|
| 207 | + elseif (property_exists($this, $name)) |
|
| 208 | 208 | $value = $this->$name; |
| 209 | 209 | |
| 210 | - else switch (strtolower ($name)) |
|
| 210 | + else switch (strtolower($name)) |
|
| 211 | 211 | { |
| 212 | 212 | case 'count': |
| 213 | 213 | case 'length': |
| 214 | 214 | try |
| 215 | 215 | { |
| 216 | - return $this->getProperty ('Count'); |
|
| 216 | + return $this->getProperty('Count'); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | catch (\WinFormsException $e) |
| 220 | 220 | { |
| 221 | - return $this->getProperty ('Length'); |
|
| 221 | + return $this->getProperty('Length'); |
|
| 222 | 222 | } |
| 223 | 223 | break; |
| 224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $list = []; |
| 228 | 228 | |
| 229 | 229 | for ($i = 0; $i < $size; ++$i) |
| 230 | - $list[] = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $i)); |
|
| 230 | + $list[] = EngineAdditions::coupleSelector(\VoidCore::getArrayValue($this->selector, $i)); |
|
| 231 | 231 | |
| 232 | 232 | return $list; |
| 233 | 233 | break; |
@@ -239,31 +239,31 @@ discard block |
||
| 239 | 239 | for ($i = 0; $i < $size; ++$i) |
| 240 | 240 | try |
| 241 | 241 | { |
| 242 | - $names[] = \VoidCore::getProperty (\VoidCore::getArrayValue ($this->selector, [$i, 'object']), 'Text'); |
|
| 242 | + $names[] = \VoidCore::getProperty(\VoidCore::getArrayValue($this->selector, [$i, 'object']), 'Text'); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | catch (\WinFormsException $e) |
| 246 | 246 | { |
| 247 | - $names[] = \VoidCore::getArrayValue ($this->selector, [$i, 'string']); |
|
| 247 | + $names[] = \VoidCore::getArrayValue($this->selector, [$i, 'string']); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | return $names; |
| 251 | 251 | break; |
| 252 | 252 | |
| 253 | 253 | default: |
| 254 | - $value = $this->getProperty ($name); |
|
| 254 | + $value = $this->getProperty($name); |
|
| 255 | 255 | break; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - return EngineAdditions::coupleSelector ($value, $this->selector); |
|
| 258 | + return EngineAdditions::coupleSelector($value, $this->selector); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - public function __set ($name, $value) |
|
| 261 | + public function __set($name, $value) |
|
| 262 | 262 | { |
| 263 | - if (method_exists ($this, $method = "set_$name")) |
|
| 263 | + if (method_exists($this, $method = "set_$name")) |
|
| 264 | 264 | try |
| 265 | 265 | { |
| 266 | - return $this->$method ($value); |
|
| 266 | + return $this->$method($value); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | # Метод "set_$name" может принимать в качестве параметра объект WFObject |
@@ -272,72 +272,70 @@ discard block |
||
| 272 | 272 | catch (\Throwable $e) |
| 273 | 273 | { |
| 274 | 274 | return $value instanceof WFObject ? |
| 275 | - $this->$method ($value->selector) : null; |
|
| 275 | + $this->$method($value->selector) : null; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - elseif (substr ($name, -5) == 'Event') |
|
| 279 | - Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
| 278 | + elseif (substr($name, -5) == 'Event') |
|
| 279 | + Events::setObjectEvent($this->selector, substr($name, 0, -5), $value); |
|
| 280 | 280 | |
| 281 | 281 | else |
| 282 | 282 | { |
| 283 | - if (is_array ($value) && is_string (current ($value))) |
|
| 284 | - $value = getNetArray ('System.String', $value); |
|
| 283 | + if (is_array($value) && is_string(current($value))) |
|
| 284 | + $value = getNetArray('System.String', $value); |
|
| 285 | 285 | |
| 286 | - $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
| 286 | + $this->setProperty($name, EngineAdditions::uncoupleSelector($value)); |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - public function __call ($method, $args) |
|
| 290 | + public function __call($method, $args) |
|
| 291 | 291 | { |
| 292 | - $args = array_map (function ($arg) |
|
| 292 | + $args = array_map(function($arg) |
|
| 293 | 293 | { |
| 294 | - return EngineAdditions::uncoupleSelector ($arg); |
|
| 294 | + return EngineAdditions::uncoupleSelector($arg); |
|
| 295 | 295 | }, $args); |
| 296 | 296 | |
| 297 | - return EngineAdditions::coupleSelector ($this->callMethod ($method, ...$args), $this->selector); |
|
| 297 | + return EngineAdditions::coupleSelector($this->callMethod($method, ...$args), $this->selector); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - public function addRange ($values, $assoc = false): void |
|
| 300 | + public function addRange($values, $assoc = false): void |
|
| 301 | 301 | { |
| 302 | - if (is_array ($values)) |
|
| 302 | + if (is_array($values)) |
|
| 303 | 303 | foreach ($values as $id => $value) |
| 304 | - $this->offsetSet ($assoc ? $id : null, $value); |
|
| 304 | + $this->offsetSet($assoc ? $id : null, $value); |
|
| 305 | 305 | |
| 306 | - else $this->callMethod ('AddRange', EngineAdditions::uncoupleSelector ($values)); |
|
| 306 | + else $this->callMethod('AddRange', EngineAdditions::uncoupleSelector($values)); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - public function offsetSet ($index, $value) |
|
| 309 | + public function offsetSet($index, $value) |
|
| 310 | 310 | { |
| 311 | 311 | try |
| 312 | 312 | { |
| 313 | 313 | return $index === null ? |
| 314 | - $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
|
| 315 | - $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
|
| 314 | + $this->callMethod('Add', EngineAdditions::uncoupleSelector($value)) : $this->callMethod('Insert', $index, EngineAdditions::uncoupleSelector($value)); |
|
| 316 | 315 | } |
| 317 | 316 | |
| 318 | 317 | catch (\Throwable $e) |
| 319 | 318 | { |
| 320 | 319 | return $index === null ? |
| 321 | - \VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) : |
|
| 322 | - \VoidCore::setArrayValue ($this->selector, $index, EngineAdditions::uncoupleSelector ($value)); |
|
| 320 | + \VoidCore::setArrayValue($this->selector, $this->count, EngineAdditions::uncoupleSelector($value)) : \VoidCore::setArrayValue($this->selector, $index, EngineAdditions::uncoupleSelector($value)); |
|
| 323 | 321 | } |
| 324 | 322 | } |
| 325 | 323 | |
| 326 | - public function offsetGet ($index) |
|
| 324 | + public function offsetGet($index) |
|
| 327 | 325 | { |
| 328 | - return EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $index), $this->selector); |
|
| 326 | + return EngineAdditions::coupleSelector(\VoidCore::getArrayValue($this->selector, $index), $this->selector); |
|
| 329 | 327 | } |
| 330 | 328 | |
| 331 | - public function offsetUnset ($index): void |
|
| 329 | + public function offsetUnset($index): void |
|
| 332 | 330 | { |
| 333 | - $this->callMethod ('RemoveAt', $index); |
|
| 331 | + $this->callMethod('RemoveAt', $index); |
|
| 334 | 332 | } |
| 335 | 333 | |
| 336 | - public function offsetExists ($index): bool |
|
| 334 | + public function offsetExists($index): bool |
|
| 337 | 335 | { |
| 338 | 336 | try |
| 339 | 337 | { |
| 340 | - $this->offsetGet ($index); |
|
| 338 | + $this->offsetGet($index); |
|
| 341 | 339 | } |
| 342 | 340 | |
| 343 | 341 | catch (\Exception $e) |
@@ -348,19 +346,19 @@ discard block |
||
| 348 | 346 | return true; |
| 349 | 347 | } |
| 350 | 348 | |
| 351 | - public function indexOf ($value): int |
|
| 349 | + public function indexOf($value): int |
|
| 352 | 350 | { |
| 353 | - return $this->callMethod ('IndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
| 351 | + return $this->callMethod('IndexOf', EngineAdditions::uncoupleSelector($value)); |
|
| 354 | 352 | } |
| 355 | 353 | |
| 356 | - public function lastIndexOf ($value): int |
|
| 354 | + public function lastIndexOf($value): int |
|
| 357 | 355 | { |
| 358 | - return $this->callMethod ('LastIndexOf', EngineAdditions::uncoupleSelector ($value)); |
|
| 356 | + return $this->callMethod('LastIndexOf', EngineAdditions::uncoupleSelector($value)); |
|
| 359 | 357 | } |
| 360 | 358 | |
| 361 | - public function contains ($value): bool |
|
| 359 | + public function contains($value): bool |
|
| 362 | 360 | { |
| 363 | - return $this->callMethod ('Contains', EngineAdditions::uncoupleSelector ($value)); |
|
| 361 | + return $this->callMethod('Contains', EngineAdditions::uncoupleSelector($value)); |
|
| 364 | 362 | } |
| 365 | 363 | |
| 366 | 364 | public function foreach (callable $callback, string $type = null): void |
@@ -368,71 +366,71 @@ discard block |
||
| 368 | 366 | $size = $this->count; |
| 369 | 367 | |
| 370 | 368 | for ($i = 0; $i < $size; ++$i) |
| 371 | - $callback (EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
| 369 | + $callback(EngineAdditions::coupleSelector(\VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
| 372 | 370 | } |
| 373 | 371 | |
| 374 | - public function where (callable $comparator, string $type = null): array |
|
| 372 | + public function where(callable $comparator, string $type = null): array |
|
| 375 | 373 | { |
| 376 | 374 | $size = $this->count; |
| 377 | 375 | $return = []; |
| 378 | 376 | |
| 379 | 377 | for ($i = 0; $i < $size; ++$i) |
| 380 | - if ($comparator ($value = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
| 378 | + if ($comparator($value = EngineAdditions::coupleSelector(\VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
| 381 | 379 | $return[] = $value; |
| 382 | 380 | |
| 383 | 381 | return $return; |
| 384 | 382 | } |
| 385 | 383 | |
| 386 | - protected function getProperty ($name) |
|
| 384 | + protected function getProperty($name) |
|
| 387 | 385 | { |
| 388 | 386 | try |
| 389 | 387 | { |
| 390 | - return \VoidCore::getProperty ($this->selector, $name); |
|
| 388 | + return \VoidCore::getProperty($this->selector, $name); |
|
| 391 | 389 | } |
| 392 | 390 | |
| 393 | 391 | catch (\WinFormsException $e) |
| 394 | 392 | { |
| 395 | - return \VoidCore::getField ($this->selector, $name); |
|
| 393 | + return \VoidCore::getField($this->selector, $name); |
|
| 396 | 394 | } |
| 397 | 395 | } |
| 398 | 396 | |
| 399 | - protected function setProperty ($name, $value) |
|
| 397 | + protected function setProperty($name, $value) |
|
| 400 | 398 | { |
| 401 | 399 | try |
| 402 | 400 | { |
| 403 | - \VoidCore::setProperty ($this->selector, $name, $value); |
|
| 401 | + \VoidCore::setProperty($this->selector, $name, $value); |
|
| 404 | 402 | } |
| 405 | 403 | |
| 406 | 404 | catch (\WinFormsException $e) |
| 407 | 405 | { |
| 408 | - \VoidCore::setField ($this->selector, $name, $value); |
|
| 406 | + \VoidCore::setField($this->selector, $name, $value); |
|
| 409 | 407 | } |
| 410 | 408 | } |
| 411 | 409 | |
| 412 | - protected function callMethod ($method, ...$args) |
|
| 410 | + protected function callMethod($method, ...$args) |
|
| 413 | 411 | { |
| 414 | - return \VoidCore::callMethod ($this->selector, $method, ...$args); |
|
| 412 | + return \VoidCore::callMethod($this->selector, $method, ...$args); |
|
| 415 | 413 | } |
| 416 | 414 | |
| 417 | - protected function getArrayProperty ($name, string $type = null) |
|
| 415 | + protected function getArrayProperty($name, string $type = null) |
|
| 418 | 416 | { |
| 419 | - $array = $this->getProperty ($name); |
|
| 420 | - $size = \VoidCore::getProperty ($array, 'Length'); |
|
| 417 | + $array = $this->getProperty($name); |
|
| 418 | + $size = \VoidCore::getProperty($array, 'Length'); |
|
| 421 | 419 | $return = []; |
| 422 | 420 | |
| 423 | 421 | for ($i = 0; $i < $size; ++$i) |
| 424 | - $return[] = \VoidCore::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
| 422 | + $return[] = \VoidCore::getArrayValue($array, $type === null ? $i : [$i, $type]); |
|
| 425 | 423 | |
| 426 | - \VoidCore::removeObjects ($array); |
|
| 424 | + \VoidCore::removeObjects($array); |
|
| 427 | 425 | |
| 428 | 426 | return $return; |
| 429 | 427 | } |
| 430 | 428 | |
| 431 | - public function get_name () |
|
| 429 | + public function get_name() |
|
| 432 | 430 | { |
| 433 | 431 | try |
| 434 | 432 | { |
| 435 | - return $this->getProperty ('Name'); |
|
| 433 | + return $this->getProperty('Name'); |
|
| 436 | 434 | } |
| 437 | 435 | |
| 438 | 436 | catch (\Throwable $e) |
@@ -441,11 +439,11 @@ discard block |
||
| 441 | 439 | } |
| 442 | 440 | } |
| 443 | 441 | |
| 444 | - public function set_name (string $name) |
|
| 442 | + public function set_name(string $name) |
|
| 445 | 443 | { |
| 446 | 444 | try |
| 447 | 445 | { |
| 448 | - $this->setProperty ('Name', $name); |
|
| 446 | + $this->setProperty('Name', $name); |
|
| 449 | 447 | } |
| 450 | 448 | |
| 451 | 449 | catch (\Throwable $e) |
@@ -454,22 +452,22 @@ discard block |
||
| 454 | 452 | } |
| 455 | 453 | } |
| 456 | 454 | |
| 457 | - public function __toString (): string |
|
| 455 | + public function __toString(): string |
|
| 458 | 456 | { |
| 459 | - return $this->callMethod ('ToString'); |
|
| 457 | + return $this->callMethod('ToString'); |
|
| 460 | 458 | } |
| 461 | 459 | } |
| 462 | 460 | |
| 463 | 461 | class WFClass extends WFObject |
| 464 | 462 | { |
| 465 | - public function __construct ($class, $classGroup = false) |
|
| 463 | + public function __construct($class, $classGroup = false) |
|
| 466 | 464 | { |
| 467 | - if (is_string ($class)) |
|
| 468 | - $this->selector = \VoidCore::getClass ($class, $classGroup); |
|
| 465 | + if (is_string($class)) |
|
| 466 | + $this->selector = \VoidCore::getClass($class, $classGroup); |
|
| 469 | 467 | |
| 470 | - elseif (is_int ($class) && \VoidCore::objectExists ($class)) |
|
| 468 | + elseif (is_int($class) && \VoidCore::objectExists($class)) |
|
| 471 | 469 | $this->selector = $class; |
| 472 | 470 | |
| 473 | - else throw new \Exception ('$class parameter must be string or class selector'); |
|
| 471 | + else throw new \Exception('$class parameter must be string or class selector'); |
|
| 474 | 472 | } |
| 475 | 473 | } |
@@ -26,30 +26,37 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public static function compile (string $savePath, string $iconPath, string $phpCode, string $productDescription = null, string $productName = null, string $productVersion = null, string $companyName = null, string $copyright = null, string $callSharpCode = '', string $declareSharpCode = '', WFObject $dictionary = null, WFObject $assemblies = null): array |
| 28 | 28 | { |
| 29 | - if ($dictionary === null) |
|
| 30 | - $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
| 29 | + if ($dictionary === null) { |
|
| 30 | + $dictionary = new WFObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
| 31 | + } |
|
| 31 | 32 | |
| 32 | - if ($assemblies === null) |
|
| 33 | - $assemblies = getNetArray ('System.String', [ |
|
| 33 | + if ($assemblies === null) { |
|
| 34 | + $assemblies = getNetArray ('System.String', [ |
|
| 34 | 35 | // CORE_DIR .'/CefSharp.dll', |
| 35 | 36 | CORE_DIR .'/FastColoredTextBox.dll', |
| 36 | 37 | CORE_DIR .'/ScintillaNET.dll' |
| 37 | 38 | ]); |
| 39 | + } |
|
| 38 | 40 | |
| 39 | - if ($productName === null) |
|
| 40 | - $productName = basenameNoExt ($savePath); |
|
| 41 | + if ($productName === null) { |
|
| 42 | + $productName = basenameNoExt ($savePath); |
|
| 43 | + } |
|
| 41 | 44 | |
| 42 | - if ($productDescription === null) |
|
| 43 | - $productDescription = $productName; |
|
| 45 | + if ($productDescription === null) { |
|
| 46 | + $productDescription = $productName; |
|
| 47 | + } |
|
| 44 | 48 | |
| 45 | - if ($productVersion === null) |
|
| 46 | - $productVersion = '1.0'; |
|
| 49 | + if ($productVersion === null) { |
|
| 50 | + $productVersion = '1.0'; |
|
| 51 | + } |
|
| 47 | 52 | |
| 48 | - if ($companyName === null) |
|
| 49 | - $companyName = 'Company N'; |
|
| 53 | + if ($companyName === null) { |
|
| 54 | + $companyName = 'Company N'; |
|
| 55 | + } |
|
| 50 | 56 | |
| 51 | - if ($copyright === null) |
|
| 52 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
| 57 | + if ($copyright === null) { |
|
| 58 | + $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
| 59 | + } |
|
| 53 | 60 | |
| 54 | 61 | return (new WFClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
| 55 | 62 | } |
@@ -59,9 +66,7 @@ discard block |
||
| 59 | 66 | try |
| 60 | 67 | { |
| 61 | 68 | (new WFClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
| 62 | - } |
|
| 63 | - |
|
| 64 | - catch (\WinFormsException $e) |
|
| 69 | + } catch (\WinFormsException $e) |
|
| 65 | 70 | { |
| 66 | 71 | return false; |
| 67 | 72 | } |
@@ -73,8 +78,9 @@ discard block |
||
| 73 | 78 | { |
| 74 | 79 | $property = \VoidCore::callMethod (\VoidCore::callMethod ($selector, 'GetType'), 'GetProperty', $name); |
| 75 | 80 | |
| 76 | - if (!is_int ($property)) |
|
| 77 | - return false; |
|
| 81 | + if (!is_int ($property)) { |
|
| 82 | + return false; |
|
| 83 | + } |
|
| 78 | 84 | |
| 79 | 85 | try |
| 80 | 86 | { |
@@ -117,9 +123,7 @@ discard block |
||
| 117 | 123 | \VoidCore::getProperty ($selector, [$name, 'int']); |
| 118 | 124 | |
| 119 | 125 | $property = 'int'; |
| 120 | - } |
|
| 121 | - |
|
| 122 | - catch (\WinFormsException $e) |
|
| 126 | + } catch (\WinFormsException $e) |
|
| 123 | 127 | { |
| 124 | 128 | return [ |
| 125 | 129 | 'type' => 'vrsf', |
@@ -128,9 +132,7 @@ discard block |
||
| 128 | 132 | } |
| 129 | 133 | break; |
| 130 | 134 | } |
| 131 | - } |
|
| 132 | - |
|
| 133 | - catch (\Throwable $e) |
|
| 135 | + } catch (\Throwable $e) |
|
| 134 | 136 | { |
| 135 | 137 | $property = 'object'; |
| 136 | 138 | } |
@@ -148,8 +150,9 @@ discard block |
||
| 148 | 150 | $props = \VoidCore::callMethod (\VoidCore::callMethod ($object, 'GetType'), 'GetEvents'); |
| 149 | 151 | $len = \VoidCore::getProperty ($props, 'Length'); |
| 150 | 152 | |
| 151 | - for ($i = 0; $i < $len; ++$i) |
|
| 152 | - $events[] = \VoidCore::getProperty (\VoidCore::getArrayValue ($props, $i), 'Name'); |
|
| 153 | + for ($i = 0; $i < $len; ++$i) { |
|
| 154 | + $events[] = \VoidCore::getProperty (\VoidCore::getArrayValue ($props, $i), 'Name'); |
|
| 155 | + } |
|
| 153 | 156 | |
| 154 | 157 | return $events; |
| 155 | 158 | } |
@@ -179,8 +182,9 @@ discard block |
||
| 179 | 182 | |
| 180 | 183 | public function __construct ($object, $classGroup = false, ...$args) |
| 181 | 184 | { |
| 182 | - foreach ($args as $id => $arg) |
|
| 183 | - $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
| 185 | + foreach ($args as $id => $arg) { |
|
| 186 | + $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
| 187 | + } |
|
| 184 | 188 | |
| 185 | 189 | if (is_string ($object)) |
| 186 | 190 | { |
@@ -188,35 +192,31 @@ discard block |
||
| 188 | 192 | |
| 189 | 193 | /*$this->selector = \VoidCore::createObject ($object, $classGroup == 'auto' ? |
| 190 | 194 | substr ($object, 0, strrpos ($object, '.')) : $classGroup, ...$args);*/ |
| 195 | + } elseif (is_int ($object) && \VoidCore::objectExists ($object)) { |
|
| 196 | + $this->selector = $object; |
|
| 197 | + } else { |
|
| 198 | + throw new \Exception ('$object parameter must be string or object selector'); |
|
| 191 | 199 | } |
| 192 | - |
|
| 193 | - elseif (is_int ($object) && \VoidCore::objectExists ($object)) |
|
| 194 | - $this->selector = $object; |
|
| 195 | - |
|
| 196 | - else throw new \Exception ('$object parameter must be string or object selector'); |
|
| 197 | 200 | } |
| 198 | 201 | |
| 199 | 202 | public function __get ($name) |
| 200 | 203 | { |
| 201 | - if (method_exists ($this, $method = "get_$name")) |
|
| 202 | - $value = $this->$method (); |
|
| 203 | - |
|
| 204 | - elseif (substr ($name, -5) == 'Event') |
|
| 205 | - $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
| 206 | - |
|
| 207 | - elseif (property_exists ($this, $name)) |
|
| 208 | - $value = $this->$name; |
|
| 209 | - |
|
| 210 | - else switch (strtolower ($name)) |
|
| 204 | + if (method_exists ($this, $method = "get_$name")) { |
|
| 205 | + $value = $this->$method (); |
|
| 206 | + } elseif (substr ($name, -5) == 'Event') { |
|
| 207 | + $value = Events::getObjectEvent ($this->selector, substr ($name, 0, -5)); |
|
| 208 | + } elseif (property_exists ($this, $name)) { |
|
| 209 | + $value = $this->$name; |
|
| 210 | + } else { |
|
| 211 | + switch (strtolower ($name)) |
|
| 211 | 212 | { |
| 212 | 213 | case 'count': |
| 213 | 214 | case 'length': |
| 214 | 215 | try |
| 215 | 216 | { |
| 216 | 217 | return $this->getProperty ('Count'); |
| 217 | - } |
|
| 218 | - |
|
| 219 | - catch (\WinFormsException $e) |
|
| 218 | + } |
|
| 219 | + } catch (\WinFormsException $e) |
|
| 220 | 220 | { |
| 221 | 221 | return $this->getProperty ('Length'); |
| 222 | 222 | } |
@@ -226,8 +226,9 @@ discard block |
||
| 226 | 226 | $size = $this->count; |
| 227 | 227 | $list = []; |
| 228 | 228 | |
| 229 | - for ($i = 0; $i < $size; ++$i) |
|
| 230 | - $list[] = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $i)); |
|
| 229 | + for ($i = 0; $i < $size; ++$i) { |
|
| 230 | + $list[] = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $i)); |
|
| 231 | + } |
|
| 231 | 232 | |
| 232 | 233 | return $list; |
| 233 | 234 | break; |
@@ -236,13 +237,12 @@ discard block |
||
| 236 | 237 | $size = $this->count; |
| 237 | 238 | $names = []; |
| 238 | 239 | |
| 239 | - for ($i = 0; $i < $size; ++$i) |
|
| 240 | - try |
|
| 240 | + for ($i = 0; $i < $size; ++$i) { |
|
| 241 | + try |
|
| 241 | 242 | { |
| 242 | 243 | $names[] = \VoidCore::getProperty (\VoidCore::getArrayValue ($this->selector, [$i, 'object']), 'Text'); |
| 243 | - } |
|
| 244 | - |
|
| 245 | - catch (\WinFormsException $e) |
|
| 244 | + } |
|
| 245 | + } catch (\WinFormsException $e) |
|
| 246 | 246 | { |
| 247 | 247 | $names[] = \VoidCore::getArrayValue ($this->selector, [$i, 'string']); |
| 248 | 248 | } |
@@ -260,10 +260,11 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | public function __set ($name, $value) |
| 262 | 262 | { |
| 263 | - if (method_exists ($this, $method = "set_$name")) |
|
| 264 | - try |
|
| 263 | + if (method_exists ($this, $method = "set_$name")) { |
|
| 264 | + try |
|
| 265 | 265 | { |
| 266 | 266 | return $this->$method ($value); |
| 267 | + } |
|
| 267 | 268 | } |
| 268 | 269 | |
| 269 | 270 | # Метод "set_$name" может принимать в качестве параметра объект WFObject |
@@ -273,15 +274,13 @@ discard block |
||
| 273 | 274 | { |
| 274 | 275 | return $value instanceof WFObject ? |
| 275 | 276 | $this->$method ($value->selector) : null; |
| 276 | - } |
|
| 277 | - |
|
| 278 | - elseif (substr ($name, -5) == 'Event') |
|
| 279 | - Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
| 280 | - |
|
| 281 | - else |
|
| 277 | + } elseif (substr ($name, -5) == 'Event') { |
|
| 278 | + Events::setObjectEvent ($this->selector, substr ($name, 0, -5), $value); |
|
| 279 | + } else |
|
| 282 | 280 | { |
| 283 | - if (is_array ($value) && is_string (current ($value))) |
|
| 284 | - $value = getNetArray ('System.String', $value); |
|
| 281 | + if (is_array ($value) && is_string (current ($value))) { |
|
| 282 | + $value = getNetArray ('System.String', $value); |
|
| 283 | + } |
|
| 285 | 284 | |
| 286 | 285 | $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
| 287 | 286 | } |
@@ -299,11 +298,12 @@ discard block |
||
| 299 | 298 | |
| 300 | 299 | public function addRange ($values, $assoc = false): void |
| 301 | 300 | { |
| 302 | - if (is_array ($values)) |
|
| 303 | - foreach ($values as $id => $value) |
|
| 301 | + if (is_array ($values)) { |
|
| 302 | + foreach ($values as $id => $value) |
|
| 304 | 303 | $this->offsetSet ($assoc ? $id : null, $value); |
| 305 | - |
|
| 306 | - else $this->callMethod ('AddRange', EngineAdditions::uncoupleSelector ($values)); |
|
| 304 | + } else { |
|
| 305 | + $this->callMethod ('AddRange', EngineAdditions::uncoupleSelector ($values)); |
|
| 306 | + } |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | public function offsetSet ($index, $value) |
@@ -313,9 +313,7 @@ discard block |
||
| 313 | 313 | return $index === null ? |
| 314 | 314 | $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
| 315 | 315 | $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
| 316 | - } |
|
| 317 | - |
|
| 318 | - catch (\Throwable $e) |
|
| 316 | + } catch (\Throwable $e) |
|
| 319 | 317 | { |
| 320 | 318 | return $index === null ? |
| 321 | 319 | \VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) : |
@@ -338,9 +336,7 @@ discard block |
||
| 338 | 336 | try |
| 339 | 337 | { |
| 340 | 338 | $this->offsetGet ($index); |
| 341 | - } |
|
| 342 | - |
|
| 343 | - catch (\Exception $e) |
|
| 339 | + } catch (\Exception $e) |
|
| 344 | 340 | { |
| 345 | 341 | return false; |
| 346 | 342 | } |
@@ -367,8 +363,9 @@ discard block |
||
| 367 | 363 | { |
| 368 | 364 | $size = $this->count; |
| 369 | 365 | |
| 370 | - for ($i = 0; $i < $size; ++$i) |
|
| 371 | - $callback (EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
| 366 | + for ($i = 0; $i < $size; ++$i) { |
|
| 367 | + $callback (EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
| 368 | + } |
|
| 372 | 369 | } |
| 373 | 370 | |
| 374 | 371 | public function where (callable $comparator, string $type = null): array |
@@ -376,9 +373,10 @@ discard block |
||
| 376 | 373 | $size = $this->count; |
| 377 | 374 | $return = []; |
| 378 | 375 | |
| 379 | - for ($i = 0; $i < $size; ++$i) |
|
| 380 | - if ($comparator ($value = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
| 376 | + for ($i = 0; $i < $size; ++$i) { |
|
| 377 | + if ($comparator ($value = EngineAdditions::coupleSelector (\VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
| 381 | 378 | $return[] = $value; |
| 379 | + } |
|
| 382 | 380 | |
| 383 | 381 | return $return; |
| 384 | 382 | } |
@@ -388,9 +386,7 @@ discard block |
||
| 388 | 386 | try |
| 389 | 387 | { |
| 390 | 388 | return \VoidCore::getProperty ($this->selector, $name); |
| 391 | - } |
|
| 392 | - |
|
| 393 | - catch (\WinFormsException $e) |
|
| 389 | + } catch (\WinFormsException $e) |
|
| 394 | 390 | { |
| 395 | 391 | return \VoidCore::getField ($this->selector, $name); |
| 396 | 392 | } |
@@ -401,9 +397,7 @@ discard block |
||
| 401 | 397 | try |
| 402 | 398 | { |
| 403 | 399 | \VoidCore::setProperty ($this->selector, $name, $value); |
| 404 | - } |
|
| 405 | - |
|
| 406 | - catch (\WinFormsException $e) |
|
| 400 | + } catch (\WinFormsException $e) |
|
| 407 | 401 | { |
| 408 | 402 | \VoidCore::setField ($this->selector, $name, $value); |
| 409 | 403 | } |
@@ -420,8 +414,9 @@ discard block |
||
| 420 | 414 | $size = \VoidCore::getProperty ($array, 'Length'); |
| 421 | 415 | $return = []; |
| 422 | 416 | |
| 423 | - for ($i = 0; $i < $size; ++$i) |
|
| 424 | - $return[] = \VoidCore::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
| 417 | + for ($i = 0; $i < $size; ++$i) { |
|
| 418 | + $return[] = \VoidCore::getArrayValue ($array, $type === null ? $i : [$i, $type]); |
|
| 419 | + } |
|
| 425 | 420 | |
| 426 | 421 | \VoidCore::removeObjects ($array); |
| 427 | 422 | |
@@ -433,9 +428,7 @@ discard block |
||
| 433 | 428 | try |
| 434 | 429 | { |
| 435 | 430 | return $this->getProperty ('Name'); |
| 436 | - } |
|
| 437 | - |
|
| 438 | - catch (\Throwable $e) |
|
| 431 | + } catch (\Throwable $e) |
|
| 439 | 432 | { |
| 440 | 433 | return $this->name; |
| 441 | 434 | } |
@@ -446,9 +439,7 @@ discard block |
||
| 446 | 439 | try |
| 447 | 440 | { |
| 448 | 441 | $this->setProperty ('Name', $name); |
| 449 | - } |
|
| 450 | - |
|
| 451 | - catch (\Throwable $e) |
|
| 442 | + } catch (\Throwable $e) |
|
| 452 | 443 | { |
| 453 | 444 | $this->name = $name; |
| 454 | 445 | } |
@@ -464,12 +455,12 @@ discard block |
||
| 464 | 455 | { |
| 465 | 456 | public function __construct ($class, $classGroup = false) |
| 466 | 457 | { |
| 467 | - if (is_string ($class)) |
|
| 468 | - $this->selector = \VoidCore::getClass ($class, $classGroup); |
|
| 469 | - |
|
| 470 | - elseif (is_int ($class) && \VoidCore::objectExists ($class)) |
|
| 471 | - $this->selector = $class; |
|
| 472 | - |
|
| 473 | - else throw new \Exception ('$class parameter must be string or class selector'); |
|
| 458 | + if (is_string ($class)) { |
|
| 459 | + $this->selector = \VoidCore::getClass ($class, $classGroup); |
|
| 460 | + } elseif (is_int ($class) && \VoidCore::objectExists ($class)) { |
|
| 461 | + $this->selector = $class; |
|
| 462 | + } else { |
|
| 463 | + throw new \Exception ('$class parameter must be string or class selector'); |
|
| 464 | + } |
|
| 474 | 465 | } |
| 475 | 466 | } |
@@ -2,50 +2,50 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace VoidEngine; |
| 4 | 4 | |
| 5 | -register_superglobals ('APPLICATION', 'SCREEN'); |
|
| 5 | +register_superglobals('APPLICATION', 'SCREEN'); |
|
| 6 | 6 | |
| 7 | 7 | $APPLICATION = new class |
| 8 | 8 | { |
| 9 | 9 | public WFClass $application; |
| 10 | 10 | public string $executablePath; |
| 11 | 11 | |
| 12 | - public function __construct () |
|
| 12 | + public function __construct() |
|
| 13 | 13 | { |
| 14 | - $this->application = new WFClass ('System.Windows.Forms.Application'); |
|
| 14 | + $this->application = new WFClass('System.Windows.Forms.Application'); |
|
| 15 | 15 | $this->executablePath = $this->application->executablePath; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public function run ($form = null): void |
|
| 18 | + public function run($form = null): void |
|
| 19 | 19 | { |
| 20 | 20 | if ($form instanceof WFObject) |
| 21 | - $this->application->run ($form->selector); |
|
| 21 | + $this->application->run($form->selector); |
|
| 22 | 22 | |
| 23 | - elseif (is_int ($form) && \VoidCore::objectExists ($form)) |
|
| 24 | - $this->application->run ($form); |
|
| 23 | + elseif (is_int($form) && \VoidCore::objectExists($form)) |
|
| 24 | + $this->application->run($form); |
|
| 25 | 25 | |
| 26 | 26 | elseif ($form === null) |
| 27 | - $this->application->run (); |
|
| 27 | + $this->application->run(); |
|
| 28 | 28 | |
| 29 | - else throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
| 29 | + else throw new \Exception('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function restart (): void |
|
| 32 | + public function restart(): void |
|
| 33 | 33 | { |
| 34 | - $this->application->restart (); |
|
| 35 | - $this->close (); |
|
| 34 | + $this->application->restart(); |
|
| 35 | + $this->close(); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function close (): void |
|
| 38 | + public function close(): void |
|
| 39 | 39 | { |
| 40 | - $this->application->exit (); |
|
| 40 | + $this->application->exit(); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function __call (string $name, array $args) |
|
| 43 | + public function __call(string $name, array $args) |
|
| 44 | 44 | { |
| 45 | - return $this->application->$name (...$args); |
|
| 45 | + return $this->application->$name(...$args); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function __get (string $name) |
|
| 48 | + public function __get(string $name) |
|
| 49 | 49 | { |
| 50 | 50 | return $this->application->$name; |
| 51 | 51 | } |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | public WFObject $screen; |
| 57 | 57 | |
| 58 | - public function __construct () |
|
| 58 | + public function __construct() |
|
| 59 | 59 | { |
| 60 | - $this->screen = new WFClass ('System.Windows.Forms.Screen'); |
|
| 60 | + $this->screen = new WFClass('System.Windows.Forms.Screen'); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function __get ($name) |
|
| 63 | + public function __get($name) |
|
| 64 | 64 | { |
| 65 | - switch (strtolower ($name)) |
|
| 65 | + switch (strtolower($name)) |
|
| 66 | 66 | { |
| 67 | 67 | case 'width': |
| 68 | 68 | case 'w': |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - public function __debugInfo (): array |
|
| 83 | + public function __debugInfo(): array |
|
| 84 | 84 | { |
| 85 | 85 | return [ |
| 86 | 86 | $this->w, |
@@ -17,16 +17,15 @@ |
||
| 17 | 17 | |
| 18 | 18 | public function run ($form = null): void |
| 19 | 19 | { |
| 20 | - if ($form instanceof WFObject) |
|
| 21 | - $this->application->run ($form->selector); |
|
| 22 | - |
|
| 23 | - elseif (is_int ($form) && \VoidCore::objectExists ($form)) |
|
| 24 | - $this->application->run ($form); |
|
| 25 | - |
|
| 26 | - elseif ($form === null) |
|
| 27 | - $this->application->run (); |
|
| 28 | - |
|
| 29 | - else throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
| 20 | + if ($form instanceof WFObject) { |
|
| 21 | + $this->application->run ($form->selector); |
|
| 22 | + } elseif (is_int ($form) && \VoidCore::objectExists ($form)) { |
|
| 23 | + $this->application->run ($form); |
|
| 24 | + } elseif ($form === null) { |
|
| 25 | + $this->application->run (); |
|
| 26 | + } else { |
|
| 27 | + throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector'); |
|
| 28 | + } |
|
| 30 | 29 | } |
| 31 | 30 | |
| 32 | 31 | public function restart (): void |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | * @return array - возвращает список созданных объектов |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | - public static function run ($syntaxTree, string $resourcesDir = null, array $parent = null): array |
|
| 23 | + public static function run($syntaxTree, string $resourcesDir = null, array $parent = null): array |
|
| 24 | 24 | { |
| 25 | 25 | if ($syntaxTree instanceof VLFParser) |
| 26 | 26 | $syntaxTree = $syntaxTree->tree; |
| 27 | 27 | |
| 28 | - elseif (!is_array ($syntaxTree) && self::$throw_errors) |
|
| 29 | - throw new \Exception ('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
| 28 | + elseif (!is_array($syntaxTree) && self::$throw_errors) |
|
| 29 | + throw new \Exception('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
| 30 | 30 | |
| 31 | 31 | foreach ($syntaxTree as $id => $syntaxInfo) |
| 32 | 32 | if (isset ($syntaxInfo['type'])) |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | $args = $syntaxInfo['info']['arguments']; |
| 44 | 44 | |
| 45 | 45 | foreach ($args as $arg_id => $arg) |
| 46 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
| 46 | + if (is_object($arg) && $arg instanceof VLFLink) |
|
| 47 | 47 | $args[$arg_id] = isset (self::$objects[$arg->name]) ? |
| 48 | - self::formatLine ($arg->name, self::$objects) : null; |
|
| 48 | + self::formatLine($arg->name, self::$objects) : null; |
|
| 49 | 49 | |
| 50 | - else $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
| 50 | + else $args[$arg_id] = self::formatLine($arg, self::$objects); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | try |
| 54 | 54 | { |
| 55 | - self::$objects[$name] = eval ("namespace VoidEngine; return new $class (". implode (', ', $args) .");"); |
|
| 55 | + self::$objects[$name] = eval ("namespace VoidEngine; return new $class (".implode(', ', $args).");"); |
|
| 56 | 56 | |
| 57 | 57 | try |
| 58 | 58 | { |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | catch (\Throwable $e) |
| 66 | 66 | { |
| 67 | 67 | if (self::$throw_errors) |
| 68 | - throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
| 68 | + throw new \Exception('Interpeter couldn\'t create object "'.$class.'" with name "'.$name.'" at line "'.$syntaxInfo['line'].'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
| 69 | 69 | } |
| 70 | 70 | break; |
| 71 | 71 | |
| 72 | 72 | case VLF_SUBOBJECT_DEFINITION: |
| 73 | - self::$objects = self::run ((new VLFParser ($syntaxInfo['info']['object_vlf_info']))->tree, null, $syntaxInfo); |
|
| 73 | + self::$objects = self::run((new VLFParser($syntaxInfo['info']['object_vlf_info']))->tree, null, $syntaxInfo); |
|
| 74 | 74 | break; |
| 75 | 75 | |
| 76 | 76 | case VLF_PROPERTY_SET: |
@@ -80,34 +80,34 @@ discard block |
||
| 80 | 80 | $propertyValue = $syntaxInfo['info']['property_value']; |
| 81 | 81 | $preset = ''; |
| 82 | 82 | |
| 83 | - if (is_object ($propertyValue) && $propertyValue instanceof VLFLink) |
|
| 83 | + if (is_object($propertyValue) && $propertyValue instanceof VLFLink) |
|
| 84 | 84 | $propertyValue = isset (self::$objects[$propertyValue->name]) ? |
| 85 | - self::formatLine ($propertyValue->name, self::$objects) : null; |
|
| 85 | + self::formatLine($propertyValue->name, self::$objects) : null; |
|
| 86 | 86 | |
| 87 | - elseif (preg_match ('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
| 87 | + elseif (preg_match('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
| 88 | 88 | { |
| 89 | - $use = substr ($propertyValue, strpos ($propertyValue, 'use')); |
|
| 90 | - $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos); |
|
| 91 | - $use = explode (' ', $use); |
|
| 89 | + $use = substr($propertyValue, strpos($propertyValue, 'use')); |
|
| 90 | + $use = $ouse = substr($use, ($pos = strpos($use, '(') + 1), strpos($use, ')') - $pos); |
|
| 91 | + $use = explode(' ', $use); |
|
| 92 | 92 | |
| 93 | 93 | foreach ($use as $id => $useParam) |
| 94 | 94 | if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
| 95 | 95 | { |
| 96 | 96 | $fname = $use[$id + 1]; |
| 97 | 97 | |
| 98 | - if (substr ($fname, strlen ($fname) - 1) == ',') |
|
| 99 | - $fname = substr ($fname, 0, -1); |
|
| 98 | + if (substr($fname, strlen($fname) - 1) == ',') |
|
| 99 | + $fname = substr($fname, 0, -1); |
|
| 100 | 100 | |
| 101 | 101 | $preset .= "$fname = $useParam; "; |
| 102 | 102 | |
| 103 | 103 | unset ($use[$id]); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - $preset = self::formatLine ($preset, self::$objects); |
|
| 107 | - $propertyValue = self::formatLine (str_replace ($ouse, join (' ', $use), $propertyValue), self::$objects); |
|
| 106 | + $preset = self::formatLine($preset, self::$objects); |
|
| 107 | + $propertyValue = self::formatLine(str_replace($ouse, join(' ', $use), $propertyValue), self::$objects); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - else $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
| 110 | + else $propertyValue = self::formatLine($propertyValue, self::$objects); |
|
| 111 | 111 | |
| 112 | 112 | try |
| 113 | 113 | { |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | $propertyValue = $syntaxInfo['info']['property_raw_value']; |
| 122 | 122 | |
| 123 | - if (strpos ($propertyName, '->') !== false) |
|
| 124 | - eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';'); |
|
| 123 | + if (strpos($propertyName, '->') !== false) |
|
| 124 | + eval ('namespace VoidEngine; '.$preset.' _c('.self::$objects[$name]->selector.')->'.$propertyName.' = '.$propertyValue.';'); |
|
| 125 | 125 | |
| 126 | 126 | else self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
| 127 | 127 | } |
@@ -129,13 +129,13 @@ discard block |
||
| 129 | 129 | catch (\Throwable $e) |
| 130 | 130 | { |
| 131 | 131 | if (self::$throw_errors) |
| 132 | - throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
| 132 | + throw new \Exception('Interpeter couldn\'t set property "'.$propertyName.'" with value "'.$propertyValue.'" at line "'.$syntaxInfo['line'].'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | elseif (self::$throw_errors) |
| 138 | - throw new \Exception ('Setting property to an non-object at line "'. $syntaxInfo['line']); |
|
| 138 | + throw new \Exception('Setting property to an non-object at line "'.$syntaxInfo['line']); |
|
| 139 | 139 | break; |
| 140 | 140 | |
| 141 | 141 | case VLF_METHOD_CALL: |
@@ -145,61 +145,61 @@ discard block |
||
| 145 | 145 | $methodArgs = $syntaxInfo['info']['method_arguments']; |
| 146 | 146 | |
| 147 | 147 | foreach ($methodArgs as $arg_id => $arg) |
| 148 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
| 148 | + if (is_object($arg) && $arg instanceof VLFLink) |
|
| 149 | 149 | $methodArgs[$arg_id] = isset (self::$objects[$arg->name]) ? |
| 150 | - self::formatLine ($arg->name, self::$objects) : null; |
|
| 150 | + self::formatLine($arg->name, self::$objects) : null; |
|
| 151 | 151 | |
| 152 | - else $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
| 152 | + else $methodArgs[$arg_id] = self::formatLine($arg, self::$objects); |
|
| 153 | 153 | |
| 154 | 154 | try |
| 155 | 155 | { |
| 156 | - if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
| 157 | - eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
| 156 | + if (strpos($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
| 157 | + eval ('namespace VoidEngine; _c('.self::$objects[$name]->selector.')->'.$methodName.' ('.implode(', ', $methodArgs).');'); |
|
| 158 | 158 | |
| 159 | - elseif (sizeof ($methodArgs) > 0) |
|
| 160 | - self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
| 159 | + elseif (sizeof($methodArgs) > 0) |
|
| 160 | + self::$objects[$name]->$methodName(...eval ('namespace VoidEngine; return ['.implode(', ', $methodArgs).'];')); |
|
| 161 | 161 | |
| 162 | - else self::$objects[$name]->$methodName (); |
|
| 162 | + else self::$objects[$name]->$methodName(); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | catch (\Throwable $e) |
| 166 | 166 | { |
| 167 | 167 | if (self::$throw_errors) |
| 168 | - throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
| 168 | + throw new \Exception('Interpeter couldn\'t call method "'.$methodName.'" with arguments '.json_encode($methodArgs).' at line "'.$syntaxInfo['line'].'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | elseif (self::$throw_errors) |
| 173 | - throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
| 173 | + throw new \Exception('Calling method to an non-object at line "'.$syntaxInfo['line'].'"'); |
|
| 174 | 174 | break; |
| 175 | 175 | |
| 176 | 176 | case VLF_RUNTIME_EXECUTABLE: |
| 177 | - eval (self::formatLine ($syntaxInfo['info']['code'], self::$objects)); |
|
| 177 | + eval (self::formatLine($syntaxInfo['info']['code'], self::$objects)); |
|
| 178 | 178 | break; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) |
|
| 182 | - self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
| 181 | + if (isset ($syntaxInfo['syntax_nodes']) && sizeof($syntaxInfo['syntax_nodes']) > 0) |
|
| 182 | + self::$objects = self::run($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - else throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
| 185 | + else throw new \Exception('Catched unknown syntax node: "'.json_encode($syntaxInfo).'"'); |
|
| 186 | 186 | |
| 187 | - if (is_dir ($resourcesDir)) |
|
| 188 | - foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
| 187 | + if (is_dir($resourcesDir)) |
|
| 188 | + foreach (glob($resourcesDir.'/*.vrsf') as $id => $dir) |
|
| 189 | 189 | { |
| 190 | - $baseName = basenameNoExt ($dir); |
|
| 191 | - $info = explode ('.', $baseName); |
|
| 190 | + $baseName = basenameNoExt($dir); |
|
| 191 | + $info = explode('.', $baseName); |
|
| 192 | 192 | |
| 193 | 193 | if (isset (self::$objects[$info[0]])) |
| 194 | 194 | { |
| 195 | 195 | if (isset ($info[2])) |
| 196 | 196 | { |
| 197 | - $collection = \VoidCore::getProperty (self::$objects[$info[0]]->selector, $info[1]); |
|
| 197 | + $collection = \VoidCore::getProperty(self::$objects[$info[0]]->selector, $info[1]); |
|
| 198 | 198 | |
| 199 | - \VoidCore::callMethod ($collection, 'Add', [\VoidCore::importObject (base64_encode (file_get_contents ($dir))), 'object']); |
|
| 199 | + \VoidCore::callMethod($collection, 'Add', [\VoidCore::importObject(base64_encode(file_get_contents($dir))), 'object']); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - else \VoidCore::setProperty (self::$objects[$info[0]]->selector, $info[1], \VoidCore::importObject (base64_encode (file_get_contents ($dir)))); |
|
| 202 | + else \VoidCore::setProperty(self::$objects[$info[0]]->selector, $info[1], \VoidCore::importObject(base64_encode(file_get_contents($dir)))); |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
@@ -216,26 +216,25 @@ discard block |
||
| 216 | 216 | * @return string - возвращает форматированную строку |
| 217 | 217 | */ |
| 218 | 218 | |
| 219 | - public static function formatLine (string $line, array $objects = []): string |
|
| 219 | + public static function formatLine(string $line, array $objects = []): string |
|
| 220 | 220 | { |
| 221 | - if (sizeof ($objects) > 0) |
|
| 221 | + if (sizeof($objects) > 0) |
|
| 222 | 222 | { |
| 223 | - $len = strlen ($line); |
|
| 223 | + $len = strlen($line); |
|
| 224 | 224 | $newLine = ''; |
| 225 | 225 | |
| 226 | - $replacement = array_map (function ($object) |
|
| 226 | + $replacement = array_map(function($object) |
|
| 227 | 227 | { |
| 228 | - return Components::componentExists ($object->selector) !== false ? |
|
| 229 | - '\VoidEngine\_c('. $object->selector .')' : |
|
| 230 | - 'unserialize (\''. serialize ($object) .'\')'; |
|
| 228 | + return Components::componentExists($object->selector) !== false ? |
|
| 229 | + '\VoidEngine\_c('.$object->selector.')' : 'unserialize (\''.serialize($object).'\')'; |
|
| 231 | 230 | }, $objects); |
| 232 | 231 | |
| 233 | - $replacement = array_map (function ($name) |
|
| 232 | + $replacement = array_map(function($name) |
|
| 234 | 233 | { |
| 235 | - return strlen ($name = trim ($name)) + substr_count ($name, '_'); |
|
| 236 | - }, $omap = array_flip ($replacement)); |
|
| 234 | + return strlen($name = trim($name)) + substr_count($name, '_'); |
|
| 235 | + }, $omap = array_flip($replacement)); |
|
| 237 | 236 | |
| 238 | - arsort ($replacement); |
|
| 237 | + arsort($replacement); |
|
| 239 | 238 | |
| 240 | 239 | $nReplacement = []; |
| 241 | 240 | |
@@ -243,14 +242,14 @@ discard block |
||
| 243 | 242 | $nReplacement[$omap[$replaceTo]] = $replaceTo; |
| 244 | 243 | |
| 245 | 244 | $replacement = $nReplacement; |
| 246 | - $blacklist = array_flip (['\'', '"', '$']); |
|
| 245 | + $blacklist = array_flip(['\'', '"', '$']); |
|
| 247 | 246 | |
| 248 | 247 | for ($i = 0; $i < $len; ++$i) |
| 249 | 248 | { |
| 250 | 249 | $replaced = false; |
| 251 | 250 | |
| 252 | 251 | foreach ($replacement as $name => $replaceAt) |
| 253 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
| 252 | + if (substr($line, $i, ($l = strlen($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
| 254 | 253 | { |
| 255 | 254 | $newLine .= $replaceAt; |
| 256 | 255 | |
@@ -22,19 +22,20 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public static function run ($syntaxTree, string $resourcesDir = null, array $parent = null): array |
| 24 | 24 | { |
| 25 | - if ($syntaxTree instanceof VLFParser) |
|
| 26 | - $syntaxTree = $syntaxTree->tree; |
|
| 27 | - |
|
| 28 | - elseif (!is_array ($syntaxTree) && self::$throw_errors) |
|
| 29 | - throw new \Exception ('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
| 25 | + if ($syntaxTree instanceof VLFParser) { |
|
| 26 | + $syntaxTree = $syntaxTree->tree; |
|
| 27 | + } elseif (!is_array ($syntaxTree) && self::$throw_errors) { |
|
| 28 | + throw new \Exception ('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - foreach ($syntaxTree as $id => $syntaxInfo) |
|
| 32 | - if (isset ($syntaxInfo['type'])) |
|
| 31 | + foreach ($syntaxTree as $id => $syntaxInfo) { |
|
| 32 | + if (isset ($syntaxInfo['type'])) |
|
| 33 | 33 | { |
| 34 | 34 | switch ($syntaxInfo['type']) |
| 35 | 35 | { |
| 36 | 36 | case VLF_OBJECT_DEFINITION: |
| 37 | 37 | $class = $syntaxInfo['info']['object_class']; |
| 38 | + } |
|
| 38 | 39 | $name = $syntaxInfo['info']['object_name']; |
| 39 | 40 | $args = []; |
| 40 | 41 | |
@@ -42,12 +43,15 @@ discard block |
||
| 42 | 43 | { |
| 43 | 44 | $args = $syntaxInfo['info']['arguments']; |
| 44 | 45 | |
| 45 | - foreach ($args as $arg_id => $arg) |
|
| 46 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
| 46 | + foreach ($args as $arg_id => $arg) { |
|
| 47 | + if (is_object ($arg) && $arg instanceof VLFLink) |
|
| 47 | 48 | $args[$arg_id] = isset (self::$objects[$arg->name]) ? |
| 48 | 49 | self::formatLine ($arg->name, self::$objects) : null; |
| 50 | + } |
|
| 49 | 51 | |
| 50 | - else $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
| 52 | + else { |
|
| 53 | + $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
| 54 | + } |
|
| 51 | 55 | } |
| 52 | 56 | |
| 53 | 57 | try |
@@ -57,15 +61,12 @@ discard block |
||
| 57 | 61 | try |
| 58 | 62 | { |
| 59 | 63 | self::$objects[$name]->name = $name; |
| 60 | - } |
|
| 61 | - |
|
| 62 | - catch (\Throwable $e) {} |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - catch (\Throwable $e) |
|
| 64 | + } catch (\Throwable $e) {} |
|
| 65 | + } catch (\Throwable $e) |
|
| 66 | 66 | { |
| 67 | - if (self::$throw_errors) |
|
| 68 | - throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
| 67 | + if (self::$throw_errors) { |
|
| 68 | + throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
| 69 | + } |
|
| 69 | 70 | } |
| 70 | 71 | break; |
| 71 | 72 | |
@@ -80,23 +81,24 @@ discard block |
||
| 80 | 81 | $propertyValue = $syntaxInfo['info']['property_value']; |
| 81 | 82 | $preset = ''; |
| 82 | 83 | |
| 83 | - if (is_object ($propertyValue) && $propertyValue instanceof VLFLink) |
|
| 84 | - $propertyValue = isset (self::$objects[$propertyValue->name]) ? |
|
| 84 | + if (is_object ($propertyValue) && $propertyValue instanceof VLFLink) { |
|
| 85 | + $propertyValue = isset (self::$objects[$propertyValue->name]) ? |
|
| 85 | 86 | self::formatLine ($propertyValue->name, self::$objects) : null; |
| 86 | - |
|
| 87 | - elseif (preg_match ('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
| 87 | + } elseif (preg_match ('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
| 88 | 88 | { |
| 89 | 89 | $use = substr ($propertyValue, strpos ($propertyValue, 'use')); |
| 90 | 90 | $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos); |
| 91 | 91 | $use = explode (' ', $use); |
| 92 | 92 | |
| 93 | - foreach ($use as $id => $useParam) |
|
| 94 | - if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
|
| 93 | + foreach ($use as $id => $useParam) { |
|
| 94 | + if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
|
| 95 | 95 | { |
| 96 | 96 | $fname = $use[$id + 1]; |
| 97 | + } |
|
| 97 | 98 | |
| 98 | - if (substr ($fname, strlen ($fname) - 1) == ',') |
|
| 99 | - $fname = substr ($fname, 0, -1); |
|
| 99 | + if (substr ($fname, strlen ($fname) - 1) == ',') { |
|
| 100 | + $fname = substr ($fname, 0, -1); |
|
| 101 | + } |
|
| 100 | 102 | |
| 101 | 103 | $preset .= "$fname = $useParam; "; |
| 102 | 104 | |
@@ -105,37 +107,34 @@ discard block |
||
| 105 | 107 | |
| 106 | 108 | $preset = self::formatLine ($preset, self::$objects); |
| 107 | 109 | $propertyValue = self::formatLine (str_replace ($ouse, join (' ', $use), $propertyValue), self::$objects); |
| 110 | + } else { |
|
| 111 | + $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
| 108 | 112 | } |
| 109 | 113 | |
| 110 | - else $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
| 111 | - |
|
| 112 | 114 | try |
| 113 | 115 | { |
| 114 | 116 | self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
| 115 | - } |
|
| 116 | - |
|
| 117 | - catch (\Throwable $e) |
|
| 117 | + } catch (\Throwable $e) |
|
| 118 | 118 | { |
| 119 | 119 | try |
| 120 | 120 | { |
| 121 | 121 | $propertyValue = $syntaxInfo['info']['property_raw_value']; |
| 122 | 122 | |
| 123 | - if (strpos ($propertyName, '->') !== false) |
|
| 124 | - eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';'); |
|
| 125 | - |
|
| 126 | - else self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - catch (\Throwable $e) |
|
| 123 | + if (strpos ($propertyName, '->') !== false) { |
|
| 124 | + eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';'); |
|
| 125 | + } else { |
|
| 126 | + self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
|
| 127 | + } |
|
| 128 | + } catch (\Throwable $e) |
|
| 130 | 129 | { |
| 131 | - if (self::$throw_errors) |
|
| 132 | - throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
| 130 | + if (self::$throw_errors) { |
|
| 131 | + throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
| 132 | + } |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | + } elseif (self::$throw_errors) { |
|
| 136 | + throw new \Exception ('Setting property to an non-object at line "'. $syntaxInfo['line']); |
|
| 135 | 137 | } |
| 136 | - |
|
| 137 | - elseif (self::$throw_errors) |
|
| 138 | - throw new \Exception ('Setting property to an non-object at line "'. $syntaxInfo['line']); |
|
| 139 | 138 | break; |
| 140 | 139 | |
| 141 | 140 | case VLF_METHOD_CALL: |
@@ -144,33 +143,34 @@ discard block |
||
| 144 | 143 | $methodName = $syntaxInfo['info']['method_name']; |
| 145 | 144 | $methodArgs = $syntaxInfo['info']['method_arguments']; |
| 146 | 145 | |
| 147 | - foreach ($methodArgs as $arg_id => $arg) |
|
| 148 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
| 146 | + foreach ($methodArgs as $arg_id => $arg) { |
|
| 147 | + if (is_object ($arg) && $arg instanceof VLFLink) |
|
| 149 | 148 | $methodArgs[$arg_id] = isset (self::$objects[$arg->name]) ? |
| 150 | 149 | self::formatLine ($arg->name, self::$objects) : null; |
| 150 | + } |
|
| 151 | 151 | |
| 152 | - else $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
| 152 | + else { |
|
| 153 | + $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
| 154 | + } |
|
| 153 | 155 | |
| 154 | 156 | try |
| 155 | 157 | { |
| 156 | - if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
| 157 | - eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
| 158 | - |
|
| 159 | - elseif (sizeof ($methodArgs) > 0) |
|
| 160 | - self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
| 161 | - |
|
| 162 | - else self::$objects[$name]->$methodName (); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - catch (\Throwable $e) |
|
| 158 | + if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) { |
|
| 159 | + eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
| 160 | + } elseif (sizeof ($methodArgs) > 0) { |
|
| 161 | + self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
| 162 | + } else { |
|
| 163 | + self::$objects[$name]->$methodName (); |
|
| 164 | + } |
|
| 165 | + } catch (\Throwable $e) |
|
| 166 | 166 | { |
| 167 | - if (self::$throw_errors) |
|
| 168 | - throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
| 167 | + if (self::$throw_errors) { |
|
| 168 | + throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
| 169 | + } |
|
| 169 | 170 | } |
| 171 | + } elseif (self::$throw_errors) { |
|
| 172 | + throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
| 170 | 173 | } |
| 171 | - |
|
| 172 | - elseif (self::$throw_errors) |
|
| 173 | - throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
| 174 | 174 | break; |
| 175 | 175 | |
| 176 | 176 | case VLF_RUNTIME_EXECUTABLE: |
@@ -178,16 +178,18 @@ discard block |
||
| 178 | 178 | break; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) |
|
| 182 | - self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
| 181 | + if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) { |
|
| 182 | + self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
| 183 | + } |
|
| 184 | + } else { |
|
| 185 | + throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
| 183 | 186 | } |
| 184 | 187 | |
| 185 | - else throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
| 186 | - |
|
| 187 | - if (is_dir ($resourcesDir)) |
|
| 188 | - foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
| 188 | + if (is_dir ($resourcesDir)) { |
|
| 189 | + foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
| 189 | 190 | { |
| 190 | 191 | $baseName = basenameNoExt ($dir); |
| 192 | + } |
|
| 191 | 193 | $info = explode ('.', $baseName); |
| 192 | 194 | |
| 193 | 195 | if (isset (self::$objects[$info[0]])) |
@@ -197,9 +199,9 @@ discard block |
||
| 197 | 199 | $collection = \VoidCore::getProperty (self::$objects[$info[0]]->selector, $info[1]); |
| 198 | 200 | |
| 199 | 201 | \VoidCore::callMethod ($collection, 'Add', [\VoidCore::importObject (base64_encode (file_get_contents ($dir))), 'object']); |
| 202 | + } else { |
|
| 203 | + \VoidCore::setProperty (self::$objects[$info[0]]->selector, $info[1], \VoidCore::importObject (base64_encode (file_get_contents ($dir)))); |
|
| 200 | 204 | } |
| 201 | - |
|
| 202 | - else \VoidCore::setProperty (self::$objects[$info[0]]->selector, $info[1], \VoidCore::importObject (base64_encode (file_get_contents ($dir)))); |
|
| 203 | 205 | } |
| 204 | 206 | } |
| 205 | 207 | |
@@ -239,8 +241,9 @@ discard block |
||
| 239 | 241 | |
| 240 | 242 | $nReplacement = []; |
| 241 | 243 | |
| 242 | - foreach ($replacement as $replaceTo => $nLn) |
|
| 243 | - $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
| 244 | + foreach ($replacement as $replaceTo => $nLn) { |
|
| 245 | + $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
| 246 | + } |
|
| 244 | 247 | |
| 245 | 248 | $replacement = $nReplacement; |
| 246 | 249 | $blacklist = array_flip (['\'', '"', '$']); |
@@ -249,10 +252,11 @@ discard block |
||
| 249 | 252 | { |
| 250 | 253 | $replaced = false; |
| 251 | 254 | |
| 252 | - foreach ($replacement as $name => $replaceAt) |
|
| 253 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
| 255 | + foreach ($replacement as $name => $replaceAt) { |
|
| 256 | + if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
| 254 | 257 | { |
| 255 | 258 | $newLine .= $replaceAt; |
| 259 | + } |
|
| 256 | 260 | |
| 257 | 261 | $i += $l - 1; |
| 258 | 262 | $replaced = true; |
@@ -260,8 +264,9 @@ discard block |
||
| 260 | 264 | break; |
| 261 | 265 | } |
| 262 | 266 | |
| 263 | - if (!$replaced) |
|
| 264 | - $newLine .= $line[$i]; |
|
| 267 | + if (!$replaced) { |
|
| 268 | + $newLine .= $line[$i]; |
|
| 269 | + } |
|
| 265 | 270 | } |
| 266 | 271 | |
| 267 | 272 | $line = $newLine; |
@@ -4,28 +4,28 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Process extends Component |
| 6 | 6 | { |
| 7 | - public $class = 'System.Diagnostics.Process'; |
|
| 8 | - public $namespace = 'System'; |
|
| 7 | + public $class = 'System.Diagnostics.Process'; |
|
| 8 | + public $namespace = 'System'; |
|
| 9 | 9 | |
| 10 | - public function __construct (int $pid = null) |
|
| 11 | - { |
|
| 10 | + public function __construct (int $pid = null) |
|
| 11 | + { |
|
| 12 | 12 | $this->selector = \VoidCore::getClass ($this->class, $this->namespace); |
| 13 | 13 | |
| 14 | - if ($pid !== null) |
|
| 14 | + if ($pid !== null) |
|
| 15 | 15 | $this->selector = $pid == getmypid () ? |
| 16 | 16 | \VoidCore::callMethod ($this->selector, 'GetCurrentProcess') : |
| 17 | 17 | \VoidCore::callMethod ($this->selector, 'GetProcessById', $pid); |
| 18 | 18 | |
| 19 | - Components::addComponent ($this->selector, $this); |
|
| 20 | - } |
|
| 19 | + Components::addComponent ($this->selector, $this); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - public static function getProcessById (int $pid) |
|
| 23 | - { |
|
| 24 | - return new self ($pid); |
|
| 25 | - } |
|
| 22 | + public static function getProcessById (int $pid) |
|
| 23 | + { |
|
| 24 | + return new self ($pid); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - public static function getCurrentProcess () |
|
| 28 | - { |
|
| 29 | - return new self (getmypid ()); |
|
| 30 | - } |
|
| 27 | + public static function getCurrentProcess () |
|
| 28 | + { |
|
| 29 | + return new self (getmypid ()); |
|
| 30 | + } |
|
| 31 | 31 | } |
@@ -4,28 +4,27 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Process extends Component |
| 6 | 6 | { |
| 7 | - public $class = 'System.Diagnostics.Process'; |
|
| 7 | + public $class = 'System.Diagnostics.Process'; |
|
| 8 | 8 | public $namespace = 'System'; |
| 9 | 9 | |
| 10 | - public function __construct (int $pid = null) |
|
| 10 | + public function __construct(int $pid = null) |
|
| 11 | 11 | { |
| 12 | - $this->selector = \VoidCore::getClass ($this->class, $this->namespace); |
|
| 12 | + $this->selector = \VoidCore::getClass($this->class, $this->namespace); |
|
| 13 | 13 | |
| 14 | 14 | if ($pid !== null) |
| 15 | - $this->selector = $pid == getmypid () ? |
|
| 16 | - \VoidCore::callMethod ($this->selector, 'GetCurrentProcess') : |
|
| 17 | - \VoidCore::callMethod ($this->selector, 'GetProcessById', $pid); |
|
| 15 | + $this->selector = $pid == getmypid() ? |
|
| 16 | + \VoidCore::callMethod($this->selector, 'GetCurrentProcess') : \VoidCore::callMethod($this->selector, 'GetProcessById', $pid); |
|
| 18 | 17 | |
| 19 | - Components::addComponent ($this->selector, $this); |
|
| 18 | + Components::addComponent($this->selector, $this); |
|
| 20 | 19 | } |
| 21 | 20 | |
| 22 | - public static function getProcessById (int $pid) |
|
| 21 | + public static function getProcessById(int $pid) |
|
| 23 | 22 | { |
| 24 | - return new self ($pid); |
|
| 23 | + return new self($pid); |
|
| 25 | 24 | } |
| 26 | 25 | |
| 27 | - public static function getCurrentProcess () |
|
| 26 | + public static function getCurrentProcess() |
|
| 28 | 27 | { |
| 29 | - return new self (getmypid ()); |
|
| 28 | + return new self(getmypid()); |
|
| 30 | 29 | } |
| 31 | 30 | } |
@@ -11,10 +11,11 @@ |
||
| 11 | 11 | { |
| 12 | 12 | $this->selector = \VoidCore::getClass ($this->class, $this->namespace); |
| 13 | 13 | |
| 14 | - if ($pid !== null) |
|
| 15 | - $this->selector = $pid == getmypid () ? |
|
| 14 | + if ($pid !== null) { |
|
| 15 | + $this->selector = $pid == getmypid () ? |
|
| 16 | 16 | \VoidCore::callMethod ($this->selector, 'GetCurrentProcess') : |
| 17 | 17 | \VoidCore::callMethod ($this->selector, 'GetProcessById', $pid); |
| 18 | + } |
|
| 18 | 19 | |
| 19 | 20 | Components::addComponent ($this->selector, $this); |
| 20 | 21 | } |