@@ -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 |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | |
263 | 263 | class EngineAdditions |
264 | 264 | { |
265 | - /** |
|
265 | + /** |
|
266 | 266 | * * Компиляция PHP кода |
267 | 267 | * |
268 | 268 | * TODO: дополнить описание |
@@ -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,15 +246,15 @@ 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 | |
@@ -281,16 +279,16 @@ discard block |
||
281 | 279 | * |
282 | 280 | * @return array - возвращает список ошибок компиляции |
283 | 281 | */ |
284 | - 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 |
|
282 | + 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 |
|
285 | 283 | { |
286 | 284 | if ($dictionary === null) |
287 | - $dictionary = new NetObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
285 | + $dictionary = new NetObject('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
288 | 286 | |
289 | 287 | if ($assemblies === null) |
290 | - $assemblies = getNetArray ('System.String', []); |
|
288 | + $assemblies = getNetArray('System.String', []); |
|
291 | 289 | |
292 | 290 | if ($productName === null) |
293 | - $productName = basenameNoExt ($savePath); |
|
291 | + $productName = basenameNoExt($savePath); |
|
294 | 292 | |
295 | 293 | if ($productDescription === null) |
296 | 294 | $productDescription = $productName; |
@@ -302,16 +300,16 @@ discard block |
||
302 | 300 | $companyName = 'Company N'; |
303 | 301 | |
304 | 302 | if ($copyright === null) |
305 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
303 | + $copyright = $companyName.' copyright (c) '.date('Y'); |
|
306 | 304 | |
307 | - return (new NetClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
305 | + return (new NetClass('WinForms_PHP.WFCompiler', null))->compile($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
|
308 | 306 | } |
309 | 307 | |
310 | - public static function loadModule (string $path): bool |
|
308 | + public static function loadModule(string $path): bool |
|
311 | 309 | { |
312 | 310 | try |
313 | 311 | { |
314 | - (new NetClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
|
312 | + (new NetClass('System.Reflection.Assembly', 'mscorlib'))->loadFrom($path); |
|
315 | 313 | } |
316 | 314 | |
317 | 315 | catch (\WinformsException $e) |
@@ -322,15 +320,15 @@ discard block |
||
322 | 320 | return true; |
323 | 321 | } |
324 | 322 | |
325 | - public static function coupleSelector ($selector) |
|
323 | + public static function coupleSelector($selector) |
|
326 | 324 | { |
327 | - return is_int ($selector) && VoidCore::objectExists ($selector) ? |
|
328 | - new NetObject ($selector) : $selector; |
|
325 | + return is_int($selector) && VoidCore::objectExists($selector) ? |
|
326 | + new NetObject($selector) : $selector; |
|
329 | 327 | } |
330 | 328 | |
331 | - public static function uncoupleSelector ($object) |
|
329 | + public static function uncoupleSelector($object) |
|
332 | 330 | { |
333 | - return is_object ($object) && $object instanceof NetObject ? |
|
331 | + return is_object($object) && $object instanceof NetObject ? |
|
334 | 332 | $object->selector : $object; |
335 | 333 | } |
336 | 334 | } |
@@ -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 | |
@@ -283,26 +271,33 @@ discard block |
||
283 | 271 | */ |
284 | 272 | 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 |
285 | 273 | { |
286 | - if ($dictionary === null) |
|
287 | - $dictionary = new NetObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
274 | + if ($dictionary === null) { |
|
275 | + $dictionary = new NetObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
276 | + } |
|
288 | 277 | |
289 | - if ($assemblies === null) |
|
290 | - $assemblies = getNetArray ('System.String', []); |
|
278 | + if ($assemblies === null) { |
|
279 | + $assemblies = getNetArray ('System.String', []); |
|
280 | + } |
|
291 | 281 | |
292 | - if ($productName === null) |
|
293 | - $productName = basenameNoExt ($savePath); |
|
282 | + if ($productName === null) { |
|
283 | + $productName = basenameNoExt ($savePath); |
|
284 | + } |
|
294 | 285 | |
295 | - if ($productDescription === null) |
|
296 | - $productDescription = $productName; |
|
286 | + if ($productDescription === null) { |
|
287 | + $productDescription = $productName; |
|
288 | + } |
|
297 | 289 | |
298 | - if ($productVersion === null) |
|
299 | - $productVersion = '1.0'; |
|
290 | + if ($productVersion === null) { |
|
291 | + $productVersion = '1.0'; |
|
292 | + } |
|
300 | 293 | |
301 | - if ($companyName === null) |
|
302 | - $companyName = 'Company N'; |
|
294 | + if ($companyName === null) { |
|
295 | + $companyName = 'Company N'; |
|
296 | + } |
|
303 | 297 | |
304 | - if ($copyright === null) |
|
305 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
298 | + if ($copyright === null) { |
|
299 | + $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
300 | + } |
|
306 | 301 | |
307 | 302 | return (new NetClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
308 | 303 | } |
@@ -312,9 +307,7 @@ discard block |
||
312 | 307 | try |
313 | 308 | { |
314 | 309 | (new NetClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
315 | - } |
|
316 | - |
|
317 | - catch (\WinformsException $e) |
|
310 | + } catch (\WinformsException $e) |
|
318 | 311 | { |
319 | 312 | return false; |
320 | 313 | } |