@@ -20,33 +20,33 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return AST - возвращает AST дерево разметки |
22 | 22 | */ |
23 | - public static function parse (string $vst): AST |
|
23 | + public static function parse(string $vst): AST |
|
24 | 24 | { |
25 | 25 | $tree = new AST; |
26 | 26 | $objects = new Stack; |
27 | 27 | |
28 | - if (file_exists ($vst)) |
|
29 | - $vst = file_get_contents ($vst); |
|
28 | + if (file_exists($vst)) |
|
29 | + $vst = file_get_contents($vst); |
|
30 | 30 | |
31 | - $lines = explode (self::$divider, $vst); |
|
31 | + $lines = explode(self::$divider, $vst); |
|
32 | 32 | $skip_at = -1; |
33 | 33 | |
34 | 34 | foreach ($lines as $line_num => $line) |
35 | 35 | { |
36 | 36 | // \VoidEngine\pre ($line_num .', '. ($skip_at > $line_num ? 'skip' : 'not skip') .': '. $line); |
37 | 37 | |
38 | - if ($skip_at > $line_num || !self::filter ($line)) |
|
38 | + if ($skip_at > $line_num || !self::filter($line)) |
|
39 | 39 | continue; |
40 | 40 | |
41 | - $height = self::getHeight ($line); |
|
42 | - $words = array_filter (explode (' ', $line), 'VLF\Parser::filter'); |
|
41 | + $height = self::getHeight($line); |
|
42 | + $words = array_filter(explode(' ', $line), 'VLF\Parser::filter'); |
|
43 | 43 | $poped = false; |
44 | 44 | |
45 | 45 | # Очищаем стек объектов |
46 | - while ($objects->size () > 0) |
|
47 | - if ($objects->current ()->height >= $height) |
|
46 | + while ($objects->size() > 0) |
|
47 | + if ($objects->current()->height >= $height) |
|
48 | 48 | { |
49 | - $objects->pop (); |
|
49 | + $objects->pop(); |
|
50 | 50 | |
51 | 51 | $poped = true; |
52 | 52 | } |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | else break; |
55 | 55 | |
56 | 56 | # Создаём новую ссылку на объект |
57 | - if ($poped && $objects->size () > 0) |
|
57 | + if ($poped && $objects->size() > 0) |
|
58 | 58 | { |
59 | - $object = $objects->pop (); |
|
59 | + $object = $objects->pop(); |
|
60 | 60 | |
61 | - $objects->push (new Node (array_merge ($object->export (), ['nodes' => []]))); |
|
62 | - $tree->push ($objects->current ()); |
|
61 | + $objects->push(new Node(array_merge($object->export(), ['nodes' => []]))); |
|
62 | + $tree->push($objects->current()); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | if (isset ($words[0][1])) |
74 | 74 | { |
75 | 75 | if ($words[0][1] == '^') |
76 | - $skip_at = self::parseSubtext ($lines, $line_num, $height)[1]; |
|
76 | + $skip_at = self::parseSubtext($lines, $line_num, $height)[1]; |
|
77 | 77 | |
78 | - else throw new \Exception ('Unknown char founded after comment definition at line '. ($line_num + 1)); |
|
78 | + else throw new \Exception('Unknown char founded after comment definition at line '.($line_num + 1)); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | continue; |
@@ -86,30 +86,30 @@ discard block |
||
86 | 86 | */ |
87 | 87 | elseif ($words[0][0] == '.') |
88 | 88 | { |
89 | - $pos = strpos ($line, ':'); |
|
89 | + $pos = strpos($line, ':'); |
|
90 | 90 | $parents = null; |
91 | 91 | |
92 | 92 | if ($pos !== false) |
93 | 93 | { |
94 | - $name = trim (substr ($line, 1, $pos - 1)); |
|
94 | + $name = trim(substr($line, 1, $pos - 1)); |
|
95 | 95 | |
96 | 96 | if (isset ($line[$pos])) |
97 | 97 | { |
98 | - $parents = trim (substr ($line, $pos + 1)); |
|
98 | + $parents = trim(substr($line, $pos + 1)); |
|
99 | 99 | |
100 | - if (strlen ($parents) == 0) |
|
100 | + if (strlen($parents) == 0) |
|
101 | 101 | $parents = null; |
102 | 102 | |
103 | - else $parents = array_map ('trim', explode (',', $parents)); |
|
103 | + else $parents = array_map('trim', explode(',', $parents)); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - else $name = trim (substr ($line, 1)); |
|
107 | + else $name = trim(substr($line, 1)); |
|
108 | 108 | |
109 | - if ($parents === null && $objects->size () > 0 && $objects->current ()->height < $height) |
|
110 | - $parents = [$objects->current ()->args['name']]; |
|
109 | + if ($parents === null && $objects->size() > 0 && $objects->current()->height < $height) |
|
110 | + $parents = [$objects->current()->args['name']]; |
|
111 | 111 | |
112 | - $objects->push (new Node ([ |
|
112 | + $objects->push(new Node([ |
|
113 | 113 | 'type' => \VLF\STYLE_DEFINITION, |
114 | 114 | 'line' => $line, |
115 | 115 | 'words' => $words, |
@@ -121,35 +121,35 @@ discard block |
||
121 | 121 | ] |
122 | 122 | ])); |
123 | 123 | |
124 | - $tree->push ($objects->current ()); |
|
124 | + $tree->push($objects->current()); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Установка свойства |
129 | 129 | */ |
130 | - elseif (($pos = strpos ($line, ':')) !== false) |
|
130 | + elseif (($pos = strpos($line, ':')) !== false) |
|
131 | 131 | { |
132 | - if ($objects->size () == 0) |
|
133 | - throw new \Exception ('Trying to set property to unknown object at line '. ($line_num + 1)); |
|
132 | + if ($objects->size() == 0) |
|
133 | + throw new \Exception('Trying to set property to unknown object at line '.($line_num + 1)); |
|
134 | 134 | |
135 | 135 | if (!isset ($words[1])) |
136 | - throw new \Exception ('Trying to set void property value at line '. ($line_num + 1)); |
|
136 | + throw new \Exception('Trying to set void property value at line '.($line_num + 1)); |
|
137 | 137 | |
138 | - $propertyName = substr ($line, 0, $pos); |
|
139 | - $propertyValue = substr ($line, $pos + 1); |
|
138 | + $propertyName = substr($line, 0, $pos); |
|
139 | + $propertyValue = substr($line, $pos + 1); |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Обработка многострочных свойств |
143 | 143 | */ |
144 | 144 | if ($line[$pos + 1] == '^') |
145 | 145 | { |
146 | - $parsed = self::parseSubtext ($lines, $line_num, $height); |
|
146 | + $parsed = self::parseSubtext($lines, $line_num, $height); |
|
147 | 147 | |
148 | - $propertyValue = substr ($propertyValue, 1) . $parsed[0]; |
|
148 | + $propertyValue = substr($propertyValue, 1).$parsed[0]; |
|
149 | 149 | $skip_at = $parsed[1]; |
150 | 150 | } |
151 | 151 | |
152 | - $objects->current ()->push (new Node ([ |
|
152 | + $objects->current()->push(new Node([ |
|
153 | 153 | 'type' => \VLF\PROPERTY_SET, |
154 | 154 | 'line' => $line, |
155 | 155 | 'words' => $words, |
@@ -167,26 +167,26 @@ discard block |
||
167 | 167 | */ |
168 | 168 | elseif (isset ($words[0][1]) && $words[0][0] == '-' && $words[0][1] == '>') |
169 | 169 | { |
170 | - if ($objects->size () == 0) |
|
171 | - throw new \Exception ('Trying to call method from unknown object at line '. ($line_num + 1)); |
|
170 | + if ($objects->size() == 0) |
|
171 | + throw new \Exception('Trying to call method from unknown object at line '.($line_num + 1)); |
|
172 | 172 | |
173 | 173 | $methodArgs = []; |
174 | 174 | |
175 | - if (($pos = strpos ($line, '(')) !== false) |
|
175 | + if (($pos = strpos($line, '(')) !== false) |
|
176 | 176 | { |
177 | - if (($end = strrpos ($line, ')', $pos)) === false) |
|
178 | - throw new \Exception ('Incorrect method arguments syntax at line '. ($line_num + 1)); |
|
177 | + if (($end = strrpos($line, ')', $pos)) === false) |
|
178 | + throw new \Exception('Incorrect method arguments syntax at line '.($line_num + 1)); |
|
179 | 179 | |
180 | - $methodArgs = substr ($line, $pos + 1, $end - $pos - 1); |
|
180 | + $methodArgs = substr($line, $pos + 1, $end - $pos - 1); |
|
181 | 181 | |
182 | - $methodName = trim (substr ($line, 2, $pos - 2)); |
|
183 | - $methodArgs = self::filter ($methodArgs) ? |
|
184 | - self::parseArguments ($methodArgs) : []; |
|
182 | + $methodName = trim(substr($line, 2, $pos - 2)); |
|
183 | + $methodArgs = self::filter($methodArgs) ? |
|
184 | + self::parseArguments($methodArgs) : []; |
|
185 | 185 | } |
186 | 186 | |
187 | - else $methodName = trim (substr ($line, 2)); |
|
187 | + else $methodName = trim(substr($line, 2)); |
|
188 | 188 | |
189 | - $objects->current ()->push (new Node ([ |
|
189 | + $objects->current()->push(new Node([ |
|
190 | 190 | 'type' => \VLF\METHOD_CALL, |
191 | 191 | 'line' => $line, |
192 | 192 | 'words' => $words, |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | /** |
203 | 203 | * Неопознанная структура |
204 | 204 | */ |
205 | - else throw new \Exception ('Unsupported structure founded at line '. ($line_num + 1)); |
|
205 | + else throw new \Exception('Unsupported structure founded at line '.($line_num + 1)); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | return $tree; |
@@ -25,8 +25,9 @@ discard block |
||
25 | 25 | $tree = new AST; |
26 | 26 | $objects = new Stack; |
27 | 27 | |
28 | - if (file_exists ($vst)) |
|
29 | - $vst = file_get_contents ($vst); |
|
28 | + if (file_exists ($vst)) { |
|
29 | + $vst = file_get_contents ($vst); |
|
30 | + } |
|
30 | 31 | |
31 | 32 | $lines = explode (self::$divider, $vst); |
32 | 33 | $skip_at = -1; |
@@ -35,24 +36,26 @@ discard block |
||
35 | 36 | { |
36 | 37 | // \VoidEngine\pre ($line_num .', '. ($skip_at > $line_num ? 'skip' : 'not skip') .': '. $line); |
37 | 38 | |
38 | - if ($skip_at > $line_num || !self::filter ($line)) |
|
39 | - continue; |
|
39 | + if ($skip_at > $line_num || !self::filter ($line)) { |
|
40 | + continue; |
|
41 | + } |
|
40 | 42 | |
41 | 43 | $height = self::getHeight ($line); |
42 | 44 | $words = array_filter (explode (' ', $line), 'VLF\Parser::filter'); |
43 | 45 | $poped = false; |
44 | 46 | |
45 | 47 | # Очищаем стек объектов |
46 | - while ($objects->size () > 0) |
|
47 | - if ($objects->current ()->height >= $height) |
|
48 | + while ($objects->size () > 0) { |
|
49 | + if ($objects->current ()->height >= $height) |
|
48 | 50 | { |
49 | 51 | $objects->pop (); |
52 | + } |
|
50 | 53 | |
51 | 54 | $poped = true; |
55 | + } else { |
|
56 | + break; |
|
52 | 57 | } |
53 | 58 | |
54 | - else break; |
|
55 | - |
|
56 | 59 | # Создаём новую ссылку на объект |
57 | 60 | if ($poped && $objects->size () > 0) |
58 | 61 | { |
@@ -72,10 +75,11 @@ discard block |
||
72 | 75 | */ |
73 | 76 | if (isset ($words[0][1])) |
74 | 77 | { |
75 | - if ($words[0][1] == '^') |
|
76 | - $skip_at = self::parseSubtext ($lines, $line_num, $height)[1]; |
|
77 | - |
|
78 | - else throw new \Exception ('Unknown char founded after comment definition at line '. ($line_num + 1)); |
|
78 | + if ($words[0][1] == '^') { |
|
79 | + $skip_at = self::parseSubtext ($lines, $line_num, $height)[1]; |
|
80 | + } else { |
|
81 | + throw new \Exception ('Unknown char founded after comment definition at line '. ($line_num + 1)); |
|
82 | + } |
|
79 | 83 | } |
80 | 84 | |
81 | 85 | continue; |
@@ -97,17 +101,19 @@ discard block |
||
97 | 101 | { |
98 | 102 | $parents = trim (substr ($line, $pos + 1)); |
99 | 103 | |
100 | - if (strlen ($parents) == 0) |
|
101 | - $parents = null; |
|
102 | - |
|
103 | - else $parents = array_map ('trim', explode (',', $parents)); |
|
104 | + if (strlen ($parents) == 0) { |
|
105 | + $parents = null; |
|
106 | + } else { |
|
107 | + $parents = array_map ('trim', explode (',', $parents)); |
|
108 | + } |
|
104 | 109 | } |
110 | + } else { |
|
111 | + $name = trim (substr ($line, 1)); |
|
105 | 112 | } |
106 | 113 | |
107 | - else $name = trim (substr ($line, 1)); |
|
108 | - |
|
109 | - if ($parents === null && $objects->size () > 0 && $objects->current ()->height < $height) |
|
110 | - $parents = [$objects->current ()->args['name']]; |
|
114 | + if ($parents === null && $objects->size () > 0 && $objects->current ()->height < $height) { |
|
115 | + $parents = [$objects->current ()->args['name']]; |
|
116 | + } |
|
111 | 117 | |
112 | 118 | $objects->push (new Node ([ |
113 | 119 | 'type' => \VLF\STYLE_DEFINITION, |
@@ -129,11 +135,13 @@ discard block |
||
129 | 135 | */ |
130 | 136 | elseif (($pos = strpos ($line, ':')) !== false) |
131 | 137 | { |
132 | - if ($objects->size () == 0) |
|
133 | - throw new \Exception ('Trying to set property to unknown object at line '. ($line_num + 1)); |
|
138 | + if ($objects->size () == 0) { |
|
139 | + throw new \Exception ('Trying to set property to unknown object at line '. ($line_num + 1)); |
|
140 | + } |
|
134 | 141 | |
135 | - if (!isset ($words[1])) |
|
136 | - throw new \Exception ('Trying to set void property value at line '. ($line_num + 1)); |
|
142 | + if (!isset ($words[1])) { |
|
143 | + throw new \Exception ('Trying to set void property value at line '. ($line_num + 1)); |
|
144 | + } |
|
137 | 145 | |
138 | 146 | $propertyName = substr ($line, 0, $pos); |
139 | 147 | $propertyValue = substr ($line, $pos + 1); |
@@ -167,25 +175,27 @@ discard block |
||
167 | 175 | */ |
168 | 176 | elseif (isset ($words[0][1]) && $words[0][0] == '-' && $words[0][1] == '>') |
169 | 177 | { |
170 | - if ($objects->size () == 0) |
|
171 | - throw new \Exception ('Trying to call method from unknown object at line '. ($line_num + 1)); |
|
178 | + if ($objects->size () == 0) { |
|
179 | + throw new \Exception ('Trying to call method from unknown object at line '. ($line_num + 1)); |
|
180 | + } |
|
172 | 181 | |
173 | 182 | $methodArgs = []; |
174 | 183 | |
175 | 184 | if (($pos = strpos ($line, '(')) !== false) |
176 | 185 | { |
177 | - if (($end = strrpos ($line, ')', $pos)) === false) |
|
178 | - throw new \Exception ('Incorrect method arguments syntax at line '. ($line_num + 1)); |
|
186 | + if (($end = strrpos ($line, ')', $pos)) === false) { |
|
187 | + throw new \Exception ('Incorrect method arguments syntax at line '. ($line_num + 1)); |
|
188 | + } |
|
179 | 189 | |
180 | 190 | $methodArgs = substr ($line, $pos + 1, $end - $pos - 1); |
181 | 191 | |
182 | 192 | $methodName = trim (substr ($line, 2, $pos - 2)); |
183 | 193 | $methodArgs = self::filter ($methodArgs) ? |
184 | 194 | self::parseArguments ($methodArgs) : []; |
195 | + } else { |
|
196 | + $methodName = trim (substr ($line, 2)); |
|
185 | 197 | } |
186 | 198 | |
187 | - else $methodName = trim (substr ($line, 2)); |
|
188 | - |
|
189 | 199 | $objects->current ()->push (new Node ([ |
190 | 200 | 'type' => \VLF\METHOD_CALL, |
191 | 201 | 'line' => $line, |
@@ -202,7 +212,9 @@ discard block |
||
202 | 212 | /** |
203 | 213 | * Неопознанная структура |
204 | 214 | */ |
205 | - else throw new \Exception ('Unsupported structure founded at line '. ($line_num + 1)); |
|
215 | + else { |
|
216 | + throw new \Exception ('Unsupported structure founded at line '. ($line_num + 1)); |
|
217 | + } |
|
206 | 218 | } |
207 | 219 | |
208 | 220 | return $tree; |
@@ -26,30 +26,30 @@ |
||
26 | 26 | * |
27 | 27 | * @return array - возвращает список созданных объектов |
28 | 28 | */ |
29 | - public static function run (AST $tree, Node $parent = null): array |
|
29 | + public static function run(AST $tree, Node $parent = null): array |
|
30 | 30 | { |
31 | - foreach ($tree->getNodes () as $id => $node) |
|
31 | + foreach ($tree->getNodes() as $id => $node) |
|
32 | 32 | { |
33 | 33 | if ($node->type == \VLF\STYLE_DEFINITION) |
34 | 34 | { |
35 | 35 | $name = $node->args['name']; |
36 | - $nodes = $node->getNodes (); |
|
36 | + $nodes = $node->getNodes(); |
|
37 | 37 | |
38 | 38 | if ($node->args['parents'] !== null) |
39 | 39 | foreach ($node->args['parents'] as $parent) |
40 | 40 | { |
41 | 41 | if (!isset (self::$styles[$parent]) && self::$throw_errors) |
42 | - throw new \Exception ('Style "'. $parent .'" not founded'); |
|
42 | + throw new \Exception('Style "'.$parent.'" not founded'); |
|
43 | 43 | |
44 | - $nodes = array_merge ($nodes, self::$styles[$parent]); |
|
44 | + $nodes = array_merge($nodes, self::$styles[$parent]); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | self::$styles[$name] = isset (self::$objects[$name]) ? |
48 | 48 | array_merge (self::$styles[$name], $nodes) : $nodes; |
49 | 49 | } |
50 | 50 | |
51 | - self::$styles = self::run (new AST (array_map ( |
|
52 | - fn ($node) => $node->export (), $node->getNodes ())), $node); |
|
51 | + self::$styles = self::run(new AST(array_map( |
|
52 | + fn($node) => $node->export(), $node->getNodes())), $node); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | return self::$styles; |
@@ -35,11 +35,12 @@ |
||
35 | 35 | $name = $node->args['name']; |
36 | 36 | $nodes = $node->getNodes (); |
37 | 37 | |
38 | - if ($node->args['parents'] !== null) |
|
39 | - foreach ($node->args['parents'] as $parent) |
|
38 | + if ($node->args['parents'] !== null) { |
|
39 | + foreach ($node->args['parents'] as $parent) |
|
40 | 40 | { |
41 | 41 | if (!isset (self::$styles[$parent]) && self::$throw_errors) |
42 | 42 | throw new \Exception ('Style "'. $parent .'" not founded'); |
43 | + } |
|
43 | 44 | |
44 | 45 | $nodes = array_merge ($nodes, self::$styles[$parent]); |
45 | 46 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @return Stack - возвращает сам себя |
19 | 19 | */ |
20 | - public function push ($item): Stack |
|
20 | + public function push($item): Stack |
|
21 | 21 | { |
22 | 22 | $this->items[] = $item; |
23 | 23 | |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return mixed - возвращает текущий элемент |
31 | 31 | */ |
32 | - public function current () |
|
32 | + public function current() |
|
33 | 33 | { |
34 | - return end ($this->items); |
|
34 | + return end($this->items); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return mixed - возвращает текущий элемент |
41 | 41 | */ |
42 | - public function pop () |
|
42 | + public function pop() |
|
43 | 43 | { |
44 | - return array_pop ($this->items); |
|
44 | + return array_pop($this->items); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return int - возвращает размер стэка |
51 | 51 | */ |
52 | - public function size (): int |
|
52 | + public function size(): int |
|
53 | 53 | { |
54 | - return sizeof ($this->items); |
|
54 | + return sizeof($this->items); |
|
55 | 55 | } |
56 | 56 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | protected $WinAPI; |
29 | 29 | |
30 | - public function __construct () |
|
30 | + public function __construct() |
|
31 | 31 | { |
32 | 32 | /** |
33 | 33 | * Большинство функций было взято из класса "WinAPI" проекта "DevelStudio XL" |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @see <https://vk.com/evsoft> |
37 | 37 | * @see <https://vk.com/magic.breeze> |
38 | 38 | */ |
39 | - $this->WinAPI = \FFI::cdef (' |
|
39 | + $this->WinAPI = \FFI::cdef(' |
|
40 | 40 | struct LPCTSTR |
41 | 41 | { |
42 | 42 | char string; |
@@ -72,10 +72,9 @@ discard block |
||
72 | 72 | ', 'User32.dll'); |
73 | 73 | } |
74 | 74 | |
75 | - public function __call ($method, $args) |
|
75 | + public function __call($method, $args) |
|
76 | 76 | { |
77 | - return method_exists ($this, $method) ? |
|
78 | - $this->$method (...$args) : |
|
79 | - $this->WinAPI->$method (...$args); |
|
77 | + return method_exists($this, $method) ? |
|
78 | + $this->$method(...$args) : $this->WinAPI->$method(...$args); |
|
80 | 79 | } |
81 | 80 | } |
@@ -48,10 +48,12 @@ |
||
48 | 48 | require 'components/Component.php'; |
49 | 49 | require 'components/Control.php'; |
50 | 50 | |
51 | -foreach (glob ('components/*/*.php') as $name) |
|
51 | +foreach (glob ('components/*/*.php') as $name) { |
|
52 | 52 | require $name; |
53 | +} |
|
53 | 54 | |
54 | -if (file_exists ('extensions')) |
|
55 | +if (file_exists ('extensions')) { |
|
55 | 56 | foreach (scandir ('extensions') as $ext) |
56 | 57 | if (file_exists ($ext = 'extensions/'. $ext .'/main.php')) |
57 | 58 | require $ext; |
59 | +} |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | const ENGINE_VERSION = '4.0.0rc1'; |
35 | 35 | const ENGINE_DIR = __DIR__; |
36 | 36 | |
37 | -chdir (ENGINE_DIR); |
|
37 | +chdir(ENGINE_DIR); |
|
38 | 38 | |
39 | 39 | require 'common/Events.php'; |
40 | 40 | require 'common/EngineInterfaces.php'; |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | require 'common/Components.php'; |
44 | 44 | require 'common/Others.php'; |
45 | 45 | |
46 | -define ('VoidEngine\CORE_VERSION', $APPLICATION->productVersion); |
|
46 | +define('VoidEngine\CORE_VERSION', $APPLICATION->productVersion); |
|
47 | 47 | |
48 | 48 | require 'components/Component.php'; |
49 | 49 | require 'components/Control.php'; |
50 | 50 | |
51 | -foreach (glob ('components/*/*.php') as $name) |
|
51 | +foreach (glob('components/*/*.php') as $name) |
|
52 | 52 | require $name; |
53 | 53 | |
54 | -if (file_exists ('extensions')) |
|
55 | - foreach (scandir ('extensions') as $ext) |
|
56 | - if (file_exists ($ext = 'extensions/'. $ext .'/main.php')) |
|
54 | +if (file_exists('extensions')) |
|
55 | + foreach (scandir('extensions') as $ext) |
|
56 | + if (file_exists($ext = 'extensions/'.$ext.'/main.php')) |
|
57 | 57 | require $ext; |
@@ -55,7 +55,7 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -12,16 +12,17 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct ($name, $assembly = false, ...$args) |
14 | 14 | { |
15 | - foreach ($args as $id => $arg) |
|
16 | - $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
15 | + foreach ($args as $id => $arg) { |
|
16 | + $args[$id] = EngineAdditions::uncoupleSelector ($arg); |
|
17 | + } |
|
17 | 18 | |
18 | - if (is_int ($name) && VoidCore::objectExists ($name)) |
|
19 | - $this->selector = $name; |
|
20 | - |
|
21 | - elseif (is_string ($name)) |
|
22 | - $this->selector = VoidCore::createObject ($name, $assembly, ...$args); |
|
23 | - |
|
24 | - else throw new \Exception ('Incorrect params passed'); |
|
19 | + if (is_int ($name) && VoidCore::objectExists ($name)) { |
|
20 | + $this->selector = $name; |
|
21 | + } elseif (is_string ($name)) { |
|
22 | + $this->selector = VoidCore::createObject ($name, $assembly, ...$args); |
|
23 | + } else { |
|
24 | + throw new \Exception ('Incorrect params passed'); |
|
25 | + } |
|
25 | 26 | |
26 | 27 | /*$this->isCollection = $this->getType () |
27 | 28 | ->isSubclassOf (VoidCore::typeof ('System.Collectons.Generic.ICollection'));*/ |
@@ -43,9 +44,7 @@ discard block |
||
43 | 44 | try |
44 | 45 | { |
45 | 46 | return $this->getProperty ('Count'); |
46 | - } |
|
47 | - |
|
48 | - catch (\WinformsException $e) |
|
47 | + } catch (\WinformsException $e) |
|
49 | 48 | { |
50 | 49 | return $this->getProperty ('Length'); |
51 | 50 | } |
@@ -55,8 +54,9 @@ discard block |
||
55 | 54 | $size = $this->count; |
56 | 55 | $list = []; |
57 | 56 | |
58 | - for ($i = 0; $i < $size; ++$i) |
|
59 | - $list[] = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $i)); |
|
57 | + for ($i = 0; $i < $size; ++$i) { |
|
58 | + $list[] = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $i)); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | return $list; |
62 | 62 | break; |
@@ -65,13 +65,12 @@ discard block |
||
65 | 65 | $size = $this->count; |
66 | 66 | $names = []; |
67 | 67 | |
68 | - for ($i = 0; $i < $size; ++$i) |
|
69 | - try |
|
68 | + for ($i = 0; $i < $size; ++$i) { |
|
69 | + try |
|
70 | 70 | { |
71 | 71 | $names[] = VoidCore::getProperty (VoidCore::getArrayValue ($this->selector, [$i, VC_OBJECT]), 'Text'); |
72 | - } |
|
73 | - |
|
74 | - catch (\WinformsException $e) |
|
72 | + } |
|
73 | + } catch (\WinformsException $e) |
|
75 | 74 | { |
76 | 75 | $names[] = VoidCore::getArrayValue ($this->selector, [$i, VC_STRING]); |
77 | 76 | } |
@@ -80,8 +79,9 @@ discard block |
||
80 | 79 | break; |
81 | 80 | } |
82 | 81 | |
83 | - if (method_exists ($this, $method = 'get_'. $name)) |
|
84 | - return $this->$method (); |
|
82 | + if (method_exists ($this, $method = 'get_'. $name)) { |
|
83 | + return $this->$method (); |
|
84 | + } |
|
85 | 85 | |
86 | 86 | return isset ($this->$name) ? |
87 | 87 | $this->$name : EngineAdditions::coupleSelector ($this->getProperty ($name)); |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | |
90 | 90 | public function __set (string $name, $value): void |
91 | 91 | { |
92 | - if (substr ($name, -5) == 'Event') |
|
93 | - Events::setEvent ($this->selector, substr ($name, 0, -5), $value); |
|
94 | - |
|
95 | - elseif (method_exists ($this, $method = 'set_'. $name)) |
|
96 | - $this->$method ($value); |
|
97 | - |
|
98 | - else $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
92 | + if (substr ($name, -5) == 'Event') { |
|
93 | + Events::setEvent ($this->selector, substr ($name, 0, -5), $value); |
|
94 | + } elseif (method_exists ($this, $method = 'set_'. $name)) { |
|
95 | + $this->$method ($value); |
|
96 | + } else { |
|
97 | + $this->setProperty ($name, EngineAdditions::uncoupleSelector ($value)); |
|
98 | + } |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | public function __call (string $name, array $args) |
@@ -130,9 +130,7 @@ discard block |
||
130 | 130 | $index === null ? |
131 | 131 | $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
132 | 132 | $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
133 | - } |
|
134 | - |
|
135 | - catch (\Throwable $e) |
|
133 | + } catch (\Throwable $e) |
|
136 | 134 | { |
137 | 135 | $index === null ? |
138 | 136 | VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) : |
@@ -155,9 +153,7 @@ discard block |
||
155 | 153 | try |
156 | 154 | { |
157 | 155 | $this->offsetGet ($index); |
158 | - } |
|
159 | - |
|
160 | - catch (\WinformsException $e) |
|
156 | + } catch (\WinformsException $e) |
|
161 | 157 | { |
162 | 158 | return false; |
163 | 159 | } |
@@ -171,8 +167,9 @@ discard block |
||
171 | 167 | { |
172 | 168 | $size = $this->count; |
173 | 169 | |
174 | - for ($i = 0; $i < $size; ++$i) |
|
175 | - $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
170 | + for ($i = 0; $i < $size; ++$i) { |
|
171 | + $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
172 | + } |
|
176 | 173 | } |
177 | 174 | |
178 | 175 | public function where (callable $comparator, string $type = null): array |
@@ -180,9 +177,10 @@ discard block |
||
180 | 177 | $size = $this->count; |
181 | 178 | $return = []; |
182 | 179 | |
183 | - for ($i = 0; $i < $size; ++$i) |
|
184 | - if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
180 | + for ($i = 0; $i < $size; ++$i) { |
|
181 | + if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
185 | 182 | $return[] = $value; |
183 | + } |
|
186 | 184 | |
187 | 185 | return $return; |
188 | 186 | } |
@@ -206,16 +204,12 @@ discard block |
||
206 | 204 | try |
207 | 205 | { |
208 | 206 | $info['name'] = $this->getProperty ('Name'); |
209 | - } |
|
210 | - |
|
211 | - catch (\WinformsException $e) {} |
|
207 | + } catch (\WinformsException $e) {} |
|
212 | 208 | |
213 | 209 | try |
214 | 210 | { |
215 | 211 | $info['info'] = $this->callMethod ('ToString'); |
216 | - } |
|
217 | - |
|
218 | - catch (\WinformsException $e) {} |
|
212 | + } catch (\WinformsException $e) {} |
|
219 | 213 | |
220 | 214 | return $info; |
221 | 215 | } |
@@ -225,13 +219,13 @@ discard block |
||
225 | 219 | { |
226 | 220 | public function __construct ($name, $assembly = false, ...$args) |
227 | 221 | { |
228 | - if (is_int ($name) && VoidCore::objectExists ($name)) |
|
229 | - $this->selector = $name; |
|
230 | - |
|
231 | - elseif (is_string ($name)) |
|
232 | - $this->selector = VoidCore::getClass ($name, $assembly, ...$args); |
|
233 | - |
|
234 | - else throw new \Exception ('Incorrect params passed'); |
|
222 | + if (is_int ($name) && VoidCore::objectExists ($name)) { |
|
223 | + $this->selector = $name; |
|
224 | + } elseif (is_string ($name)) { |
|
225 | + $this->selector = VoidCore::getClass ($name, $assembly, ...$args); |
|
226 | + } else { |
|
227 | + throw new \Exception ('Incorrect params passed'); |
|
228 | + } |
|
235 | 229 | } |
236 | 230 | } |
237 | 231 |
@@ -10,44 +10,44 @@ discard block |
||
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 |
||
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,93 +68,91 @@ discard block |
||
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, EngineAdditions::uncoupleSelector ($value)); |
|
98 | + else $this->setProperty($name, EngineAdditions::uncoupleSelector($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 ( |
|
104 | - fn ($arg) => EngineAdditions::uncoupleSelector ($arg), $args))); |
|
103 | + return EngineAdditions::coupleSelector($this->callMethod($name, array_map( |
|
104 | + fn($arg) => EngineAdditions::uncoupleSelector($arg), $args))); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | # Управление VoidCore |
108 | 108 | |
109 | - protected function getProperty ($name) |
|
109 | + protected function getProperty($name) |
|
110 | 110 | { |
111 | - return VoidCore::getProperty ($this->selector, $name); |
|
111 | + return VoidCore::getProperty($this->selector, $name); |
|
112 | 112 | } |
113 | 113 | |
114 | - protected function setProperty (string $name, $value): void |
|
114 | + protected function setProperty(string $name, $value): void |
|
115 | 115 | { |
116 | - VoidCore::setProperty ($this->selector, $name, $value); |
|
116 | + VoidCore::setProperty($this->selector, $name, $value); |
|
117 | 117 | } |
118 | 118 | |
119 | - protected function callMethod (string $name, array $args = []) |
|
119 | + protected function callMethod(string $name, array $args = []) |
|
120 | 120 | { |
121 | - return VoidCore::callMethod ($this->selector, $name, ...$args); |
|
121 | + return VoidCore::callMethod($this->selector, $name, ...$args); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | # ArrayAccess |
125 | 125 | |
126 | - public function offsetSet ($index, $value) |
|
126 | + public function offsetSet($index, $value) |
|
127 | 127 | { |
128 | 128 | try |
129 | 129 | { |
130 | 130 | $index === null ? |
131 | - $this->callMethod ('Add', EngineAdditions::uncoupleSelector ($value)) : |
|
132 | - $this->callMethod ('Insert', $index, EngineAdditions::uncoupleSelector ($value)); |
|
131 | + $this->callMethod('Add', EngineAdditions::uncoupleSelector($value)) : $this->callMethod('Insert', $index, EngineAdditions::uncoupleSelector($value)); |
|
133 | 132 | } |
134 | 133 | |
135 | 134 | catch (\Throwable $e) |
136 | 135 | { |
137 | 136 | $index === null ? |
138 | - VoidCore::setArrayValue ($this->selector, $this->count, EngineAdditions::uncoupleSelector ($value)) : |
|
139 | - VoidCore::setArrayValue ($this->selector, $index, EngineAdditions::uncoupleSelector ($value)); |
|
137 | + VoidCore::setArrayValue($this->selector, $this->count, EngineAdditions::uncoupleSelector($value)) : VoidCore::setArrayValue($this->selector, $index, EngineAdditions::uncoupleSelector($value)); |
|
140 | 138 | } |
141 | 139 | } |
142 | 140 | |
143 | - public function offsetGet ($index) |
|
141 | + public function offsetGet($index) |
|
144 | 142 | { |
145 | - return EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $index), $this->selector); |
|
143 | + return EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $index), $this->selector); |
|
146 | 144 | } |
147 | 145 | |
148 | - public function offsetUnset ($index): void |
|
146 | + public function offsetUnset($index): void |
|
149 | 147 | { |
150 | - $this->callMethod ('RemoveAt', $index); |
|
148 | + $this->callMethod('RemoveAt', $index); |
|
151 | 149 | } |
152 | 150 | |
153 | - public function offsetExists ($index): bool |
|
151 | + public function offsetExists($index): bool |
|
154 | 152 | { |
155 | 153 | try |
156 | 154 | { |
157 | - $this->offsetGet ($index); |
|
155 | + $this->offsetGet($index); |
|
158 | 156 | } |
159 | 157 | |
160 | 158 | catch (\WinformsException $e) |
@@ -172,16 +170,16 @@ discard block |
||
172 | 170 | $size = $this->count; |
173 | 171 | |
174 | 172 | for ($i = 0; $i < $size; ++$i) |
175 | - $callback (EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
173 | + $callback(EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i); |
|
176 | 174 | } |
177 | 175 | |
178 | - public function where (callable $comparator, string $type = null): array |
|
176 | + public function where(callable $comparator, string $type = null): array |
|
179 | 177 | { |
180 | 178 | $size = $this->count; |
181 | 179 | $return = []; |
182 | 180 | |
183 | 181 | for ($i = 0; $i < $size; ++$i) |
184 | - if ($comparator ($value = EngineAdditions::coupleSelector (VoidCore::getArrayValue ($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
182 | + if ($comparator($value = EngineAdditions::coupleSelector(VoidCore::getArrayValue($this->selector, $type !== null ? [$i, $type] : $i), $this->selector), $i)) |
|
185 | 183 | $return[] = $value; |
186 | 184 | |
187 | 185 | return $return; |
@@ -189,30 +187,30 @@ discard block |
||
189 | 187 | |
190 | 188 | # Магические методы |
191 | 189 | |
192 | - public function __destruct () |
|
190 | + public function __destruct() |
|
193 | 191 | { |
194 | - VoidCore::destructObject ($this->selector); |
|
192 | + VoidCore::destructObject($this->selector); |
|
195 | 193 | } |
196 | 194 | |
197 | - public function __toString (): string |
|
195 | + public function __toString(): string |
|
198 | 196 | { |
199 | 197 | return $this->selector; |
200 | 198 | } |
201 | 199 | |
202 | - public function __debugInfo (): array |
|
200 | + public function __debugInfo(): array |
|
203 | 201 | { |
204 | 202 | $info = ['selector' => $this->selector]; |
205 | 203 | |
206 | 204 | try |
207 | 205 | { |
208 | - $info['name'] = $this->getProperty ('Name'); |
|
206 | + $info['name'] = $this->getProperty('Name'); |
|
209 | 207 | } |
210 | 208 | |
211 | 209 | catch (\WinformsException $e) {} |
212 | 210 | |
213 | 211 | try |
214 | 212 | { |
215 | - $info['info'] = $this->callMethod ('ToString'); |
|
213 | + $info['info'] = $this->callMethod('ToString'); |
|
216 | 214 | } |
217 | 215 | |
218 | 216 | catch (\WinformsException $e) {} |
@@ -223,29 +221,29 @@ discard block |
||
223 | 221 | |
224 | 222 | class NetClass extends NetObject |
225 | 223 | { |
226 | - public function __construct ($name, $assembly = false, ...$args) |
|
224 | + public function __construct($name, $assembly = false, ...$args) |
|
227 | 225 | { |
228 | - if (is_int ($name) && VoidCore::objectExists ($name)) |
|
226 | + if (is_int($name) && VoidCore::objectExists($name)) |
|
229 | 227 | $this->selector = $name; |
230 | 228 | |
231 | - elseif (is_string ($name)) |
|
232 | - $this->selector = VoidCore::getClass ($name, $assembly, ...$args); |
|
229 | + elseif (is_string($name)) |
|
230 | + $this->selector = VoidCore::getClass($name, $assembly, ...$args); |
|
233 | 231 | |
234 | - else throw new \Exception ('Incorrect params passed'); |
|
232 | + else throw new \Exception('Incorrect params passed'); |
|
235 | 233 | } |
236 | 234 | } |
237 | 235 | |
238 | 236 | class EngineAdditions |
239 | 237 | { |
240 | - public static function coupleSelector ($selector) |
|
238 | + public static function coupleSelector($selector) |
|
241 | 239 | { |
242 | - return is_int ($selector) && VoidCore::objectExists ($selector) ? |
|
243 | - new NetObject ($selector) : $selector; |
|
240 | + return is_int($selector) && VoidCore::objectExists($selector) ? |
|
241 | + new NetObject($selector) : $selector; |
|
244 | 242 | } |
245 | 243 | |
246 | - public static function uncoupleSelector ($object) |
|
244 | + public static function uncoupleSelector($object) |
|
247 | 245 | { |
248 | - return is_object ($object) && $object instanceof NetObject ? |
|
246 | + return is_object($object) && $object instanceof NetObject ? |
|
249 | 247 | $object->selector : $object; |
250 | 248 | } |
251 | 249 | } |
@@ -9,17 +9,17 @@ |
||
9 | 9 | public static function setEvent (int $selector, string $eventName, callable $function): void |
10 | 10 | { |
11 | 11 | VoidCore::setEvent ($selector, $eventName, function ($sender, ...$args) use ($function) |
12 | - { |
|
12 | + { |
|
13 | 13 | try |
14 | - { |
|
14 | + { |
|
15 | 15 | foreach ($args as $id => $arg) |
16 | 16 | $args[$id] = EngineAdditions::coupleSelector ($arg); |
17 | 17 | |
18 | 18 | return $function (_c ($sender) ?: new NetObject ($sender), ...$args); |
19 | 19 | } |
20 | 20 | |
21 | - catch (\Throwable $e) |
|
22 | - { |
|
21 | + catch (\Throwable $e) |
|
22 | + { |
|
23 | 23 | message ([ |
24 | 24 | 'type' => get_class ($e), |
25 | 25 | 'text' => $e->getMessage (), |
@@ -6,34 +6,34 @@ |
||
6 | 6 | |
7 | 7 | class Events |
8 | 8 | { |
9 | - public static function setEvent (int $selector, string $eventName, callable $function): void |
|
9 | + public static function setEvent(int $selector, string $eventName, callable $function): void |
|
10 | 10 | { |
11 | - VoidCore::setEvent ($selector, $eventName, function ($sender, ...$args) use ($function) |
|
11 | + VoidCore::setEvent($selector, $eventName, function($sender, ...$args) use ($function) |
|
12 | 12 | { |
13 | 13 | try |
14 | 14 | { |
15 | 15 | foreach ($args as $id => $arg) |
16 | - $args[$id] = EngineAdditions::coupleSelector ($arg); |
|
16 | + $args[$id] = EngineAdditions::coupleSelector($arg); |
|
17 | 17 | |
18 | - return $function (_c ($sender) ?: new NetObject ($sender), ...$args); |
|
18 | + return $function(_c($sender) ?: new NetObject($sender), ...$args); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | catch (\Throwable $e) |
22 | 22 | { |
23 | - message ([ |
|
24 | - 'type' => get_class ($e), |
|
25 | - 'text' => $e->getMessage (), |
|
26 | - 'file' => $e->getFile (), |
|
27 | - 'line' => $e->getLine (), |
|
28 | - 'code' => $e->getCode (), |
|
29 | - 'trace' => $e->getTraceAsString () |
|
23 | + message([ |
|
24 | + 'type' => get_class($e), |
|
25 | + 'text' => $e->getMessage(), |
|
26 | + 'file' => $e->getFile(), |
|
27 | + 'line' => $e->getLine(), |
|
28 | + 'code' => $e->getCode(), |
|
29 | + 'trace' => $e->getTraceAsString() |
|
30 | 30 | ], 'PHP Critical Error'); |
31 | 31 | } |
32 | 32 | }); |
33 | 33 | } |
34 | 34 | |
35 | - public static function removeEvent (int $selector, string $eventName): void |
|
35 | + public static function removeEvent(int $selector, string $eventName): void |
|
36 | 36 | { |
37 | - VoidCore::removeEvent ($selector, $eventName); |
|
37 | + VoidCore::removeEvent($selector, $eventName); |
|
38 | 38 | } |
39 | 39 | } |
@@ -12,13 +12,12 @@ |
||
12 | 12 | { |
13 | 13 | try |
14 | 14 | { |
15 | - foreach ($args as $id => $arg) |
|
16 | - $args[$id] = EngineAdditions::coupleSelector ($arg); |
|
15 | + foreach ($args as $id => $arg) { |
|
16 | + $args[$id] = EngineAdditions::coupleSelector ($arg); |
|
17 | + } |
|
17 | 18 | |
18 | 19 | return $function (_c ($sender) ?: new NetObject ($sender), ...$args); |
19 | - } |
|
20 | - |
|
21 | - catch (\Throwable $e) |
|
20 | + } catch (\Throwable $e) |
|
22 | 21 | { |
23 | 22 | message ([ |
24 | 23 | 'type' => get_class ($e), |
@@ -2,50 +2,50 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -register_superglobals ('APPLICATION', 'SCREEN'); |
|
5 | +register_superglobals('APPLICATION', 'SCREEN'); |
|
6 | 6 | |
7 | 7 | $APPLICATION = new class |
8 | 8 | { |
9 | 9 | public NetClass $application; |
10 | 10 | public string $executablePath; |
11 | 11 | |
12 | - public function __construct () |
|
12 | + public function __construct() |
|
13 | 13 | { |
14 | - $this->application = new NetClass ('System.Windows.Forms.Application'); |
|
14 | + $this->application = new NetClass('System.Windows.Forms.Application'); |
|
15 | 15 | $this->executablePath = $this->application->executablePath; |
16 | 16 | } |
17 | 17 | |
18 | - public function run ($form = null): void |
|
18 | + public function run($form = null): void |
|
19 | 19 | { |
20 | 20 | if ($form instanceof NetObject) |
21 | - $this->application->run ($form->selector); |
|
21 | + $this->application->run($form->selector); |
|
22 | 22 | |
23 | - elseif (is_int ($form) && \VoidCore::objectExists ($form)) |
|
24 | - $this->application->run ($form); |
|
23 | + elseif (is_int($form) && \VoidCore::objectExists($form)) |
|
24 | + $this->application->run($form); |
|
25 | 25 | |
26 | 26 | elseif ($form === null) |
27 | - $this->application->run (); |
|
27 | + $this->application->run(); |
|
28 | 28 | |
29 | - else throw new \Exception ('$form param must be instance of "VoidEngine\NetObject" ("VoidEngine\Form"), be null or object selector'); |
|
29 | + else throw new \Exception('$form param must be instance of "VoidEngine\NetObject" ("VoidEngine\Form"), be null or object selector'); |
|
30 | 30 | } |
31 | 31 | |
32 | - public function restart (): void |
|
32 | + public function restart(): void |
|
33 | 33 | { |
34 | - $this->application->restart (); |
|
35 | - $this->close (); |
|
34 | + $this->application->restart(); |
|
35 | + $this->close(); |
|
36 | 36 | } |
37 | 37 | |
38 | - public function close (): void |
|
38 | + public function close(): void |
|
39 | 39 | { |
40 | - $this->application->exit (); |
|
40 | + $this->application->exit(); |
|
41 | 41 | } |
42 | 42 | |
43 | - public function __call (string $name, array $args) |
|
43 | + public function __call(string $name, array $args) |
|
44 | 44 | { |
45 | - return $this->application->$name (...$args); |
|
45 | + return $this->application->$name(...$args); |
|
46 | 46 | } |
47 | 47 | |
48 | - public function __get (string $name) |
|
48 | + public function __get(string $name) |
|
49 | 49 | { |
50 | 50 | return $this->application->$name; |
51 | 51 | } |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | { |
56 | 56 | public NetClass $screen; |
57 | 57 | |
58 | - public function __construct () |
|
58 | + public function __construct() |
|
59 | 59 | { |
60 | - $this->screen = new NetClass ('System.Windows.Forms.Screen'); |
|
60 | + $this->screen = new NetClass('System.Windows.Forms.Screen'); |
|
61 | 61 | } |
62 | 62 | |
63 | - public function __get ($name) |
|
63 | + public function __get($name) |
|
64 | 64 | { |
65 | - switch (strtolower ($name)) |
|
65 | + switch (strtolower($name)) |
|
66 | 66 | { |
67 | 67 | case 'width': |
68 | 68 | case 'w': |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - public function __debugInfo (): array |
|
83 | + public function __debugInfo(): array |
|
84 | 84 | { |
85 | 85 | return [ |
86 | 86 | $this->w, |
@@ -17,16 +17,15 @@ |
||
17 | 17 | |
18 | 18 | public function run ($form = null): void |
19 | 19 | { |
20 | - if ($form instanceof NetObject) |
|
21 | - $this->application->run ($form->selector); |
|
22 | - |
|
23 | - elseif (is_int ($form) && \VoidCore::objectExists ($form)) |
|
24 | - $this->application->run ($form); |
|
25 | - |
|
26 | - elseif ($form === null) |
|
27 | - $this->application->run (); |
|
28 | - |
|
29 | - else throw new \Exception ('$form param must be instance of "VoidEngine\NetObject" ("VoidEngine\Form"), be null or object selector'); |
|
20 | + if ($form instanceof NetObject) { |
|
21 | + $this->application->run ($form->selector); |
|
22 | + } elseif (is_int ($form) && \VoidCore::objectExists ($form)) { |
|
23 | + $this->application->run ($form); |
|
24 | + } elseif ($form === null) { |
|
25 | + $this->application->run (); |
|
26 | + } else { |
|
27 | + throw new \Exception ('$form param must be instance of "VoidEngine\NetObject" ("VoidEngine\Form"), be null or object selector'); |
|
28 | + } |
|
30 | 29 | } |
31 | 30 | |
32 | 31 | public function restart (): void |
@@ -6,61 +6,61 @@ |
||
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 | -function c (string $name): ?NetObject |
|
56 | +function c(string $name): ?NetObject |
|
57 | 57 | { |
58 | 58 | if (($object = _c($name)) !== null) |
59 | 59 | return $object; |
60 | 60 | |
61 | - foreach (Components::getObjects () as $selector => $reference) |
|
61 | + foreach (Components::getObjects() as $selector => $reference) |
|
62 | 62 | { |
63 | - $object = $reference->get (); |
|
63 | + $object = $reference->get(); |
|
64 | 64 | |
65 | 65 | if ($object === null) |
66 | 66 | continue; |
@@ -13,13 +13,15 @@ discard block |
||
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 |
||
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 | |
@@ -55,23 +58,24 @@ discard block |
||
55 | 58 | // TODO: поддержка многоуровневых ссылок вида родитель->родитель->объект |
56 | 59 | function c (string $name): ?NetObject |
57 | 60 | { |
58 | - if (($object = _c($name)) !== null) |
|
59 | - return $object; |
|
61 | + if (($object = _c($name)) !== null) { |
|
62 | + return $object; |
|
63 | + } |
|
60 | 64 | |
61 | 65 | foreach (Components::getObjects () as $selector => $reference) |
62 | 66 | { |
63 | 67 | $object = $reference->get (); |
64 | 68 | |
65 | - if ($object === null) |
|
66 | - continue; |
|
69 | + if ($object === null) { |
|
70 | + continue; |
|
71 | + } |
|
67 | 72 | |
68 | 73 | try |
69 | 74 | { |
70 | - if ($object->name == $name) |
|
71 | - return $object; |
|
72 | - } |
|
73 | - |
|
74 | - catch (\WinformsException $e) {} |
|
75 | + if ($object->name == $name) { |
|
76 | + return $object; |
|
77 | + } |
|
78 | + } catch (\WinformsException $e) {} |
|
75 | 79 | } |
76 | 80 | |
77 | 81 | return null; |