Passed
Push — master ( b52801...dfae58 )
by Observer
01:34
created
engine/common/EngineInterfaces.php 1 patch
Braces   +67 added lines, -68 removed lines patch added patch discarded remove patch
@@ -12,16 +12,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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, EngineAdditions::uncoupleSelector ($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, EngineAdditions::uncoupleSelector ($value));
98
+        }
99 99
     }
100 100
 
101 101
     public function __call (string $name, array $args)
@@ -130,9 +130,7 @@  discard block
 block discarded – undo
130 130
             $index === null ?
131 131
                 $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) :
132 132
                 $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value));
133
-        }
134
-
135
-        catch (\Throwable $e)
133
+        } catch (\Throwable $e)
136 134
         {
137 135
             $index === null ?
138 136
                 VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) :
@@ -155,9 +153,7 @@  discard block
 block discarded – undo
155 153
         try
156 154
         {
157 155
             $this->offsetGet ($index);
158
-        }
159
-
160
-        catch (\WinformsException $e)
156
+        } catch (\WinformsException $e)
161 157
         {
162 158
             return false;
163 159
         }
@@ -171,8 +167,9 @@  discard block
 block discarded – undo
171 167
     {
172 168
         $size = $this->count;
173 169
 
174
-        for ($i = 0; $i < $size; ++$i)
175
-            $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i);
170
+        for ($i = 0; $i < $size; ++$i) {
171
+                    $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i);
172
+        }
176 173
     }
177 174
 
178 175
     public function where (callable $comparator, string $type = null): array
@@ -180,9 +177,10 @@  discard block
 block discarded – undo
180 177
         $size   = $this->count;
181 178
         $return = [];
182 179
 
183
-        for ($i = 0; $i < $size; ++$i)
184
-            if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i))
180
+        for ($i = 0; $i < $size; ++$i) {
181
+                    if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i))
185 182
                 $return[] = $value;
183
+        }
186 184
 
187 185
         return $return;
188 186
     }
@@ -206,16 +204,12 @@  discard block
 block discarded – undo
206 204
         try
207 205
         {
208 206
             $info['name'] = $this->getProperty ('Name');
209
-        }
210
-
211
-        catch (\WinformsException $e) {}
207
+        } catch (\WinformsException $e) {}
212 208
 
213 209
         try
214 210
         {
215 211
             $info['info'] = $this->callMethod ('ToString');
216
-        }
217
-
218
-        catch (\WinformsException $e) {}
212
+        } catch (\WinformsException $e) {}
219 213
 
220 214
         return $info;
221 215
     }
@@ -225,13 +219,13 @@  discard block
 block discarded – undo
225 219
 {
226 220
     public function __construct ($name, $assembly = false)
227 221
     {
228
-        if (is_int ($name) && VoidCore::objectExists ($name))
229
-            $this->selector = $name;
230
-
231
-        elseif (is_string ($name))
232
-            $this->selector = VoidCore::getClass ($name, $assembly);
233
-
234
-        else throw new \Exception ('Incorrect params passed');
222
+        if (is_int ($name) && VoidCore::objectExists ($name)) {
223
+                    $this->selector = $name;
224
+        } elseif (is_string ($name)) {
225
+                    $this->selector = VoidCore::getClass ($name, $assembly);
226
+        } else {
227
+            throw new \Exception ('Incorrect params passed');
228
+        }
235 229
     }
236 230
 }
237 231
 
@@ -258,26 +252,33 @@  discard block
 block discarded – undo
258 252
      */
259 253
     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 254
     {
261
-        if ($dictionary === null)
262
-            $dictionary = new NetObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null);
255
+        if ($dictionary === null) {
256
+                    $dictionary = new NetObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null);
257
+        }
263 258
 
264
-        if ($assemblies === null)
265
-            $assemblies = dnArray ('System.String', []);
259
+        if ($assemblies === null) {
260
+                    $assemblies = dnArray ('System.String', []);
261
+        }
266 262
 
267
-        if ($productName === null)
268
-            $productName = basenameNoExt ($savePath);
263
+        if ($productName === null) {
264
+                    $productName = basenameNoExt ($savePath);
265
+        }
269 266
 
270
-        if ($productDescription === null)
271
-            $productDescription = $productName;
267
+        if ($productDescription === null) {
268
+                    $productDescription = $productName;
269
+        }
272 270
 
273
-        if ($productVersion === null)
274
-            $productVersion = '1.0';
271
+        if ($productVersion === null) {
272
+                    $productVersion = '1.0';
273
+        }
275 274
 
276
-        if ($companyName === null)
277
-            $companyName = 'Company N';
275
+        if ($companyName === null) {
276
+                    $companyName = 'Company N';
277
+        }
278 278
 
279
-        if ($copyright === null)
280
-            $copyright = $companyName .' copyright (c) '. date ('Y');
279
+        if ($copyright === null) {
280
+                    $copyright = $companyName .' copyright (c) '. date ('Y');
281
+        }
281 282
 
282 283
         return (new NetClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names;
283 284
     }
@@ -287,9 +288,7 @@  discard block
 block discarded – undo
287 288
         try
288 289
         {
289 290
             (new NetClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path);
290
-        }
291
-
292
-        catch (\WinformsException $e)
291
+        } catch (\WinformsException $e)
293 292
         {
294 293
             return false;
295 294
         }
Please login to merge, or discard this patch.