Passed
Push — master ( af6f8b...b52801 )
by Observer
01:41
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,102 +68,100 @@  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;
80 80
             break;
81 81
         }
82 82
 
83
-        if (method_exists ($this, $method = 'get_'. $name))
84
-            return $this->$method ();
83
+        if (method_exists($this, $method = 'get_'.$name))
84
+            return $this->$method();
85 85
 
86 86
         return isset ($this->$name) ?
87
-            $this->$name : EngineAdditions::coupleSelector ($this->getProperty ($name));
87
+            $this->$name : EngineAdditions::coupleSelector($this->getProperty($name));
88 88
     }
89 89
 
90
-    public function __set (string $name, $value): void
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);
92
+        if (substr($name, -5) == 'Event')
93
+            Events::setEvent($this->selector, substr($name, 0, -5), $value);
94 94
 
95
-        elseif (method_exists ($this, $method = 'set_'. $name))
96
-            $this->$method ($value);
95
+        elseif (method_exists($this, $method = 'set_'.$name))
96
+            $this->$method($value);
97 97
         
98
-        else $this->setProperty ($name, $this->formatArg ($value));
98
+        else $this->setProperty($name, $this->formatArg($value));
99 99
     }
100 100
 
101
-    public function __call (string $name, array $args)
101
+    public function __call(string $name, array $args)
102 102
     {
103
-        return EngineAdditions::coupleSelector ($this->callMethod ($name, array_map ([$this, 'formatArg'], $args)));
103
+        return EngineAdditions::coupleSelector($this->callMethod($name, array_map([$this, 'formatArg'], $args)));
104 104
     }
105 105
 
106
-    protected function formatArg ($item)
106
+    protected function formatArg($item)
107 107
     {
108
-        $item = EngineAdditions::uncoupleSelector ($item);
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
         return $item;
114 114
     }
115 115
 
116 116
     # Управление VoidCore
117 117
 
118
-    protected function getProperty ($name)
118
+    protected function getProperty($name)
119 119
     {
120
-        return VoidCore::getProperty ($this->selector, $name);
120
+        return VoidCore::getProperty($this->selector, $name);
121 121
     }
122 122
 
123
-    protected function setProperty (string $name, $value): void
123
+    protected function setProperty(string $name, $value): void
124 124
     {
125
-        VoidCore::setProperty ($this->selector, $name, $value);
125
+        VoidCore::setProperty($this->selector, $name, $value);
126 126
     }
127 127
 
128
-    protected function callMethod (string $name, array $args = [])
128
+    protected function callMethod(string $name, array $args = [])
129 129
     {
130
-        return VoidCore::callMethod ($this->selector, $name, ...$args);
130
+        return VoidCore::callMethod($this->selector, $name, ...$args);
131 131
     }
132 132
 
133 133
     # ArrayAccess
134 134
 
135
-    public function offsetSet ($index, $value)
135
+    public function offsetSet($index, $value)
136 136
 	{
137 137
         try
138 138
         {
139 139
             $index === null ?
140
-                $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) :
141
-                $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value));
140
+                $this->callMethod('Add', EngineAdditions::uncoupleSelector($value)) : $this->callMethod('Insert', $index, EngineAdditions::uncoupleSelector($value));
142 141
         }
143 142
 
144 143
         catch (\Throwable $e)
145 144
         {
146 145
             $index === null ?
147
-                VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) :
148
-                VoidCore::setArrayValue ($this->selector, $index, EngineAdditions::uncoupleSelector ($value));
146
+                VoidCore::setArrayValue($this->selector, $this->count, EngineAdditions::uncoupleSelector($value)) : VoidCore::setArrayValue($this->selector, $index, EngineAdditions::uncoupleSelector($value));
149 147
         }
150 148
     }
151 149
 	
152
-	public function offsetGet ($index)
150
+	public function offsetGet($index)
153 151
 	{
154
-		return EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $index), $this->selector);
152
+		return EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $index), $this->selector);
155 153
     }
156 154
 	
157
-	public function offsetUnset ($index): void
155
+	public function offsetUnset($index): void
158 156
 	{
159
-		$this->callMethod ('RemoveAt', $index);
157
+		$this->callMethod('RemoveAt', $index);
160 158
     }
161 159
     
162
-    public function offsetExists ($index): bool
160
+    public function offsetExists($index): bool
163 161
     {
164 162
         try
165 163
         {
166
-            $this->offsetGet ($index);
164
+            $this->offsetGet($index);
167 165
         }
168 166
 
169 167
         catch (\WinformsException $e)
@@ -181,16 +179,16 @@  discard block
 block discarded – undo
181 179
         $size = $this->count;
182 180
 
183 181
         for ($i = 0; $i < $size; ++$i)
184
-            $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i);
182
+            $callback(EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i);
185 183
     }
186 184
 
187
-    public function where (callable $comparator, string $type = null): array
185
+    public function where(callable $comparator, string $type = null): array
188 186
     {
189 187
         $size   = $this->count;
190 188
         $return = [];
191 189
 
192 190
         for ($i = 0; $i < $size; ++$i)
193
-            if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i))
191
+            if ($comparator($value = EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i))
194 192
                 $return[] = $value;
195 193
 
196 194
         return $return;
@@ -198,30 +196,30 @@  discard block
 block discarded – undo
198 196
 
199 197
     # Магические методы
200 198
 
201
-    public function __destruct ()
199
+    public function __destruct()
202 200
     {
203
-        VoidCore::destructObject ($this->selector);
201
+        VoidCore::destructObject($this->selector);
204 202
     }
205 203
 
206
-    public function __toString (): string
204
+    public function __toString(): string
207 205
     {
208 206
         return $this->selector;
209 207
     }
210 208
 
211
-    public function __debugInfo (): array
209
+    public function __debugInfo(): array
212 210
     {
213 211
         $info = ['selector' => $this->selector];
214 212
 
215 213
         try
216 214
         {
217
-            $info['name'] = $this->getProperty ('Name');
215
+            $info['name'] = $this->getProperty('Name');
218 216
         }
219 217
 
220 218
         catch (\WinformsException $e) {}
221 219
 
222 220
         try
223 221
         {
224
-            $info['info'] = $this->callMethod ('ToString');
222
+            $info['info'] = $this->callMethod('ToString');
225 223
         }
226 224
 
227 225
         catch (\WinformsException $e) {}
@@ -232,15 +230,15 @@  discard block
 block discarded – undo
232 230
 
233 231
 class NetClass extends NetObject
234 232
 {
235
-    public function __construct ($name, $assembly = false)
233
+    public function __construct($name, $assembly = false)
236 234
     {
237
-        if (is_int ($name) && VoidCore::objectExists ($name))
235
+        if (is_int($name) && VoidCore::objectExists($name))
238 236
             $this->selector = $name;
239 237
 
240
-        elseif (is_string ($name))
241
-            $this->selector = VoidCore::getClass ($name, $assembly);
238
+        elseif (is_string($name))
239
+            $this->selector = VoidCore::getClass($name, $assembly);
242 240
 
243
-        else throw new \Exception ('Incorrect params passed');
241
+        else throw new \Exception('Incorrect params passed');
244 242
     }
245 243
 }
246 244
 
@@ -265,16 +263,16 @@  discard block
 block discarded – undo
265 263
      * 
266 264
      * @return array - возвращает список ошибок компиляции
267 265
      */
268
-    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
266
+    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 267
     {
270 268
         if ($dictionary === null)
271
-            $dictionary = new NetObject ('System.Collections.Generic.Dictionary`2[System.String,System.String]', null);
269
+            $dictionary = new NetObject('System.Collections.Generic.Dictionary`2[System.String,System.String]', null);
272 270
 
273 271
         if ($assemblies === null)
274
-            $assemblies = dnArray ('System.String', []);
272
+            $assemblies = dnArray('System.String', []);
275 273
 
276 274
         if ($productName === null)
277
-            $productName = basenameNoExt ($savePath);
275
+            $productName = basenameNoExt($savePath);
278 276
 
279 277
         if ($productDescription === null)
280 278
             $productDescription = $productName;
@@ -286,16 +284,16 @@  discard block
 block discarded – undo
286 284
             $companyName = 'Company N';
287 285
 
288 286
         if ($copyright === null)
289
-            $copyright = $companyName .' copyright (c) '. date ('Y');
287
+            $copyright = $companyName.' copyright (c) '.date('Y');
290 288
 
291
-        return (new NetClass ('WinForms_PHP.WFCompiler', null))->compile ($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names;
289
+        return (new NetClass('WinForms_PHP.WFCompiler', null))->compile($savePath, $iconPath, $phpCode, $productDescription, $productName, $productVersion, $companyName, $copyright, $callSharpCode, $declareSharpCode, $dictionary, $assemblies)->names;
292 290
     }
293 291
 
294
-    public static function loadModule (string $path): bool
292
+    public static function loadModule(string $path): bool
295 293
     {
296 294
         try
297 295
         {
298
-            (new NetClass ('System.Reflection.Assembly', 'mscorlib'))->loadFrom ($path);
296
+            (new NetClass('System.Reflection.Assembly', 'mscorlib'))->loadFrom($path);
299 297
         }
300 298
 
301 299
         catch (\WinformsException $e)
@@ -306,15 +304,15 @@  discard block
 block discarded – undo
306 304
         return true;
307 305
     }
308 306
 	
309
-    public static function coupleSelector ($selector)
307
+    public static function coupleSelector($selector)
310 308
     {
311
-        return is_int ($selector) && VoidCore::objectExists ($selector) ?
312
-            new NetObject ($selector) : $selector;
309
+        return is_int($selector) && VoidCore::objectExists($selector) ?
310
+            new NetObject($selector) : $selector;
313 311
     }
314 312
 
315
-    public static function uncoupleSelector ($object)
313
+    public static function uncoupleSelector($object)
316 314
     {
317
-        return is_object ($object) && $object instanceof NetObject ?
315
+        return is_object($object) && $object instanceof NetObject ?
318 316
             $object->selector : $object;
319 317
     }
320 318
 }
Please login to merge, or discard this patch.