@@ -10,44 +10,44 @@ discard block |
||
| 10 | 10 | protected ?string $name = null; |
| 11 | 11 | // protected bool $isCollection = false; |
| 12 | 12 | |
| 13 | - public function __construct ($name, $assembly = false, ...$args) |
|
| 13 | + public function __construct($name, $assembly = false, ...$args) |
|
| 14 | 14 | { |
| 15 | 15 | foreach ($args as $id => $arg) |
| 16 | - $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
| 16 | + $args[$id] = EngineAdditions::uncoupleSelector($arg); |
|
| 17 | 17 | |
| 18 | - if (is_int ($name) && VoidCore::objectExists ($name)) |
|
| 18 | + if (is_int($name) && VoidCore::objectExists($name)) |
|
| 19 | 19 | $this->selector = $name; |
| 20 | 20 | |
| 21 | - elseif (is_string ($name)) |
|
| 22 | - $this->selector = VoidCore::createObject ($name, $assembly, ...$args); |
|
| 21 | + elseif (is_string($name)) |
|
| 22 | + $this->selector = VoidCore::createObject($name, $assembly, ...$args); |
|
| 23 | 23 | |
| 24 | - else throw new \Exception ('Incorrect params passed'); |
|
| 24 | + else throw new \Exception('Incorrect params passed'); |
|
| 25 | 25 | |
| 26 | 26 | /*$this->isCollection = $this->getType () |
| 27 | 27 | ->isSubclassOf (VoidCore::typeof ('System.Collectons.Generic.ICollection'));*/ |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function dispose (): void |
|
| 30 | + public function dispose(): void |
|
| 31 | 31 | { |
| 32 | - VoidCore::removeObjects ($this->selector); |
|
| 32 | + VoidCore::removeObjects($this->selector); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | # Основные магические методы |
| 36 | 36 | |
| 37 | - public function __get (string $name) |
|
| 37 | + public function __get(string $name) |
|
| 38 | 38 | { |
| 39 | - switch (strtolower ($name)) |
|
| 39 | + switch (strtolower($name)) |
|
| 40 | 40 | { |
| 41 | 41 | case 'count': |
| 42 | 42 | case 'length': |
| 43 | 43 | try |
| 44 | 44 | { |
| 45 | - return $this->getProperty ('Count'); |
|
| 45 | + return $this->getProperty('Count'); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | catch (\WinformsException $e) |
| 49 | 49 | { |
| 50 | - return $this->getProperty ('Length'); |
|
| 50 | + return $this->getProperty('Length'); |
|
| 51 | 51 | } |
| 52 | 52 | break; |
| 53 | 53 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $list = []; |
| 57 | 57 | |
| 58 | 58 | for ($i = 0; $i < $size; ++$i) |
| 59 | - $list[] = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $i)); |
|
| 59 | + $list[] = EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $i)); |
|
| 60 | 60 | |
| 61 | 61 | return $list; |
| 62 | 62 | break; |
@@ -68,93 +68,91 @@ discard block |
||
| 68 | 68 | for ($i = 0; $i < $size; ++$i) |
| 69 | 69 | try |
| 70 | 70 | { |
| 71 | - $names[] = VoidCore::getProperty (VoidCore::getArrayValue ($this->selector, [$i, VC_OBJECT]), 'Text'); |
|
| 71 | + $names[] = VoidCore::getProperty(VoidCore::getArrayValue($this->selector, [$i, VC_OBJECT]), 'Text'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | catch (\WinformsException $e) |
| 75 | 75 | { |
| 76 | - $names[] = VoidCore::getArrayValue ($this->selector, [$i, VC_STRING]); |
|
| 76 | + $names[] = VoidCore::getArrayValue($this->selector, [$i, VC_STRING]); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | return $names; |
| 80 | 80 | break; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if (method_exists ($this, $method = 'get_'. $name)) |
|
| 84 | - return $this->$method (); |
|
| 83 | + if (method_exists($this, $method = 'get_'.$name)) |
|
| 84 | + return $this->$method(); |
|
| 85 | 85 | |
| 86 | 86 | return isset ($this->$name) ? |
| 87 | - $this->$name : EngineAdditions::coupleSelector ($this->getProperty ($name)); |
|
| 87 | + $this->$name : EngineAdditions::coupleSelector($this->getProperty($name)); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function __set (string $name, $value): void |
|
| 90 | + public function __set(string $name, $value): void |
|
| 91 | 91 | { |
| 92 | - if (substr ($name, -5) == 'Event') |
|
| 93 | - Events::setEvent ($this->selector, substr ($name, 0, -5), $value); |
|
| 92 | + if (substr($name, -5) == 'Event') |
|
| 93 | + Events::setEvent($this->selector, substr($name, 0, -5), $value); |
|
| 94 | 94 | |
| 95 | - elseif (method_exists ($this, $method = 'set_'. $name)) |
|
| 96 | - $this->$method ($value); |
|
| 95 | + elseif (method_exists($this, $method = 'set_'.$name)) |
|
| 96 | + $this->$method($value); |
|
| 97 | 97 | |
| 98 | - else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
| 98 | + else $this->setProperty($name, EngineAdditions::uncoupleSelector($value)); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function __call (string $name, array $args) |
|
| 101 | + public function __call(string $name, array $args) |
|
| 102 | 102 | { |
| 103 | - return EngineAdditions::coupleSelector ($this->callMethod ($name, |
|
| 104 | - array_map ('VoidEngine\\EngineAdditions::uncoupleSelector', $args))); |
|
| 103 | + return EngineAdditions::coupleSelector($this->callMethod($name, |
|
| 104 | + array_map('VoidEngine\\EngineAdditions::uncoupleSelector', $args))); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | # Управление VoidCore |
| 108 | 108 | |
| 109 | - protected function getProperty ($name) |
|
| 109 | + protected function getProperty($name) |
|
| 110 | 110 | { |
| 111 | - return VoidCore::getProperty ($this->selector, $name); |
|
| 111 | + return VoidCore::getProperty($this->selector, $name); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - protected function setProperty (string $name, $value): void |
|
| 114 | + protected function setProperty(string $name, $value): void |
|
| 115 | 115 | { |
| 116 | - VoidCore::setProperty ($this->selector, $name, $value); |
|
| 116 | + VoidCore::setProperty($this->selector, $name, $value); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - protected function callMethod (string $name, array $args = []) |
|
| 119 | + protected function callMethod(string $name, array $args = []) |
|
| 120 | 120 | { |
| 121 | - return VoidCore::callMethod ($this->selector, $name, ...$args); |
|
| 121 | + return VoidCore::callMethod($this->selector, $name, ...$args); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | # ArrayAccess |
| 125 | 125 | |
| 126 | - public function offsetSet ($index, $value) |
|
| 126 | + public function offsetSet($index, $value) |
|
| 127 | 127 | { |
| 128 | 128 | try |
| 129 | 129 | { |
| 130 | 130 | $index === null ? |
| 131 | - $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
|
| 132 | - $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
|
| 131 | + $this->callMethod('Add', EngineAdditions::uncoupleSelector($value)) : $this->callMethod('Insert', $index, EngineAdditions::uncoupleSelector($value)); |
|
| 133 | 132 | } |
| 134 | 133 | |
| 135 | 134 | catch (\Throwable $e) |
| 136 | 135 | { |
| 137 | 136 | $index === null ? |
| 138 | - VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) : |
|
| 139 | - VoidCore::setArrayValue ($this->selector, $index, EngineAdditions::uncoupleSelector ($value)); |
|
| 137 | + VoidCore::setArrayValue($this->selector, $this->count, EngineAdditions::uncoupleSelector($value)) : VoidCore::setArrayValue($this->selector, $index, EngineAdditions::uncoupleSelector($value)); |
|
| 140 | 138 | } |
| 141 | 139 | } |
| 142 | 140 | |
| 143 | - public function offsetGet ($index) |
|
| 141 | + public function offsetGet($index) |
|
| 144 | 142 | { |
| 145 | - return EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $index), $this->selector); |
|
| 143 | + return EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $index), $this->selector); |
|
| 146 | 144 | } |
| 147 | 145 | |
| 148 | - public function offsetUnset ($index): void |
|
| 146 | + public function offsetUnset($index): void |
|
| 149 | 147 | { |
| 150 | - $this->callMethod ('RemoveAt', $index); |
|
| 148 | + $this->callMethod('RemoveAt', $index); |
|
| 151 | 149 | } |
| 152 | 150 | |
| 153 | - public function offsetExists ($index): bool |
|
| 151 | + public function offsetExists($index): bool |
|
| 154 | 152 | { |
| 155 | 153 | try |
| 156 | 154 | { |
| 157 | - $this->offsetGet ($index); |
|
| 155 | + $this->offsetGet($index); |
|
| 158 | 156 | } |
| 159 | 157 | |
| 160 | 158 | catch (\WinformsException $e) |
@@ -172,16 +170,16 @@ discard block |
||
| 172 | 170 | $size = $this->count; |
| 173 | 171 | |
| 174 | 172 | for ($i = 0; $i < $size; ++$i) |
| 175 | - $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
| 173 | + $callback(EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
| 176 | 174 | } |
| 177 | 175 | |
| 178 | - public function where (callable $comparator, string $type = null): array |
|
| 176 | + public function where(callable $comparator, string $type = null): array |
|
| 179 | 177 | { |
| 180 | 178 | $size = $this->count; |
| 181 | 179 | $return = []; |
| 182 | 180 | |
| 183 | 181 | for ($i = 0; $i < $size; ++$i) |
| 184 | - if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
| 182 | + if ($comparator($value = EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
| 185 | 183 | $return[] = $value; |
| 186 | 184 | |
| 187 | 185 | return $return; |
@@ -189,30 +187,30 @@ discard block |
||
| 189 | 187 | |
| 190 | 188 | # Магические методы |
| 191 | 189 | |
| 192 | - public function __destruct () |
|
| 190 | + public function __destruct() |
|
| 193 | 191 | { |
| 194 | - VoidCore::destructObject ($this->selector); |
|
| 192 | + VoidCore::destructObject($this->selector); |
|
| 195 | 193 | } |
| 196 | 194 | |
| 197 | - public function __toString (): string |
|
| 195 | + public function __toString(): string |
|
| 198 | 196 | { |
| 199 | 197 | return $this->selector; |
| 200 | 198 | } |
| 201 | 199 | |
| 202 | - public function __debugInfo (): array |
|
| 200 | + public function __debugInfo(): array |
|
| 203 | 201 | { |
| 204 | 202 | $info = ['selector' => $this->selector]; |
| 205 | 203 | |
| 206 | 204 | try |
| 207 | 205 | { |
| 208 | - $info['name'] = $this->getProperty ('Name'); |
|
| 206 | + $info['name'] = $this->getProperty('Name'); |
|
| 209 | 207 | } |
| 210 | 208 | |
| 211 | 209 | catch (\WinformsException $e) {} |
| 212 | 210 | |
| 213 | 211 | try |
| 214 | 212 | { |
| 215 | - $info['info'] = $this->callMethod ('ToString'); |
|
| 213 | + $info['info'] = $this->callMethod('ToString'); |
|
| 216 | 214 | } |
| 217 | 215 | |
| 218 | 216 | catch (\WinformsException $e) {} |
@@ -223,15 +221,15 @@ discard block |
||
| 223 | 221 | |
| 224 | 222 | class NetClass extends NetObject |
| 225 | 223 | { |
| 226 | - public function __construct ($name, $assembly = false) |
|
| 224 | + public function __construct($name, $assembly = false) |
|
| 227 | 225 | { |
| 228 | - if (is_int ($name) && VoidCore::objectExists ($name)) |
|
| 226 | + if (is_int($name) && VoidCore::objectExists($name)) |
|
| 229 | 227 | $this->selector = $name; |
| 230 | 228 | |
| 231 | - elseif (is_string ($name)) |
|
| 232 | - $this->selector = VoidCore::getClass ($name, $assembly); |
|
| 229 | + elseif (is_string($name)) |
|
| 230 | + $this->selector = VoidCore::getClass($name, $assembly); |
|
| 233 | 231 | |
| 234 | - else throw new \Exception ('Incorrect params passed'); |
|
| 232 | + else throw new \Exception('Incorrect params passed'); |
|
| 235 | 233 | } |
| 236 | 234 | } |
| 237 | 235 | |
@@ -256,16 +254,16 @@ discard block |
||
| 256 | 254 | * |
| 257 | 255 | * @return array - возвращает список ошибок компиляции |
| 258 | 256 | */ |
| 259 | - public static function compile (string $savePath, string $iconPath, string $phpCode, string $productDescription = null, string $productName = null, string $productVersion = null, string $companyName = null, string $copyright = null, string $callSharpCode = '', string $declareSharpCode = '', NetObject $dictionary = null, NetObject $assemblies = null): array |
|
| 257 | + public static function compile(string $savePath, string $iconPath, string $phpCode, string $productDescription = null, string $productName = null, string $productVersion = null, string $companyName = null, string $copyright = null, string $callSharpCode = '', string $declareSharpCode = '', NetObject $dictionary = null, NetObject $assemblies = null): array |
|
| 260 | 258 | { |
| 261 | 259 | if ($dictionary === null) |
| 262 | - $dictionary = new NetObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
| 260 | + $dictionary = new NetObject('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
| 263 | 261 | |
| 264 | 262 | if ($assemblies === null) |
| 265 | - $assemblies = dnArray ('System.String', []); |
|
| 263 | + $assemblies = dnArray('System.String', []); |
|
| 266 | 264 | |
| 267 | 265 | if ($productName === null) |
| 268 | - $productName = basenameNoExt ($savePath); |
|
| 266 | + $productName = basenameNoExt($savePath); |
|
| 269 | 267 | |
| 270 | 268 | if ($productDescription === null) |
| 271 | 269 | $productDescription = $productName; |
@@ -277,16 +275,16 @@ discard block |
||
| 277 | 275 | $companyName = 'Company N'; |
| 278 | 276 | |
| 279 | 277 | if ($copyright === null) |
| 280 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
| 278 | + $copyright = $companyName.' copyright (c) '.date('Y'); |
|
| 281 | 279 | |
| 282 | - return (new NetClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
| 280 | + return (new NetClass('WinForms_PHP.WFCompiler', null))->compile($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
| 283 | 281 | } |
| 284 | 282 | |
| 285 | - public static function loadModule (string $path): bool |
|
| 283 | + public static function loadModule(string $path): bool |
|
| 286 | 284 | { |
| 287 | 285 | try |
| 288 | 286 | { |
| 289 | - (new NetClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
|
| 287 | + (new NetClass('System.Reflection.Assembly', 'mscorlib'))->loadFrom($path); |
|
| 290 | 288 | } |
| 291 | 289 | |
| 292 | 290 | catch (\WinformsException $e) |
@@ -297,15 +295,15 @@ discard block |
||
| 297 | 295 | return true; |
| 298 | 296 | } |
| 299 | 297 | |
| 300 | - public static function coupleSelector ($selector) |
|
| 298 | + public static function coupleSelector($selector) |
|
| 301 | 299 | { |
| 302 | - return is_int ($selector) && VoidCore::objectExists ($selector) ? |
|
| 303 | - new NetObject ($selector) : $selector; |
|
| 300 | + return is_int($selector) && VoidCore::objectExists($selector) ? |
|
| 301 | + new NetObject($selector) : $selector; |
|
| 304 | 302 | } |
| 305 | 303 | |
| 306 | - public static function uncoupleSelector ($object) |
|
| 304 | + public static function uncoupleSelector($object) |
|
| 307 | 305 | { |
| 308 | - return is_object ($object) && $object instanceof NetObject ? |
|
| 306 | + return is_object($object) && $object instanceof NetObject ? |
|
| 309 | 307 | $object->selector : $object; |
| 310 | 308 | } |
| 311 | 309 | } |