Passed
Push — master ( af6f8b...b52801 )
by Observer
01:41
created
engine/extensions/VLF/bin/interpreter.php 3 patches
Braces   +67 added lines, -65 removed lines patch added patch discarded remove patch
@@ -33,15 +33,17 @@  discard block
 block discarded – undo
33 33
                     $name  = $node->args['name'];
34 34
                     $args  = [];
35 35
 
36
-                    if (isset (self::$objects[$name]))
37
-                        break;
36
+                    if (isset (self::$objects[$name])) {
37
+                                            break;
38
+                    }
38 39
 
39 40
                     if (isset ($node->args['args']))
40 41
                     {
41 42
                         $args = $node->args['args'];
42 43
 
43
-                        foreach ($args as $arg_id => $arg)
44
-                            $args[$arg_id] = self::formatLine ($arg, self::$objects);
44
+                        foreach ($args as $arg_id => $arg) {
45
+                                                    $args[$arg_id] = self::formatLine ($arg, self::$objects);
46
+                        }
45 47
                     }
46 48
 
47 49
                     try
@@ -51,15 +53,12 @@  discard block
 block discarded – undo
51 53
                         try
52 54
                         {
53 55
                             self::$objects[$name]->name = $name;
54
-                        }
55
-
56
-                        catch (\Throwable $e) {}
57
-                    }
58
-
59
-                    catch (\Throwable $e)
56
+                        } catch (\Throwable $e) {}
57
+                    } catch (\Throwable $e)
60 58
                     {
61
-                        if (self::$throw_errors)
62
-                            throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e);
59
+                        if (self::$throw_errors) {
60
+                                                    throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e);
61
+                        }
63 62
                     }
64 63
                 break;
65 64
 
@@ -78,13 +77,15 @@  discard block
 block discarded – undo
78 77
                             $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos);
79 78
                             $use = explode (' ', $use);
80 79
 
81
-                            foreach ($use as $id => $useParam)  
82
-                                if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$')
80
+                            foreach ($use as $id => $useParam) {
81
+                                                            if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$')
83 82
                                 {
84 83
                                     $fname = $use[$id + 1];
84
+                            }
85 85
 
86
-                                    if (substr ($fname, strlen ($fname) - 1) == ',')
87
-                                        $fname = substr ($fname, 0, -1);
86
+                                    if (substr ($fname, strlen ($fname) - 1) == ',') {
87
+                                                                            $fname = substr ($fname, 0, -1);
88
+                                    }
88 89
 
89 90
                                     $preset .= "$fname = $useParam; ";
90 91
 
@@ -93,27 +94,26 @@  discard block
 block discarded – undo
93 94
 
94 95
                             $preset        = self::formatLine ($preset, self::$objects);
95 96
                             $propertyValue = self::formatLine (str_replace ($ouse, implode (' ', $use), $propertyValue), self::$objects);
97
+                        } else {
98
+                            $propertyValue = self::formatLine ($propertyValue, self::$objects);
96 99
                         }
97 100
 
98
-                        else $propertyValue = self::formatLine ($propertyValue, self::$objects);
99
-
100 101
                         try
101 102
                         {
102
-							if (strpos ($propertyName, '->') !== false && self::$allow_multimethods_calls)
103
-                                eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';');
104
-                            
105
-                            else self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;");
106
-                        }
107
-
108
-                        catch (\Throwable $e)
103
+							if (strpos ($propertyName, '->') !== false && self::$allow_multimethods_calls) {
104
+							                                eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';');
105
+							} else {
106
+                                self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;");
107
+                            }
108
+                        } catch (\Throwable $e)
109 109
                         {
110
-                            if (self::$throw_errors)
111
-                                throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e);
110
+                            if (self::$throw_errors) {
111
+                                                            throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e);
112
+                            }
112 113
                         }
114
+                    } elseif (self::$throw_errors) {
115
+                                            throw new \Exception ('Setting property to an non-object at line "'. $node->line);
113 116
                     }
114
-
115
-                    elseif (self::$throw_errors)
116
-                        throw new \Exception ('Setting property to an non-object at line "'. $node->line);
117 117
                 break;
118 118
 
119 119
                 case METHOD_CALL:
@@ -124,29 +124,28 @@  discard block
 block discarded – undo
124 124
                         $methodName = $node->args['name'];
125 125
                         $methodArgs = $node->args['args'];
126 126
 
127
-                        foreach ($methodArgs as $arg_id => $arg)
128
-                            $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects);
127
+                        foreach ($methodArgs as $arg_id => $arg) {
128
+                                                    $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects);
129
+                        }
129 130
 
130 131
                         try
131 132
                         {
132
-                            if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls)
133
-                                eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');');
134
-
135
-                            elseif (sizeof ($methodArgs) > 0)
136
-                                self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];'));
137
-
138
-                            else self::$objects[$name]->$methodName ();
139
-                        }
140
-
141
-                        catch (\Throwable $e)
133
+                            if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) {
134
+                                                            eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');');
135
+                            } elseif (sizeof ($methodArgs) > 0) {
136
+                                                            self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];'));
137
+                            } else {
138
+                                self::$objects[$name]->$methodName ();
139
+                            }
140
+                        } catch (\Throwable $e)
142 141
                         {
143
-                            if (self::$throw_errors)
144
-                                throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e);
142
+                            if (self::$throw_errors) {
143
+                                                            throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e);
144
+                            }
145 145
                         }
146
+                    } elseif (self::$throw_errors) {
147
+                                            throw new \Exception ('Calling method to an non-object at line "'. $node->line .'"');
146 148
                     }
147
-
148
-                    elseif (self::$throw_errors)
149
-                        throw new \Exception ('Calling method to an non-object at line "'. $node->line .'"');
150 149
                 break;
151 150
 
152 151
                 case STYLES_IMPORTING:
@@ -156,11 +155,10 @@  discard block
 block discarded – undo
156 155
 
157 156
                         if (!file_exists ($path))
158 157
                         {
159
-                            if (self::$throw_errors)
160
-                                throw new \Exception ('Trying to import nonexistent style at line "'. $node->line .'"');
161
-                        }
162
-                        
163
-                        elseif (!isset (self::$imported_styles[$path]))
158
+                            if (self::$throw_errors) {
159
+                                                            throw new \Exception ('Trying to import nonexistent style at line "'. $node->line .'"');
160
+                            }
161
+                        } elseif (!isset (self::$imported_styles[$path]))
164 162
                         {
165 163
                             \VLF\VST\Interpreter::run (\VLF\VST\Parser::parse (file_get_contents ($path)));
166 164
 
@@ -178,16 +176,17 @@  discard block
 block discarded – undo
178 176
 
179 177
             if ($node->type == OBJECT_DEFINITION)
180 178
             {
181
-                if (isset (\VLF\VST\Interpreter::$default_styles[$node->args['class']]))
182
-                    $nodes = array_merge ($nodes, \VLF\VST\Interpreter::$default_styles[$node->args['class']]);
179
+                if (isset (\VLF\VST\Interpreter::$default_styles[$node->args['class']])) {
180
+                                    $nodes = array_merge ($nodes, \VLF\VST\Interpreter::$default_styles[$node->args['class']]);
181
+                }
183 182
 
184
-                if (isset ($node->args['styles']))
185
-                    foreach ($node->args['styles'] as $style)
183
+                if (isset ($node->args['styles'])) {
184
+                                    foreach ($node->args['styles'] as $style)
186 185
                         if (isset (\VLF\VST\Interpreter::$styles[$style]))
187 186
                             $nodes = array_merge ($nodes, \VLF\VST\Interpreter::$styles[$style]);
188
-
189
-                        elseif (self::$throw_errors)
190
-                            throw new \Exception ('Trying to set undefined style "'. $style .'" to object at line "'. $node->line .'"');
187
+                } elseif (self::$throw_errors) {
188
+                                                    throw new \Exception ('Trying to set undefined style "'. $style .'" to object at line "'. $node->line .'"');
189
+                        }
191 190
             }
192 191
 
193 192
             self::$objects = self::run (new AST (array_map (
@@ -228,8 +227,9 @@  discard block
 block discarded – undo
228 227
 
229 228
             $nReplacement = [];
230 229
 
231
-            foreach ($replacement as $replaceTo => $nLn)
232
-                $nReplacement[$omap[$replaceTo]] = $replaceTo;
230
+            foreach ($replacement as $replaceTo => $nLn) {
231
+                            $nReplacement[$omap[$replaceTo]] = $replaceTo;
232
+            }
233 233
 
234 234
             $replacement = $nReplacement;
235 235
             $blacklist   = array_flip (['\'', '"', '$']);
@@ -238,10 +238,11 @@  discard block
 block discarded – undo
238 238
             {
239 239
                 $replaced = false;
240 240
 
241
-                foreach ($replacement as $name => $replaceAt)
242
-                    if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]]))
241
+                foreach ($replacement as $name => $replaceAt) {
242
+                                    if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]]))
243 243
                     {
244 244
                         $newLine .= $replaceAt;
245
+                }
245 246
 
246 247
                         $i += $l - 1;
247 248
                         $replaced = true;
@@ -249,8 +250,9 @@  discard block
 block discarded – undo
249 250
                         break;
250 251
                     }
251 252
 
252
-                if (!$replaced)
253
-                    $newLine .= $line[$i];
253
+                if (!$replaced) {
254
+                                    $newLine .= $line[$i];
255
+                }
254 256
             }
255 257
 
256 258
             $line = $newLine;
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
                         try
101 101
                         {
102
-							if (strpos ($propertyName, '->') !== false && self::$allow_multimethods_calls)
102
+                            if (strpos ($propertyName, '->') !== false && self::$allow_multimethods_calls)
103 103
                                 eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';');
104 104
                             
105 105
                             else self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;");
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
         return $line;
260 260
     }
261 261
 	
262
-	public static function clear (): void
263
-	{
264
-		self::$objects = [];
265
-		self::$imported_styles = [];
266
-	}
262
+    public static function clear (): void
263
+    {
264
+        self::$objects = [];
265
+        self::$imported_styles = [];
266
+    }
267 267
 }
Please login to merge, or discard this patch.
Spacing   +50 added lines, -51 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
      * 
23 23
      * @return array - возвращает список созданных объектов
24 24
      */
25
-    public static function run (AST $tree, Node $parent = null): array
25
+    public static function run(AST $tree, Node $parent = null): array
26 26
     {
27
-        foreach ($tree->getNodes () as $node)
27
+        foreach ($tree->getNodes() as $node)
28 28
         {
29 29
             switch ($node->type)
30 30
             {
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
                         $args = $node->args['args'];
42 42
 
43 43
                         foreach ($args as $arg_id => $arg)
44
-                            $args[$arg_id] = self::formatLine ($arg, self::$objects);
44
+                            $args[$arg_id] = self::formatLine($arg, self::$objects);
45 45
                     }
46 46
 
47 47
                     try
48 48
                     {
49
-                        self::$objects[$name] = eval ("namespace VoidEngine; return new $class (". implode (', ', $args) .");");
49
+                        self::$objects[$name] = eval ("namespace VoidEngine; return new $class (".implode(', ', $args).");");
50 50
 
51 51
                         try
52 52
                         {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                     catch (\Throwable $e)
60 60
                     {
61 61
                         if (self::$throw_errors)
62
-                            throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e);
62
+                            throw new \Exception('Interpeter couldn\'t create object "'.$class.'" with name "'.$name.'" at line "'.$node->line.'". Exception info:'."\n\n".(string) $e, 0, $e);
63 63
                     }
64 64
                 break;
65 65
 
@@ -72,35 +72,35 @@  discard block
 block discarded – undo
72 72
                         $propertyValue = $node->args['value'];
73 73
                         $preset        = '';
74 74
 
75
-                        if (preg_match ('/function \((.*)\) use \((.*)\)/', $propertyValue))
75
+                        if (preg_match('/function \((.*)\) use \((.*)\)/', $propertyValue))
76 76
                         {
77
-                            $use = substr ($propertyValue, strpos ($propertyValue, 'use'));
78
-                            $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos);
79
-                            $use = explode (' ', $use);
77
+                            $use = substr($propertyValue, strpos($propertyValue, 'use'));
78
+                            $use = $ouse = substr($use, ($pos = strpos($use, '(') + 1), strpos($use, ')') - $pos);
79
+                            $use = explode(' ', $use);
80 80
 
81 81
                             foreach ($use as $id => $useParam)  
82 82
                                 if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$')
83 83
                                 {
84 84
                                     $fname = $use[$id + 1];
85 85
 
86
-                                    if (substr ($fname, strlen ($fname) - 1) == ',')
87
-                                        $fname = substr ($fname, 0, -1);
86
+                                    if (substr($fname, strlen($fname) - 1) == ',')
87
+                                        $fname = substr($fname, 0, -1);
88 88
 
89 89
                                     $preset .= "$fname = $useParam; ";
90 90
 
91 91
                                     unset ($use[$id]);
92 92
                                 }
93 93
 
94
-                            $preset        = self::formatLine ($preset, self::$objects);
95
-                            $propertyValue = self::formatLine (str_replace ($ouse, implode (' ', $use), $propertyValue), self::$objects);
94
+                            $preset        = self::formatLine($preset, self::$objects);
95
+                            $propertyValue = self::formatLine(str_replace($ouse, implode(' ', $use), $propertyValue), self::$objects);
96 96
                         }
97 97
 
98
-                        else $propertyValue = self::formatLine ($propertyValue, self::$objects);
98
+                        else $propertyValue = self::formatLine($propertyValue, self::$objects);
99 99
 
100 100
                         try
101 101
                         {
102
-							if (strpos ($propertyName, '->') !== false && self::$allow_multimethods_calls)
103
-                                eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';');
102
+							if (strpos($propertyName, '->') !== false && self::$allow_multimethods_calls)
103
+                                eval ('namespace VoidEngine; '.$preset.' _c('.self::$objects[$name]->selector.')->'.$propertyName.' = '.$propertyValue.';');
104 104
                             
105 105
                             else self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;");
106 106
                         }
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
                         catch (\Throwable $e)
109 109
                         {
110 110
                             if (self::$throw_errors)
111
-                                throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e);
111
+                                throw new \Exception('Interpeter couldn\'t set property "'.$propertyName.'" with value "'.$propertyValue.'" at line "'.$node->line.'". Exception info:'."\n\n".(string) $e, 0, $e);
112 112
                         }
113 113
                     }
114 114
 
115 115
                     elseif (self::$throw_errors)
116
-                        throw new \Exception ('Setting property to an non-object at line "'. $node->line);
116
+                        throw new \Exception('Setting property to an non-object at line "'.$node->line);
117 117
                 break;
118 118
 
119 119
                 case METHOD_CALL:
@@ -125,44 +125,44 @@  discard block
 block discarded – undo
125 125
                         $methodArgs = $node->args['args'];
126 126
 
127 127
                         foreach ($methodArgs as $arg_id => $arg)
128
-                            $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects);
128
+                            $methodArgs[$arg_id] = self::formatLine($arg, self::$objects);
129 129
 
130 130
                         try
131 131
                         {
132
-                            if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls)
133
-                                eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');');
132
+                            if (strpos($methodName, '->') !== false && self::$allow_multimethods_calls)
133
+                                eval ('namespace VoidEngine; _c('.self::$objects[$name]->selector.')->'.$methodName.' ('.implode(', ', $methodArgs).');');
134 134
 
135
-                            elseif (sizeof ($methodArgs) > 0)
136
-                                self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];'));
135
+                            elseif (sizeof($methodArgs) > 0)
136
+                                self::$objects[$name]->$methodName(...eval ('namespace VoidEngine; return ['.implode(', ', $methodArgs).'];'));
137 137
 
138
-                            else self::$objects[$name]->$methodName ();
138
+                            else self::$objects[$name]->$methodName();
139 139
                         }
140 140
 
141 141
                         catch (\Throwable $e)
142 142
                         {
143 143
                             if (self::$throw_errors)
144
-                                throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e);
144
+                                throw new \Exception('Interpeter couldn\'t call method "'.$methodName.'" with arguments '.json_encode($methodArgs).' at line "'.$node->line.'". Exception info:'."\n\n".(string) $e, 0, $e);
145 145
                         }
146 146
                     }
147 147
 
148 148
                     elseif (self::$throw_errors)
149
-                        throw new \Exception ('Calling method to an non-object at line "'. $node->line .'"');
149
+                        throw new \Exception('Calling method to an non-object at line "'.$node->line.'"');
150 150
                 break;
151 151
 
152 152
                 case STYLES_IMPORTING:
153 153
                     foreach ($node->args['imports'] as $style)
154 154
                     {
155
-                        $path = eval ('namespace VoidEngine; return '. self::formatLine ($style, self::$objects) .';');
155
+                        $path = eval ('namespace VoidEngine; return '.self::formatLine($style, self::$objects).';');
156 156
 
157
-                        if (!file_exists ($path))
157
+                        if (!file_exists($path))
158 158
                         {
159 159
                             if (self::$throw_errors)
160
-                                throw new \Exception ('Trying to import nonexistent style at line "'. $node->line .'"');
160
+                                throw new \Exception('Trying to import nonexistent style at line "'.$node->line.'"');
161 161
                         }
162 162
                         
163 163
                         elseif (!isset (self::$imported_styles[$path]))
164 164
                         {
165
-                            \VLF\VST\Interpreter::run (\VLF\VST\Parser::parse (file_get_contents ($path)));
165
+                            \VLF\VST\Interpreter::run(\VLF\VST\Parser::parse(file_get_contents($path)));
166 166
 
167 167
                             self::$imported_styles[$path] = true;
168 168
                         }
@@ -170,28 +170,28 @@  discard block
 block discarded – undo
170 170
                 break;
171 171
 
172 172
                 case RUNTIME_EXECUTION:
173
-                    eval (self::formatLine ($node->args['code'], self::$objects));
173
+                    eval (self::formatLine($node->args['code'], self::$objects));
174 174
                 break;
175 175
             }
176 176
 
177
-            $nodes = $node->getNodes ();
177
+            $nodes = $node->getNodes();
178 178
 
179 179
             if ($node->type == OBJECT_DEFINITION)
180 180
             {
181 181
                 if (isset (\VLF\VST\Interpreter::$default_styles[$node->args['class']]))
182
-                    $nodes = array_merge ($nodes, \VLF\VST\Interpreter::$default_styles[$node->args['class']]);
182
+                    $nodes = array_merge($nodes, \VLF\VST\Interpreter::$default_styles[$node->args['class']]);
183 183
 
184 184
                 if (isset ($node->args['styles']))
185 185
                     foreach ($node->args['styles'] as $style)
186 186
                         if (isset (\VLF\VST\Interpreter::$styles[$style]))
187
-                            $nodes = array_merge ($nodes, \VLF\VST\Interpreter::$styles[$style]);
187
+                            $nodes = array_merge($nodes, \VLF\VST\Interpreter::$styles[$style]);
188 188
 
189 189
                         elseif (self::$throw_errors)
190
-                            throw new \Exception ('Trying to set undefined style "'. $style .'" to object at line "'. $node->line .'"');
190
+                            throw new \Exception('Trying to set undefined style "'.$style.'" to object at line "'.$node->line.'"');
191 191
             }
192 192
 
193
-            self::$objects = self::run (new AST (array_map (
194
-                fn ($node) => $node->export (), $nodes)), $node);
193
+            self::$objects = self::run(new AST(array_map(
194
+                fn($node) => $node->export(), $nodes)), $node);
195 195
         }
196 196
 
197 197
         return self::$objects;
@@ -205,26 +205,25 @@  discard block
 block discarded – undo
205 205
      * 
206 206
      * @return string - возвращает форматированную строку
207 207
      */
208
-    public static function formatLine (string $line, array $objects = []): string
208
+    public static function formatLine(string $line, array $objects = []): string
209 209
     {
210
-        if (sizeof ($objects) > 0)
210
+        if (sizeof($objects) > 0)
211 211
         {
212
-            $len     = strlen ($line);
212
+            $len     = strlen($line);
213 213
             $newLine = '';
214 214
 
215
-            $replacement = array_map (function ($object)
215
+            $replacement = array_map(function($object)
216 216
             {
217
-                return \VoidEngine\Components::exists ($object->selector) !== false ? 
218
-                    '\VoidEngine\_c('. $object->selector .')' :
219
-                    'unserialize (\''. serialize ($object) .'\')';
217
+                return \VoidEngine\Components::exists($object->selector) !== false ? 
218
+                    '\VoidEngine\_c('.$object->selector.')' : 'unserialize (\''.serialize($object).'\')';
220 219
             }, $objects);
221 220
 
222
-            $replacement = array_map (function ($name)
221
+            $replacement = array_map(function($name)
223 222
             {
224
-                return strlen ($name = trim ($name)) + substr_count ($name, '_');
225
-            }, $omap = array_flip ($replacement));
223
+                return strlen($name = trim($name)) + substr_count($name, '_');
224
+            }, $omap = array_flip($replacement));
226 225
 
227
-            arsort ($replacement);
226
+            arsort($replacement);
228 227
 
229 228
             $nReplacement = [];
230 229
 
@@ -232,14 +231,14 @@  discard block
 block discarded – undo
232 231
                 $nReplacement[$omap[$replaceTo]] = $replaceTo;
233 232
 
234 233
             $replacement = $nReplacement;
235
-            $blacklist   = array_flip (['\'', '"', '$']);
234
+            $blacklist   = array_flip(['\'', '"', '$']);
236 235
 
237 236
             for ($i = 0; $i < $len; ++$i)
238 237
             {
239 238
                 $replaced = false;
240 239
 
241 240
                 foreach ($replacement as $name => $replaceAt)
242
-                    if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]]))
241
+                    if (substr($line, $i, ($l = strlen($name))) == $name && !isset ($blacklist[$line[$i - 1]]))
243 242
                     {
244 243
                         $newLine .= $replaceAt;
245 244
 
@@ -259,7 +258,7 @@  discard block
 block discarded – undo
259 258
         return $line;
260 259
     }
261 260
 	
262
-	public static function clear (): void
261
+	public static function clear(): void
263 262
 	{
264 263
 		self::$objects = [];
265 264
 		self::$imported_styles = [];
Please login to merge, or discard this patch.
engine/common/Components.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,62 +6,62 @@
 block discarded – undo
6 6
 {
7 7
     protected static array $objects = [];
8 8
 
9
-    public static function add (NetObject $object): void
9
+    public static function add(NetObject $object): void
10 10
     {
11
-        self::$objects[$object->selector] = \WeakReference::create ($object);
11
+        self::$objects[$object->selector] = \WeakReference::create($object);
12 12
     }
13 13
 
14
-    public static function get (int $selector): ?NetObject
14
+    public static function get(int $selector): ?NetObject
15 15
     {
16 16
         if (!isset (self::$objects[$selector]))
17 17
             return null;
18 18
         
19
-        $object = self::$objects[$selector]->get ();
19
+        $object = self::$objects[$selector]->get();
20 20
 
21 21
         if ($object === null)
22
-            self::remove ($selector);
22
+            self::remove($selector);
23 23
 
24 24
         return $object;
25 25
     }
26 26
 
27
-    public static function exists (int $selector): bool
27
+    public static function exists(int $selector): bool
28 28
     {
29 29
         return isset (self::$objects[$selector]);
30 30
     }
31 31
 
32
-    public static function getObjects (): array
32
+    public static function getObjects(): array
33 33
     {
34 34
         return self::$objects;
35 35
     }
36 36
 
37
-    public static function remove (int $selector): void
37
+    public static function remove(int $selector): void
38 38
     {
39 39
         unset (self::$objects[$selector]);
40 40
     }
41 41
 
42
-    public static function clean (): void
42
+    public static function clean(): void
43 43
     {
44 44
         foreach (self::$objects as $selector => $reference)
45
-            if ($reference->get () === null)
45
+            if ($reference->get() === null)
46 46
                 unset (self::$objects[$selector]);
47 47
     }
48 48
 }
49 49
 
50
-function _c (int $selector): ?NetObject
50
+function _c(int $selector): ?NetObject
51 51
 {
52
-    return Components::get ($selector);
52
+    return Components::get($selector);
53 53
 }
54 54
 
55 55
 // TODO: поддержка многоуровневых ссылок вида родитель->родитель->объект
56 56
 // VoidCore::getPrevClass
57
-function c (string $name): ?NetObject
57
+function c(string $name): ?NetObject
58 58
 {
59
-    if (is_int ($name) && ($object = _c($name)) !== null)
59
+    if (is_int($name) && ($object = _c($name)) !== null)
60 60
         return $object;
61 61
 
62
-    foreach (Components::getObjects () as $selector => $reference)
62
+    foreach (Components::getObjects() as $selector => $reference)
63 63
     {
64
-        $object = $reference->get ();
64
+        $object = $reference->get();
65 65
 
66 66
         if ($object === null)
67 67
             continue;
Please login to merge, or discard this patch.
Braces   +19 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,13 +13,15 @@  discard block
 block discarded – undo
13 13
 
14 14
     public static function get (int $selector): ?NetObject
15 15
     {
16
-        if (!isset (self::$objects[$selector]))
17
-            return null;
16
+        if (!isset (self::$objects[$selector])) {
17
+                    return null;
18
+        }
18 19
         
19 20
         $object = self::$objects[$selector]->get ();
20 21
 
21
-        if ($object === null)
22
-            self::remove ($selector);
22
+        if ($object === null) {
23
+                    self::remove ($selector);
24
+        }
23 25
 
24 26
         return $object;
25 27
     }
@@ -41,9 +43,10 @@  discard block
 block discarded – undo
41 43
 
42 44
     public static function clean (): void
43 45
     {
44
-        foreach (self::$objects as $selector => $reference)
45
-            if ($reference->get () === null)
46
+        foreach (self::$objects as $selector => $reference) {
47
+                    if ($reference->get () === null)
46 48
                 unset (self::$objects[$selector]);
49
+        }
47 50
     }
48 51
 }
49 52
 
@@ -56,23 +59,24 @@  discard block
 block discarded – undo
56 59
 // VoidCore::getPrevClass
57 60
 function c (string $name): ?NetObject
58 61
 {
59
-    if (is_int ($name) && ($object = _c($name)) !== null)
60
-        return $object;
62
+    if (is_int ($name) && ($object = _c($name)) !== null) {
63
+            return $object;
64
+    }
61 65
 
62 66
     foreach (Components::getObjects () as $selector => $reference)
63 67
     {
64 68
         $object = $reference->get ();
65 69
 
66
-        if ($object === null)
67
-            continue;
70
+        if ($object === null) {
71
+                    continue;
72
+        }
68 73
 
69 74
         try
70 75
         {
71
-            if ($object->name == $name)
72
-                return $object;
73
-        }
74
-
75
-        catch (\Throwable $e) {}
76
+            if ($object->name == $name) {
77
+                            return $object;
78
+            }
79
+        } catch (\Throwable $e) {}
76 80
     }
77 81
 
78 82
     return null;
Please login to merge, or discard this patch.
engine/common/EngineInterfaces.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                 $size = $this->count;
56 56
                 $list = [];
57 57
                 
58
-				for ($i = 0; $i < $size; ++$i)
58
+                for ($i = 0; $i < $size; ++$i)
59 59
                     $list[] = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $i));
60 60
                 
61 61
                 return $list;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     # ArrayAccess
125 125
 
126 126
     public function offsetSet ($index, $value)
127
-	{
127
+    {
128 128
         try
129 129
         {
130 130
             $index === null ?
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
         }
141 141
     }
142 142
 	
143
-	public function offsetGet ($index)
144
-	{
145
-		return EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $index), $this->selector);
143
+    public function offsetGet ($index)
144
+    {
145
+        return EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $index), $this->selector);
146 146
     }
147 147
 	
148
-	public function offsetUnset ($index): void
149
-	{
150
-		$this->callMethod ('RemoveAt', $index);
148
+    public function offsetUnset ($index): void
149
+    {
150
+        $this->callMethod ('RemoveAt', $index);
151 151
     }
152 152
     
153 153
     public function offsetExists ($index): bool
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
 class EngineAdditions
239 239
 {
240
-	/**
240
+    /**
241 241
      * * Компиляция PHP кода
242 242
      * 
243 243
      * TODO: дополнить описание
Please login to merge, or discard this 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.
Braces   +70 added lines, -70 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, $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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
app_bundle/start.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@
 block discarded – undo
11 11
 const APP_DIR = __DIR__;
12 12
 
13 13
 define ('VoidEngine\CORE_DIR',
14
-	file_exists ($dir = dirname (__DIR__) .'/qero-packages/winforms-php/VoidFramework/core') ? $dir : __DIR__);
14
+    file_exists ($dir = dirname (__DIR__) .'/qero-packages/winforms-php/VoidFramework/core') ? $dir : __DIR__);
15 15
 
16 16
 # Подгружаем PHP расширения
17 17
 foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext)
18
-	if (!extension_loaded (substr (basename ($ext), 4, -4)))
19
-		load_extension ($ext);
18
+    if (!extension_loaded (substr (basename ($ext), 4, -4)))
19
+        load_extension ($ext);
20 20
 
21 21
 # Подгружаем Qero-пакеты
22 22
 require __DIR__ .'/../qero-packages/autoload.php';
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,20 +10,20 @@
 block discarded – undo
10 10
 # Объявление констант
11 11
 const APP_DIR = __DIR__;
12 12
 
13
-define ('VoidEngine\CORE_DIR',
14
-	file_exists ($dir = dirname (__DIR__) .'/qero-packages/winforms-php/VoidFramework/core') ? $dir : __DIR__);
13
+define('VoidEngine\CORE_DIR',
14
+	file_exists($dir = dirname(__DIR__).'/qero-packages/winforms-php/VoidFramework/core') ? $dir : __DIR__);
15 15
 
16 16
 # Подгружаем PHP расширения
17
-foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext)
18
-	if (!extension_loaded (substr (basename ($ext), 4, -4)))
19
-		load_extension ($ext);
17
+foreach (glob(CORE_DIR.'/ext/php_*.dll') as $ext)
18
+	if (!extension_loaded(substr(basename($ext), 4, -4)))
19
+		load_extension($ext);
20 20
 
21 21
 # Подгружаем Qero-пакеты
22
-require __DIR__ .'/../qero-packages/autoload.php';
22
+require __DIR__.'/../qero-packages/autoload.php';
23 23
 
24
-chdir (APP_DIR); // Меняем стандартную директорию на директорию приложения
24
+chdir(APP_DIR); // Меняем стандартную директорию на директорию приложения
25 25
 
26 26
 # Парсим разметку app.vlf и запускаем приложение
27
-$objects = Interpreter::run (Parser::parse ('app.vlf'));
27
+$objects = Interpreter::run(Parser::parse('app.vlf'));
28 28
 
29
-$APPLICATION->run ($objects['MainForm']);
29
+$APPLICATION->run($objects['MainForm']);
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,9 +14,10 @@
 block discarded – undo
14 14
 	file_exists ($dir = dirname (__DIR__) .'/qero-packages/winforms-php/VoidFramework/core') ? $dir : __DIR__);
15 15
 
16 16
 # Подгружаем PHP расширения
17
-foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext)
17
+foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext) {
18 18
 	if (!extension_loaded (substr (basename ($ext), 4, -4)))
19 19
 		load_extension ($ext);
20
+}
20 21
 
21 22
 # Подгружаем Qero-пакеты
22 23
 require __DIR__ .'/../qero-packages/autoload.php';
Please login to merge, or discard this patch.