@@ -48,10 +48,12 @@ |
||
| 48 | 48 | require 'components/Component.php'; |
| 49 | 49 | require 'components/Control.php'; |
| 50 | 50 | |
| 51 | -foreach (glob ('components/*/*.php') as $name) |
|
| 51 | +foreach (glob ('components/*/*.php') as $name) { |
|
| 52 | 52 | require $name; |
| 53 | +} |
|
| 53 | 54 | |
| 54 | -if (file_exists ('extensions')) |
|
| 55 | +if (file_exists ('extensions')) { |
|
| 55 | 56 | foreach (scandir ('extensions') as $ext) |
| 56 | 57 | if (file_exists ($ext = 'extensions/'. $ext .'/main.php')) |
| 57 | 58 | require $ext; |
| 59 | +} |
|
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | const ENGINE_VERSION = '4.0.0rc2'; |
| 35 | 35 | const ENGINE_DIR = __DIR__; |
| 36 | 36 | |
| 37 | -chdir (ENGINE_DIR); |
|
| 37 | +chdir(ENGINE_DIR); |
|
| 38 | 38 | |
| 39 | 39 | require 'common/Events.php'; |
| 40 | 40 | require 'common/EngineInterfaces.php'; |
@@ -43,15 +43,15 @@ discard block |
||
| 43 | 43 | require 'common/Components.php'; |
| 44 | 44 | require 'common/Others.php'; |
| 45 | 45 | |
| 46 | -define ('VoidEngine\CORE_VERSION', $APPLICATION->productVersion); |
|
| 46 | +define('VoidEngine\CORE_VERSION', $APPLICATION->productVersion); |
|
| 47 | 47 | |
| 48 | 48 | require 'components/Component.php'; |
| 49 | 49 | require 'components/Control.php'; |
| 50 | 50 | |
| 51 | -foreach (glob ('components/*/*.php') as $name) |
|
| 51 | +foreach (glob('components/*/*.php') as $name) |
|
| 52 | 52 | require $name; |
| 53 | 53 | |
| 54 | -if (file_exists ('extensions')) |
|
| 55 | - foreach (scandir ('extensions') as $ext) |
|
| 56 | - if (file_exists ($ext = 'extensions/'. $ext .'/main.php')) |
|
| 54 | +if (file_exists('extensions')) |
|
| 55 | + foreach (scandir('extensions') as $ext) |
|
| 56 | + if (file_exists($ext = 'extensions/'.$ext.'/main.php')) |
|
| 57 | 57 | require $ext; |
@@ -9,17 +9,17 @@ |
||
| 9 | 9 | public static function setEvent (int $selector, string $eventName, callable $function): void |
| 10 | 10 | { |
| 11 | 11 | VoidCore::setEvent ($selector, $eventName, function ($sender, ...$args) use ($function) |
| 12 | - { |
|
| 12 | + { |
|
| 13 | 13 | try |
| 14 | - { |
|
| 14 | + { |
|
| 15 | 15 | foreach ($args as $id => $arg) |
| 16 | 16 | $args[$id] = EngineAdditions::coupleSelector ($arg); |
| 17 | 17 | |
| 18 | 18 | return $function (_c ($sender) ?: new NetObject ($sender), ...$args); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - catch (\Throwable $e) |
|
| 22 | - { |
|
| 21 | + catch (\Throwable $e) |
|
| 22 | + { |
|
| 23 | 23 | message ([ |
| 24 | 24 | 'type' => get_class ($e), |
| 25 | 25 | 'text' => $e->getMessage (), |
@@ -6,34 +6,34 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Events |
| 8 | 8 | { |
| 9 | - public static function setEvent (int $selector, string $eventName, callable $function): void |
|
| 9 | + public static function setEvent(int $selector, string $eventName, callable $function): void |
|
| 10 | 10 | { |
| 11 | - VoidCore::setEvent ($selector, $eventName, function ($sender, ...$args) use ($function) |
|
| 11 | + VoidCore::setEvent($selector, $eventName, function($sender, ...$args) use ($function) |
|
| 12 | 12 | { |
| 13 | 13 | try |
| 14 | 14 | { |
| 15 | 15 | foreach ($args as $id => $arg) |
| 16 | - $args[$id] = EngineAdditions::coupleSelector ($arg); |
|
| 16 | + $args[$id] = EngineAdditions::coupleSelector($arg); |
|
| 17 | 17 | |
| 18 | - return $function (_c ($sender) ?: new NetObject ($sender), ...$args); |
|
| 18 | + return $function(_c($sender) ?: new NetObject($sender), ...$args); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | catch (\Throwable $e) |
| 22 | 22 | { |
| 23 | - message ([ |
|
| 24 | - 'type' => get_class ($e), |
|
| 25 | - 'text' => $e->getMessage (), |
|
| 26 | - 'file' => $e->getFile (), |
|
| 27 | - 'line' => $e->getLine (), |
|
| 28 | - 'code' => $e->getCode (), |
|
| 29 | - 'trace' => $e->getTraceAsString () |
|
| 23 | + message([ |
|
| 24 | + 'type' => get_class($e), |
|
| 25 | + 'text' => $e->getMessage(), |
|
| 26 | + 'file' => $e->getFile(), |
|
| 27 | + 'line' => $e->getLine(), |
|
| 28 | + 'code' => $e->getCode(), |
|
| 29 | + 'trace' => $e->getTraceAsString() |
|
| 30 | 30 | ], 'PHP Critical Error'); |
| 31 | 31 | } |
| 32 | 32 | }); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public static function removeEvent (int $selector, string $eventName): void |
|
| 35 | + public static function removeEvent(int $selector, string $eventName): void |
|
| 36 | 36 | { |
| 37 | - VoidCore::removeEvent ($selector, $eventName); |
|
| 37 | + VoidCore::removeEvent($selector, $eventName); |
|
| 38 | 38 | } |
| 39 | 39 | } |
@@ -12,13 +12,12 @@ |
||
| 12 | 12 | { |
| 13 | 13 | try |
| 14 | 14 | { |
| 15 | - foreach ($args as $id => $arg) |
|
| 16 | - $args[$id] = EngineAdditions::coupleSelector ($arg); |
|
| 15 | + foreach ($args as $id => $arg) { |
|
| 16 | + $args[$id] = EngineAdditions::coupleSelector ($arg); |
|
| 17 | + } |
|
| 17 | 18 | |
| 18 | 19 | return $function (_c ($sender) ?: new NetObject ($sender), ...$args); |
| 19 | - } |
|
| 20 | - |
|
| 21 | - catch (\Throwable $e) |
|
| 20 | + } catch (\Throwable $e) |
|
| 22 | 21 | { |
| 23 | 22 | message ([ |
| 24 | 23 | 'type' => get_class ($e), |
@@ -2,50 +2,50 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace VoidEngine; |
| 4 | 4 | |
| 5 | -register_superglobals ('APPLICATION', 'SCREEN'); |
|
| 5 | +register_superglobals('APPLICATION', 'SCREEN'); |
|
| 6 | 6 | |
| 7 | 7 | $APPLICATION = new class |
| 8 | 8 | { |
| 9 | 9 | public NetClass $application; |
| 10 | 10 | public string $executablePath; |
| 11 | 11 | |
| 12 | - public function __construct () |
|
| 12 | + public function __construct() |
|
| 13 | 13 | { |
| 14 | - $this->application = new NetClass ('System.Windows.Forms.Application'); |
|
| 14 | + $this->application = new NetClass('System.Windows.Forms.Application'); |
|
| 15 | 15 | $this->executablePath = $this->application->executablePath; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public function run ($form = null): void |
|
| 18 | + public function run($form = null): void |
|
| 19 | 19 | { |
| 20 | 20 | if ($form instanceof NetObject) |
| 21 | - $this->application->run ($form->selector); |
|
| 21 | + $this->application->run($form->selector); |
|
| 22 | 22 | |
| 23 | - elseif (is_int ($form) && \VoidCore::objectExists ($form)) |
|
| 24 | - $this->application->run ($form); |
|
| 23 | + elseif (is_int($form) && \VoidCore::objectExists($form)) |
|
| 24 | + $this->application->run($form); |
|
| 25 | 25 | |
| 26 | 26 | elseif ($form === null) |
| 27 | - $this->application->run (); |
|
| 27 | + $this->application->run(); |
|
| 28 | 28 | |
| 29 | - else throw new \Exception ('$form param must be instance of "VoidEngine\NetObject" ("VoidEngine\Form"), be null or object selector'); |
|
| 29 | + else throw new \Exception('$form param must be instance of "VoidEngine\NetObject" ("VoidEngine\Form"), be null or object selector'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function restart (): void |
|
| 32 | + public function restart(): void |
|
| 33 | 33 | { |
| 34 | - $this->application->restart (); |
|
| 35 | - $this->close (); |
|
| 34 | + $this->application->restart(); |
|
| 35 | + $this->close(); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function close (): void |
|
| 38 | + public function close(): void |
|
| 39 | 39 | { |
| 40 | - $this->application->exit (); |
|
| 40 | + $this->application->exit(); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function __call (string $name, array $args) |
|
| 43 | + public function __call(string $name, array $args) |
|
| 44 | 44 | { |
| 45 | - return $this->application->$name (...$args); |
|
| 45 | + return $this->application->$name(...$args); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function __get (string $name) |
|
| 48 | + public function __get(string $name) |
|
| 49 | 49 | { |
| 50 | 50 | return $this->application->$name; |
| 51 | 51 | } |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | public NetClass $screen; |
| 57 | 57 | |
| 58 | - public function __construct () |
|
| 58 | + public function __construct() |
|
| 59 | 59 | { |
| 60 | - $this->screen = new NetClass ('System.Windows.Forms.Screen'); |
|
| 60 | + $this->screen = new NetClass('System.Windows.Forms.Screen'); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function __get ($name) |
|
| 63 | + public function __get($name) |
|
| 64 | 64 | { |
| 65 | - switch (strtolower ($name)) |
|
| 65 | + switch (strtolower($name)) |
|
| 66 | 66 | { |
| 67 | 67 | case 'width': |
| 68 | 68 | case 'w': |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - public function __debugInfo (): array |
|
| 83 | + public function __debugInfo(): array |
|
| 84 | 84 | { |
| 85 | 85 | return [ |
| 86 | 86 | $this->w, |
@@ -17,16 +17,15 @@ |
||
| 17 | 17 | |
| 18 | 18 | public function run ($form = null): void |
| 19 | 19 | { |
| 20 | - if ($form instanceof NetObject) |
|
| 21 | - $this->application->run ($form->selector); |
|
| 22 | - |
|
| 23 | - elseif (is_int ($form) && \VoidCore::objectExists ($form)) |
|
| 24 | - $this->application->run ($form); |
|
| 25 | - |
|
| 26 | - elseif ($form === null) |
|
| 27 | - $this->application->run (); |
|
| 28 | - |
|
| 29 | - else throw new \Exception ('$form param must be instance of "VoidEngine\NetObject" ("VoidEngine\Form"), be null or object selector'); |
|
| 20 | + if ($form instanceof NetObject) { |
|
| 21 | + $this->application->run ($form->selector); |
|
| 22 | + } elseif (is_int ($form) && \VoidCore::objectExists ($form)) { |
|
| 23 | + $this->application->run ($form); |
|
| 24 | + } elseif ($form === null) { |
|
| 25 | + $this->application->run (); |
|
| 26 | + } else { |
|
| 27 | + throw new \Exception ('$form param must be instance of "VoidEngine\NetObject" ("VoidEngine\Form"), be null or object selector'); |
|
| 28 | + } |
|
| 30 | 29 | } |
| 31 | 30 | |
| 32 | 31 | public function restart (): void |
@@ -6,61 +6,61 @@ |
||
| 6 | 6 | { |
| 7 | 7 | protected static array $objects = []; |
| 8 | 8 | |
| 9 | - public static function add (NetObject $object): void |
|
| 9 | + public static function add(NetObject $object): void |
|
| 10 | 10 | { |
| 11 | - self::$objects[$object->selector] = \WeakReference::create ($object); |
|
| 11 | + self::$objects[$object->selector] = \WeakReference::create($object); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public static function get (int $selector): ?NetObject |
|
| 14 | + public static function get(int $selector): ?NetObject |
|
| 15 | 15 | { |
| 16 | 16 | if (!isset (self::$objects[$selector])) |
| 17 | 17 | return null; |
| 18 | 18 | |
| 19 | - $object = self::$objects[$selector]->get (); |
|
| 19 | + $object = self::$objects[$selector]->get(); |
|
| 20 | 20 | |
| 21 | 21 | if ($object === null) |
| 22 | - self::remove ($selector); |
|
| 22 | + self::remove($selector); |
|
| 23 | 23 | |
| 24 | 24 | return $object; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public static function exists (int $selector): bool |
|
| 27 | + public static function exists(int $selector): bool |
|
| 28 | 28 | { |
| 29 | 29 | return isset (self::$objects[$selector]); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public static function getObjects (): array |
|
| 32 | + public static function getObjects(): array |
|
| 33 | 33 | { |
| 34 | 34 | return self::$objects; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public static function remove (int $selector): void |
|
| 37 | + public static function remove(int $selector): void |
|
| 38 | 38 | { |
| 39 | 39 | unset (self::$objects[$selector]); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public static function clean (): void |
|
| 42 | + public static function clean(): void |
|
| 43 | 43 | { |
| 44 | 44 | foreach (self::$objects as $selector => $reference) |
| 45 | - if ($reference->get () === null) |
|
| 45 | + if ($reference->get() === null) |
|
| 46 | 46 | unset (self::$objects[$selector]); |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | -function _c (int $selector): ?NetObject |
|
| 50 | +function _c(int $selector): ?NetObject |
|
| 51 | 51 | { |
| 52 | - return Components::get ($selector); |
|
| 52 | + return Components::get($selector); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // TODO: поддержка многоуровневых ссылок вида родитель->родитель->объект |
| 56 | -function c (string $name): ?NetObject |
|
| 56 | +function c(string $name): ?NetObject |
|
| 57 | 57 | { |
| 58 | 58 | if (($object = _c($name)) !== null) |
| 59 | 59 | return $object; |
| 60 | 60 | |
| 61 | - foreach (Components::getObjects () as $selector => $reference) |
|
| 61 | + foreach (Components::getObjects() as $selector => $reference) |
|
| 62 | 62 | { |
| 63 | - $object = $reference->get (); |
|
| 63 | + $object = $reference->get(); |
|
| 64 | 64 | |
| 65 | 65 | if ($object === null) |
| 66 | 66 | continue; |
@@ -13,13 +13,15 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | public static function get (int $selector): ?NetObject |
| 15 | 15 | { |
| 16 | - if (!isset (self::$objects[$selector])) |
|
| 17 | - return null; |
|
| 16 | + if (!isset (self::$objects[$selector])) { |
|
| 17 | + return null; |
|
| 18 | + } |
|
| 18 | 19 | |
| 19 | 20 | $object = self::$objects[$selector]->get (); |
| 20 | 21 | |
| 21 | - if ($object === null) |
|
| 22 | - self::remove ($selector); |
|
| 22 | + if ($object === null) { |
|
| 23 | + self::remove ($selector); |
|
| 24 | + } |
|
| 23 | 25 | |
| 24 | 26 | return $object; |
| 25 | 27 | } |
@@ -41,9 +43,10 @@ discard block |
||
| 41 | 43 | |
| 42 | 44 | public static function clean (): void |
| 43 | 45 | { |
| 44 | - foreach (self::$objects as $selector => $reference) |
|
| 45 | - if ($reference->get () === null) |
|
| 46 | + foreach (self::$objects as $selector => $reference) { |
|
| 47 | + if ($reference->get () === null) |
|
| 46 | 48 | unset (self::$objects[$selector]); |
| 49 | + } |
|
| 47 | 50 | } |
| 48 | 51 | } |
| 49 | 52 | |
@@ -55,23 +58,24 @@ discard block |
||
| 55 | 58 | // TODO: поддержка многоуровневых ссылок вида родитель->родитель->объект |
| 56 | 59 | function c (string $name): ?NetObject |
| 57 | 60 | { |
| 58 | - if (($object = _c($name)) !== null) |
|
| 59 | - return $object; |
|
| 61 | + if (($object = _c($name)) !== null) { |
|
| 62 | + return $object; |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | foreach (Components::getObjects () as $selector => $reference) |
| 62 | 66 | { |
| 63 | 67 | $object = $reference->get (); |
| 64 | 68 | |
| 65 | - if ($object === null) |
|
| 66 | - continue; |
|
| 69 | + if ($object === null) { |
|
| 70 | + continue; |
|
| 71 | + } |
|
| 67 | 72 | |
| 68 | 73 | try |
| 69 | 74 | { |
| 70 | - if ($object->name == $name) |
|
| 71 | - return $object; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - catch (\WinformsException $e) {} |
|
| 75 | + if ($object->name == $name) { |
|
| 76 | + return $object; |
|
| 77 | + } |
|
| 78 | + } catch (\WinformsException $e) {} |
|
| 75 | 79 | } |
| 76 | 80 | |
| 77 | 81 | return null; |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | function pre (...$args): void |
| 135 | 135 | { |
| 136 | - message (sizeof ($args) < 2 ? current ($args) : $args); |
|
| 136 | + message (sizeof ($args) < 2 ? current ($args) : $args); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | function messageBox (string $message, string $caption = '', ...$args): int |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $timer->interval = $interval; |
| 153 | 153 | $timer->tickEvent = fn ($self) => $function ($self); |
| 154 | 154 | |
| 155 | - $timer->start (); |
|
| 155 | + $timer->start (); |
|
| 156 | 156 | |
| 157 | 157 | return $timer; |
| 158 | 158 | } |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | $function ($self); |
| 169 | 169 | }; |
| 170 | 170 | |
| 171 | - $timer->start (); |
|
| 171 | + $timer->start (); |
|
| 172 | 172 | |
| 173 | - return $timer; |
|
| 173 | + return $timer; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | set_error_handler (function ($no, $str, $file, $line) |
@@ -4,176 +4,176 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use VoidCore; |
| 6 | 6 | |
| 7 | -function dn (...$args): NetObject |
|
| 7 | +function dn(...$args): NetObject |
|
| 8 | 8 | { |
| 9 | 9 | try |
| 10 | 10 | { |
| 11 | - $object = new NetObject (...$args); |
|
| 11 | + $object = new NetObject(...$args); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | catch (\WinformsException $e) |
| 15 | 15 | { |
| 16 | - if (VoidCore::callMethod ($e->getNetException (), 'ToString') == 'System.MemberAccessException') |
|
| 16 | + if (VoidCore::callMethod($e->getNetException(), 'ToString') == 'System.MemberAccessException') |
|
| 17 | 17 | throw $e; |
| 18 | 18 | |
| 19 | - $object = new NetClass (...$args); |
|
| 19 | + $object = new NetClass(...$args); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | return $object; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -function thread (callable $callable): NetObject |
|
| 25 | +function thread(callable $callable): NetObject |
|
| 26 | 26 | { |
| 27 | - return new NetObject (VoidCore::createThread ($callable)); |
|
| 27 | + return new NetObject(VoidCore::createThread($callable)); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | -function enum (string $baseType, string $value) |
|
| 30 | +function enum(string $baseType, string $value) |
|
| 31 | 31 | { |
| 32 | 32 | try |
| 33 | 33 | { |
| 34 | - return VoidCore::callMethod (VoidCore::getClass ('System.Enum'), ['parse', VC_OBJECT], VoidCore::typeof ($baseType), $value, true); |
|
| 34 | + return VoidCore::callMethod(VoidCore::getClass('System.Enum'), ['parse', VC_OBJECT], VoidCore::typeof($baseType), $value, true); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | catch (\WinformsException $e) |
| 38 | 38 | { |
| 39 | - return (new NetClass ($baseType))->$value; |
|
| 39 | + return (new NetClass($baseType))->$value; |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -function getNetArray (string $type, array $items = []): NetObject |
|
| 43 | +function getNetArray(string $type, array $items = []): NetObject |
|
| 44 | 44 | { |
| 45 | - $array = (new NetClass ('System.Array')) |
|
| 46 | - ->createInstance (VoidCore::typeof ($type), $size = sizeof ($items)); |
|
| 45 | + $array = (new NetClass('System.Array')) |
|
| 46 | + ->createInstance(VoidCore::typeof($type), $size = sizeof($items)); |
|
| 47 | 47 | |
| 48 | 48 | for ($i = 0; $i < $size; ++$i) |
| 49 | - $array[$i] = array_shift ($items); |
|
| 49 | + $array[$i] = array_shift($items); |
|
| 50 | 50 | |
| 51 | 51 | return $array; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | -function dir_create (string $path, int $mode = 0777): void |
|
| 54 | +function dir_create(string $path, int $mode = 0777): void |
|
| 55 | 55 | { |
| 56 | - if (!is_dir ($path)) |
|
| 57 | - mkdir ($path, $mode, true); |
|
| 56 | + if (!is_dir($path)) |
|
| 57 | + mkdir($path, $mode, true); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | -function dir_delete (string $path): bool |
|
| 60 | +function dir_delete(string $path): bool |
|
| 61 | 61 | { |
| 62 | - if (!is_dir ($path)) |
|
| 62 | + if (!is_dir($path)) |
|
| 63 | 63 | return false; |
| 64 | 64 | |
| 65 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
| 66 | - if (is_dir ($file = $path .'/'. $file)) |
|
| 65 | + foreach (array_slice(scandir($path), 2) as $file) |
|
| 66 | + if (is_dir($file = $path.'/'.$file)) |
|
| 67 | 67 | { |
| 68 | - dir_delete ($file); |
|
| 68 | + dir_delete($file); |
|
| 69 | 69 | |
| 70 | - if (is_dir ($file)) |
|
| 71 | - rmdir ($file); |
|
| 70 | + if (is_dir($file)) |
|
| 71 | + rmdir($file); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - else unlink ($file); |
|
| 74 | + else unlink($file); |
|
| 75 | 75 | |
| 76 | - rmdir ($path); |
|
| 76 | + rmdir($path); |
|
| 77 | 77 | |
| 78 | 78 | return true; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | -function dir_clean (string $path): void |
|
| 81 | +function dir_clean(string $path): void |
|
| 82 | 82 | { |
| 83 | - dir_delete ($path); |
|
| 84 | - dir_create ($path); |
|
| 83 | + dir_delete($path); |
|
| 84 | + dir_create($path); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | -function dir_copy (string $from, string $to): bool |
|
| 87 | +function dir_copy(string $from, string $to): bool |
|
| 88 | 88 | { |
| 89 | - if (!is_dir ($from)) |
|
| 89 | + if (!is_dir($from)) |
|
| 90 | 90 | return false; |
| 91 | 91 | |
| 92 | - if (!is_dir ($to)) |
|
| 93 | - dir_create ($to); |
|
| 92 | + if (!is_dir($to)) |
|
| 93 | + dir_create($to); |
|
| 94 | 94 | |
| 95 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
| 96 | - if (is_dir ($f = $from .'/'. $file)) |
|
| 97 | - dir_copy ($f, $to .'/'. $file); |
|
| 95 | + foreach (array_slice(scandir($from), 2) as $file) |
|
| 96 | + if (is_dir($f = $from.'/'.$file)) |
|
| 97 | + dir_copy($f, $to.'/'.$file); |
|
| 98 | 98 | |
| 99 | - else copy ($f, $to .'/'. $file); |
|
| 99 | + else copy($f, $to.'/'.$file); |
|
| 100 | 100 | |
| 101 | 101 | return true; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -function argb (string $color) |
|
| 104 | +function argb(string $color) |
|
| 105 | 105 | { |
| 106 | - return (new NetClass ('System.Drawing.ColorTranslator'))->fromHtml ($color); |
|
| 106 | + return (new NetClass('System.Drawing.ColorTranslator'))->fromHtml($color); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | -function replaceSl (string $string): string |
|
| 109 | +function replaceSl(string $string): string |
|
| 110 | 110 | { |
| 111 | - return str_replace ('\\', '/', $string); |
|
| 111 | + return str_replace('\\', '/', $string); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | -function replaceSr (string $string): string |
|
| 114 | +function replaceSr(string $string): string |
|
| 115 | 115 | { |
| 116 | - return str_replace ('/', '\\', $string); |
|
| 116 | + return str_replace('/', '\\', $string); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | -function basenameNoExt (string $path): string |
|
| 119 | +function basenameNoExt(string $path): string |
|
| 120 | 120 | { |
| 121 | - return pathinfo ($path, PATHINFO_FILENAME); |
|
| 121 | + return pathinfo($path, PATHINFO_FILENAME); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | -function file_ext (string $path): string |
|
| 124 | +function file_ext(string $path): string |
|
| 125 | 125 | { |
| 126 | - return strtolower (pathinfo ($path, PATHINFO_EXTENSION)); |
|
| 126 | + return strtolower(pathinfo($path, PATHINFO_EXTENSION)); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | -function filepathNoExt (string $path): string |
|
| 129 | +function filepathNoExt(string $path): string |
|
| 130 | 130 | { |
| 131 | - return dirname ($path) .'/'. basenameNoExt ($path); |
|
| 131 | + return dirname($path).'/'.basenameNoExt($path); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | -function pre (...$args): void |
|
| 134 | +function pre(...$args): void |
|
| 135 | 135 | { |
| 136 | - message (sizeof ($args) < 2 ? current ($args) : $args); |
|
| 136 | + message(sizeof($args) < 2 ? current ($args) : $args); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | -function messageBox (string $message, string $caption = '', ...$args): int |
|
| 139 | +function messageBox(string $message, string $caption = '', ...$args): int |
|
| 140 | 140 | { |
| 141 | - return (new MessageBox)->show ($message, $caption, ...$args); |
|
| 141 | + return (new MessageBox)->show($message, $caption, ...$args); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | -function run (string $path, ...$args) |
|
| 144 | +function run(string $path, ...$args) |
|
| 145 | 145 | { |
| 146 | - return (new Process)->start ($path, ...$args); |
|
| 146 | + return (new Process)->start($path, ...$args); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | -function setTimer (int $interval, callable $function): Timer |
|
| 149 | +function setTimer(int $interval, callable $function): Timer |
|
| 150 | 150 | { |
| 151 | 151 | $timer = new Timer; |
| 152 | 152 | $timer->interval = $interval; |
| 153 | - $timer->tickEvent = fn ($self) => $function ($self); |
|
| 153 | + $timer->tickEvent = fn($self) => $function($self); |
|
| 154 | 154 | |
| 155 | - $timer->start (); |
|
| 155 | + $timer->start(); |
|
| 156 | 156 | |
| 157 | 157 | return $timer; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | -function setTimeout (int $timeout, callable $function): Timer |
|
| 160 | +function setTimeout(int $timeout, callable $function): Timer |
|
| 161 | 161 | { |
| 162 | 162 | $timer = new Timer; |
| 163 | 163 | $timer->interval = $timeout; |
| 164 | - $timer->tickEvent = function ($self) use ($function) |
|
| 164 | + $timer->tickEvent = function($self) use ($function) |
|
| 165 | 165 | { |
| 166 | - $self->stop (); |
|
| 166 | + $self->stop(); |
|
| 167 | 167 | |
| 168 | - $function ($self); |
|
| 168 | + $function($self); |
|
| 169 | 169 | }; |
| 170 | 170 | |
| 171 | - $timer->start (); |
|
| 171 | + $timer->start(); |
|
| 172 | 172 | |
| 173 | 173 | return $timer; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | -set_error_handler (function ($no, $str, $file, $line) |
|
| 176 | +set_error_handler(function($no, $str, $file, $line) |
|
| 177 | 177 | { |
| 178 | 178 | // Мог ли я здесь сделать более адекватный код с использованием pow/sqrt? Да, мог |
| 179 | 179 | // Почему не сделал? Скорость важнее |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | 16384 => 'E_USER_DEPRECATED' |
| 196 | 196 | ]; |
| 197 | 197 | |
| 198 | - message ([ |
|
| 198 | + message([ |
|
| 199 | 199 | 'type' => $errarr[$no], |
| 200 | 200 | 'text' => $str, |
| 201 | 201 | 'file' => $file, |
@@ -9,12 +9,11 @@ discard block |
||
| 9 | 9 | try |
| 10 | 10 | { |
| 11 | 11 | $object = new NetObject (...$args); |
| 12 | - } |
|
| 13 | - |
|
| 14 | - catch (\WinformsException $e) |
|
| 12 | + } catch (\WinformsException $e) |
|
| 15 | 13 | { |
| 16 | - if (VoidCore::callMethod ($e->getNetException (), 'ToString') == 'System.MemberAccessException') |
|
| 17 | - throw $e; |
|
| 14 | + if (VoidCore::callMethod ($e->getNetException (), 'ToString') == 'System.MemberAccessException') { |
|
| 15 | + throw $e; |
|
| 16 | + } |
|
| 18 | 17 | |
| 19 | 18 | $object = new NetClass (...$args); |
| 20 | 19 | } |
@@ -32,9 +31,7 @@ discard block |
||
| 32 | 31 | try |
| 33 | 32 | { |
| 34 | 33 | return VoidCore::callMethod (VoidCore::getClass ('System.Enum'), ['parse', VC_OBJECT], VoidCore::typeof ($baseType), $value, true); |
| 35 | - } |
|
| 36 | - |
|
| 37 | - catch (\WinformsException $e) |
|
| 34 | + } catch (\WinformsException $e) |
|
| 38 | 35 | { |
| 39 | 36 | return (new NetClass ($baseType))->$value; |
| 40 | 37 | } |
@@ -45,34 +42,39 @@ discard block |
||
| 45 | 42 | $array = (new NetClass ('System.Array')) |
| 46 | 43 | ->createInstance (VoidCore::typeof ($type), $size = sizeof ($items)); |
| 47 | 44 | |
| 48 | - for ($i = 0; $i < $size; ++$i) |
|
| 49 | - $array[$i] = array_shift ($items); |
|
| 45 | + for ($i = 0; $i < $size; ++$i) { |
|
| 46 | + $array[$i] = array_shift ($items); |
|
| 47 | + } |
|
| 50 | 48 | |
| 51 | 49 | return $array; |
| 52 | 50 | } |
| 53 | 51 | |
| 54 | 52 | function dir_create (string $path, int $mode = 0777): void |
| 55 | 53 | { |
| 56 | - if (!is_dir ($path)) |
|
| 57 | - mkdir ($path, $mode, true); |
|
| 58 | -} |
|
| 54 | + if (!is_dir ($path)) { |
|
| 55 | + mkdir ($path, $mode, true); |
|
| 56 | + } |
|
| 57 | + } |
|
| 59 | 58 | |
| 60 | 59 | function dir_delete (string $path): bool |
| 61 | 60 | { |
| 62 | - if (!is_dir ($path)) |
|
| 63 | - return false; |
|
| 61 | + if (!is_dir ($path)) { |
|
| 62 | + return false; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
| 66 | - if (is_dir ($file = $path .'/'. $file)) |
|
| 65 | + foreach (array_slice (scandir ($path), 2) as $file) { |
|
| 66 | + if (is_dir ($file = $path .'/'. $file)) |
|
| 67 | 67 | { |
| 68 | 68 | dir_delete ($file); |
| 69 | + } |
|
| 69 | 70 | |
| 70 | - if (is_dir ($file)) |
|
| 71 | - rmdir ($file); |
|
| 71 | + if (is_dir ($file)) { |
|
| 72 | + rmdir ($file); |
|
| 73 | + } |
|
| 74 | + } else { |
|
| 75 | + unlink ($file); |
|
| 72 | 76 | } |
| 73 | 77 | |
| 74 | - else unlink ($file); |
|
| 75 | - |
|
| 76 | 78 | rmdir ($path); |
| 77 | 79 | |
| 78 | 80 | return true; |
@@ -86,17 +88,22 @@ discard block |
||
| 86 | 88 | |
| 87 | 89 | function dir_copy (string $from, string $to): bool |
| 88 | 90 | { |
| 89 | - if (!is_dir ($from)) |
|
| 90 | - return false; |
|
| 91 | + if (!is_dir ($from)) { |
|
| 92 | + return false; |
|
| 93 | + } |
|
| 91 | 94 | |
| 92 | - if (!is_dir ($to)) |
|
| 93 | - dir_create ($to); |
|
| 95 | + if (!is_dir ($to)) { |
|
| 96 | + dir_create ($to); |
|
| 97 | + } |
|
| 94 | 98 | |
| 95 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
| 96 | - if (is_dir ($f = $from .'/'. $file)) |
|
| 99 | + foreach (array_slice (scandir ($from), 2) as $file) { |
|
| 100 | + if (is_dir ($f = $from .'/'. $file)) |
|
| 97 | 101 | dir_copy ($f, $to .'/'. $file); |
| 102 | + } |
|
| 98 | 103 | |
| 99 | - else copy ($f, $to .'/'. $file); |
|
| 104 | + else { |
|
| 105 | + copy ($f, $to .'/'. $file); |
|
| 106 | + } |
|
| 100 | 107 | |
| 101 | 108 | return true; |
| 102 | 109 | } |
@@ -5,11 +5,11 @@ |
||
| 5 | 5 | class Label extends Control |
| 6 | 6 | { |
| 7 | 7 | protected ?string $classname = 'System.Windows.Forms.Label'; |
| 8 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 8 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | class LinkLabel extends Control |
| 12 | 12 | { |
| 13 | 13 | protected ?string $classname = 'System.Windows.Forms.LinkLabel'; |
| 14 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 14 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 15 | 15 | } |
@@ -5,11 +5,11 @@ |
||
| 5 | 5 | class Label extends Control |
| 6 | 6 | { |
| 7 | 7 | protected ?string $classname = 'System.Windows.Forms.Label'; |
| 8 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 8 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | class LinkLabel extends Control |
| 12 | 12 | { |
| 13 | 13 | protected ?string $classname = 'System.Windows.Forms.LinkLabel'; |
| 14 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 14 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 15 | 15 | } |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | class ProgressBar extends Control |
| 6 | 6 | { |
| 7 | 7 | protected ?string $classname = 'System.Windows.Forms.ProgressBar'; |
| 8 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 8 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 9 | 9 | |
| 10 | 10 | public function get_max () |
| 11 | 11 | { |
@@ -5,35 +5,35 @@ |
||
| 5 | 5 | class ProgressBar extends Control |
| 6 | 6 | { |
| 7 | 7 | protected ?string $classname = 'System.Windows.Forms.ProgressBar'; |
| 8 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 8 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 9 | 9 | |
| 10 | - public function get_max () |
|
| 10 | + public function get_max() |
|
| 11 | 11 | { |
| 12 | - return $this->getProperty ('Maximum'); |
|
| 12 | + return $this->getProperty('Maximum'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function set_max (int $max) |
|
| 15 | + public function set_max(int $max) |
|
| 16 | 16 | { |
| 17 | - $this->setProperty ('Maximum', $max); |
|
| 17 | + $this->setProperty('Maximum', $max); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function get_min () |
|
| 20 | + public function get_min() |
|
| 21 | 21 | { |
| 22 | - return $this->getProperty ('Minimum'); |
|
| 22 | + return $this->getProperty('Minimum'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function set_min (int $min) |
|
| 25 | + public function set_min(int $min) |
|
| 26 | 26 | { |
| 27 | - $this->setProperty ('Minimum', $min); |
|
| 27 | + $this->setProperty('Minimum', $min); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function get_position () |
|
| 30 | + public function get_position() |
|
| 31 | 31 | { |
| 32 | - return $this->getProperty ('Value'); |
|
| 32 | + return $this->getProperty('Value'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function set_position (int $position) |
|
| 35 | + public function set_position(int $position) |
|
| 36 | 36 | { |
| 37 | - $this->setProperty ('Value', $position); |
|
| 37 | + $this->setProperty('Value', $position); |
|
| 38 | 38 | } |
| 39 | 39 | } |
@@ -5,5 +5,5 @@ |
||
| 5 | 5 | class Panel extends Control |
| 6 | 6 | { |
| 7 | 7 | protected ?string $classname = 'System.Windows.Forms.Panel'; |
| 8 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 8 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 9 | 9 | } |
@@ -5,5 +5,5 @@ |
||
| 5 | 5 | class Panel extends Control |
| 6 | 6 | { |
| 7 | 7 | protected ?string $classname = 'System.Windows.Forms.Panel'; |
| 8 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 8 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 9 | 9 | } |
@@ -5,11 +5,11 @@ |
||
| 5 | 5 | class ToolStrip extends Control |
| 6 | 6 | { |
| 7 | 7 | protected ?string $classname = 'System.Windows.Forms.ToolStrip'; |
| 8 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 8 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | class ToolStripStatusLabel extends Control |
| 12 | 12 | { |
| 13 | 13 | protected ?string $classname = 'System.Windows.Forms.ToolStripStatusLabel'; |
| 14 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 14 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 15 | 15 | } |
@@ -5,11 +5,11 @@ |
||
| 5 | 5 | class ToolStrip extends Control |
| 6 | 6 | { |
| 7 | 7 | protected ?string $classname = 'System.Windows.Forms.ToolStrip'; |
| 8 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 8 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | class ToolStripStatusLabel extends Control |
| 12 | 12 | { |
| 13 | 13 | protected ?string $classname = 'System.Windows.Forms.ToolStripStatusLabel'; |
| 14 | - protected ?string $assembly = 'System.Windows.Forms'; |
|
| 14 | + protected ?string $assembly = 'System.Windows.Forms'; |
|
| 15 | 15 | } |