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