@@ -6,8 +6,8 @@ |
||
| 6 | 6 | { |
| 7 | 7 | public $class = 'System.Windows.Forms.MessageBox'; |
| 8 | 8 | |
| 9 | - public function __construct () |
|
| 9 | + public function __construct() |
|
| 10 | 10 | { |
| 11 | - parent::__construct ($this->class); |
|
| 11 | + parent::__construct($this->class); |
|
| 12 | 12 | } |
| 13 | 13 | } |
@@ -12,11 +12,11 @@ |
||
| 12 | 12 | protected $styles; |
| 13 | 13 | |
| 14 | 14 | public function __construct (Component $parent = null) |
| 15 | - { |
|
| 15 | + { |
|
| 16 | 16 | parent::__construct ($parent, $this->class); |
| 17 | 17 | |
| 18 | 18 | $this->styles = $this->getProperty ('Styles'); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | public function resetSyntax () |
| 22 | 22 | { |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace VoidEngine; |
| 4 | 4 | |
| 5 | -EngineAdditions::loadModule ('ScintillaNET.dll'); |
|
| 5 | +EngineAdditions::loadModule('ScintillaNET.dll'); |
|
| 6 | 6 | |
| 7 | 7 | class Scintilla extends NoVisual |
| 8 | 8 | { |
@@ -11,71 +11,71 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | protected $styles; |
| 13 | 13 | |
| 14 | - public function __construct (Component $parent = null) |
|
| 14 | + public function __construct(Component $parent = null) |
|
| 15 | 15 | { |
| 16 | - parent::__construct ($parent, $this->class); |
|
| 16 | + parent::__construct($parent, $this->class); |
|
| 17 | 17 | |
| 18 | - $this->styles = $this->getProperty ('Styles'); |
|
| 18 | + $this->styles = $this->getProperty('Styles'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function resetSyntax () |
|
| 21 | + public function resetSyntax() |
|
| 22 | 22 | { |
| 23 | - $this->callMethod ('StyleResetDefault'); |
|
| 23 | + $this->callMethod('StyleResetDefault'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function clearSyntax () |
|
| 26 | + public function clearSyntax() |
|
| 27 | 27 | { |
| 28 | - $this->callMethod ('StyleClearAll'); |
|
| 28 | + $this->callMethod('StyleClearAll'); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function setKeywords (int $index, string $keywords) |
|
| 31 | + public function setKeywords(int $index, string $keywords) |
|
| 32 | 32 | { |
| 33 | - $this->callMethod ('SetKeywords', [$index, 'int'], [$keywords, 'string']); |
|
| 33 | + $this->callMethod('SetKeywords', [$index, 'int'], [$keywords, 'string']); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function propertyInit (string $propertyName, $propertyValue) |
|
| 36 | + public function propertyInit(string $propertyName, $propertyValue) |
|
| 37 | 37 | { |
| 38 | - $this->callMethod ('SetProperty', [$propertyName, 'string'], [$propertyValue, 'string']); |
|
| 38 | + $this->callMethod('SetProperty', [$propertyName, 'string'], [$propertyValue, 'string']); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function set_syntax ($syntax) |
|
| 41 | + public function set_syntax($syntax) |
|
| 42 | 42 | { |
| 43 | - if (file_exists ($syntax)) |
|
| 44 | - $syntax = file_get_contents ($syntax); |
|
| 43 | + if (file_exists($syntax)) |
|
| 44 | + $syntax = file_get_contents($syntax); |
|
| 45 | 45 | |
| 46 | - $syntax = json_decode ($syntax, true); |
|
| 46 | + $syntax = json_decode($syntax, true); |
|
| 47 | 47 | |
| 48 | 48 | if ( |
| 49 | - !is_array ($syntax['syntax']) || |
|
| 50 | - !is_array ($syntax['references']) || |
|
| 49 | + !is_array($syntax['syntax']) || |
|
| 50 | + !is_array($syntax['references']) || |
|
| 51 | 51 | !isset ($syntax['lexer']) |
| 52 | 52 | ) return false; |
| 53 | 53 | |
| 54 | 54 | else |
| 55 | 55 | { |
| 56 | - $this->resetSyntax (); |
|
| 57 | - $this->clearSyntax (); |
|
| 56 | + $this->resetSyntax(); |
|
| 57 | + $this->clearSyntax(); |
|
| 58 | 58 | |
| 59 | 59 | foreach ($syntax['references'] as $name => $value) |
| 60 | 60 | if (isset ($syntax['syntax'][$name])) |
| 61 | 61 | { |
| 62 | - $element = \VoidCore::getArrayValue ($this->styles, $value); |
|
| 62 | + $element = \VoidCore::getArrayValue($this->styles, $value); |
|
| 63 | 63 | $color = $syntax['syntax'][$name]; |
| 64 | 64 | |
| 65 | - if (defined ($color)) |
|
| 66 | - $color = constant ($color); |
|
| 65 | + if (defined($color)) |
|
| 66 | + $color = constant($color); |
|
| 67 | 67 | |
| 68 | - \VoidCore::setProperty ($element, 'ForeColor', [$color, 'color']); |
|
| 68 | + \VoidCore::setProperty($element, 'ForeColor', [$color, 'color']); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $this->lexer = $syntax['lexer']; |
| 72 | 72 | |
| 73 | - if (is_array ($syntax['keywords'])) |
|
| 73 | + if (is_array($syntax['keywords'])) |
|
| 74 | 74 | foreach ($syntax['keywords'] as $id => $keywords) |
| 75 | - $this->setKeywords ($id, $keywords); |
|
| 75 | + $this->setKeywords($id, $keywords); |
|
| 76 | 76 | |
| 77 | - $this->propertyInit ('fold', 1); |
|
| 78 | - $this->propertyInit ('fold.compact', 1); |
|
| 77 | + $this->propertyInit('fold', 1); |
|
| 78 | + $this->propertyInit('fold.compact', 1); |
|
| 79 | 79 | |
| 80 | 80 | return true; |
| 81 | 81 | } |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | public function set_syntax ($syntax) |
| 42 | 42 | { |
| 43 | - if (file_exists ($syntax)) |
|
| 44 | - $syntax = file_get_contents ($syntax); |
|
| 43 | + if (file_exists ($syntax)) { |
|
| 44 | + $syntax = file_get_contents ($syntax); |
|
| 45 | + } |
|
| 45 | 46 | |
| 46 | 47 | $syntax = json_decode ($syntax, true); |
| 47 | 48 | |
@@ -49,30 +50,33 @@ discard block |
||
| 49 | 50 | !is_array ($syntax['syntax']) || |
| 50 | 51 | !is_array ($syntax['references']) || |
| 51 | 52 | !isset ($syntax['lexer']) |
| 52 | - ) return false; |
|
| 53 | - |
|
| 54 | - else |
|
| 53 | + ) { |
|
| 54 | + return false; |
|
| 55 | + } else |
|
| 55 | 56 | { |
| 56 | 57 | $this->resetSyntax (); |
| 57 | 58 | $this->clearSyntax (); |
| 58 | 59 | |
| 59 | - foreach ($syntax['references'] as $name => $value) |
|
| 60 | - if (isset ($syntax['syntax'][$name])) |
|
| 60 | + foreach ($syntax['references'] as $name => $value) { |
|
| 61 | + if (isset ($syntax['syntax'][$name])) |
|
| 61 | 62 | { |
| 62 | 63 | $element = \VoidCore::getArrayValue ($this->styles, $value); |
| 64 | + } |
|
| 63 | 65 | $color = $syntax['syntax'][$name]; |
| 64 | 66 | |
| 65 | - if (defined ($color)) |
|
| 66 | - $color = constant ($color); |
|
| 67 | + if (defined ($color)) { |
|
| 68 | + $color = constant ($color); |
|
| 69 | + } |
|
| 67 | 70 | |
| 68 | 71 | \VoidCore::setProperty ($element, 'ForeColor', [$color, 'color']); |
| 69 | 72 | } |
| 70 | 73 | |
| 71 | 74 | $this->lexer = $syntax['lexer']; |
| 72 | 75 | |
| 73 | - if (is_array ($syntax['keywords'])) |
|
| 74 | - foreach ($syntax['keywords'] as $id => $keywords) |
|
| 76 | + if (is_array ($syntax['keywords'])) { |
|
| 77 | + foreach ($syntax['keywords'] as $id => $keywords) |
|
| 75 | 78 | $this->setKeywords ($id, $keywords); |
| 79 | + } |
|
| 76 | 80 | |
| 77 | 81 | $this->propertyInit ('fold', 1); |
| 78 | 82 | $this->propertyInit ('fold.compact', 1); |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | { |
| 7 | 7 | public $class = 'System.Windows.Forms.TreeView'; |
| 8 | 8 | |
| 9 | - public function get_path () |
|
| 9 | + public function get_path() |
|
| 10 | 10 | { |
| 11 | 11 | try |
| 12 | 12 | { |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | public $class = 'System.Windows.Forms.TreeNode'; |
| 28 | 28 | |
| 29 | - public function __construct (string $text = '') |
|
| 29 | + public function __construct(string $text = '') |
|
| 30 | 30 | { |
| 31 | - parent::__construct (null, $this->class); |
|
| 31 | + parent::__construct(null, $this->class); |
|
| 32 | 32 | |
| 33 | 33 | $this->text = $text; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function get_path () |
|
| 36 | + public function get_path() |
|
| 37 | 37 | { |
| 38 | - return $this->getProperty ('FullPath'); |
|
| 38 | + return $this->getProperty('FullPath'); |
|
| 39 | 39 | } |
| 40 | 40 | } |
@@ -11,9 +11,7 @@ |
||
| 11 | 11 | try |
| 12 | 12 | { |
| 13 | 13 | $node = $this->selectedNode; |
| 14 | - } |
|
| 15 | - |
|
| 16 | - catch (\WinFormsException $e) |
|
| 14 | + } catch (\WinFormsException $e) |
|
| 17 | 15 | { |
| 18 | 16 | return false; |
| 19 | 17 | } |
@@ -18,11 +18,11 @@ |
||
| 18 | 18 | |
| 19 | 19 | protected $items; |
| 20 | 20 | |
| 21 | - public function __construct (string $text = '') |
|
| 21 | + public function __construct(string $text = '') |
|
| 22 | 22 | { |
| 23 | - parent::__construct (null, $this->class); |
|
| 23 | + parent::__construct(null, $this->class); |
|
| 24 | 24 | |
| 25 | 25 | $this->text = $text; |
| 26 | - $this->items = new WFObject ($this->getProperty ('DropDownItems')); |
|
| 26 | + $this->items = new WFObject($this->getProperty('DropDownItems')); |
|
| 27 | 27 | } |
| 28 | 28 | } |
@@ -6,6 +6,6 @@ |
||
| 6 | 6 | |
| 7 | 7 | class FastColoredTextBox extends NoVisual |
| 8 | 8 | { |
| 9 | - public $class = 'FastColoredTextBoxNS.FastColoredTextBox'; |
|
| 9 | + public $class = 'FastColoredTextBoxNS.FastColoredTextBox'; |
|
| 10 | 10 | public $namespace = 'FastColoredTextBox'; |
| 11 | 11 | } |
@@ -2,10 +2,10 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace VoidEngine; |
| 4 | 4 | |
| 5 | -EngineAdditions::loadModule ('FastColoredTextBox.dll'); |
|
| 5 | +EngineAdditions::loadModule('FastColoredTextBox.dll'); |
|
| 6 | 6 | |
| 7 | 7 | class FastColoredTextBox extends NoVisual |
| 8 | 8 | { |
| 9 | - public $class = 'FastColoredTextBoxNS.FastColoredTextBox'; |
|
| 9 | + public $class = 'FastColoredTextBoxNS.FastColoredTextBox'; |
|
| 10 | 10 | public $namespace = 'FastColoredTextBox'; |
| 11 | 11 | } |
@@ -10,12 +10,12 @@ |
||
| 10 | 10 | protected $panel2; |
| 11 | 11 | |
| 12 | 12 | public function __construct (Component $parent = null) |
| 13 | - { |
|
| 13 | + { |
|
| 14 | 14 | parent::__construct ($parent, $this->class); |
| 15 | 15 | |
| 16 | 16 | $this->panel1 = new SplitterPanel ($this->getProperty ('Panel1')); |
| 17 | 17 | $this->panel2 = new SplitterPanel ($this->getProperty ('Panel2')); |
| 18 | - } |
|
| 18 | + } |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | class SplitterPanel extends Control |
@@ -9,18 +9,18 @@ |
||
| 9 | 9 | protected $panel1; |
| 10 | 10 | protected $panel2; |
| 11 | 11 | |
| 12 | - public function __construct (Component $parent = null) |
|
| 12 | + public function __construct(Component $parent = null) |
|
| 13 | 13 | { |
| 14 | - parent::__construct ($parent, $this->class); |
|
| 14 | + parent::__construct($parent, $this->class); |
|
| 15 | 15 | |
| 16 | - $this->panel1 = new SplitterPanel ($this->getProperty ('Panel1')); |
|
| 17 | - $this->panel2 = new SplitterPanel ($this->getProperty ('Panel2')); |
|
| 16 | + $this->panel1 = new SplitterPanel($this->getProperty('Panel1')); |
|
| 17 | + $this->panel2 = new SplitterPanel($this->getProperty('Panel2')); |
|
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | class SplitterPanel extends Control |
| 22 | 22 | { |
| 23 | - public function __construct (int $selector) |
|
| 23 | + public function __construct(int $selector) |
|
| 24 | 24 | { |
| 25 | 25 | $this->selector = $selector; |
| 26 | 26 | } |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | public $class = 'System.Windows.Forms.ListViewItem'; |
| 13 | 13 | |
| 14 | - public function __construct (string $text = '') |
|
| 14 | + public function __construct(string $text = '') |
|
| 15 | 15 | { |
| 16 | - parent::__construct (null, $this->class); |
|
| 16 | + parent::__construct(null, $this->class); |
|
| 17 | 17 | |
| 18 | 18 | $this->text = $text; |
| 19 | 19 | } |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | public $class = 'System.Windows.Forms.ColumnHeader'; |
| 25 | 25 | |
| 26 | - public function __construct (string $text = '') |
|
| 26 | + public function __construct(string $text = '') |
|
| 27 | 27 | { |
| 28 | - parent::__construct (null, $this->class); |
|
| 28 | + parent::__construct(null, $this->class); |
|
| 29 | 29 | |
| 30 | 30 | $this->text = $text; |
| 31 | 31 | } |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | public $class = 'System.Windows.Forms.ListViewGroup'; |
| 37 | 37 | |
| 38 | - public function __construct (string $text = '') |
|
| 38 | + public function __construct(string $text = '') |
|
| 39 | 39 | { |
| 40 | - parent::__construct (null, $this->class); |
|
| 40 | + parent::__construct(null, $this->class); |
|
| 41 | 41 | |
| 42 | 42 | $this->header = $text; |
| 43 | 43 | } |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | public function dispose (): void |
| 52 | - { |
|
| 52 | + { |
|
| 53 | 53 | foreach (array_diff (get_object_vars ($this), ['selector']) as $param => $value) |
| 54 | 54 | { |
| 55 | 55 | if (is_int ($value)) |
@@ -9,81 +9,81 @@ |
||
| 9 | 9 | public $class = 'System.Windows.Forms.Component'; |
| 10 | 10 | public $namespace = 'System.Windows.Forms'; |
| 11 | 11 | |
| 12 | - public function __construct ($className = null, ...$args) |
|
| 12 | + public function __construct($className = null, ...$args) |
|
| 13 | 13 | { |
| 14 | - parent::__construct ( |
|
| 14 | + parent::__construct( |
|
| 15 | 15 | $className === null ? $this->class : $className, |
| 16 | 16 | $this->namespace ?? false, |
| 17 | 17 | ...$args |
| 18 | 18 | ); |
| 19 | 19 | |
| 20 | - Components::addComponent ($this->selector, $this); |
|
| 20 | + Components::addComponent($this->selector, $this); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function __debugInfo (): array |
|
| 23 | + public function __debugInfo(): array |
|
| 24 | 24 | { |
| 25 | 25 | return [ |
| 26 | - 'description' => @$this->__toString (), |
|
| 26 | + 'description' => @$this->__toString(), |
|
| 27 | 27 | 'selector' => @$this->selector, |
| 28 | 28 | 'name' => @$this->name, |
| 29 | - 'objectInfo' => @json_encode ($this, JSON_PRETTY_PRINT) |
|
| 29 | + 'objectInfo' => @json_encode($this, JSON_PRETTY_PRINT) |
|
| 30 | 30 | ]; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function __unset ($name) |
|
| 33 | + public function __unset($name) |
|
| 34 | 34 | { |
| 35 | 35 | if (isset ($this->$name)) |
| 36 | 36 | { |
| 37 | - if (is_int ($this->$name)) |
|
| 37 | + if (is_int($this->$name)) |
|
| 38 | 38 | { |
| 39 | - Components::removeComponent ($this->$name); |
|
| 39 | + Components::removeComponent($this->$name); |
|
| 40 | 40 | |
| 41 | - if (\VoidCore::objectExists ($this->$name)) |
|
| 42 | - \VoidCore::removeObjects ($this->$name); |
|
| 41 | + if (\VoidCore::objectExists($this->$name)) |
|
| 42 | + \VoidCore::removeObjects($this->$name); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | elseif ($this->$name instanceof Component) |
| 46 | - $this->$name->dispose (); |
|
| 46 | + $this->$name->dispose(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | unset ($this->$name); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function dispose (): void |
|
| 52 | + public function dispose(): void |
|
| 53 | 53 | { |
| 54 | - foreach (array_diff (get_object_vars ($this), ['selector']) as $param => $value) |
|
| 54 | + foreach (array_diff(get_object_vars($this), ['selector']) as $param => $value) |
|
| 55 | 55 | { |
| 56 | - if (is_int ($value)) |
|
| 56 | + if (is_int($value)) |
|
| 57 | 57 | { |
| 58 | - Components::removeComponent ($value); |
|
| 58 | + Components::removeComponent($value); |
|
| 59 | 59 | |
| 60 | - if (\VoidCore::objectExists ($value)) |
|
| 61 | - \VoidCore::removeObjects ($value); |
|
| 60 | + if (\VoidCore::objectExists($value)) |
|
| 61 | + \VoidCore::removeObjects($value); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | elseif ($value instanceof Component) |
| 65 | - $value->dispose (); |
|
| 65 | + $value->dispose(); |
|
| 66 | 66 | |
| 67 | 67 | unset ($this->$param); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | if (isset ($this->selector)) |
| 71 | 71 | { |
| 72 | - if (\VoidCore::objectExists ($this->selector)) |
|
| 73 | - \VoidCore::removeObjects ($this->selector); |
|
| 72 | + if (\VoidCore::objectExists($this->selector)) |
|
| 73 | + \VoidCore::removeObjects($this->selector); |
|
| 74 | 74 | |
| 75 | - Components::removeComponent ($this->selector); |
|
| 75 | + Components::removeComponent($this->selector); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - Components::cleanJunk (); |
|
| 78 | + Components::cleanJunk(); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function __destruct () |
|
| 81 | + public function __destruct() |
|
| 82 | 82 | { |
| 83 | - if (isset ($this->selector) && \VoidCore::destructObject ($this->selector)) |
|
| 83 | + if (isset ($this->selector) && \VoidCore::destructObject($this->selector)) |
|
| 84 | 84 | { |
| 85 | - \VoidCore::removeObjects ($this->selector); |
|
| 86 | - Components::removeComponent ($this->selector); |
|
| 85 | + \VoidCore::removeObjects($this->selector); |
|
| 86 | + Components::removeComponent($this->selector); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -38,12 +38,12 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | Components::removeComponent ($this->$name); |
| 40 | 40 | |
| 41 | - if (\VoidCore::objectExists ($this->$name)) |
|
| 42 | - \VoidCore::removeObjects ($this->$name); |
|
| 41 | + if (\VoidCore::objectExists ($this->$name)) { |
|
| 42 | + \VoidCore::removeObjects ($this->$name); |
|
| 43 | + } |
|
| 44 | + } elseif ($this->$name instanceof Component) { |
|
| 45 | + $this->$name->dispose (); |
|
| 43 | 46 | } |
| 44 | - |
|
| 45 | - elseif ($this->$name instanceof Component) |
|
| 46 | - $this->$name->dispose (); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | unset ($this->$name); |
@@ -57,20 +57,21 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | Components::removeComponent ($value); |
| 59 | 59 | |
| 60 | - if (\VoidCore::objectExists ($value)) |
|
| 61 | - \VoidCore::removeObjects ($value); |
|
| 60 | + if (\VoidCore::objectExists ($value)) { |
|
| 61 | + \VoidCore::removeObjects ($value); |
|
| 62 | + } |
|
| 63 | + } elseif ($value instanceof Component) { |
|
| 64 | + $value->dispose (); |
|
| 62 | 65 | } |
| 63 | 66 | |
| 64 | - elseif ($value instanceof Component) |
|
| 65 | - $value->dispose (); |
|
| 66 | - |
|
| 67 | 67 | unset ($this->$param); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | if (isset ($this->selector)) |
| 71 | 71 | { |
| 72 | - if (\VoidCore::objectExists ($this->selector)) |
|
| 73 | - \VoidCore::removeObjects ($this->selector); |
|
| 72 | + if (\VoidCore::objectExists ($this->selector)) { |
|
| 73 | + \VoidCore::removeObjects ($this->selector); |
|
| 74 | + } |
|
| 74 | 75 | |
| 75 | 76 | Components::removeComponent ($this->selector); |
| 76 | 77 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | return [ |
| 49 | 49 | 'text' => $e->getMessage (), |
| 50 | - 'line' => $e->getLine () |
|
| 50 | + 'line' => $e->getLine () |
|
| 51 | 51 | ]; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -165,17 +165,17 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | function substr_icount (string $haystack, string $needle, ...$params): int |
| 167 | 167 | { |
| 168 | - return substr_count (strtolower ($haystack), strtolower ($needle), ...$params); |
|
| 168 | + return substr_count (strtolower ($haystack), strtolower ($needle), ...$params); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | function str_replace_assoc (string $subject, array $replacements): string |
| 172 | 172 | { |
| 173 | - return str_replace (array_keys ($replacements), array_values ($replacements), $subject); |
|
| 173 | + return str_replace (array_keys ($replacements), array_values ($replacements), $subject); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | function pre (...$args): void |
| 177 | 177 | { |
| 178 | - message (sizeof ($args) < 2 ? current ($args) : $args); |
|
| 178 | + message (sizeof ($args) < 2 ? current ($args) : $args); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | function messageBox (string $message, string $caption = '', ...$args) |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | catch (\Throwable $e) |
| 311 | - { |
|
| 312 | - continue; |
|
| 313 | - } |
|
| 311 | + { |
|
| 312 | + continue; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | return false; |
| 316 | 316 | } |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | call_user_func ($function, $self); |
| 334 | 334 | }; |
| 335 | 335 | |
| 336 | - $timer->start (); |
|
| 336 | + $timer->start (); |
|
| 337 | 337 | |
| 338 | 338 | return $timer; |
| 339 | 339 | } |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | $timer->start (); |
| 355 | 355 | |
| 356 | - return $timer; |
|
| 356 | + return $timer; |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | class Clipboard |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace VoidEngine; |
| 4 | 4 | |
| 5 | -function err_status (bool $status = null): bool |
|
| 5 | +function err_status(bool $status = null): bool |
|
| 6 | 6 | { |
| 7 | 7 | $oldStatus = $GLOBALS['__debug']['error_status']; |
| 8 | 8 | |
@@ -12,216 +12,216 @@ discard block |
||
| 12 | 12 | return $oldStatus; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -function err_no (): bool |
|
| 15 | +function err_no(): bool |
|
| 16 | 16 | { |
| 17 | - return err_status (false); |
|
| 17 | + return err_status(false); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -function err_yes (): bool |
|
| 20 | +function err_yes(): bool |
|
| 21 | 21 | { |
| 22 | - return err_status (true); |
|
| 22 | + return err_status(true); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -function run (string $path, ...$args) |
|
| 25 | +function run(string $path, ...$args) |
|
| 26 | 26 | { |
| 27 | - return (new Process)->start ($path, ...$args); |
|
| 27 | + return (new Process)->start($path, ...$args); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | -function vbs_exec (string $code) |
|
| 30 | +function vbs_exec(string $code) |
|
| 31 | 31 | { |
| 32 | - file_put_contents ($path = getenv ('temp') .'/'. crc32 ($code) .'.vbs', $code); |
|
| 32 | + file_put_contents($path = getenv('temp').'/'.crc32($code).'.vbs', $code); |
|
| 33 | 33 | |
| 34 | - (new \COM ('WScript.Shell'))->Run ($path, 0, true); |
|
| 34 | + (new \COM('WScript.Shell'))->Run($path, 0, true); |
|
| 35 | 35 | |
| 36 | - unlink ($path); |
|
| 36 | + unlink($path); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -function php_errors_check (string $code): ?array |
|
| 39 | +function php_errors_check(string $code): ?array |
|
| 40 | 40 | { |
| 41 | 41 | try |
| 42 | 42 | { |
| 43 | - eval ('return; '. $code); |
|
| 43 | + eval ('return; '.$code); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | catch (\Throwable $e) |
| 47 | 47 | { |
| 48 | 48 | return [ |
| 49 | - 'text' => $e->getMessage (), |
|
| 50 | - 'line' => $e->getLine () |
|
| 49 | + 'text' => $e->getMessage(), |
|
| 50 | + 'line' => $e->getLine() |
|
| 51 | 51 | ]; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | return null; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | -function enum (string $name): array |
|
| 57 | +function enum(string $name): array |
|
| 58 | 58 | { |
| 59 | 59 | return [ |
| 60 | - substr ($name, strrpos ($name, '.') + 1), |
|
| 61 | - ($name = substr ($name, 0, strrpos ($name, '.'))) .', '. substr ($name, 0, strrpos ($name, '.')) |
|
| 60 | + substr($name, strrpos($name, '.') + 1), |
|
| 61 | + ($name = substr($name, 0, strrpos($name, '.'))).', '.substr($name, 0, strrpos($name, '.')) |
|
| 62 | 62 | ]; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | -function enum_parse (string $baseType, string $value) |
|
| 65 | +function enum_parse(string $baseType, string $value) |
|
| 66 | 66 | { |
| 67 | 67 | try |
| 68 | 68 | { |
| 69 | - return \VoidCore::callMethod (\VoidCore::getClass ('System.Enum',''), ['parse', 'object'], \VoidCore::typeof ($baseType), $value, true); |
|
| 69 | + return \VoidCore::callMethod(\VoidCore::getClass('System.Enum', ''), ['parse', 'object'], \VoidCore::typeof($baseType), $value, true); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | catch (\WinFormsException $e) |
| 73 | 73 | { |
| 74 | - return (new WFClass ($baseType))->$value; |
|
| 74 | + return (new WFClass($baseType))->$value; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | -function getNetArray (string $type, array $items = []): WFObject |
|
| 78 | +function getNetArray(string $type, array $items = []): WFObject |
|
| 79 | 79 | { |
| 80 | - $array = (new WFClass ('System.Array', null)) |
|
| 81 | - ->createInstance (\VoidCore::typeof ($type), $size = sizeof ($items)); |
|
| 80 | + $array = (new WFClass('System.Array', null)) |
|
| 81 | + ->createInstance(\VoidCore::typeof($type), $size = sizeof($items)); |
|
| 82 | 82 | |
| 83 | 83 | for ($i = 0; $i < $size; ++$i) |
| 84 | - $array[$i] = array_shift ($items); |
|
| 84 | + $array[$i] = array_shift($items); |
|
| 85 | 85 | |
| 86 | 86 | return $array; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | -function dir_create (string $path, int $mode = 0777): void |
|
| 89 | +function dir_create(string $path, int $mode = 0777): void |
|
| 90 | 90 | { |
| 91 | - if (!is_dir ($path)) |
|
| 92 | - mkdir ($path, $mode, true); |
|
| 91 | + if (!is_dir($path)) |
|
| 92 | + mkdir($path, $mode, true); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | -function dir_delete (string $path): bool |
|
| 95 | +function dir_delete(string $path): bool |
|
| 96 | 96 | { |
| 97 | - if (!is_dir ($path)) |
|
| 97 | + if (!is_dir($path)) |
|
| 98 | 98 | return false; |
| 99 | 99 | |
| 100 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
| 101 | - if (is_dir ($file = $path .'/'. $file)) |
|
| 100 | + foreach (array_slice(scandir($path), 2) as $file) |
|
| 101 | + if (is_dir($file = $path.'/'.$file)) |
|
| 102 | 102 | { |
| 103 | - dir_delete ($file); |
|
| 103 | + dir_delete($file); |
|
| 104 | 104 | |
| 105 | - if (is_dir ($file)) |
|
| 106 | - rmdir ($file); |
|
| 105 | + if (is_dir($file)) |
|
| 106 | + rmdir($file); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - else unlink ($file); |
|
| 109 | + else unlink($file); |
|
| 110 | 110 | |
| 111 | - rmdir ($path); |
|
| 111 | + rmdir($path); |
|
| 112 | 112 | |
| 113 | 113 | return true; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | -function dir_clean (string $path): void |
|
| 116 | +function dir_clean(string $path): void |
|
| 117 | 117 | { |
| 118 | - dir_delete ($path); |
|
| 119 | - dir_create ($path); |
|
| 118 | + dir_delete($path); |
|
| 119 | + dir_create($path); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | -function dir_copy (string $from, string $to): bool |
|
| 122 | +function dir_copy(string $from, string $to): bool |
|
| 123 | 123 | { |
| 124 | - if (!is_dir ($from)) |
|
| 124 | + if (!is_dir($from)) |
|
| 125 | 125 | return false; |
| 126 | 126 | |
| 127 | - if (!is_dir ($to)) |
|
| 128 | - dir_create ($to); |
|
| 127 | + if (!is_dir($to)) |
|
| 128 | + dir_create($to); |
|
| 129 | 129 | |
| 130 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
| 131 | - if (is_dir ($f = $from .'/'. $file)) |
|
| 132 | - dir_copy ($f, $to .'/'. $file); |
|
| 130 | + foreach (array_slice(scandir($from), 2) as $file) |
|
| 131 | + if (is_dir($f = $from.'/'.$file)) |
|
| 132 | + dir_copy($f, $to.'/'.$file); |
|
| 133 | 133 | |
| 134 | - else copy ($f, $to .'/'. $file); |
|
| 134 | + else copy($f, $to.'/'.$file); |
|
| 135 | 135 | |
| 136 | 136 | return true; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | -function getARGBColor (string $color) |
|
| 139 | +function getARGBColor(string $color) |
|
| 140 | 140 | { |
| 141 | - return (new WFClass ('System.Drawing.ColorTranslator'))->fromHtml ($color); |
|
| 141 | + return (new WFClass('System.Drawing.ColorTranslator'))->fromHtml($color); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | -function replaceSl (string $string): string |
|
| 144 | +function replaceSl(string $string): string |
|
| 145 | 145 | { |
| 146 | - return str_replace ('\\', '/', $string); |
|
| 146 | + return str_replace('\\', '/', $string); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | -function replaceSr (string $string): string |
|
| 149 | +function replaceSr(string $string): string |
|
| 150 | 150 | { |
| 151 | - return str_replace ('/', '\\', $string); |
|
| 151 | + return str_replace('/', '\\', $string); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | -function basenameNoExt (string $path): string |
|
| 154 | +function basenameNoExt(string $path): string |
|
| 155 | 155 | { |
| 156 | - return pathinfo ($path, PATHINFO_FILENAME); |
|
| 156 | + return pathinfo($path, PATHINFO_FILENAME); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | -function file_ext (string $path): string |
|
| 159 | +function file_ext(string $path): string |
|
| 160 | 160 | { |
| 161 | - return strtolower (pathinfo ($path, PATHINFO_EXTENSION)); |
|
| 161 | + return strtolower(pathinfo($path, PATHINFO_EXTENSION)); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | -function filepathNoExt (string $path): string |
|
| 164 | +function filepathNoExt(string $path): string |
|
| 165 | 165 | { |
| 166 | - return dirname ($path) .'/'. basenameNoExt ($path); |
|
| 166 | + return dirname($path).'/'.basenameNoExt($path); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | -function array_first (array $array) |
|
| 169 | +function array_first(array $array) |
|
| 170 | 170 | { |
| 171 | - return array_shift ($array); |
|
| 171 | + return array_shift($array); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | -function array_end (array $array) |
|
| 174 | +function array_end(array $array) |
|
| 175 | 175 | { |
| 176 | - return array_pop ($array); |
|
| 176 | + return array_pop($array); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | -function substr_icount (string $haystack, string $needle, ...$params): int |
|
| 179 | +function substr_icount(string $haystack, string $needle, ...$params): int |
|
| 180 | 180 | { |
| 181 | - return substr_count (strtolower ($haystack), strtolower ($needle), ...$params); |
|
| 181 | + return substr_count(strtolower($haystack), strtolower($needle), ...$params); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | -function str_replace_assoc (string $subject, array $replacements): string |
|
| 184 | +function str_replace_assoc(string $subject, array $replacements): string |
|
| 185 | 185 | { |
| 186 | - return str_replace (array_keys ($replacements), array_values ($replacements), $subject); |
|
| 186 | + return str_replace(array_keys($replacements), array_values($replacements), $subject); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | -function pre (...$args): void |
|
| 189 | +function pre(...$args): void |
|
| 190 | 190 | { |
| 191 | - message (sizeof ($args) < 2 ? current ($args) : $args); |
|
| 191 | + message(sizeof($args) < 2 ? current ($args) : $args); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | -function messageBox (string $message, string $caption = '', ...$args) |
|
| 194 | +function messageBox(string $message, string $caption = '', ...$args) |
|
| 195 | 195 | { |
| 196 | - return (new MessageBox)->show ($message, $caption, ...$args); |
|
| 196 | + return (new MessageBox)->show($message, $caption, ...$args); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | class Components |
| 200 | 200 | { |
| 201 | 201 | static array $components = []; |
| 202 | 202 | |
| 203 | - public static function addComponent (int $selector, object $object): void |
|
| 203 | + public static function addComponent(int $selector, object $object): void |
|
| 204 | 204 | { |
| 205 | 205 | self::$components[$selector] = $object; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - public static function getComponent (int $selector) |
|
| 208 | + public static function getComponent(int $selector) |
|
| 209 | 209 | { |
| 210 | 210 | return isset (self::$components[$selector]) ? |
| 211 | 211 | self::$components[$selector] : false; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - public static function componentExists (int $selector): bool |
|
| 214 | + public static function componentExists(int $selector): bool |
|
| 215 | 215 | { |
| 216 | 216 | return isset (self::$components[$selector]); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - public static function removeComponent (int $selector): void |
|
| 219 | + public static function removeComponent(int $selector): void |
|
| 220 | 220 | { |
| 221 | 221 | unset (self::$components[$selector]); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - public static function cleanJunk (): void |
|
| 224 | + public static function cleanJunk(): void |
|
| 225 | 225 | { |
| 226 | 226 | // TODO: более строгие правила очистки мусорных объектов |
| 227 | 227 | |
@@ -229,46 +229,46 @@ discard block |
||
| 229 | 229 | { |
| 230 | 230 | try |
| 231 | 231 | { |
| 232 | - if ($object->getType ()->isSubclassOf (\VoidCore::typeof ('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
| 232 | + if ($object->getType()->isSubclassOf(\VoidCore::typeof('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
| 233 | 233 | continue; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | catch (\Exception $e) {} |
| 237 | 237 | |
| 238 | - \VoidCore::destructObject ($selector); |
|
| 238 | + \VoidCore::destructObject($selector); |
|
| 239 | 239 | |
| 240 | - if (!\VoidCore::objectExists ($selector)) |
|
| 240 | + if (!\VoidCore::objectExists($selector)) |
|
| 241 | 241 | unset (self::$components[$selector]); |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | -function _c (int $selector) |
|
| 246 | +function _c(int $selector) |
|
| 247 | 247 | { |
| 248 | - return Components::getComponent ($selector); |
|
| 248 | + return Components::getComponent($selector); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | -function c ($name, bool $returnAllSimilarObjects = false) |
|
| 251 | +function c($name, bool $returnAllSimilarObjects = false) |
|
| 252 | 252 | { |
| 253 | - if (is_int ($name) && is_object ($object = _c ($name))) |
|
| 253 | + if (is_int($name) && is_object($object = _c($name))) |
|
| 254 | 254 | return $object; |
| 255 | 255 | |
| 256 | 256 | else |
| 257 | 257 | { |
| 258 | - $path = explode ('->', $name); |
|
| 258 | + $path = explode('->', $name); |
|
| 259 | 259 | $similar = []; |
| 260 | 260 | |
| 261 | 261 | foreach (Components::$components as $object) |
| 262 | 262 | try |
| 263 | 263 | { |
| 264 | - if ($object->name == end ($path)) |
|
| 264 | + if ($object->name == end($path)) |
|
| 265 | 265 | { |
| 266 | - if (sizeof ($path) > 1) |
|
| 266 | + if (sizeof($path) > 1) |
|
| 267 | 267 | try |
| 268 | 268 | { |
| 269 | - if (is_object ($parent = _c($object->parent->selector))) |
|
| 269 | + if (is_object($parent = _c($object->parent->selector))) |
|
| 270 | 270 | { |
| 271 | - if (c(join ('->', array_slice ($path, 0, -1))) == $parent) |
|
| 271 | + if (c(join('->', array_slice($path, 0, -1))) == $parent) |
|
| 272 | 272 | { |
| 273 | 273 | if ($returnAllSimilarObjects) |
| 274 | 274 | $similar[] = $object; |
@@ -302,18 +302,18 @@ discard block |
||
| 302 | 302 | continue; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if (sizeof ($path) == 2) |
|
| 305 | + if (sizeof($path) == 2) |
|
| 306 | 306 | { |
| 307 | 307 | $objects = c($path[1], true); |
| 308 | 308 | |
| 309 | - if (is_array ($objects)) |
|
| 309 | + if (is_array($objects)) |
|
| 310 | 310 | { |
| 311 | 311 | foreach ($objects as $id => $object) |
| 312 | 312 | try |
| 313 | 313 | { |
| 314 | - while (is_object ($parent = _c($object->parent->selector))) |
|
| 314 | + while (is_object($parent = _c($object->parent->selector))) |
|
| 315 | 315 | { |
| 316 | - if ($parent->getType ()->isSubclassOf (\VoidCore::typeof ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
|
| 316 | + if ($parent->getType()->isSubclassOf(\VoidCore::typeof('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
|
| 317 | 317 | return $objects[$id]; |
| 318 | 318 | |
| 319 | 319 | else $object = $parent; |
@@ -331,70 +331,70 @@ discard block |
||
| 331 | 331 | else return false; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - else return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
| 334 | + else return $returnAllSimilarObjects && sizeof($similar) > 0 ? |
|
| 335 | 335 | $similar : false; |
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | -function setTimer (int $interval, callable $function): Timer |
|
| 339 | +function setTimer(int $interval, callable $function): Timer |
|
| 340 | 340 | { |
| 341 | 341 | $timer = new Timer; |
| 342 | 342 | $timer->interval = $interval; |
| 343 | 343 | |
| 344 | - $timer->tickEvent = function ($self) use ($function) |
|
| 344 | + $timer->tickEvent = function($self) use ($function) |
|
| 345 | 345 | { |
| 346 | - call_user_func ($function, $self); |
|
| 346 | + call_user_func($function, $self); |
|
| 347 | 347 | }; |
| 348 | 348 | |
| 349 | - $timer->start (); |
|
| 349 | + $timer->start(); |
|
| 350 | 350 | |
| 351 | 351 | return $timer; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | // FIXME: выполняется несколько раз, а не единожды |
| 355 | -function setTimeout (int $timeout, callable $function): Timer |
|
| 355 | +function setTimeout(int $timeout, callable $function): Timer |
|
| 356 | 356 | { |
| 357 | 357 | $timer = new Timer; |
| 358 | 358 | $timer->interval = $timeout; |
| 359 | 359 | |
| 360 | - $timer->tickEvent = function ($self) use ($function) |
|
| 360 | + $timer->tickEvent = function($self) use ($function) |
|
| 361 | 361 | { |
| 362 | - call_user_func ($function, $self); |
|
| 362 | + call_user_func($function, $self); |
|
| 363 | 363 | |
| 364 | - $self->stop (); |
|
| 364 | + $self->stop(); |
|
| 365 | 365 | }; |
| 366 | 366 | |
| 367 | - $timer->start (); |
|
| 367 | + $timer->start(); |
|
| 368 | 368 | |
| 369 | 369 | return $timer; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | class Clipboard |
| 373 | 373 | { |
| 374 | - public static function getText () |
|
| 374 | + public static function getText() |
|
| 375 | 375 | { |
| 376 | - return (new WFClass ('System.Windows.Forms.Clipboard'))->getText (); |
|
| 376 | + return (new WFClass('System.Windows.Forms.Clipboard'))->getText(); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - public static function setText (string $text): void |
|
| 379 | + public static function setText(string $text): void |
|
| 380 | 380 | { |
| 381 | - (new WFClass ('System.Windows.Forms.Clipboard'))->setText ($text); |
|
| 381 | + (new WFClass('System.Windows.Forms.Clipboard'))->setText($text); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - public static function getFiles (): array |
|
| 384 | + public static function getFiles(): array |
|
| 385 | 385 | { |
| 386 | - return (new WFClass ('System.Windows.Forms.Clipboard'))->getFileDropList ()->list; |
|
| 386 | + return (new WFClass('System.Windows.Forms.Clipboard'))->getFileDropList()->list; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - public static function setFiles (array $files): void |
|
| 389 | + public static function setFiles(array $files): void |
|
| 390 | 390 | { |
| 391 | - $collection = new WFObject ('System.Collections.Specialized.StringCollection'); |
|
| 391 | + $collection = new WFObject('System.Collections.Specialized.StringCollection'); |
|
| 392 | 392 | |
| 393 | 393 | foreach ($files as $file) |
| 394 | - $collection->add ((string) $file); |
|
| 394 | + $collection->add((string) $file); |
|
| 395 | 395 | |
| 396 | - (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection); |
|
| 397 | - \VoidCore::removeObjects ($collection->selector); |
|
| 396 | + (new WFClass('System.Windows.Forms.Clipboard'))->setFileDropList($collection); |
|
| 397 | + \VoidCore::removeObjects($collection->selector); |
|
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | |
@@ -402,14 +402,13 @@ discard block |
||
| 402 | 402 | { |
| 403 | 403 | protected $cursor; |
| 404 | 404 | |
| 405 | - public function __construct (int $handle = null) |
|
| 405 | + public function __construct(int $handle = null) |
|
| 406 | 406 | { |
| 407 | 407 | $handle !== null ? |
| 408 | - $this->cursor = new WFObject ('System.Windows.Forms.Cursor', false, $handle) : |
|
| 409 | - $this->cursor = new WFClass ('System.Windows.Forms.Cursor'); |
|
| 408 | + $this->cursor = new WFObject('System.Windows.Forms.Cursor', false, $handle) : $this->cursor = new WFClass('System.Windows.Forms.Cursor'); |
|
| 410 | 409 | } |
| 411 | 410 | |
| 412 | - public function getPosition (): array |
|
| 411 | + public function getPosition(): array |
|
| 413 | 412 | { |
| 414 | 413 | $pos = $this->cursor->position; |
| 415 | 414 | |
@@ -420,22 +419,22 @@ discard block |
||
| 420 | 419 | } |
| 421 | 420 | } |
| 422 | 421 | |
| 423 | -function get_cursor_x (int $handle = null): int |
|
| 422 | +function get_cursor_x(int $handle = null): int |
|
| 424 | 423 | { |
| 425 | - return (new Cursor ($handle))->getPosition ()[0]; |
|
| 424 | + return (new Cursor($handle))->getPosition()[0]; |
|
| 426 | 425 | } |
| 427 | 426 | |
| 428 | -function get_cursor_y (int $handle = null): int |
|
| 427 | +function get_cursor_y(int $handle = null): int |
|
| 429 | 428 | { |
| 430 | - return (new Cursor ($handle))->getPosition ()[1]; |
|
| 429 | + return (new Cursor($handle))->getPosition()[1]; |
|
| 431 | 430 | } |
| 432 | 431 | |
| 433 | -function get_cursor_pos (int $handle = null): array |
|
| 432 | +function get_cursor_pos(int $handle = null): array |
|
| 434 | 433 | { |
| 435 | - return (new Cursor ($handle))->getPosition (); |
|
| 434 | + return (new Cursor($handle))->getPosition(); |
|
| 436 | 435 | } |
| 437 | 436 | |
| 438 | -set_error_handler (function ($no, $str, $file, $line) |
|
| 437 | +set_error_handler(function($no, $str, $file, $line) |
|
| 439 | 438 | { |
| 440 | 439 | // Мог ли я здесь сделать более адекватный код с использованием pow/sqrt? Да, мог |
| 441 | 440 | // Почему не сделал? Скорость важнее |
@@ -458,7 +457,7 @@ discard block |
||
| 458 | 457 | ]; |
| 459 | 458 | |
| 460 | 459 | if ($GLOBALS['__debug']['error_status']) |
| 461 | - message ([ |
|
| 460 | + message([ |
|
| 462 | 461 | 'type' => $errarr[$no], |
| 463 | 462 | 'text' => $str, |
| 464 | 463 | 'file' => $file, |
@@ -6,8 +6,9 @@ discard block |
||
| 6 | 6 | { |
| 7 | 7 | $oldStatus = $GLOBALS['__debug']['error_status']; |
| 8 | 8 | |
| 9 | - if ($status !== null) |
|
| 10 | - $GLOBALS['__debug']['error_status'] = $status; |
|
| 9 | + if ($status !== null) { |
|
| 10 | + $GLOBALS['__debug']['error_status'] = $status; |
|
| 11 | + } |
|
| 11 | 12 | |
| 12 | 13 | return $oldStatus; |
| 13 | 14 | } |
@@ -41,9 +42,7 @@ discard block |
||
| 41 | 42 | try |
| 42 | 43 | { |
| 43 | 44 | eval ('return; '. $code); |
| 44 | - } |
|
| 45 | - |
|
| 46 | - catch (\Throwable $e) |
|
| 45 | + } catch (\Throwable $e) |
|
| 47 | 46 | { |
| 48 | 47 | return [ |
| 49 | 48 | 'text' => $e->getMessage (), |
@@ -67,9 +66,7 @@ discard block |
||
| 67 | 66 | try |
| 68 | 67 | { |
| 69 | 68 | return \VoidCore::callMethod (\VoidCore::getClass ('System.Enum',''), ['parse', 'object'], \VoidCore::typeof ($baseType), $value, true); |
| 70 | - } |
|
| 71 | - |
|
| 72 | - catch (\WinFormsException $e) |
|
| 69 | + } catch (\WinFormsException $e) |
|
| 73 | 70 | { |
| 74 | 71 | return (new WFClass ($baseType))->$value; |
| 75 | 72 | } |
@@ -80,34 +77,39 @@ discard block |
||
| 80 | 77 | $array = (new WFClass ('System.Array', null)) |
| 81 | 78 | ->createInstance (\VoidCore::typeof ($type), $size = sizeof ($items)); |
| 82 | 79 | |
| 83 | - for ($i = 0; $i < $size; ++$i) |
|
| 84 | - $array[$i] = array_shift ($items); |
|
| 80 | + for ($i = 0; $i < $size; ++$i) { |
|
| 81 | + $array[$i] = array_shift ($items); |
|
| 82 | + } |
|
| 85 | 83 | |
| 86 | 84 | return $array; |
| 87 | 85 | } |
| 88 | 86 | |
| 89 | 87 | function dir_create (string $path, int $mode = 0777): void |
| 90 | 88 | { |
| 91 | - if (!is_dir ($path)) |
|
| 92 | - mkdir ($path, $mode, true); |
|
| 93 | -} |
|
| 89 | + if (!is_dir ($path)) { |
|
| 90 | + mkdir ($path, $mode, true); |
|
| 91 | + } |
|
| 92 | + } |
|
| 94 | 93 | |
| 95 | 94 | function dir_delete (string $path): bool |
| 96 | 95 | { |
| 97 | - if (!is_dir ($path)) |
|
| 98 | - return false; |
|
| 96 | + if (!is_dir ($path)) { |
|
| 97 | + return false; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
| 101 | - if (is_dir ($file = $path .'/'. $file)) |
|
| 100 | + foreach (array_slice (scandir ($path), 2) as $file) { |
|
| 101 | + if (is_dir ($file = $path .'/'. $file)) |
|
| 102 | 102 | { |
| 103 | 103 | dir_delete ($file); |
| 104 | + } |
|
| 104 | 105 | |
| 105 | - if (is_dir ($file)) |
|
| 106 | - rmdir ($file); |
|
| 106 | + if (is_dir ($file)) { |
|
| 107 | + rmdir ($file); |
|
| 108 | + } |
|
| 109 | + } else { |
|
| 110 | + unlink ($file); |
|
| 107 | 111 | } |
| 108 | 112 | |
| 109 | - else unlink ($file); |
|
| 110 | - |
|
| 111 | 113 | rmdir ($path); |
| 112 | 114 | |
| 113 | 115 | return true; |
@@ -121,17 +123,22 @@ discard block |
||
| 121 | 123 | |
| 122 | 124 | function dir_copy (string $from, string $to): bool |
| 123 | 125 | { |
| 124 | - if (!is_dir ($from)) |
|
| 125 | - return false; |
|
| 126 | + if (!is_dir ($from)) { |
|
| 127 | + return false; |
|
| 128 | + } |
|
| 126 | 129 | |
| 127 | - if (!is_dir ($to)) |
|
| 128 | - dir_create ($to); |
|
| 130 | + if (!is_dir ($to)) { |
|
| 131 | + dir_create ($to); |
|
| 132 | + } |
|
| 129 | 133 | |
| 130 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
| 131 | - if (is_dir ($f = $from .'/'. $file)) |
|
| 134 | + foreach (array_slice (scandir ($from), 2) as $file) { |
|
| 135 | + if (is_dir ($f = $from .'/'. $file)) |
|
| 132 | 136 | dir_copy ($f, $to .'/'. $file); |
| 137 | + } |
|
| 133 | 138 | |
| 134 | - else copy ($f, $to .'/'. $file); |
|
| 139 | + else { |
|
| 140 | + copy ($f, $to .'/'. $file); |
|
| 141 | + } |
|
| 135 | 142 | |
| 136 | 143 | return true; |
| 137 | 144 | } |
@@ -229,16 +236,16 @@ discard block |
||
| 229 | 236 | { |
| 230 | 237 | try |
| 231 | 238 | { |
| 232 | - if ($object->getType ()->isSubclassOf (\VoidCore::typeof ('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
| 233 | - continue; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - catch (\Exception $e) {} |
|
| 239 | + if ($object->getType ()->isSubclassOf (\VoidCore::typeof ('System.Windows.Forms.Form', 'System.Windows.Forms'))) { |
|
| 240 | + continue; |
|
| 241 | + } |
|
| 242 | + } catch (\Exception $e) {} |
|
| 237 | 243 | |
| 238 | 244 | \VoidCore::destructObject ($selector); |
| 239 | 245 | |
| 240 | - if (!\VoidCore::objectExists ($selector)) |
|
| 241 | - unset (self::$components[$selector]); |
|
| 246 | + if (!\VoidCore::objectExists ($selector)) { |
|
| 247 | + unset (self::$components[$selector]); |
|
| 248 | + } |
|
| 242 | 249 | } |
| 243 | 250 | } |
| 244 | 251 | } |
@@ -250,16 +257,15 @@ discard block |
||
| 250 | 257 | |
| 251 | 258 | function c ($name, bool $returnAllSimilarObjects = false) |
| 252 | 259 | { |
| 253 | - if (is_int ($name) && is_object ($object = _c ($name))) |
|
| 254 | - return $object; |
|
| 255 | - |
|
| 256 | - else |
|
| 260 | + if (is_int ($name) && is_object ($object = _c ($name))) { |
|
| 261 | + return $object; |
|
| 262 | + } else |
|
| 257 | 263 | { |
| 258 | 264 | $path = explode ('->', $name); |
| 259 | 265 | $similar = []; |
| 260 | 266 | |
| 261 | - foreach (Components::$components as $object) |
|
| 262 | - try |
|
| 267 | + foreach (Components::$components as $object) { |
|
| 268 | + try |
|
| 263 | 269 | { |
| 264 | 270 | if ($object->name == end ($path)) |
| 265 | 271 | { |
@@ -272,32 +278,30 @@ discard block |
||
| 272 | 278 | { |
| 273 | 279 | if ($returnAllSimilarObjects) |
| 274 | 280 | $similar[] = $object; |
| 281 | + } |
|
| 275 | 282 | |
| 276 | - else return $object; |
|
| 283 | + else { |
|
| 284 | + return $object; |
|
| 285 | + } |
|
| 286 | + } else { |
|
| 287 | + continue; |
|
| 277 | 288 | } |
| 278 | - |
|
| 279 | - else continue; |
|
| 289 | + } else { |
|
| 290 | + continue; |
|
| 280 | 291 | } |
| 281 | - |
|
| 282 | - else continue; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - catch (\Throwable $e) |
|
| 292 | + } catch (\Throwable $e) |
|
| 286 | 293 | { |
| 287 | 294 | continue; |
| 288 | - } |
|
| 289 | - |
|
| 290 | - else |
|
| 295 | + } else |
|
| 291 | 296 | { |
| 292 | - if ($returnAllSimilarObjects) |
|
| 293 | - $similar[] = $object; |
|
| 294 | - |
|
| 295 | - else return $object; |
|
| 297 | + if ($returnAllSimilarObjects) { |
|
| 298 | + $similar[] = $object; |
|
| 299 | + } else { |
|
| 300 | + return $object; |
|
| 301 | + } |
|
| 296 | 302 | } |
| 297 | 303 | } |
| 298 | - } |
|
| 299 | - |
|
| 300 | - catch (\Exception $e) |
|
| 304 | + } catch (\Exception $e) |
|
| 301 | 305 | { |
| 302 | 306 | continue; |
| 303 | 307 | } |
@@ -308,31 +312,32 @@ discard block |
||
| 308 | 312 | |
| 309 | 313 | if (is_array ($objects)) |
| 310 | 314 | { |
| 311 | - foreach ($objects as $id => $object) |
|
| 312 | - try |
|
| 315 | + foreach ($objects as $id => $object) { |
|
| 316 | + try |
|
| 313 | 317 | { |
| 314 | 318 | while (is_object ($parent = _c($object->parent->selector))) |
| 315 | 319 | { |
| 316 | 320 | if ($parent->getType ()->isSubclassOf (\VoidCore::typeof ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
| 317 | 321 | return $objects[$id]; |
| 322 | + } |
|
| 318 | 323 | |
| 319 | - else $object = $parent; |
|
| 324 | + else { |
|
| 325 | + $object = $parent; |
|
| 326 | + } |
|
| 320 | 327 | } |
| 321 | - } |
|
| 322 | - |
|
| 323 | - catch (\Throwable $e) |
|
| 328 | + } catch (\Throwable $e) |
|
| 324 | 329 | { |
| 325 | 330 | continue; |
| 326 | 331 | } |
| 327 | 332 | |
| 328 | 333 | return false; |
| 334 | + } else { |
|
| 335 | + return false; |
|
| 329 | 336 | } |
| 330 | - |
|
| 331 | - else return false; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - else return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
| 337 | + } else { |
|
| 338 | + return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
| 335 | 339 | $similar : false; |
| 340 | + } |
|
| 336 | 341 | } |
| 337 | 342 | } |
| 338 | 343 | |
@@ -390,8 +395,9 @@ discard block |
||
| 390 | 395 | { |
| 391 | 396 | $collection = new WFObject ('System.Collections.Specialized.StringCollection'); |
| 392 | 397 | |
| 393 | - foreach ($files as $file) |
|
| 394 | - $collection->add ((string) $file); |
|
| 398 | + foreach ($files as $file) { |
|
| 399 | + $collection->add ((string) $file); |
|
| 400 | + } |
|
| 395 | 401 | |
| 396 | 402 | (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection); |
| 397 | 403 | \VoidCore::removeObjects ($collection->selector); |
@@ -457,11 +463,12 @@ discard block |
||
| 457 | 463 | 16384 => 'E_USER_DEPRECATED' |
| 458 | 464 | ]; |
| 459 | 465 | |
| 460 | - if ($GLOBALS['__debug']['error_status']) |
|
| 461 | - message ([ |
|
| 466 | + if ($GLOBALS['__debug']['error_status']) { |
|
| 467 | + message ([ |
|
| 462 | 468 | 'type' => $errarr[$no], |
| 463 | 469 | 'text' => $str, |
| 464 | 470 | 'file' => $file, |
| 465 | 471 | 'line' => $line |
| 466 | 472 | ], 'PHP Script Error'); |
| 467 | -}); |
|
| 473 | + } |
|
| 474 | + }); |
|