Passed
Push — master ( 54b931...b32b47 )
by Observer
01:26
created
engine/common/EngineInterfaces.php 1 patch
Spacing   +72 added lines, -74 removed lines patch added patch discarded remove patch
@@ -10,44 +10,44 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.