@@ -6,18 +6,18 @@ |
||
6 | 6 | { |
7 | 7 | public $class = 'System.Windows.Forms.ColorDialog'; |
8 | 8 | |
9 | - public function __construct () |
|
9 | + public function __construct() |
|
10 | 10 | { |
11 | - parent::__construct ($this->class); |
|
11 | + parent::__construct($this->class); |
|
12 | 12 | } |
13 | 13 | |
14 | - public function get_color () |
|
14 | + public function get_color() |
|
15 | 15 | { |
16 | - return $this->getProperty (['Color', 'color']); |
|
16 | + return $this->getProperty(['Color', 'color']); |
|
17 | 17 | } |
18 | 18 | |
19 | - public function set_color (int $color) |
|
19 | + public function set_color(int $color) |
|
20 | 20 | { |
21 | - $this->setProperty ('Color', [$color, 'color']); |
|
21 | + $this->setProperty('Color', [$color, 'color']); |
|
22 | 22 | } |
23 | 23 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | protected $items; |
10 | 10 | |
11 | 11 | public function __construct (Component $parent = null) |
12 | - { |
|
12 | + { |
|
13 | 13 | parent::__construct ($parent, $this->class); |
14 | 14 | |
15 | 15 | $this->items = new WFObject ($this->getProperty ('TabPages')); |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | |
9 | 9 | protected $items; |
10 | 10 | |
11 | - public function __construct (Component $parent = null) |
|
11 | + public function __construct(Component $parent = null) |
|
12 | 12 | { |
13 | - parent::__construct ($parent, $this->class); |
|
13 | + parent::__construct($parent, $this->class); |
|
14 | 14 | |
15 | - $this->items = new WFObject ($this->getProperty ('TabPages')); |
|
15 | + $this->items = new WFObject($this->getProperty('TabPages')); |
|
16 | 16 | } |
17 | 17 | } |
18 | 18 | |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | { |
21 | 21 | public $class = 'System.Windows.Forms.TabPage'; |
22 | 22 | |
23 | - public function __construct (string $text = '') |
|
23 | + public function __construct(string $text = '') |
|
24 | 24 | { |
25 | - parent::__construct (null, $this->class); |
|
25 | + parent::__construct(null, $this->class); |
|
26 | 26 | |
27 | 27 | $this->text = $text; |
28 | 28 | } |
@@ -6,8 +6,8 @@ |
||
6 | 6 | { |
7 | 7 | public $class = 'System.Windows.Forms.FolderBrowserDialog'; |
8 | 8 | |
9 | - public function get_path () |
|
9 | + public function get_path() |
|
10 | 10 | { |
11 | - return $this->getProperty ('SelectedPath'); |
|
11 | + return $this->getProperty('SelectedPath'); |
|
12 | 12 | } |
13 | 13 | } |
@@ -6,8 +6,8 @@ |
||
6 | 6 | { |
7 | 7 | public $class = 'System.Windows.Forms.MessageBox'; |
8 | 8 | |
9 | - public function __construct () |
|
9 | + public function __construct() |
|
10 | 10 | { |
11 | - parent::__construct ($this->class); |
|
11 | + parent::__construct($this->class); |
|
12 | 12 | } |
13 | 13 | } |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | class CheckBox extends Control |
6 | 6 | { |
7 | - public $class = 'System.Windows.Forms.CheckBox'; |
|
7 | + public $class = 'System.Windows.Forms.CheckBox'; |
|
8 | 8 | } |
@@ -4,36 +4,36 @@ |
||
4 | 4 | |
5 | 5 | class Chart extends Control |
6 | 6 | { |
7 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.Chart'; |
|
8 | - public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
7 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.Chart'; |
|
8 | + public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | class Annotation extends Control |
12 | 12 | { |
13 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.Annotation'; |
|
14 | - public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
13 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.Annotation'; |
|
14 | + public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | class ChartArea extends Control |
18 | 18 | { |
19 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.ChartArea'; |
|
20 | - public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
19 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.ChartArea'; |
|
20 | + public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | class Legend extends Control |
24 | 24 | { |
25 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.Legend'; |
|
26 | - public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
25 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.Legend'; |
|
26 | + public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | class Series extends Control |
30 | 30 | { |
31 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.Series'; |
|
32 | - public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
31 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.Series'; |
|
32 | + public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | class Title extends Control |
36 | 36 | { |
37 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.Title'; |
|
38 | - public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
37 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.Title'; |
|
38 | + public $namespace = 'System.Windows.Forms.DataVisualization'; |
|
39 | 39 | } |
@@ -4,36 +4,36 @@ |
||
4 | 4 | |
5 | 5 | class Chart extends Control |
6 | 6 | { |
7 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.Chart'; |
|
7 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.Chart'; |
|
8 | 8 | public $namespace = 'System.Windows.Forms.DataVisualization'; |
9 | 9 | } |
10 | 10 | |
11 | 11 | class Annotation extends Control |
12 | 12 | { |
13 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.Annotation'; |
|
13 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.Annotation'; |
|
14 | 14 | public $namespace = 'System.Windows.Forms.DataVisualization'; |
15 | 15 | } |
16 | 16 | |
17 | 17 | class ChartArea extends Control |
18 | 18 | { |
19 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.ChartArea'; |
|
19 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.ChartArea'; |
|
20 | 20 | public $namespace = 'System.Windows.Forms.DataVisualization'; |
21 | 21 | } |
22 | 22 | |
23 | 23 | class Legend extends Control |
24 | 24 | { |
25 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.Legend'; |
|
25 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.Legend'; |
|
26 | 26 | public $namespace = 'System.Windows.Forms.DataVisualization'; |
27 | 27 | } |
28 | 28 | |
29 | 29 | class Series extends Control |
30 | 30 | { |
31 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.Series'; |
|
31 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.Series'; |
|
32 | 32 | public $namespace = 'System.Windows.Forms.DataVisualization'; |
33 | 33 | } |
34 | 34 | |
35 | 35 | class Title extends Control |
36 | 36 | { |
37 | - public $class = 'System.Windows.Forms.DataVisualization.Charting.Title'; |
|
37 | + public $class = 'System.Windows.Forms.DataVisualization.Charting.Title'; |
|
38 | 38 | public $namespace = 'System.Windows.Forms.DataVisualization'; |
39 | 39 | } |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | { |
12 | 12 | public $class = 'System.Windows.Forms.ListViewItem'; |
13 | 13 | |
14 | - public function __construct (string $text = '') |
|
14 | + public function __construct(string $text = '') |
|
15 | 15 | { |
16 | - parent::__construct (null, $this->class); |
|
16 | + parent::__construct(null, $this->class); |
|
17 | 17 | |
18 | 18 | $this->text = $text; |
19 | 19 | } |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | { |
24 | 24 | public $class = 'System.Windows.Forms.ColumnHeader'; |
25 | 25 | |
26 | - public function __construct (string $text = '') |
|
26 | + public function __construct(string $text = '') |
|
27 | 27 | { |
28 | - parent::__construct (null, $this->class); |
|
28 | + parent::__construct(null, $this->class); |
|
29 | 29 | |
30 | 30 | $this->text = $text; |
31 | 31 | } |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | { |
36 | 36 | public $class = 'System.Windows.Forms.ListViewGroup'; |
37 | 37 | |
38 | - public function __construct (string $text = '') |
|
38 | + public function __construct(string $text = '') |
|
39 | 39 | { |
40 | - parent::__construct (null, $this->class); |
|
40 | + parent::__construct(null, $this->class); |
|
41 | 41 | |
42 | 42 | $this->header = $text; |
43 | 43 | } |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | * АААААААААААААААААААААААА |
32 | 32 | */ |
33 | 33 | |
34 | - public function __construct (string $content, array $settings = []) |
|
34 | + public function __construct(string $content, array $settings = []) |
|
35 | 35 | { |
36 | - if (file_exists ($content)) |
|
37 | - $content = file_get_contents ($content); |
|
36 | + if (file_exists($content)) |
|
37 | + $content = file_get_contents($content); |
|
38 | 38 | |
39 | 39 | // Зачем? Так надо! |
40 | 40 | // ДА БАГ ЭТО, НЕ ПИ%ДИ!!! И Я ПОНЯТИЯ НЕ ИМЕЮ КАК И ПОЧЕМУ!!! |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | if (isset ($this->$name)) |
46 | 46 | $this->$name = $setting; |
47 | 47 | |
48 | - else throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
48 | + else throw new \Exception('Trying to setting up undefined property "'.$name.'"'); |
|
49 | 49 | } |
50 | 50 | |
51 | - if ($this->use_caching && file_exists ($file = VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache')) |
|
51 | + if ($this->use_caching && file_exists($file = VLF_EXT_DIR.'/cache/'.sha1($content).'.cache')) |
|
52 | 52 | { |
53 | - $info = unserialize (gzinflate (file_get_contents ($file))); |
|
53 | + $info = unserialize(gzinflate(file_get_contents($file))); |
|
54 | 54 | |
55 | - if ($info[0] == sha1 (file_get_contents (__FILE__))) |
|
55 | + if ($info[0] == sha1(file_get_contents(__FILE__))) |
|
56 | 56 | { |
57 | 57 | $this->tree = $info[1][0]; |
58 | 58 | $this->links = $info[1][1]; |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | - else unlink ($file); |
|
63 | + else unlink($file); |
|
64 | 64 | } |
65 | 65 | |
66 | - $info = $this->generateSyntaxTree ($content); |
|
66 | + $info = $this->generateSyntaxTree($content); |
|
67 | 67 | |
68 | 68 | $this->tree = $info[0]; |
69 | 69 | $this->links = $info[1]; |
70 | 70 | |
71 | 71 | if ($this->use_caching) |
72 | 72 | { |
73 | - if (!is_dir (dirname (__DIR__) .'/cache')) |
|
74 | - mkdir (dirname (__DIR__) .'/cache'); |
|
73 | + if (!is_dir(dirname(__DIR__).'/cache')) |
|
74 | + mkdir(dirname(__DIR__).'/cache'); |
|
75 | 75 | |
76 | - file_put_contents (VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache', gzdeflate (serialize ([sha1 (file_get_contents (__FILE__)), $info]))); |
|
76 | + file_put_contents(VLF_EXT_DIR.'/cache/'.sha1($content).'.cache', gzdeflate(serialize([sha1(file_get_contents(__FILE__)), $info]))); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return array - возвращает АСД |
87 | 87 | */ |
88 | - protected function generateSyntaxTree (string $content): array |
|
88 | + protected function generateSyntaxTree(string $content): array |
|
89 | 89 | { |
90 | - $lines = $this->linesFilter ($untouched_lines = explode ($this->divider, $content)); |
|
90 | + $lines = $this->linesFilter($untouched_lines = explode($this->divider, $content)); |
|
91 | 91 | $current_object = null; |
92 | 92 | $parent_objects = []; |
93 | 93 | $skip_at = -1; |
@@ -95,18 +95,18 @@ discard block |
||
95 | 95 | $links = []; |
96 | 96 | |
97 | 97 | if ($this->debug_mode) |
98 | - pre ($lines); |
|
98 | + pre($lines); |
|
99 | 99 | |
100 | 100 | foreach ($lines as $id => $line) |
101 | 101 | { |
102 | 102 | if ($skip_at > $id) |
103 | 103 | continue; |
104 | 104 | |
105 | - $height = $this->getLineHeight ($line); |
|
106 | - $words = $this->linesFilter (explode (' ', $line)); |
|
105 | + $height = $this->getLineHeight($line); |
|
106 | + $words = $this->linesFilter(explode(' ', $line)); |
|
107 | 107 | |
108 | 108 | if ($this->debug_mode) |
109 | - pre ($words); |
|
109 | + pre($words); |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Высокоинтеллектуальный фикс |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $updated = false; |
129 | 129 | |
130 | 130 | if ($this->debug_mode) |
131 | - pre ($current_object); |
|
131 | + pre($current_object); |
|
132 | 132 | |
133 | 133 | while (isset ($tree[$current_object]['info']['subparent_link']) && $tree[$link = $tree[$current_object]['info']['subparent_link']->link]['hard'] < $tree[$current_object]['hard']) |
134 | 134 | { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $updated = true; |
137 | 137 | |
138 | 138 | if ($this->debug_mode) |
139 | - pre ($current_object); |
|
139 | + pre($current_object); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if ( |
@@ -151,16 +151,16 @@ discard block |
||
151 | 151 | break; |
152 | 152 | |
153 | 153 | if ($this->debug_mode) |
154 | - pre ($current_object); |
|
154 | + pre($current_object); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Button ... |
159 | 159 | */ |
160 | - if (class_exists ($words[0]) || class_exists ('\VoidEngine\\'. $words[0])) |
|
160 | + if (class_exists($words[0]) || class_exists('\VoidEngine\\'.$words[0])) |
|
161 | 161 | { |
162 | 162 | if (!isset ($words[1])) |
163 | - throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
163 | + throw new \Exception('Object name mustn\'t be empty at line "'.$line.'"'); |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Button NewButton |
@@ -206,39 +206,38 @@ discard block |
||
206 | 206 | 'syntax_nodes' => [] |
207 | 207 | ]; |
208 | 208 | |
209 | - if (($begin = strpos ($line, '(')) !== false) |
|
209 | + if (($begin = strpos($line, '(')) !== false) |
|
210 | 210 | { |
211 | 211 | ++$begin; |
212 | 212 | |
213 | - $end = strrpos ($line, ')'); |
|
213 | + $end = strrpos($line, ')'); |
|
214 | 214 | |
215 | 215 | if ($end === false) |
216 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
216 | + throw new \Exception('Line "'.$line.'" have arguments list initialization, but not have list ending'); |
|
217 | 217 | |
218 | 218 | elseif ($begin < $end) |
219 | 219 | { |
220 | 220 | $arguments = []; |
221 | - $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
|
221 | + $parsed = explode(',', substr($line, $begin, $end - $begin)); |
|
222 | 222 | |
223 | 223 | foreach ($parsed as $argument_id => $argument) |
224 | 224 | { |
225 | - $argument = trim ($argument); |
|
225 | + $argument = trim($argument); |
|
226 | 226 | |
227 | - if (strlen ($argument) > 0) |
|
227 | + if (strlen($argument) > 0) |
|
228 | 228 | $arguments[] = isset ($links[$argument]) ? |
229 | - new VLFLink ($argument, $links[$argument]) : |
|
230 | - $argument; |
|
229 | + new VLFLink($argument, $links[$argument]) : $argument; |
|
231 | 230 | |
232 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
231 | + else throw new \Exception('Argument '.($argument_id + 1).' mustn\'t have zero length at line "'.$line.'"'); |
|
233 | 232 | } |
234 | 233 | |
235 | 234 | $tree[$id]['info']['arguments'] = $arguments; |
236 | 235 | |
237 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
238 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
236 | + if (!$this->ignore_postobject_info && trim(substr($line, $end)) > 0) |
|
237 | + throw new \Exception('You mustn\'t write any chars after arguments definition'); |
|
239 | 238 | } |
240 | 239 | |
241 | - $tree[$id]['info']['subparent_link'] = new VLFLink ($tree[$current_object]['info']['object_name'], $current_object); |
|
240 | + $tree[$id]['info']['subparent_link'] = new VLFLink($tree[$current_object]['info']['object_name'], $current_object); |
|
242 | 241 | } |
243 | 242 | |
244 | 243 | /** |
@@ -248,7 +247,7 @@ discard block |
||
248 | 247 | elseif ($current_object !== null && $tree[$current_object]['hard'] < $height) |
249 | 248 | { |
250 | 249 | $tree[$id]['info']['arguments'] = [ |
251 | - new VLFLink ($tree[$current_object]['info']['object_name'], $current_object) |
|
250 | + new VLFLink($tree[$current_object]['info']['object_name'], $current_object) |
|
252 | 251 | ]; |
253 | 252 | |
254 | 253 | $parent_objects[$id] = $current_object; |
@@ -295,17 +294,17 @@ discard block |
||
295 | 294 | { |
296 | 295 | if ($words[0][1] == '^') |
297 | 296 | { |
298 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
297 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
299 | 298 | |
300 | 299 | $comment .= $parsed[0]; |
301 | 300 | $skip_at = $parsed[1]; |
302 | 301 | } |
303 | 302 | |
304 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
303 | + else throw new \Exception('Unknown char founded after syntax-control symbol at line "'.$line.'"'); |
|
305 | 304 | } |
306 | 305 | |
307 | 306 | if ($this->debug_mode) |
308 | - pre ("Comment:\n\n$comment"); |
|
307 | + pre("Comment:\n\n$comment"); |
|
309 | 308 | } |
310 | 309 | |
311 | 310 | /** |
@@ -317,19 +316,19 @@ discard block |
||
317 | 316 | */ |
318 | 317 | elseif ($words[0][0] == '%') |
319 | 318 | { |
320 | - $code = substr ($line, strlen ($words[0])); |
|
319 | + $code = substr($line, strlen($words[0])); |
|
321 | 320 | |
322 | 321 | if (isset ($words[0][1])) |
323 | 322 | { |
324 | 323 | if ($words[0][1] == '^') |
325 | 324 | { |
326 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
325 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
327 | 326 | |
328 | 327 | $code .= $parsed[0]; |
329 | 328 | $skip_at = $parsed[1]; |
330 | 329 | } |
331 | 330 | |
332 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
331 | + else throw new \Exception('Unknown char founded after syntax-control symbol at line "'.$line.'"'); |
|
333 | 332 | } |
334 | 333 | |
335 | 334 | $tree[$id] = [ |
@@ -354,7 +353,7 @@ discard block |
||
354 | 353 | * Form MyForm |
355 | 354 | * Button MyButton |
356 | 355 | */ |
357 | - elseif (is_int ($current_object) && isset ($tree[$current_object]['hard'])) |
|
356 | + elseif (is_int($current_object) && isset ($tree[$current_object]['hard'])) |
|
358 | 357 | { |
359 | 358 | if ($height <= $tree[$current_object]['hard'] && isset ($parent_objects[$current_object])) |
360 | 359 | { |
@@ -380,16 +379,16 @@ discard block |
||
380 | 379 | /** |
381 | 380 | * property_name: property_value |
382 | 381 | */ |
383 | - $postChar = substr ($words[0], strlen ($words[0]) - 1); |
|
382 | + $postChar = substr($words[0], strlen($words[0]) - 1); |
|
384 | 383 | |
385 | 384 | if ($postChar == ':' || $postChar == '^') |
386 | 385 | { |
387 | 386 | if (!isset ($words[1])) |
388 | - throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
387 | + throw new \Exception('Property value mustn\'t be empty at line "'.$line.'"'); |
|
389 | 388 | |
390 | - $propertyName = substr ($words[0], 0, -1); |
|
391 | - $propertyValue = implode (' ', array_slice ($words, 1)); |
|
392 | - $propertyRawValue = ltrim (substr ($line, strlen ($words[0]))); |
|
389 | + $propertyName = substr($words[0], 0, -1); |
|
390 | + $propertyValue = implode(' ', array_slice($words, 1)); |
|
391 | + $propertyRawValue = ltrim(substr($line, strlen($words[0]))); |
|
393 | 392 | |
394 | 393 | /** |
395 | 394 | * property_name:^ property_value_1 |
@@ -397,10 +396,10 @@ discard block |
||
397 | 396 | */ |
398 | 397 | if ($postChar == '^') |
399 | 398 | { |
400 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
399 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
401 | 400 | |
402 | 401 | $skip_at = $parsed[1]; |
403 | - $propertyName = substr ($propertyName, 0, -1); |
|
402 | + $propertyName = substr($propertyName, 0, -1); |
|
404 | 403 | $propertyRawValue .= $parsed[0]; |
405 | 404 | $propertyValue = $propertyRawValue; |
406 | 405 | } |
@@ -421,7 +420,7 @@ discard block |
||
421 | 420 | ]; |
422 | 421 | |
423 | 422 | if (isset ($links[$info['info']['property_value']])) |
424 | - $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
423 | + $info['info']['property_value'] = new VLFLink($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
425 | 424 | |
426 | 425 | $tree[$current_object]['syntax_nodes'][] = $info; |
427 | 426 | } |
@@ -429,37 +428,36 @@ discard block |
||
429 | 428 | /** |
430 | 429 | * ->method_name ([method_arguments]) |
431 | 430 | */ |
432 | - elseif (substr ($words[0], 0, 2) == '->') |
|
431 | + elseif (substr($words[0], 0, 2) == '->') |
|
433 | 432 | { |
434 | 433 | $arguments = []; |
435 | 434 | |
436 | - if (($begin = strpos ($line, '(')) !== false) |
|
435 | + if (($begin = strpos($line, '(')) !== false) |
|
437 | 436 | { |
438 | 437 | ++$begin; |
439 | 438 | |
440 | - $end = strrpos ($line, ')'); |
|
439 | + $end = strrpos($line, ')'); |
|
441 | 440 | |
442 | 441 | if ($end === false) |
443 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
442 | + throw new \Exception('Line "'.$line.'" have arguments list initialization, but not have list ending'); |
|
444 | 443 | |
445 | 444 | elseif ($begin < $end) |
446 | 445 | { |
447 | - $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
|
446 | + $parsed = explode(',', substr($line, $begin, $end - $begin)); |
|
448 | 447 | |
449 | 448 | foreach ($parsed as $argument_id => $argument) |
450 | 449 | { |
451 | - $argument = trim ($argument); |
|
450 | + $argument = trim($argument); |
|
452 | 451 | |
453 | - if (strlen ($argument) > 0) |
|
452 | + if (strlen($argument) > 0) |
|
454 | 453 | $arguments[] = isset ($links[$argument]) ? |
455 | - new VLFLink ($argument, $links[$argument]) : |
|
456 | - $argument; |
|
454 | + new VLFLink($argument, $links[$argument]) : $argument; |
|
457 | 455 | |
458 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
456 | + else throw new \Exception('Argument '.($argument_id + 1).' mustn\'t have zero length at line "'.$line.'"'); |
|
459 | 457 | } |
460 | 458 | |
461 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
462 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
459 | + if (!$this->ignore_postobject_info && trim(substr($line, $end)) > 0) |
|
460 | + throw new \Exception('You mustn\'t write any chars after arguments definition'); |
|
463 | 461 | } |
464 | 462 | } |
465 | 463 | |
@@ -467,7 +465,7 @@ discard block |
||
467 | 465 | * ->show |
468 | 466 | */ |
469 | 467 | elseif (!$this->ignore_unexpected_method_args) |
470 | - throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
468 | + throw new \Exception('Unexpected method arguments list at line "'.$line.'"'); |
|
471 | 469 | |
472 | 470 | $tree[$current_object]['syntax_nodes'][] = [ |
473 | 471 | 'type' => VLF_METHOD_CALL, |
@@ -476,7 +474,7 @@ discard block |
||
476 | 474 | 'words' => $words, |
477 | 475 | |
478 | 476 | 'info' => [ |
479 | - 'method_name' => substr ($words[0], 2), |
|
477 | + 'method_name' => substr($words[0], 2), |
|
480 | 478 | 'method_arguments' => $arguments |
481 | 479 | ], |
482 | 480 | |
@@ -499,7 +497,7 @@ discard block |
||
499 | 497 | */ |
500 | 498 | else |
501 | 499 | { |
502 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
500 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
503 | 501 | $skip_at = $parsed[1]; |
504 | 502 | |
505 | 503 | $tree[$id] = [ |
@@ -509,7 +507,7 @@ discard block |
||
509 | 507 | 'words' => $words, |
510 | 508 | |
511 | 509 | 'info' => [ |
512 | - 'object_vlf_info' => $line ."\n". $parsed[0] |
|
510 | + 'object_vlf_info' => $line."\n".$parsed[0] |
|
513 | 511 | ], |
514 | 512 | |
515 | 513 | 'syntax_nodes' => [] |
@@ -520,7 +518,7 @@ discard block |
||
520 | 518 | /** |
521 | 519 | * Что-то загадочное, таинственное, неизвестное человечеству |
522 | 520 | */ |
523 | - else throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
521 | + else throw new \Exception('Unknown structures founded at line "'.$line.'"'); |
|
524 | 522 | } |
525 | 523 | |
526 | 524 | return [$tree, $links]; |
@@ -536,7 +534,7 @@ discard block |
||
536 | 534 | * |
537 | 535 | * @return array - возвращает спарсенные подстроки |
538 | 536 | */ |
539 | - protected function parseSubText (array $lines, $begin_id, int $down_height): array |
|
537 | + protected function parseSubText(array $lines, $begin_id, int $down_height): array |
|
540 | 538 | { |
541 | 539 | $parsed = "\n"; |
542 | 540 | |
@@ -545,17 +543,17 @@ discard block |
||
545 | 543 | if ($line_id <= $begin_id) |
546 | 544 | continue; |
547 | 545 | |
548 | - if (!(bool)(trim ($line))) |
|
546 | + if (!(bool) (trim($line))) |
|
549 | 547 | { |
550 | 548 | $parsed .= "\n"; |
551 | 549 | |
552 | 550 | continue; |
553 | 551 | } |
554 | 552 | |
555 | - $height = $this->getLineHeight ($line); |
|
553 | + $height = $this->getLineHeight($line); |
|
556 | 554 | |
557 | 555 | if ($this->debug_mode) |
558 | - pre ("$height, $down_height, $line"); |
|
556 | + pre("$height, $down_height, $line"); |
|
559 | 557 | |
560 | 558 | if ($height > $down_height) |
561 | 559 | $parsed .= "$line\n"; |
@@ -566,7 +564,7 @@ discard block |
||
566 | 564 | return [$parsed, $line_id]; |
567 | 565 | } |
568 | 566 | |
569 | - public function __get ($name) // Возвращалка переменных парсера |
|
567 | + public function __get($name) // Возвращалка переменных парсера |
|
570 | 568 | { |
571 | 569 | return isset ($this->$name) ? |
572 | 570 | $this->$name : false; |
@@ -580,14 +578,14 @@ discard block |
||
580 | 578 | * |
581 | 579 | * @return int - высота строки |
582 | 580 | */ |
583 | - protected function getLineHeight (string &$line): int |
|
581 | + protected function getLineHeight(string &$line): int |
|
584 | 582 | { |
585 | 583 | $i = 0; |
586 | 584 | |
587 | 585 | while (isset ($line[$i]) && $line[$i] == "\t") |
588 | 586 | ++$i; |
589 | 587 | |
590 | - return strlen ($line = str_repeat (' ', $i) . substr ($line, $i)) - strlen ($line = trim ($line)); |
|
588 | + return strlen($line = str_repeat(' ', $i).substr($line, $i)) - strlen($line = trim($line)); |
|
591 | 589 | } |
592 | 590 | |
593 | 591 | /** |
@@ -598,14 +596,14 @@ discard block |
||
598 | 596 | * |
599 | 597 | * @return array - возвращает очищенный массив |
600 | 598 | */ |
601 | - protected function linesFilter (array $segments): array |
|
599 | + protected function linesFilter(array $segments): array |
|
602 | 600 | { |
603 | - return array_filter ($segments, function ($text) |
|
601 | + return array_filter($segments, function($text) |
|
604 | 602 | { |
605 | - if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) |
|
606 | - throw new \Exception ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
603 | + if ($this->strong_line_parser && preg_match('/[^a-z0-9]/i', $text)) |
|
604 | + throw new \Exception('Line "'.$text.'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
607 | 605 | |
608 | - return strlen (trim ($text)) > 0; |
|
606 | + return strlen(trim($text)) > 0; |
|
609 | 607 | }); |
610 | 608 | } |
611 | 609 | } |
@@ -33,8 +33,9 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct (string $content, array $settings = []) |
35 | 35 | { |
36 | - if (file_exists ($content)) |
|
37 | - $content = file_get_contents ($content); |
|
36 | + if (file_exists ($content)) { |
|
37 | + $content = file_get_contents ($content); |
|
38 | + } |
|
38 | 39 | |
39 | 40 | // Зачем? Так надо! |
40 | 41 | // ДА БАГ ЭТО, НЕ ПИ%ДИ!!! И Я ПОНЯТИЯ НЕ ИМЕЮ КАК И ПОЧЕМУ!!! |
@@ -42,10 +43,11 @@ discard block |
||
42 | 43 | |
43 | 44 | foreach ($settings as $name => $setting) |
44 | 45 | { |
45 | - if (isset ($this->$name)) |
|
46 | - $this->$name = $setting; |
|
47 | - |
|
48 | - else throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
46 | + if (isset ($this->$name)) { |
|
47 | + $this->$name = $setting; |
|
48 | + } else { |
|
49 | + throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
50 | + } |
|
49 | 51 | } |
50 | 52 | |
51 | 53 | if ($this->use_caching && file_exists ($file = VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache')) |
@@ -58,9 +60,9 @@ discard block |
||
58 | 60 | $this->links = $info[1][1]; |
59 | 61 | |
60 | 62 | return; |
63 | + } else { |
|
64 | + unlink ($file); |
|
61 | 65 | } |
62 | - |
|
63 | - else unlink ($file); |
|
64 | 66 | } |
65 | 67 | |
66 | 68 | $info = $this->generateSyntaxTree ($content); |
@@ -70,8 +72,9 @@ discard block |
||
70 | 72 | |
71 | 73 | if ($this->use_caching) |
72 | 74 | { |
73 | - if (!is_dir (dirname (__DIR__) .'/cache')) |
|
74 | - mkdir (dirname (__DIR__) .'/cache'); |
|
75 | + if (!is_dir (dirname (__DIR__) .'/cache')) { |
|
76 | + mkdir (dirname (__DIR__) .'/cache'); |
|
77 | + } |
|
75 | 78 | |
76 | 79 | file_put_contents (VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache', gzdeflate (serialize ([sha1 (file_get_contents (__FILE__)), $info]))); |
77 | 80 | } |
@@ -94,19 +97,22 @@ discard block |
||
94 | 97 | $tree = []; |
95 | 98 | $links = []; |
96 | 99 | |
97 | - if ($this->debug_mode) |
|
98 | - pre ($lines); |
|
100 | + if ($this->debug_mode) { |
|
101 | + pre ($lines); |
|
102 | + } |
|
99 | 103 | |
100 | 104 | foreach ($lines as $id => $line) |
101 | 105 | { |
102 | - if ($skip_at > $id) |
|
103 | - continue; |
|
106 | + if ($skip_at > $id) { |
|
107 | + continue; |
|
108 | + } |
|
104 | 109 | |
105 | 110 | $height = $this->getLineHeight ($line); |
106 | 111 | $words = $this->linesFilter (explode (' ', $line)); |
107 | 112 | |
108 | - if ($this->debug_mode) |
|
109 | - pre ($words); |
|
113 | + if ($this->debug_mode) { |
|
114 | + pre ($words); |
|
115 | + } |
|
110 | 116 | |
111 | 117 | /** |
112 | 118 | * Высокоинтеллектуальный фикс |
@@ -127,16 +133,18 @@ discard block |
||
127 | 133 | { |
128 | 134 | $updated = false; |
129 | 135 | |
130 | - if ($this->debug_mode) |
|
131 | - pre ($current_object); |
|
136 | + if ($this->debug_mode) { |
|
137 | + pre ($current_object); |
|
138 | + } |
|
132 | 139 | |
133 | 140 | while (isset ($tree[$current_object]['info']['subparent_link']) && $tree[$link = $tree[$current_object]['info']['subparent_link']->link]['hard'] < $tree[$current_object]['hard']) |
134 | 141 | { |
135 | 142 | $current_object = $link; |
136 | 143 | $updated = true; |
137 | 144 | |
138 | - if ($this->debug_mode) |
|
139 | - pre ($current_object); |
|
145 | + if ($this->debug_mode) { |
|
146 | + pre ($current_object); |
|
147 | + } |
|
140 | 148 | } |
141 | 149 | |
142 | 150 | if ( |
@@ -145,13 +153,15 @@ discard block |
||
145 | 153 | isset ($tree[$current_object]['info']['arguments'][0]) && |
146 | 154 | $tree[$current_object]['info']['arguments'][0] instanceof VLFLink && |
147 | 155 | $tree[$tree[$current_object]['info']['arguments'][0]->link]['hard'] < $tree[$current_object]['hard'] |
148 | - ) $current_object = $tree[$current_object]['info']['arguments'][0]->link; |
|
149 | - |
|
150 | - elseif (!$updated) |
|
151 | - break; |
|
156 | + ) { |
|
157 | + $current_object = $tree[$current_object]['info']['arguments'][0]->link; |
|
158 | + } elseif (!$updated) { |
|
159 | + break; |
|
160 | + } |
|
152 | 161 | |
153 | - if ($this->debug_mode) |
|
154 | - pre ($current_object); |
|
162 | + if ($this->debug_mode) { |
|
163 | + pre ($current_object); |
|
164 | + } |
|
155 | 165 | } |
156 | 166 | |
157 | 167 | /** |
@@ -159,8 +169,9 @@ discard block |
||
159 | 169 | */ |
160 | 170 | if (class_exists ($words[0]) || class_exists ('\VoidEngine\\'. $words[0])) |
161 | 171 | { |
162 | - if (!isset ($words[1])) |
|
163 | - throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
172 | + if (!isset ($words[1])) { |
|
173 | + throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
174 | + } |
|
164 | 175 | |
165 | 176 | /** |
166 | 177 | * Button NewButton |
@@ -188,9 +199,7 @@ discard block |
||
188 | 199 | $current_object = $id; |
189 | 200 | |
190 | 201 | continue; |
191 | - } |
|
192 | - |
|
193 | - else |
|
202 | + } else |
|
194 | 203 | { |
195 | 204 | $tree[$id] = [ |
196 | 205 | 'type' => VLF_OBJECT_DEFINITION, |
@@ -212,10 +221,9 @@ discard block |
||
212 | 221 | |
213 | 222 | $end = strrpos ($line, ')'); |
214 | 223 | |
215 | - if ($end === false) |
|
216 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
217 | - |
|
218 | - elseif ($begin < $end) |
|
224 | + if ($end === false) { |
|
225 | + throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
226 | + } elseif ($begin < $end) |
|
219 | 227 | { |
220 | 228 | $arguments = []; |
221 | 229 | $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
@@ -224,18 +232,20 @@ discard block |
||
224 | 232 | { |
225 | 233 | $argument = trim ($argument); |
226 | 234 | |
227 | - if (strlen ($argument) > 0) |
|
228 | - $arguments[] = isset ($links[$argument]) ? |
|
235 | + if (strlen ($argument) > 0) { |
|
236 | + $arguments[] = isset ($links[$argument]) ? |
|
229 | 237 | new VLFLink ($argument, $links[$argument]) : |
230 | 238 | $argument; |
231 | - |
|
232 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
239 | + } else { |
|
240 | + throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
241 | + } |
|
233 | 242 | } |
234 | 243 | |
235 | 244 | $tree[$id]['info']['arguments'] = $arguments; |
236 | 245 | |
237 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
238 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
246 | + if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) { |
|
247 | + throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
248 | + } |
|
239 | 249 | } |
240 | 250 | |
241 | 251 | $tree[$id]['info']['subparent_link'] = new VLFLink ($tree[$current_object]['info']['object_name'], $current_object); |
@@ -299,13 +309,14 @@ discard block |
||
299 | 309 | |
300 | 310 | $comment .= $parsed[0]; |
301 | 311 | $skip_at = $parsed[1]; |
312 | + } else { |
|
313 | + throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
302 | 314 | } |
303 | - |
|
304 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
305 | 315 | } |
306 | 316 | |
307 | - if ($this->debug_mode) |
|
308 | - pre ("Comment:\n\n$comment"); |
|
317 | + if ($this->debug_mode) { |
|
318 | + pre ("Comment:\n\n$comment"); |
|
319 | + } |
|
309 | 320 | } |
310 | 321 | |
311 | 322 | /** |
@@ -327,9 +338,9 @@ discard block |
||
327 | 338 | |
328 | 339 | $code .= $parsed[0]; |
329 | 340 | $skip_at = $parsed[1]; |
341 | + } else { |
|
342 | + throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
330 | 343 | } |
331 | - |
|
332 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
333 | 344 | } |
334 | 345 | |
335 | 346 | $tree[$id] = [ |
@@ -384,8 +395,9 @@ discard block |
||
384 | 395 | |
385 | 396 | if ($postChar == ':' || $postChar == '^') |
386 | 397 | { |
387 | - if (!isset ($words[1])) |
|
388 | - throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
398 | + if (!isset ($words[1])) { |
|
399 | + throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
400 | + } |
|
389 | 401 | |
390 | 402 | $propertyName = substr ($words[0], 0, -1); |
391 | 403 | $propertyValue = implode (' ', array_slice ($words, 1)); |
@@ -420,8 +432,9 @@ discard block |
||
420 | 432 | 'syntax_nodes' => [] |
421 | 433 | ]; |
422 | 434 | |
423 | - if (isset ($links[$info['info']['property_value']])) |
|
424 | - $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
435 | + if (isset ($links[$info['info']['property_value']])) { |
|
436 | + $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
437 | + } |
|
425 | 438 | |
426 | 439 | $tree[$current_object]['syntax_nodes'][] = $info; |
427 | 440 | } |
@@ -439,10 +452,9 @@ discard block |
||
439 | 452 | |
440 | 453 | $end = strrpos ($line, ')'); |
441 | 454 | |
442 | - if ($end === false) |
|
443 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
444 | - |
|
445 | - elseif ($begin < $end) |
|
455 | + if ($end === false) { |
|
456 | + throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
457 | + } elseif ($begin < $end) |
|
446 | 458 | { |
447 | 459 | $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
448 | 460 | |
@@ -450,24 +462,27 @@ discard block |
||
450 | 462 | { |
451 | 463 | $argument = trim ($argument); |
452 | 464 | |
453 | - if (strlen ($argument) > 0) |
|
454 | - $arguments[] = isset ($links[$argument]) ? |
|
465 | + if (strlen ($argument) > 0) { |
|
466 | + $arguments[] = isset ($links[$argument]) ? |
|
455 | 467 | new VLFLink ($argument, $links[$argument]) : |
456 | 468 | $argument; |
457 | - |
|
458 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
469 | + } else { |
|
470 | + throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
471 | + } |
|
459 | 472 | } |
460 | 473 | |
461 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
462 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
474 | + if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) { |
|
475 | + throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
476 | + } |
|
463 | 477 | } |
464 | 478 | } |
465 | 479 | |
466 | 480 | /** |
467 | 481 | * ->show |
468 | 482 | */ |
469 | - elseif (!$this->ignore_unexpected_method_args) |
|
470 | - throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
483 | + elseif (!$this->ignore_unexpected_method_args) { |
|
484 | + throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
485 | + } |
|
471 | 486 | |
472 | 487 | $tree[$current_object]['syntax_nodes'][] = [ |
473 | 488 | 'type' => VLF_METHOD_CALL, |
@@ -520,7 +535,9 @@ discard block |
||
520 | 535 | /** |
521 | 536 | * Что-то загадочное, таинственное, неизвестное человечеству |
522 | 537 | */ |
523 | - else throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
538 | + else { |
|
539 | + throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
540 | + } |
|
524 | 541 | } |
525 | 542 | |
526 | 543 | return [$tree, $links]; |
@@ -542,8 +559,9 @@ discard block |
||
542 | 559 | |
543 | 560 | foreach ($lines as $line_id => $line) |
544 | 561 | { |
545 | - if ($line_id <= $begin_id) |
|
546 | - continue; |
|
562 | + if ($line_id <= $begin_id) { |
|
563 | + continue; |
|
564 | + } |
|
547 | 565 | |
548 | 566 | if (!(bool)(trim ($line))) |
549 | 567 | { |
@@ -554,13 +572,15 @@ discard block |
||
554 | 572 | |
555 | 573 | $height = $this->getLineHeight ($line); |
556 | 574 | |
557 | - if ($this->debug_mode) |
|
558 | - pre ("$height, $down_height, $line"); |
|
559 | - |
|
560 | - if ($height > $down_height) |
|
561 | - $parsed .= "$line\n"; |
|
575 | + if ($this->debug_mode) { |
|
576 | + pre ("$height, $down_height, $line"); |
|
577 | + } |
|
562 | 578 | |
563 | - else break; |
|
579 | + if ($height > $down_height) { |
|
580 | + $parsed .= "$line\n"; |
|
581 | + } else { |
|
582 | + break; |
|
583 | + } |
|
564 | 584 | } |
565 | 585 | |
566 | 586 | return [$parsed, $line_id]; |
@@ -584,8 +604,9 @@ discard block |
||
584 | 604 | { |
585 | 605 | $i = 0; |
586 | 606 | |
587 | - while (isset ($line[$i]) && $line[$i] == "\t") |
|
588 | - ++$i; |
|
607 | + while (isset ($line[$i]) && $line[$i] == "\t") { |
|
608 | + ++$i; |
|
609 | + } |
|
589 | 610 | |
590 | 611 | return strlen ($line = str_repeat (' ', $i) . substr ($line, $i)) - strlen ($line = trim ($line)); |
591 | 612 | } |
@@ -602,8 +623,9 @@ discard block |
||
602 | 623 | { |
603 | 624 | return array_filter ($segments, function ($text) |
604 | 625 | { |
605 | - if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) |
|
606 | - throw new \Exception ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
626 | + if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) { |
|
627 | + throw new \Exception ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
628 | + } |
|
607 | 629 | |
608 | 630 | return strlen (trim ($text)) > 0; |
609 | 631 | }); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | return [ |
49 | 49 | 'text' => $e->getMessage (), |
50 | - 'line' => $e->getLine () |
|
50 | + 'line' => $e->getLine () |
|
51 | 51 | ]; |
52 | 52 | } |
53 | 53 | |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | |
166 | 166 | function substr_icount (string $haystack, string $needle, ...$params): int |
167 | 167 | { |
168 | - return substr_count (strtolower ($haystack), strtolower ($needle), ...$params); |
|
168 | + return substr_count (strtolower ($haystack), strtolower ($needle), ...$params); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | function str_replace_assoc (string $subject, array $replacements): string |
172 | 172 | { |
173 | - return str_replace (array_keys ($replacements), array_values ($replacements), $subject); |
|
173 | + return str_replace (array_keys ($replacements), array_values ($replacements), $subject); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | function pre (...$args): void |
177 | 177 | { |
178 | - message (sizeof ($args) < 2 ? current ($args) : $args); |
|
178 | + message (sizeof ($args) < 2 ? current ($args) : $args); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | function messageBox (string $message, string $caption = '', ...$args) |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | } |
334 | 334 | |
335 | 335 | catch (\Throwable $e) |
336 | - { |
|
337 | - continue; |
|
338 | - } |
|
336 | + { |
|
337 | + continue; |
|
338 | + } |
|
339 | 339 | |
340 | 340 | return false; |
341 | 341 | } |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | call_user_func ($function, $self); |
359 | 359 | }; |
360 | 360 | |
361 | - $timer->start (); |
|
361 | + $timer->start (); |
|
362 | 362 | |
363 | 363 | return $timer; |
364 | 364 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | |
379 | 379 | $timer->start (); |
380 | 380 | |
381 | - return $timer; |
|
381 | + return $timer; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | class Clipboard |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -function err_status (bool $status = null): bool |
|
5 | +function err_status(bool $status = null): bool |
|
6 | 6 | { |
7 | 7 | $oldStatus = $GLOBALS['error_status']; |
8 | 8 | |
@@ -12,203 +12,203 @@ discard block |
||
12 | 12 | return $oldStatus; |
13 | 13 | } |
14 | 14 | |
15 | -function err_no (): bool |
|
15 | +function err_no(): bool |
|
16 | 16 | { |
17 | - return err_status (false); |
|
17 | + return err_status(false); |
|
18 | 18 | } |
19 | 19 | |
20 | -function err_yes (): bool |
|
20 | +function err_yes(): bool |
|
21 | 21 | { |
22 | - return err_status (true); |
|
22 | + return err_status(true); |
|
23 | 23 | } |
24 | 24 | |
25 | -function run (string $path, ...$args) |
|
25 | +function run(string $path, ...$args) |
|
26 | 26 | { |
27 | - return (new Process)->start ($path, ...$args); |
|
27 | + return (new Process)->start($path, ...$args); |
|
28 | 28 | } |
29 | 29 | |
30 | -function vbs_exec (string $code) |
|
30 | +function vbs_exec(string $code) |
|
31 | 31 | { |
32 | - file_put_contents ($path = getenv ('temp') .'/'. crc32 ($code) .'.vbs', $code); |
|
32 | + file_put_contents($path = getenv('temp').'/'.crc32($code).'.vbs', $code); |
|
33 | 33 | |
34 | - (new \COM ('WScript.Shell'))->Run ($path, 0, true); |
|
34 | + (new \COM('WScript.Shell'))->Run($path, 0, true); |
|
35 | 35 | |
36 | - unlink ($path); |
|
36 | + unlink($path); |
|
37 | 37 | } |
38 | 38 | |
39 | -function php_errors_check (string $code): ?array |
|
39 | +function php_errors_check(string $code): ?array |
|
40 | 40 | { |
41 | 41 | try |
42 | 42 | { |
43 | - eval ('return; '. $code); |
|
43 | + eval ('return; '.$code); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | catch (\Throwable $e) |
47 | 47 | { |
48 | 48 | return [ |
49 | - 'text' => $e->getMessage (), |
|
50 | - 'line' => $e->getLine () |
|
49 | + 'text' => $e->getMessage(), |
|
50 | + 'line' => $e->getLine() |
|
51 | 51 | ]; |
52 | 52 | } |
53 | 53 | |
54 | 54 | return null; |
55 | 55 | } |
56 | 56 | |
57 | -function enum (string $name): array |
|
57 | +function enum(string $name): array |
|
58 | 58 | { |
59 | 59 | return [ |
60 | - substr ($name, strrpos ($name, '.') + 1), |
|
61 | - ($name = substr ($name, 0, strrpos ($name, '.'))) .', '. substr ($name, 0, strrpos ($name, '.')) |
|
60 | + substr($name, strrpos($name, '.') + 1), |
|
61 | + ($name = substr($name, 0, strrpos($name, '.'))).', '.substr($name, 0, strrpos($name, '.')) |
|
62 | 62 | ]; |
63 | 63 | } |
64 | 64 | |
65 | -function getNetArray (string $type, array $items = []): WFObject |
|
65 | +function getNetArray(string $type, array $items = []): WFObject |
|
66 | 66 | { |
67 | - $array = (new WFClass ('System.Array', null)) |
|
68 | - ->createInstance (VoidEngine::objectType ($type), $size = sizeof ($items)); |
|
67 | + $array = (new WFClass('System.Array', null)) |
|
68 | + ->createInstance(VoidEngine::objectType($type), $size = sizeof($items)); |
|
69 | 69 | |
70 | 70 | for ($i = 0; $i < $size; ++$i) |
71 | - $array[$i] = array_shift ($items); |
|
71 | + $array[$i] = array_shift($items); |
|
72 | 72 | |
73 | 73 | return $array; |
74 | 74 | } |
75 | 75 | |
76 | -function dir_create (string $path, int $mode = 0777): void |
|
76 | +function dir_create(string $path, int $mode = 0777): void |
|
77 | 77 | { |
78 | - if (!is_dir ($path)) |
|
79 | - mkdir ($path, $mode, true); |
|
78 | + if (!is_dir($path)) |
|
79 | + mkdir($path, $mode, true); |
|
80 | 80 | } |
81 | 81 | |
82 | -function dir_delete (string $path): bool |
|
82 | +function dir_delete(string $path): bool |
|
83 | 83 | { |
84 | - if (!is_dir ($path)) |
|
84 | + if (!is_dir($path)) |
|
85 | 85 | return false; |
86 | 86 | |
87 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
88 | - if (is_dir ($file = $path .'/'. $file)) |
|
87 | + foreach (array_slice(scandir($path), 2) as $file) |
|
88 | + if (is_dir($file = $path.'/'.$file)) |
|
89 | 89 | { |
90 | - dir_delete ($file); |
|
90 | + dir_delete($file); |
|
91 | 91 | |
92 | - if (is_dir ($file)) |
|
93 | - rmdir ($file); |
|
92 | + if (is_dir($file)) |
|
93 | + rmdir($file); |
|
94 | 94 | } |
95 | 95 | |
96 | - else unlink ($file); |
|
96 | + else unlink($file); |
|
97 | 97 | |
98 | - rmdir ($path); |
|
98 | + rmdir($path); |
|
99 | 99 | |
100 | 100 | return true; |
101 | 101 | } |
102 | 102 | |
103 | -function dir_clean (string $path): void |
|
103 | +function dir_clean(string $path): void |
|
104 | 104 | { |
105 | - dir_delete ($path); |
|
106 | - dir_create ($path); |
|
105 | + dir_delete($path); |
|
106 | + dir_create($path); |
|
107 | 107 | } |
108 | 108 | |
109 | -function dir_copy (string $from, string $to): bool |
|
109 | +function dir_copy(string $from, string $to): bool |
|
110 | 110 | { |
111 | - if (!is_dir ($from)) |
|
111 | + if (!is_dir($from)) |
|
112 | 112 | return false; |
113 | 113 | |
114 | - if (!is_dir ($to)) |
|
115 | - dir_create ($to); |
|
114 | + if (!is_dir($to)) |
|
115 | + dir_create($to); |
|
116 | 116 | |
117 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
118 | - if (is_dir ($f = $from .'/'. $file)) |
|
119 | - dir_copy ($f, $to .'/'. $file); |
|
117 | + foreach (array_slice(scandir($from), 2) as $file) |
|
118 | + if (is_dir($f = $from.'/'.$file)) |
|
119 | + dir_copy($f, $to.'/'.$file); |
|
120 | 120 | |
121 | - else copy ($f, $to .'/'. $file); |
|
121 | + else copy($f, $to.'/'.$file); |
|
122 | 122 | |
123 | 123 | return true; |
124 | 124 | } |
125 | 125 | |
126 | -function getARGBColor (string $color) |
|
126 | +function getARGBColor(string $color) |
|
127 | 127 | { |
128 | - return (new WFClass ('System.Drawing.ColorTranslator'))->fromHtml ($color); |
|
128 | + return (new WFClass('System.Drawing.ColorTranslator'))->fromHtml($color); |
|
129 | 129 | } |
130 | 130 | |
131 | -function replaceSl (string $string): string |
|
131 | +function replaceSl(string $string): string |
|
132 | 132 | { |
133 | - return str_replace ('\\', '/', $string); |
|
133 | + return str_replace('\\', '/', $string); |
|
134 | 134 | } |
135 | 135 | |
136 | -function replaceSr (string $string): string |
|
136 | +function replaceSr(string $string): string |
|
137 | 137 | { |
138 | - return str_replace ('/', '\\', $string); |
|
138 | + return str_replace('/', '\\', $string); |
|
139 | 139 | } |
140 | 140 | |
141 | -function basenameNoExt (string $path): string |
|
141 | +function basenameNoExt(string $path): string |
|
142 | 142 | { |
143 | - return pathinfo ($path, PATHINFO_FILENAME); |
|
143 | + return pathinfo($path, PATHINFO_FILENAME); |
|
144 | 144 | } |
145 | 145 | |
146 | -function file_ext (string $path): string |
|
146 | +function file_ext(string $path): string |
|
147 | 147 | { |
148 | - return strtolower (pathinfo ($path, PATHINFO_EXTENSION)); |
|
148 | + return strtolower(pathinfo($path, PATHINFO_EXTENSION)); |
|
149 | 149 | } |
150 | 150 | |
151 | -function filepathNoExt (string $path): string |
|
151 | +function filepathNoExt(string $path): string |
|
152 | 152 | { |
153 | - return dirname ($path) .'/'. basenameNoExt ($path); |
|
153 | + return dirname($path).'/'.basenameNoExt($path); |
|
154 | 154 | } |
155 | 155 | |
156 | -function array_first (array $array) |
|
156 | +function array_first(array $array) |
|
157 | 157 | { |
158 | - return array_shift ($array); |
|
158 | + return array_shift($array); |
|
159 | 159 | } |
160 | 160 | |
161 | -function array_end (array $array) |
|
161 | +function array_end(array $array) |
|
162 | 162 | { |
163 | - return array_pop ($array); |
|
163 | + return array_pop($array); |
|
164 | 164 | } |
165 | 165 | |
166 | -function substr_icount (string $haystack, string $needle, ...$params): int |
|
166 | +function substr_icount(string $haystack, string $needle, ...$params): int |
|
167 | 167 | { |
168 | - return substr_count (strtolower ($haystack), strtolower ($needle), ...$params); |
|
168 | + return substr_count(strtolower($haystack), strtolower($needle), ...$params); |
|
169 | 169 | } |
170 | 170 | |
171 | -function str_replace_assoc (string $subject, array $replacements): string |
|
171 | +function str_replace_assoc(string $subject, array $replacements): string |
|
172 | 172 | { |
173 | - return str_replace (array_keys ($replacements), array_values ($replacements), $subject); |
|
173 | + return str_replace(array_keys($replacements), array_values($replacements), $subject); |
|
174 | 174 | } |
175 | 175 | |
176 | -function pre (...$args): void |
|
176 | +function pre(...$args): void |
|
177 | 177 | { |
178 | - message (sizeof ($args) < 2 ? current ($args) : $args); |
|
178 | + message(sizeof($args) < 2 ? current ($args) : $args); |
|
179 | 179 | } |
180 | 180 | |
181 | -function messageBox (string $message, string $caption = '', ...$args) |
|
181 | +function messageBox(string $message, string $caption = '', ...$args) |
|
182 | 182 | { |
183 | - return (new MessageBox)->show ($message, $caption, ...$args); |
|
183 | + return (new MessageBox)->show($message, $caption, ...$args); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | class Components |
187 | 187 | { |
188 | 188 | static $components = []; |
189 | 189 | |
190 | - public static function addComponent (int $selector, object $object): void |
|
190 | + public static function addComponent(int $selector, object $object): void |
|
191 | 191 | { |
192 | 192 | self::$components[$selector] = $object; |
193 | 193 | } |
194 | 194 | |
195 | - public static function getComponent (int $selector) |
|
195 | + public static function getComponent(int $selector) |
|
196 | 196 | { |
197 | 197 | return isset (self::$components[$selector]) ? |
198 | 198 | self::$components[$selector] : false; |
199 | 199 | } |
200 | 200 | |
201 | - public static function componentExists (int $selector): bool |
|
201 | + public static function componentExists(int $selector): bool |
|
202 | 202 | { |
203 | 203 | return isset (self::$components[$selector]); |
204 | 204 | } |
205 | 205 | |
206 | - public static function removeComponent (int $selector): void |
|
206 | + public static function removeComponent(int $selector): void |
|
207 | 207 | { |
208 | 208 | unset (self::$components[$selector]); |
209 | 209 | } |
210 | 210 | |
211 | - public static function cleanJunk (): void |
|
211 | + public static function cleanJunk(): void |
|
212 | 212 | { |
213 | 213 | // TODO: более строгие правила очистки мусорных объектов |
214 | 214 | |
@@ -216,46 +216,46 @@ discard block |
||
216 | 216 | { |
217 | 217 | try |
218 | 218 | { |
219 | - if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
219 | + if ($object->getType()->isSubclassOf(VoidEngine::objectType('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
223 | 223 | catch (\Exception $e) {} |
224 | 224 | |
225 | - VoidEngine::destructObject ($selector); |
|
225 | + VoidEngine::destructObject($selector); |
|
226 | 226 | |
227 | - if (!VoidEngine::objectExists ($selector)) |
|
227 | + if (!VoidEngine::objectExists($selector)) |
|
228 | 228 | unset (self::$components[$selector]); |
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | -function _c (int $selector) |
|
233 | +function _c(int $selector) |
|
234 | 234 | { |
235 | - return Components::getComponent ($selector); |
|
235 | + return Components::getComponent($selector); |
|
236 | 236 | } |
237 | 237 | |
238 | -function c ($name, bool $returnAllSimilarObjects = false) |
|
238 | +function c($name, bool $returnAllSimilarObjects = false) |
|
239 | 239 | { |
240 | - if (is_int ($name) && is_object ($object = _c ($name))) |
|
240 | + if (is_int($name) && is_object($object = _c($name))) |
|
241 | 241 | return $object; |
242 | 242 | |
243 | 243 | else |
244 | 244 | { |
245 | - $path = explode ('->', $name); |
|
245 | + $path = explode('->', $name); |
|
246 | 246 | $similar = []; |
247 | 247 | |
248 | 248 | foreach (Components::$components as $object) |
249 | 249 | try |
250 | 250 | { |
251 | - if ($object->name == end ($path)) |
|
251 | + if ($object->name == end($path)) |
|
252 | 252 | { |
253 | - if (sizeof ($path) > 1) |
|
253 | + if (sizeof($path) > 1) |
|
254 | 254 | try |
255 | 255 | { |
256 | - if (is_object ($parent = _c($object->parent->selector))) |
|
256 | + if (is_object($parent = _c($object->parent->selector))) |
|
257 | 257 | { |
258 | - if (c(join ('->', array_slice ($path, 0, -1))) == $parent) |
|
258 | + if (c(join('->', array_slice($path, 0, -1))) == $parent) |
|
259 | 259 | { |
260 | 260 | if ($returnAllSimilarObjects) |
261 | 261 | $similar[] = $object; |
@@ -289,18 +289,18 @@ discard block |
||
289 | 289 | continue; |
290 | 290 | } |
291 | 291 | |
292 | - if (sizeof ($path) == 2) |
|
292 | + if (sizeof($path) == 2) |
|
293 | 293 | { |
294 | 294 | $objects = c($path[1], true); |
295 | 295 | |
296 | - if (is_array ($objects)) |
|
296 | + if (is_array($objects)) |
|
297 | 297 | { |
298 | 298 | foreach ($objects as $id => $object) |
299 | 299 | try |
300 | 300 | { |
301 | - while (is_object ($parent = _c($object->parent->selector))) |
|
301 | + while (is_object($parent = _c($object->parent->selector))) |
|
302 | 302 | { |
303 | - if ($parent->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
|
303 | + if ($parent->getType()->isSubclassOf(VoidEngine::objectType('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
|
304 | 304 | return $objects[$id]; |
305 | 305 | |
306 | 306 | else $object = $parent; |
@@ -318,70 +318,70 @@ discard block |
||
318 | 318 | else return false; |
319 | 319 | } |
320 | 320 | |
321 | - else return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
321 | + else return $returnAllSimilarObjects && sizeof($similar) > 0 ? |
|
322 | 322 | $similar : false; |
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
326 | -function setTimer (int $interval, callable $function): Timer |
|
326 | +function setTimer(int $interval, callable $function): Timer |
|
327 | 327 | { |
328 | 328 | $timer = new Timer; |
329 | 329 | $timer->interval = $interval; |
330 | 330 | |
331 | - $timer->tickEvent = function ($self) use ($function) |
|
331 | + $timer->tickEvent = function($self) use ($function) |
|
332 | 332 | { |
333 | - call_user_func ($function, $self); |
|
333 | + call_user_func($function, $self); |
|
334 | 334 | }; |
335 | 335 | |
336 | - $timer->start (); |
|
336 | + $timer->start(); |
|
337 | 337 | |
338 | 338 | return $timer; |
339 | 339 | } |
340 | 340 | |
341 | 341 | // FIXME: выполняется несколько раз, а не единожды |
342 | -function setTimeout (int $timeout, callable $function): Timer |
|
342 | +function setTimeout(int $timeout, callable $function): Timer |
|
343 | 343 | { |
344 | 344 | $timer = new Timer; |
345 | 345 | $timer->interval = $timeout; |
346 | 346 | |
347 | - $timer->tickEvent = function ($self) use ($function) |
|
347 | + $timer->tickEvent = function($self) use ($function) |
|
348 | 348 | { |
349 | - call_user_func ($function, $self); |
|
349 | + call_user_func($function, $self); |
|
350 | 350 | |
351 | - $self->stop (); |
|
351 | + $self->stop(); |
|
352 | 352 | }; |
353 | 353 | |
354 | - $timer->start (); |
|
354 | + $timer->start(); |
|
355 | 355 | |
356 | 356 | return $timer; |
357 | 357 | } |
358 | 358 | |
359 | 359 | class Clipboard |
360 | 360 | { |
361 | - public static function getText () |
|
361 | + public static function getText() |
|
362 | 362 | { |
363 | - return (new WFClass ('System.Windows.Forms.Clipboard'))->getText (); |
|
363 | + return (new WFClass('System.Windows.Forms.Clipboard'))->getText(); |
|
364 | 364 | } |
365 | 365 | |
366 | - public static function setText (string $text): void |
|
366 | + public static function setText(string $text): void |
|
367 | 367 | { |
368 | - (new WFClass ('System.Windows.Forms.Clipboard'))->setText ($text); |
|
368 | + (new WFClass('System.Windows.Forms.Clipboard'))->setText($text); |
|
369 | 369 | } |
370 | 370 | |
371 | - public static function getFiles (): array |
|
371 | + public static function getFiles(): array |
|
372 | 372 | { |
373 | - return (new WFClass ('System.Windows.Forms.Clipboard'))->getFileDropList ()->list; |
|
373 | + return (new WFClass('System.Windows.Forms.Clipboard'))->getFileDropList()->list; |
|
374 | 374 | } |
375 | 375 | |
376 | - public static function setFiles (array $files): void |
|
376 | + public static function setFiles(array $files): void |
|
377 | 377 | { |
378 | - $collection = new WFObject ('System.Collections.Specialized.StringCollection'); |
|
378 | + $collection = new WFObject('System.Collections.Specialized.StringCollection'); |
|
379 | 379 | |
380 | 380 | foreach ($files as $file) |
381 | - $collection->add ((string) $file); |
|
381 | + $collection->add((string) $file); |
|
382 | 382 | |
383 | - (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection); |
|
384 | - VoidEngine::removeObjects ($collection->selector); |
|
383 | + (new WFClass('System.Windows.Forms.Clipboard'))->setFileDropList($collection); |
|
384 | + VoidEngine::removeObjects($collection->selector); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
@@ -389,14 +389,13 @@ discard block |
||
389 | 389 | { |
390 | 390 | protected $cursor; |
391 | 391 | |
392 | - public function __construct (int $handle = null) |
|
392 | + public function __construct(int $handle = null) |
|
393 | 393 | { |
394 | 394 | $handle !== null ? |
395 | - $this->cursor = new WFObject ('System.Windows.Forms.Cursor', 'auto', $handle) : |
|
396 | - $this->cursor = new WFClass ('System.Windows.Forms.Cursor'); |
|
395 | + $this->cursor = new WFObject('System.Windows.Forms.Cursor', 'auto', $handle) : $this->cursor = new WFClass('System.Windows.Forms.Cursor'); |
|
397 | 396 | } |
398 | 397 | |
399 | - public function getPosition (): array |
|
398 | + public function getPosition(): array |
|
400 | 399 | { |
401 | 400 | $pos = $this->cursor->position; |
402 | 401 | |
@@ -407,22 +406,22 @@ discard block |
||
407 | 406 | } |
408 | 407 | } |
409 | 408 | |
410 | -function get_cursor_x (int $handle = null): int |
|
409 | +function get_cursor_x(int $handle = null): int |
|
411 | 410 | { |
412 | - return (new Cursor ($handle))->getPosition ()[0]; |
|
411 | + return (new Cursor($handle))->getPosition()[0]; |
|
413 | 412 | } |
414 | 413 | |
415 | -function get_cursor_y (int $handle = null): int |
|
414 | +function get_cursor_y(int $handle = null): int |
|
416 | 415 | { |
417 | - return (new Cursor ($handle))->getPosition ()[1]; |
|
416 | + return (new Cursor($handle))->getPosition()[1]; |
|
418 | 417 | } |
419 | 418 | |
420 | -function get_cursor_pos (int $handle = null): array |
|
419 | +function get_cursor_pos(int $handle = null): array |
|
421 | 420 | { |
422 | - return (new Cursor ($handle))->getPosition (); |
|
421 | + return (new Cursor($handle))->getPosition(); |
|
423 | 422 | } |
424 | 423 | |
425 | -set_error_handler (function ($no, $str, $file, $line) |
|
424 | +set_error_handler(function($no, $str, $file, $line) |
|
426 | 425 | { |
427 | 426 | // Мог ли я здесь сделать более адекватный код с использованием pow/sqrt? Да, мог |
428 | 427 | // Почему не сделал? Скорость важнее |
@@ -445,11 +444,11 @@ discard block |
||
445 | 444 | ]; |
446 | 445 | |
447 | 446 | if ($GLOBALS['error_status']) |
448 | - message ([ |
|
447 | + message([ |
|
449 | 448 | 'type' => $errarr[$no], |
450 | 449 | 'text' => $str, |
451 | 450 | 'file' => $file, |
452 | 451 | 'line' => $line, |
453 | - 'backtrace' => debug_backtrace () |
|
452 | + 'backtrace' => debug_backtrace() |
|
454 | 453 | ], 'PHP Script Error'); |
455 | 454 | }); |
@@ -6,8 +6,9 @@ discard block |
||
6 | 6 | { |
7 | 7 | $oldStatus = $GLOBALS['error_status']; |
8 | 8 | |
9 | - if ($status !== null) |
|
10 | - $GLOBALS['error_status'] = $status; |
|
9 | + if ($status !== null) { |
|
10 | + $GLOBALS['error_status'] = $status; |
|
11 | + } |
|
11 | 12 | |
12 | 13 | return $oldStatus; |
13 | 14 | } |
@@ -41,9 +42,7 @@ discard block |
||
41 | 42 | try |
42 | 43 | { |
43 | 44 | eval ('return; '. $code); |
44 | - } |
|
45 | - |
|
46 | - catch (\Throwable $e) |
|
45 | + } catch (\Throwable $e) |
|
47 | 46 | { |
48 | 47 | return [ |
49 | 48 | 'text' => $e->getMessage (), |
@@ -67,34 +66,39 @@ discard block |
||
67 | 66 | $array = (new WFClass ('System.Array', null)) |
68 | 67 | ->createInstance (VoidEngine::objectType ($type), $size = sizeof ($items)); |
69 | 68 | |
70 | - for ($i = 0; $i < $size; ++$i) |
|
71 | - $array[$i] = array_shift ($items); |
|
69 | + for ($i = 0; $i < $size; ++$i) { |
|
70 | + $array[$i] = array_shift ($items); |
|
71 | + } |
|
72 | 72 | |
73 | 73 | return $array; |
74 | 74 | } |
75 | 75 | |
76 | 76 | function dir_create (string $path, int $mode = 0777): void |
77 | 77 | { |
78 | - if (!is_dir ($path)) |
|
79 | - mkdir ($path, $mode, true); |
|
80 | -} |
|
78 | + if (!is_dir ($path)) { |
|
79 | + mkdir ($path, $mode, true); |
|
80 | + } |
|
81 | + } |
|
81 | 82 | |
82 | 83 | function dir_delete (string $path): bool |
83 | 84 | { |
84 | - if (!is_dir ($path)) |
|
85 | - return false; |
|
85 | + if (!is_dir ($path)) { |
|
86 | + return false; |
|
87 | + } |
|
86 | 88 | |
87 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
88 | - if (is_dir ($file = $path .'/'. $file)) |
|
89 | + foreach (array_slice (scandir ($path), 2) as $file) { |
|
90 | + if (is_dir ($file = $path .'/'. $file)) |
|
89 | 91 | { |
90 | 92 | dir_delete ($file); |
93 | + } |
|
91 | 94 | |
92 | - if (is_dir ($file)) |
|
93 | - rmdir ($file); |
|
95 | + if (is_dir ($file)) { |
|
96 | + rmdir ($file); |
|
97 | + } |
|
98 | + } else { |
|
99 | + unlink ($file); |
|
94 | 100 | } |
95 | 101 | |
96 | - else unlink ($file); |
|
97 | - |
|
98 | 102 | rmdir ($path); |
99 | 103 | |
100 | 104 | return true; |
@@ -108,17 +112,22 @@ discard block |
||
108 | 112 | |
109 | 113 | function dir_copy (string $from, string $to): bool |
110 | 114 | { |
111 | - if (!is_dir ($from)) |
|
112 | - return false; |
|
115 | + if (!is_dir ($from)) { |
|
116 | + return false; |
|
117 | + } |
|
113 | 118 | |
114 | - if (!is_dir ($to)) |
|
115 | - dir_create ($to); |
|
119 | + if (!is_dir ($to)) { |
|
120 | + dir_create ($to); |
|
121 | + } |
|
116 | 122 | |
117 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
118 | - if (is_dir ($f = $from .'/'. $file)) |
|
123 | + foreach (array_slice (scandir ($from), 2) as $file) { |
|
124 | + if (is_dir ($f = $from .'/'. $file)) |
|
119 | 125 | dir_copy ($f, $to .'/'. $file); |
126 | + } |
|
120 | 127 | |
121 | - else copy ($f, $to .'/'. $file); |
|
128 | + else { |
|
129 | + copy ($f, $to .'/'. $file); |
|
130 | + } |
|
122 | 131 | |
123 | 132 | return true; |
124 | 133 | } |
@@ -216,16 +225,16 @@ discard block |
||
216 | 225 | { |
217 | 226 | try |
218 | 227 | { |
219 | - if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) |
|
220 | - continue; |
|
221 | - } |
|
222 | - |
|
223 | - catch (\Exception $e) {} |
|
228 | + if ($object->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms'))) { |
|
229 | + continue; |
|
230 | + } |
|
231 | + } catch (\Exception $e) {} |
|
224 | 232 | |
225 | 233 | VoidEngine::destructObject ($selector); |
226 | 234 | |
227 | - if (!VoidEngine::objectExists ($selector)) |
|
228 | - unset (self::$components[$selector]); |
|
235 | + if (!VoidEngine::objectExists ($selector)) { |
|
236 | + unset (self::$components[$selector]); |
|
237 | + } |
|
229 | 238 | } |
230 | 239 | } |
231 | 240 | } |
@@ -237,16 +246,15 @@ discard block |
||
237 | 246 | |
238 | 247 | function c ($name, bool $returnAllSimilarObjects = false) |
239 | 248 | { |
240 | - if (is_int ($name) && is_object ($object = _c ($name))) |
|
241 | - return $object; |
|
242 | - |
|
243 | - else |
|
249 | + if (is_int ($name) && is_object ($object = _c ($name))) { |
|
250 | + return $object; |
|
251 | + } else |
|
244 | 252 | { |
245 | 253 | $path = explode ('->', $name); |
246 | 254 | $similar = []; |
247 | 255 | |
248 | - foreach (Components::$components as $object) |
|
249 | - try |
|
256 | + foreach (Components::$components as $object) { |
|
257 | + try |
|
250 | 258 | { |
251 | 259 | if ($object->name == end ($path)) |
252 | 260 | { |
@@ -259,32 +267,30 @@ discard block |
||
259 | 267 | { |
260 | 268 | if ($returnAllSimilarObjects) |
261 | 269 | $similar[] = $object; |
270 | + } |
|
262 | 271 | |
263 | - else return $object; |
|
272 | + else { |
|
273 | + return $object; |
|
274 | + } |
|
275 | + } else { |
|
276 | + continue; |
|
264 | 277 | } |
265 | - |
|
266 | - else continue; |
|
278 | + } else { |
|
279 | + continue; |
|
267 | 280 | } |
268 | - |
|
269 | - else continue; |
|
270 | - } |
|
271 | - |
|
272 | - catch (\Throwable $e) |
|
281 | + } catch (\Throwable $e) |
|
273 | 282 | { |
274 | 283 | continue; |
275 | - } |
|
276 | - |
|
277 | - else |
|
284 | + } else |
|
278 | 285 | { |
279 | - if ($returnAllSimilarObjects) |
|
280 | - $similar[] = $object; |
|
281 | - |
|
282 | - else return $object; |
|
286 | + if ($returnAllSimilarObjects) { |
|
287 | + $similar[] = $object; |
|
288 | + } else { |
|
289 | + return $object; |
|
290 | + } |
|
283 | 291 | } |
284 | 292 | } |
285 | - } |
|
286 | - |
|
287 | - catch (\Exception $e) |
|
293 | + } catch (\Exception $e) |
|
288 | 294 | { |
289 | 295 | continue; |
290 | 296 | } |
@@ -295,31 +301,32 @@ discard block |
||
295 | 301 | |
296 | 302 | if (is_array ($objects)) |
297 | 303 | { |
298 | - foreach ($objects as $id => $object) |
|
299 | - try |
|
304 | + foreach ($objects as $id => $object) { |
|
305 | + try |
|
300 | 306 | { |
301 | 307 | while (is_object ($parent = _c($object->parent->selector))) |
302 | 308 | { |
303 | 309 | if ($parent->getType ()->isSubclassOf (VoidEngine::objectType ('System.Windows.Forms.Form', 'System.Windows.Forms')) && $parent->name == $path[0]) |
304 | 310 | return $objects[$id]; |
311 | + } |
|
305 | 312 | |
306 | - else $object = $parent; |
|
313 | + else { |
|
314 | + $object = $parent; |
|
315 | + } |
|
307 | 316 | } |
308 | - } |
|
309 | - |
|
310 | - catch (\Throwable $e) |
|
317 | + } catch (\Throwable $e) |
|
311 | 318 | { |
312 | 319 | continue; |
313 | 320 | } |
314 | 321 | |
315 | 322 | return false; |
323 | + } else { |
|
324 | + return false; |
|
316 | 325 | } |
317 | - |
|
318 | - else return false; |
|
319 | - } |
|
320 | - |
|
321 | - else return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
326 | + } else { |
|
327 | + return $returnAllSimilarObjects && sizeof ($similar) > 0 ? |
|
322 | 328 | $similar : false; |
329 | + } |
|
323 | 330 | } |
324 | 331 | } |
325 | 332 | |
@@ -377,8 +384,9 @@ discard block |
||
377 | 384 | { |
378 | 385 | $collection = new WFObject ('System.Collections.Specialized.StringCollection'); |
379 | 386 | |
380 | - foreach ($files as $file) |
|
381 | - $collection->add ((string) $file); |
|
387 | + foreach ($files as $file) { |
|
388 | + $collection->add ((string) $file); |
|
389 | + } |
|
382 | 390 | |
383 | 391 | (new WFClass ('System.Windows.Forms.Clipboard'))->setFileDropList ($collection); |
384 | 392 | VoidEngine::removeObjects ($collection->selector); |
@@ -444,12 +452,13 @@ discard block |
||
444 | 452 | 16384 => 'E_USER_DEPRECATED' |
445 | 453 | ]; |
446 | 454 | |
447 | - if ($GLOBALS['error_status']) |
|
448 | - message ([ |
|
455 | + if ($GLOBALS['error_status']) { |
|
456 | + message ([ |
|
449 | 457 | 'type' => $errarr[$no], |
450 | 458 | 'text' => $str, |
451 | 459 | 'file' => $file, |
452 | 460 | 'line' => $line, |
453 | 461 | 'backtrace' => debug_backtrace () |
454 | 462 | ], 'PHP Script Error'); |
455 | -}); |
|
463 | + } |
|
464 | + }); |