@@ -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 | } |
@@ -80,8 +79,9 @@ discard block |
||
80 | 79 | break; |
81 | 80 | } |
82 | 81 | |
83 | - if (method_exists ($this, $method = 'get_'. $name)) |
|
84 | - return $this->$method (); |
|
82 | + if (method_exists ($this, $method = 'get_'. $name)) { |
|
83 | + return $this->$method (); |
|
84 | + } |
|
85 | 85 | |
86 | 86 | return isset ($this->$name) ? |
87 | 87 | $this->$name : EngineAdditions::coupleSelector ($this->getProperty ($name)); |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | |
90 | 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); |
|
94 | - |
|
95 | - elseif (method_exists ($this, $method = 'set_'. $name)) |
|
96 | - $this->$method ($value); |
|
97 | - |
|
98 | - else $this->setProperty ($name, $this->formatArg ($value)); |
|
92 | + if (substr ($name, -5) == 'Event') { |
|
93 | + Events::setEvent ($this->selector, substr ($name, 0, -5), $value); |
|
94 | + } elseif (method_exists ($this, $method = 'set_'. $name)) { |
|
95 | + $this->$method ($value); |
|
96 | + } else { |
|
97 | + $this->setProperty ($name, $this->formatArg ($value)); |
|
98 | + } |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | public function __call (string $name, array $args) |
@@ -107,8 +107,9 @@ discard block |
||
107 | 107 | { |
108 | 108 | $item = EngineAdditions::uncoupleSelector ($item); |
109 | 109 | |
110 | - if (is_array ($item)) |
|
111 | - $item = EngineAdditions::uncoupleSelector (dnArray (VoidCore::callMethod (VoidCore::callMethod ([current ($item), VC_OBJECT], 'GetType')), 'ToString', $item)); |
|
110 | + if (is_array ($item)) { |
|
111 | + $item = EngineAdditions::uncoupleSelector (dnArray (VoidCore::callMethod (VoidCore::callMethod ([current ($item), VC_OBJECT], 'GetType')), 'ToString', $item)); |
|
112 | + } |
|
112 | 113 | |
113 | 114 | return $item; |
114 | 115 | } |
@@ -139,9 +140,7 @@ discard block |
||
139 | 140 | $index === null ? |
140 | 141 | $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
141 | 142 | $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
142 | - } |
|
143 | - |
|
144 | - catch (\Throwable $e) |
|
143 | + } catch (\Throwable $e) |
|
145 | 144 | { |
146 | 145 | $index === null ? |
147 | 146 | VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) : |
@@ -164,9 +163,7 @@ discard block |
||
164 | 163 | try |
165 | 164 | { |
166 | 165 | $this->offsetGet ($index); |
167 | - } |
|
168 | - |
|
169 | - catch (\WinformsException $e) |
|
166 | + } catch (\WinformsException $e) |
|
170 | 167 | { |
171 | 168 | return false; |
172 | 169 | } |
@@ -180,8 +177,9 @@ discard block |
||
180 | 177 | { |
181 | 178 | $size = $this->count; |
182 | 179 | |
183 | - for ($i = 0; $i < $size; ++$i) |
|
184 | - $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
180 | + for ($i = 0; $i < $size; ++$i) { |
|
181 | + $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
182 | + } |
|
185 | 183 | } |
186 | 184 | |
187 | 185 | public function where (callable $comparator, string $type = null): array |
@@ -189,9 +187,10 @@ discard block |
||
189 | 187 | $size = $this->count; |
190 | 188 | $return = []; |
191 | 189 | |
192 | - for ($i = 0; $i < $size; ++$i) |
|
193 | - if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
190 | + for ($i = 0; $i < $size; ++$i) { |
|
191 | + if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
194 | 192 | $return[] = $value; |
193 | + } |
|
195 | 194 | |
196 | 195 | return $return; |
197 | 196 | } |
@@ -215,16 +214,12 @@ discard block |
||
215 | 214 | try |
216 | 215 | { |
217 | 216 | $info['name'] = $this->getProperty ('Name'); |
218 | - } |
|
219 | - |
|
220 | - catch (\WinformsException $e) {} |
|
217 | + } catch (\WinformsException $e) {} |
|
221 | 218 | |
222 | 219 | try |
223 | 220 | { |
224 | 221 | $info['info'] = $this->callMethod ('ToString'); |
225 | - } |
|
226 | - |
|
227 | - catch (\WinformsException $e) {} |
|
222 | + } catch (\WinformsException $e) {} |
|
228 | 223 | |
229 | 224 | return $info; |
230 | 225 | } |
@@ -234,13 +229,13 @@ discard block |
||
234 | 229 | { |
235 | 230 | public function __construct ($name, $assembly = false) |
236 | 231 | { |
237 | - if (is_int ($name) && VoidCore::objectExists ($name)) |
|
238 | - $this->selector = $name; |
|
239 | - |
|
240 | - elseif (is_string ($name)) |
|
241 | - $this->selector = VoidCore::getClass ($name, $assembly); |
|
242 | - |
|
243 | - else throw new \Exception ('Incorrect params passed'); |
|
232 | + if (is_int ($name) && VoidCore::objectExists ($name)) { |
|
233 | + $this->selector = $name; |
|
234 | + } elseif (is_string ($name)) { |
|
235 | + $this->selector = VoidCore::getClass ($name, $assembly); |
|
236 | + } else { |
|
237 | + throw new \Exception ('Incorrect params passed'); |
|
238 | + } |
|
244 | 239 | } |
245 | 240 | } |
246 | 241 | |
@@ -267,26 +262,33 @@ discard block |
||
267 | 262 | */ |
268 | 263 | 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 |
269 | 264 | { |
270 | - if ($dictionary === null) |
|
271 | - $dictionary = new NetObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
265 | + if ($dictionary === null) { |
|
266 | + $dictionary = new NetObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null); |
|
267 | + } |
|
272 | 268 | |
273 | - if ($assemblies === null) |
|
274 | - $assemblies = dnArray ('System.String', []); |
|
269 | + if ($assemblies === null) { |
|
270 | + $assemblies = dnArray ('System.String', []); |
|
271 | + } |
|
275 | 272 | |
276 | - if ($productName === null) |
|
277 | - $productName = basenameNoExt ($savePath); |
|
273 | + if ($productName === null) { |
|
274 | + $productName = basenameNoExt ($savePath); |
|
275 | + } |
|
278 | 276 | |
279 | - if ($productDescription === null) |
|
280 | - $productDescription = $productName; |
|
277 | + if ($productDescription === null) { |
|
278 | + $productDescription = $productName; |
|
279 | + } |
|
281 | 280 | |
282 | - if ($productVersion === null) |
|
283 | - $productVersion = '1.0'; |
|
281 | + if ($productVersion === null) { |
|
282 | + $productVersion = '1.0'; |
|
283 | + } |
|
284 | 284 | |
285 | - if ($companyName === null) |
|
286 | - $companyName = 'Company N'; |
|
285 | + if ($companyName === null) { |
|
286 | + $companyName = 'Company N'; |
|
287 | + } |
|
287 | 288 | |
288 | - if ($copyright === null) |
|
289 | - $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
289 | + if ($copyright === null) { |
|
290 | + $copyright = $companyName .' copyright (c) '. date ('Y'); |
|
291 | + } |
|
290 | 292 | |
291 | 293 | return (new NetClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names; |
292 | 294 | } |
@@ -296,9 +298,7 @@ discard block |
||
296 | 298 | try |
297 | 299 | { |
298 | 300 | (new NetClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path); |
299 | - } |
|
300 | - |
|
301 | - catch (\WinformsException $e) |
|
301 | + } catch (\WinformsException $e) |
|
302 | 302 | { |
303 | 303 | return false; |
304 | 304 | } |