@@ -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 | } |