@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $size = $this->count; |
| 56 | 56 | $list = []; |
| 57 | 57 | |
| 58 | - for ($i = 0; $i < $size; ++$i) |
|
| 58 | + for ($i = 0; $i < $size; ++$i) |
|
| 59 | 59 | $list[] = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $i)); |
| 60 | 60 | |
| 61 | 61 | return $list; |
@@ -79,17 +79,17 @@ discard block |
||
| 79 | 79 | return $names; |
| 80 | 80 | break; |
| 81 | 81 | |
| 82 | - case 'name': |
|
| 83 | - try |
|
| 84 | - { |
|
| 85 | - return $this->getProperty ('Name'); |
|
| 86 | - } |
|
| 82 | + case 'name': |
|
| 83 | + try |
|
| 84 | + { |
|
| 85 | + return $this->getProperty ('Name'); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - catch (\WinformsException $e) |
|
| 89 | - { |
|
| 90 | - return $this->name; |
|
| 91 | - } |
|
| 92 | - break; |
|
| 88 | + catch (\WinformsException $e) |
|
| 89 | + { |
|
| 90 | + return $this->name; |
|
| 91 | + } |
|
| 92 | + break; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | if (method_exists ($this, $method = 'get_'. $name)) |
@@ -107,18 +107,18 @@ discard block |
||
| 107 | 107 | elseif (method_exists ($this, $method = 'set_'. $name)) |
| 108 | 108 | $this->$method ($value); |
| 109 | 109 | |
| 110 | - elseif (strtolower ($name) == 'name') |
|
| 111 | - { |
|
| 112 | - try |
|
| 113 | - { |
|
| 114 | - $this->setProperty ($name, $value); |
|
| 115 | - } |
|
| 110 | + elseif (strtolower ($name) == 'name') |
|
| 111 | + { |
|
| 112 | + try |
|
| 113 | + { |
|
| 114 | + $this->setProperty ($name, $value); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - catch (\WinformsException $e) |
|
| 118 | - { |
|
| 119 | - $this->name = $value; |
|
| 120 | - } |
|
| 121 | - } |
|
| 117 | + catch (\WinformsException $e) |
|
| 118 | + { |
|
| 119 | + $this->name = $value; |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
| 124 | 124 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | # ArrayAccess |
| 150 | 150 | |
| 151 | 151 | public function offsetSet ($index, $value) |
| 152 | - { |
|
| 152 | + { |
|
| 153 | 153 | try |
| 154 | 154 | { |
| 155 | 155 | $index === null ? |
@@ -165,14 +165,14 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - public function offsetGet ($index) |
|
| 169 | - { |
|
| 170 | - return EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $index), $this->selector); |
|
| 168 | + public function offsetGet ($index) |
|
| 169 | + { |
|
| 170 | + return EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $index), $this->selector); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function offsetUnset ($index): void |
|
| 174 | - { |
|
| 175 | - $this->callMethod ('RemoveAt', $index); |
|
| 173 | + public function offsetUnset ($index): void |
|
| 174 | + { |
|
| 175 | + $this->callMethod ('RemoveAt', $index); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | public function offsetExists ($index): bool |
@@ -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,12 +68,12 @@ 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; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | case 'name': |
| 83 | 83 | try |
| 84 | 84 | { |
| 85 | - return $this->getProperty ('Name'); |
|
| 85 | + return $this->getProperty('Name'); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | catch (\WinformsException $e) |
@@ -92,26 +92,26 @@ discard block |
||
| 92 | 92 | break; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if (method_exists ($this, $method = 'get_'. $name)) |
|
| 96 | - return $this->$method (); |
|
| 95 | + if (method_exists($this, $method = 'get_'.$name)) |
|
| 96 | + return $this->$method(); |
|
| 97 | 97 | |
| 98 | 98 | return isset ($this->$name) ? |
| 99 | - $this->$name : EngineAdditions::coupleSelector ($this->getProperty ($name)); |
|
| 99 | + $this->$name : EngineAdditions::coupleSelector($this->getProperty($name)); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public function __set (string $name, $value): void |
|
| 102 | + public function __set(string $name, $value): void |
|
| 103 | 103 | { |
| 104 | - if (substr ($name, -5) == 'Event') |
|
| 105 | - Events::setEvent ($this->selector, substr ($name, 0, -5), $value); |
|
| 104 | + if (substr($name, -5) == 'Event') |
|
| 105 | + Events::setEvent($this->selector, substr($name, 0, -5), $value); |
|
| 106 | 106 | |
| 107 | - elseif (method_exists ($this, $method = 'set_'. $name)) |
|
| 108 | - $this->$method ($value); |
|
| 107 | + elseif (method_exists($this, $method = 'set_'.$name)) |
|
| 108 | + $this->$method($value); |
|
| 109 | 109 | |
| 110 | - elseif (strtolower ($name) == 'name') |
|
| 110 | + elseif (strtolower($name) == 'name') |
|
| 111 | 111 | { |
| 112 | 112 | try |
| 113 | 113 | { |
| 114 | - $this->setProperty ($name, $value); |
|
| 114 | + $this->setProperty($name, $value); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | catch (\WinformsException $e) |
@@ -120,66 +120,64 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
| 123 | + else $this->setProperty($name, EngineAdditions::uncoupleSelector($value)); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function __call (string $name, array $args) |
|
| 126 | + public function __call(string $name, array $args) |
|
| 127 | 127 | { |
| 128 | - return EngineAdditions::coupleSelector ($this->callMethod ($name, |
|
| 129 | - array_map ('VoidEngine\\EngineAdditions::uncoupleSelector', $args))); |
|
| 128 | + return EngineAdditions::coupleSelector($this->callMethod($name, |
|
| 129 | + array_map('VoidEngine\\EngineAdditions::uncoupleSelector', $args))); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | # Управление VoidCore |
| 133 | 133 | |
| 134 | - protected function getProperty ($name) |
|
| 134 | + protected function getProperty($name) |
|
| 135 | 135 | { |
| 136 | - return VoidCore::getProperty ($this->selector, $name); |
|
| 136 | + return VoidCore::getProperty($this->selector, $name); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - protected function setProperty (string $name, $value): void |
|
| 139 | + protected function setProperty(string $name, $value): void |
|
| 140 | 140 | { |
| 141 | - VoidCore::setProperty ($this->selector, $name, $value); |
|
| 141 | + VoidCore::setProperty($this->selector, $name, $value); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - protected function callMethod (string $name, array $args = []) |
|
| 144 | + protected function callMethod(string $name, array $args = []) |
|
| 145 | 145 | { |
| 146 | - return VoidCore::callMethod ($this->selector, $name, ...$args); |
|
| 146 | + return VoidCore::callMethod($this->selector, $name, ...$args); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | # ArrayAccess |
| 150 | 150 | |
| 151 | - public function offsetSet ($index, $value) |
|
| 151 | + public function offsetSet($index, $value) |
|
| 152 | 152 | { |
| 153 | 153 | try |
| 154 | 154 | { |
| 155 | 155 | $index === null ? |
| 156 | - $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
|
| 157 | - $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
|
| 156 | + $this->callMethod('Add', EngineAdditions::uncoupleSelector($value)) : $this->callMethod('Insert', $index, EngineAdditions::uncoupleSelector($value)); |
|
| 158 | 157 | } |
| 159 | 158 | |
| 160 | 159 | catch (\Throwable $e) |
| 161 | 160 | { |
| 162 | 161 | $index === null ? |
| 163 | - VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) : |
|
| 164 | - VoidCore::setArrayValue ($this->selector, $index, EngineAdditions::uncoupleSelector ($value)); |
|
| 162 | + VoidCore::setArrayValue($this->selector, $this->count, EngineAdditions::uncoupleSelector($value)) : VoidCore::setArrayValue($this->selector, $index, EngineAdditions::uncoupleSelector($value)); |
|
| 165 | 163 | } |
| 166 | 164 | } |
| 167 | 165 | |
| 168 | - public function offsetGet ($index) |
|
| 166 | + public function offsetGet($index) |
|
| 169 | 167 | { |
| 170 | - return EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $index), $this->selector); |
|
| 168 | + return EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $index), $this->selector); |
|
| 171 | 169 | } |
| 172 | 170 | |
| 173 | - public function offsetUnset ($index): void |
|
| 171 | + public function offsetUnset($index): void |
|
| 174 | 172 | { |
| 175 | - $this->callMethod ('RemoveAt', $index); |
|
| 173 | + $this->callMethod('RemoveAt', $index); |
|
| 176 | 174 | } |
| 177 | 175 | |
| 178 | - public function offsetExists ($index): bool |
|
| 176 | + public function offsetExists($index): bool |
|
| 179 | 177 | { |
| 180 | 178 | try |
| 181 | 179 | { |
| 182 | - $this->offsetGet ($index); |
|
| 180 | + $this->offsetGet($index); |
|
| 183 | 181 | } |
| 184 | 182 | |
| 185 | 183 | catch (\WinformsException $e) |
@@ -197,16 +195,16 @@ discard block |
||
| 197 | 195 | $size = $this->count; |
| 198 | 196 | |
| 199 | 197 | for ($i = 0; $i < $size; ++$i) |
| 200 | - $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
| 198 | + $callback(EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
| 201 | 199 | } |
| 202 | 200 | |
| 203 | - public function where (callable $comparator, string $type = null): array |
|
| 201 | + public function where(callable $comparator, string $type = null): array |
|
| 204 | 202 | { |
| 205 | 203 | $size = $this->count; |
| 206 | 204 | $return = []; |
| 207 | 205 | |
| 208 | 206 | for ($i = 0; $i < $size; ++$i) |
| 209 | - if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
| 207 | + if ($comparator($value = EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
| 210 | 208 | $return[] = $value; |
| 211 | 209 | |
| 212 | 210 | return $return; |
@@ -214,30 +212,30 @@ discard block |
||
| 214 | 212 | |
| 215 | 213 | # Магические методы |
| 216 | 214 | |
| 217 | - public function __destruct () |
|
| 215 | + public function __destruct() |
|
| 218 | 216 | { |
| 219 | - VoidCore::destructObject ($this->selector); |
|
| 217 | + VoidCore::destructObject($this->selector); |
|
| 220 | 218 | } |
| 221 | 219 | |
| 222 | - public function __toString (): string |
|
| 220 | + public function __toString(): string |
|
| 223 | 221 | { |
| 224 | 222 | return $this->selector; |
| 225 | 223 | } |
| 226 | 224 | |
| 227 | - public function __debugInfo (): array |
|
| 225 | + public function __debugInfo(): array |
|
| 228 | 226 | { |
| 229 | 227 | $info = ['selector' => $this->selector]; |
| 230 | 228 | |
| 231 | 229 | try |
| 232 | 230 | { |
| 233 | - $info['name'] = $this->getProperty ('Name'); |
|
| 231 | + $info['name'] = $this->getProperty('Name'); |
|
| 234 | 232 | } |
| 235 | 233 | |
| 236 | 234 | catch (\WinformsException $e) {} |
| 237 | 235 | |
| 238 | 236 | try |
| 239 | 237 | { |
| 240 | - $info['info'] = $this->callMethod ('ToString'); |
|
| 238 | + $info['info'] = $this->callMethod('ToString'); |
|
| 241 | 239 | } |
| 242 | 240 | |
| 243 | 241 | catch (\WinformsException $e) {} |
@@ -248,29 +246,29 @@ discard block |
||
| 248 | 246 | |
| 249 | 247 | class NetClass extends NetObject |
| 250 | 248 | { |
| 251 | - public function __construct ($name, $assembly = false) |
|
| 249 | + public function __construct($name, $assembly = false) |
|
| 252 | 250 | { |
| 253 | - if (is_int ($name) && VoidCore::objectExists ($name)) |
|
| 251 | + if (is_int($name) && VoidCore::objectExists($name)) |
|
| 254 | 252 | $this->selector = $name; |
| 255 | 253 | |
| 256 | - elseif (is_string ($name)) |
|
| 257 | - $this->selector = VoidCore::getClass ($name, $assembly); |
|
| 254 | + elseif (is_string($name)) |
|
| 255 | + $this->selector = VoidCore::getClass($name, $assembly); |
|
| 258 | 256 | |
| 259 | - else throw new \Exception ('Incorrect params passed'); |
|
| 257 | + else throw new \Exception('Incorrect params passed'); |
|
| 260 | 258 | } |
| 261 | 259 | } |
| 262 | 260 | |
| 263 | 261 | class EngineAdditions |
| 264 | 262 | { |
| 265 | - public static function coupleSelector ($selector) |
|
| 263 | + public static function coupleSelector($selector) |
|
| 266 | 264 | { |
| 267 | - return is_int ($selector) && VoidCore::objectExists ($selector) ? |
|
| 268 | - new NetObject ($selector) : $selector; |
|
| 265 | + return is_int($selector) && VoidCore::objectExists($selector) ? |
|
| 266 | + new NetObject($selector) : $selector; |
|
| 269 | 267 | } |
| 270 | 268 | |
| 271 | - public static function uncoupleSelector ($object) |
|
| 269 | + public static function uncoupleSelector($object) |
|
| 272 | 270 | { |
| 273 | - return is_object ($object) && $object instanceof NetObject ? |
|
| 271 | + return is_object($object) && $object instanceof NetObject ? |
|
| 274 | 272 | $object->selector : $object; |
| 275 | 273 | } |
| 276 | 274 | } |
@@ -12,16 +12,17 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function __construct ($name, $assembly = false, ...$args) |
| 14 | 14 | { |
| 15 | - foreach ($args as $id => $arg) |
|
| 16 | - $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
| 15 | + foreach ($args as $id => $arg) { |
|
| 16 | + $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
| 17 | + } |
|
| 17 | 18 | |
| 18 | - if (is_int ($name) && VoidCore::objectExists ($name)) |
|
| 19 | - $this->selector = $name; |
|
| 20 | - |
|
| 21 | - elseif (is_string ($name)) |
|
| 22 | - $this->selector = VoidCore::createObject ($name, $assembly, ...$args); |
|
| 23 | - |
|
| 24 | - else throw new \Exception ('Incorrect params passed'); |
|
| 19 | + if (is_int ($name) && VoidCore::objectExists ($name)) { |
|
| 20 | + $this->selector = $name; |
|
| 21 | + } elseif (is_string ($name)) { |
|
| 22 | + $this->selector = VoidCore::createObject ($name, $assembly, ...$args); |
|
| 23 | + } else { |
|
| 24 | + throw new \Exception ('Incorrect params passed'); |
|
| 25 | + } |
|
| 25 | 26 | |
| 26 | 27 | /*$this->isCollection = $this->getType () |
| 27 | 28 | ->isSubclassOf (VoidCore::typeof ('System.Collectons.Generic.ICollection'));*/ |
@@ -43,9 +44,7 @@ discard block |
||
| 43 | 44 | try |
| 44 | 45 | { |
| 45 | 46 | return $this->getProperty ('Count'); |
| 46 | - } |
|
| 47 | - |
|
| 48 | - catch (\WinformsException $e) |
|
| 47 | + } catch (\WinformsException $e) |
|
| 49 | 48 | { |
| 50 | 49 | return $this->getProperty ('Length'); |
| 51 | 50 | } |
@@ -55,8 +54,9 @@ discard block |
||
| 55 | 54 | $size = $this->count; |
| 56 | 55 | $list = []; |
| 57 | 56 | |
| 58 | - for ($i = 0; $i < $size; ++$i) |
|
| 59 | - $list[] = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $i)); |
|
| 57 | + for ($i = 0; $i < $size; ++$i) { |
|
| 58 | + $list[] = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $i)); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | 61 | return $list; |
| 62 | 62 | break; |
@@ -65,13 +65,12 @@ discard block |
||
| 65 | 65 | $size = $this->count; |
| 66 | 66 | $names = []; |
| 67 | 67 | |
| 68 | - for ($i = 0; $i < $size; ++$i) |
|
| 69 | - try |
|
| 68 | + for ($i = 0; $i < $size; ++$i) { |
|
| 69 | + try |
|
| 70 | 70 | { |
| 71 | 71 | $names[] = VoidCore::getProperty (VoidCore::getArrayValue ($this->selector, [$i, VC_OBJECT]), 'Text'); |
| 72 | - } |
|
| 73 | - |
|
| 74 | - catch (\WinformsException $e) |
|
| 72 | + } |
|
| 73 | + } catch (\WinformsException $e) |
|
| 75 | 74 | { |
| 76 | 75 | $names[] = VoidCore::getArrayValue ($this->selector, [$i, VC_STRING]); |
| 77 | 76 | } |
@@ -83,17 +82,16 @@ discard block |
||
| 83 | 82 | try |
| 84 | 83 | { |
| 85 | 84 | return $this->getProperty ('Name'); |
| 86 | - } |
|
| 87 | - |
|
| 88 | - catch (\WinformsException $e) |
|
| 85 | + } catch (\WinformsException $e) |
|
| 89 | 86 | { |
| 90 | 87 | return $this->name; |
| 91 | 88 | } |
| 92 | 89 | break; |
| 93 | 90 | } |
| 94 | 91 | |
| 95 | - if (method_exists ($this, $method = 'get_'. $name)) |
|
| 96 | - return $this->$method (); |
|
| 92 | + if (method_exists ($this, $method = 'get_'. $name)) { |
|
| 93 | + return $this->$method (); |
|
| 94 | + } |
|
| 97 | 95 | |
| 98 | 96 | return isset ($this->$name) ? |
| 99 | 97 | $this->$name : EngineAdditions::coupleSelector ($this->getProperty ($name)); |
@@ -101,26 +99,22 @@ discard block |
||
| 101 | 99 | |
| 102 | 100 | public function __set (string $name, $value): void |
| 103 | 101 | { |
| 104 | - if (substr ($name, -5) == 'Event') |
|
| 105 | - Events::setEvent ($this->selector, substr ($name, 0, -5), $value); |
|
| 106 | - |
|
| 107 | - elseif (method_exists ($this, $method = 'set_'. $name)) |
|
| 108 | - $this->$method ($value); |
|
| 109 | - |
|
| 110 | - elseif (strtolower ($name) == 'name') |
|
| 102 | + if (substr ($name, -5) == 'Event') { |
|
| 103 | + Events::setEvent ($this->selector, substr ($name, 0, -5), $value); |
|
| 104 | + } elseif (method_exists ($this, $method = 'set_'. $name)) { |
|
| 105 | + $this->$method ($value); |
|
| 106 | + } elseif (strtolower ($name) == 'name') |
|
| 111 | 107 | { |
| 112 | 108 | try |
| 113 | 109 | { |
| 114 | 110 | $this->setProperty ($name, $value); |
| 115 | - } |
|
| 116 | - |
|
| 117 | - catch (\WinformsException $e) |
|
| 111 | + } catch (\WinformsException $e) |
|
| 118 | 112 | { |
| 119 | 113 | $this->name = $value; |
| 120 | 114 | } |
| 121 | - } |
|
| 122 | - |
|
| 123 | - else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
| 115 | + } else { |
|
| 116 | + $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
| 117 | + } |
|
| 124 | 118 | } |
| 125 | 119 | |
| 126 | 120 | public function __call (string $name, array $args) |
@@ -155,9 +149,7 @@ discard block |
||
| 155 | 149 | $index === null ? |
| 156 | 150 | $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
| 157 | 151 | $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
| 158 | - } |
|
| 159 | - |
|
| 160 | - catch (\Throwable $e) |
|
| 152 | + } catch (\Throwable $e) |
|
| 161 | 153 | { |
| 162 | 154 | $index === null ? |
| 163 | 155 | VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) : |
@@ -180,9 +172,7 @@ discard block |
||
| 180 | 172 | try |
| 181 | 173 | { |
| 182 | 174 | $this->offsetGet ($index); |
| 183 | - } |
|
| 184 | - |
|
| 185 | - catch (\WinformsException $e) |
|
| 175 | + } catch (\WinformsException $e) |
|
| 186 | 176 | { |
| 187 | 177 | return false; |
| 188 | 178 | } |
@@ -196,8 +186,9 @@ discard block |
||
| 196 | 186 | { |
| 197 | 187 | $size = $this->count; |
| 198 | 188 | |
| 199 | - for ($i = 0; $i < $size; ++$i) |
|
| 200 | - $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
| 189 | + for ($i = 0; $i < $size; ++$i) { |
|
| 190 | + $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
| 191 | + } |
|
| 201 | 192 | } |
| 202 | 193 | |
| 203 | 194 | public function where (callable $comparator, string $type = null): array |
@@ -205,9 +196,10 @@ discard block |
||
| 205 | 196 | $size = $this->count; |
| 206 | 197 | $return = []; |
| 207 | 198 | |
| 208 | - for ($i = 0; $i < $size; ++$i) |
|
| 209 | - if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
| 199 | + for ($i = 0; $i < $size; ++$i) { |
|
| 200 | + if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
| 210 | 201 | $return[] = $value; |
| 202 | + } |
|
| 211 | 203 | |
| 212 | 204 | return $return; |
| 213 | 205 | } |
@@ -231,16 +223,12 @@ discard block |
||
| 231 | 223 | try |
| 232 | 224 | { |
| 233 | 225 | $info['name'] = $this->getProperty ('Name'); |
| 234 | - } |
|
| 235 | - |
|
| 236 | - catch (\WinformsException $e) {} |
|
| 226 | + } catch (\WinformsException $e) {} |
|
| 237 | 227 | |
| 238 | 228 | try |
| 239 | 229 | { |
| 240 | 230 | $info['info'] = $this->callMethod ('ToString'); |
| 241 | - } |
|
| 242 | - |
|
| 243 | - catch (\WinformsException $e) {} |
|
| 231 | + } catch (\WinformsException $e) {} |
|
| 244 | 232 | |
| 245 | 233 | return $info; |
| 246 | 234 | } |
@@ -250,13 +238,13 @@ discard block |
||
| 250 | 238 | { |
| 251 | 239 | public function __construct ($name, $assembly = false) |
| 252 | 240 | { |
| 253 | - if (is_int ($name) && VoidCore::objectExists ($name)) |
|
| 254 | - $this->selector = $name; |
|
| 255 | - |
|
| 256 | - elseif (is_string ($name)) |
|
| 257 | - $this->selector = VoidCore::getClass ($name, $assembly); |
|
| 258 | - |
|
| 259 | - else throw new \Exception ('Incorrect params passed'); |
|
| 241 | + if (is_int ($name) && VoidCore::objectExists ($name)) { |
|
| 242 | + $this->selector = $name; |
|
| 243 | + } elseif (is_string ($name)) { |
|
| 244 | + $this->selector = VoidCore::getClass ($name, $assembly); |
|
| 245 | + } else { |
|
| 246 | + throw new \Exception ('Incorrect params passed'); |
|
| 247 | + } |
|
| 260 | 248 | } |
| 261 | 249 | } |
| 262 | 250 | |