@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param array $commands - список команд |
19 | 19 | * [@param DefaultCommand $defaultCommand = null] - объект дефолтной команды |
20 | 20 | */ |
21 | - public function __construct (array $commands, DefaultCommand $defaultCommand = null) |
|
21 | + public function __construct(array $commands, DefaultCommand $defaultCommand = null) |
|
22 | 22 | { |
23 | 23 | $this->locale = new Locale; |
24 | 24 | $this->defaultCommand = $defaultCommand; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | if ($command instanceof Command) |
28 | 28 | $this->commands[$command->name] = $command; |
29 | 29 | |
30 | - else throw new \Exception ($this->locale->command_type_exception); |
|
30 | + else throw new \Exception($this->locale->command_type_exception); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return Manager - возвращает сам себя |
39 | 39 | */ |
40 | - public function setLocale (Locale $locale): Manager |
|
40 | + public function setLocale(Locale $locale): Manager |
|
41 | 41 | { |
42 | 42 | $this->locale = $locale; |
43 | 43 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return Manager - возвращает сам себя |
53 | 53 | */ |
54 | - public function setDefault (DefaultCommand $defaultCommand): Manager |
|
54 | + public function setDefault(DefaultCommand $defaultCommand): Manager |
|
55 | 55 | { |
56 | 56 | $this->defaultCommand = $defaultCommand; |
57 | 57 | |
@@ -63,31 +63,31 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @param array $args - список аргументов консоли |
65 | 65 | */ |
66 | - public function execute (array $args) |
|
66 | + public function execute(array $args) |
|
67 | 67 | { |
68 | - $args = array_values ($args); |
|
68 | + $args = array_values($args); |
|
69 | 69 | |
70 | 70 | if (!isset ($args[0])) |
71 | 71 | { |
72 | 72 | if ($this->defaultCommand !== null) |
73 | - return $this->defaultCommand->execute ($args); |
|
73 | + return $this->defaultCommand->execute($args); |
|
74 | 74 | |
75 | - else throw new \Exception ($this->locale->command_undefined_error); |
|
75 | + else throw new \Exception($this->locale->command_undefined_error); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $name = $args[0]; |
79 | - $args = array_slice ($args, 1); |
|
79 | + $args = array_slice($args, 1); |
|
80 | 80 | |
81 | 81 | if (!isset ($this->commands[$name])) |
82 | 82 | { |
83 | 83 | foreach ($this->commands as $command) |
84 | - if (in_array ($name, $command->aliases)) |
|
85 | - return $command->execute ($args); |
|
84 | + if (in_array($name, $command->aliases)) |
|
85 | + return $command->execute($args); |
|
86 | 86 | |
87 | 87 | return $this->defaultCommand !== null ? |
88 | - $this->defaultCommand->execute ($args) : false; |
|
88 | + $this->defaultCommand->execute($args) : false; |
|
89 | 89 | } |
90 | 90 | |
91 | - return $this->commands[$name]->execute ($args); |
|
91 | + return $this->commands[$name]->execute($args); |
|
92 | 92 | } |
93 | 93 | } |
@@ -23,11 +23,14 @@ discard block |
||
23 | 23 | $this->locale = new Locale; |
24 | 24 | $this->defaultCommand = $defaultCommand; |
25 | 25 | |
26 | - foreach ($commands as $command) |
|
27 | - if ($command instanceof Command) |
|
26 | + foreach ($commands as $command) { |
|
27 | + if ($command instanceof Command) |
|
28 | 28 | $this->commands[$command->name] = $command; |
29 | + } |
|
29 | 30 | |
30 | - else throw new \Exception ($this->locale->command_type_exception); |
|
31 | + else { |
|
32 | + throw new \Exception ($this->locale->command_type_exception); |
|
33 | + } |
|
31 | 34 | } |
32 | 35 | |
33 | 36 | /** |
@@ -69,10 +72,11 @@ discard block |
||
69 | 72 | |
70 | 73 | if (!isset ($args[0])) |
71 | 74 | { |
72 | - if ($this->defaultCommand !== null) |
|
73 | - return $this->defaultCommand->execute ($args); |
|
74 | - |
|
75 | - else throw new \Exception ($this->locale->command_undefined_error); |
|
75 | + if ($this->defaultCommand !== null) { |
|
76 | + return $this->defaultCommand->execute ($args); |
|
77 | + } else { |
|
78 | + throw new \Exception ($this->locale->command_undefined_error); |
|
79 | + } |
|
76 | 80 | } |
77 | 81 | |
78 | 82 | $name = $args[0]; |
@@ -80,9 +84,10 @@ discard block |
||
80 | 84 | |
81 | 85 | if (!isset ($this->commands[$name])) |
82 | 86 | { |
83 | - foreach ($this->commands as $command) |
|
84 | - if (in_array ($name, $command->aliases)) |
|
87 | + foreach ($this->commands as $command) { |
|
88 | + if (in_array ($name, $command->aliases)) |
|
85 | 89 | return $command->execute ($args); |
90 | + } |
|
86 | 91 | |
87 | 92 | return $this->defaultCommand !== null ? |
88 | 93 | $this->defaultCommand->execute ($args) : false; |
@@ -10,5 +10,5 @@ |
||
10 | 10 | /** |
11 | 11 | * Парсер значений |
12 | 12 | */ |
13 | - public function parse (array &$args); |
|
13 | + public function parse(array &$args); |
|
14 | 14 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @param string $name - имя флага |
18 | 18 | */ |
19 | - public function __construct (string $name) |
|
19 | + public function __construct(string $name) |
|
20 | 20 | { |
21 | 21 | $this->names = [$name]; |
22 | 22 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return Flag - возвращает сам себя |
30 | 30 | */ |
31 | - public function setLocale (Locale $locale): Param |
|
31 | + public function setLocale(Locale $locale): Param |
|
32 | 32 | { |
33 | 33 | $this->locale = $locale; |
34 | 34 | |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return Flag - возвращает сам себя |
44 | 44 | */ |
45 | - public function addAliase (string $name) |
|
45 | + public function addAliase(string $name) |
|
46 | 46 | { |
47 | - if (array_search ($name, $this->names) !== false) |
|
48 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
47 | + if (array_search($name, $this->names) !== false) |
|
48 | + throw new \Exception($this->locale->aliase_exists_exception); |
|
49 | 49 | |
50 | 50 | $this->names[] = $name; |
51 | 51 | |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | * |
60 | 60 | * Возвращает состояние флага |
61 | 61 | */ |
62 | - public function parse (array &$args) |
|
62 | + public function parse(array &$args) |
|
63 | 63 | { |
64 | - $args = array_values ($args); |
|
64 | + $args = array_values($args); |
|
65 | 65 | |
66 | 66 | foreach ($this->names as $name) |
67 | - if (($key = array_search ($name, $args)) !== false) |
|
67 | + if (($key = array_search($name, $args)) !== false) |
|
68 | 68 | { |
69 | 69 | unset ($args[$key]); |
70 | - $args = array_values ($args); |
|
70 | + $args = array_values($args); |
|
71 | 71 | |
72 | - while ($this->parse ($args) !== false); |
|
72 | + while ($this->parse($args) !== false); |
|
73 | 73 | |
74 | 74 | return true; |
75 | 75 | } |
@@ -44,8 +44,9 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function addAliase (string $name) |
46 | 46 | { |
47 | - if (array_search ($name, $this->names) !== false) |
|
48 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
47 | + if (array_search ($name, $this->names) !== false) { |
|
48 | + throw new \Exception ($this->locale->aliase_exists_exception); |
|
49 | + } |
|
49 | 50 | |
50 | 51 | $this->names[] = $name; |
51 | 52 | |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | { |
64 | 65 | $args = array_values ($args); |
65 | 66 | |
66 | - foreach ($this->names as $name) |
|
67 | - if (($key = array_search ($name, $args)) !== false) |
|
67 | + foreach ($this->names as $name) { |
|
68 | + if (($key = array_search ($name, $args)) !== false) |
|
68 | 69 | { |
69 | 70 | unset ($args[$key]); |
71 | + } |
|
70 | 72 | $args = array_values ($args); |
71 | 73 | |
72 | 74 | while ($this->parse ($args) !== false); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * [@param string $defaultValue = null] - значение сеттера по умолчанию |
23 | 23 | * [@param bool $required = false] - обязательно ли указание сеттера |
24 | 24 | */ |
25 | - public function __construct (string $name, string $separator = '=', string $defaultValue = null, bool $required = false) |
|
25 | + public function __construct(string $name, string $separator = '=', string $defaultValue = null, bool $required = false) |
|
26 | 26 | { |
27 | 27 | $this->names = [$name]; |
28 | 28 | $this->separator = $separator; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return Param - возвращает сам себя |
41 | 41 | */ |
42 | - public function setLocale (Locale $locale): Param |
|
42 | + public function setLocale(Locale $locale): Param |
|
43 | 43 | { |
44 | 44 | $this->locale = $locale; |
45 | 45 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return Param - возвращает сам себя |
55 | 55 | */ |
56 | - public function addAliase (string $name) |
|
56 | + public function addAliase(string $name) |
|
57 | 57 | { |
58 | - if (array_search ($name, $this->names) !== false) |
|
59 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
58 | + if (array_search($name, $this->names) !== false) |
|
59 | + throw new \Exception($this->locale->aliase_exists_exception); |
|
60 | 60 | |
61 | 61 | $this->names[] = $name; |
62 | 62 | |
@@ -70,26 +70,26 @@ discard block |
||
70 | 70 | * |
71 | 71 | * Возвращает найденый параметр или массив найдёных параметров, если их было указано несколько |
72 | 72 | */ |
73 | - public function parse (array &$args) |
|
73 | + public function parse(array &$args) |
|
74 | 74 | { |
75 | - $args = array_values ($args); |
|
76 | - $l = strlen ($this->separator); |
|
75 | + $args = array_values($args); |
|
76 | + $l = strlen($this->separator); |
|
77 | 77 | |
78 | 78 | foreach ($this->names as $name) |
79 | 79 | foreach ($args as $id => $arg) |
80 | - if (substr ($arg, 0, ($pos = strlen ($name) + $l)) == $name . $this->separator) |
|
80 | + if (substr($arg, 0, ($pos = strlen($name) + $l)) == $name.$this->separator) |
|
81 | 81 | { |
82 | - $param = [substr ($arg, $pos)]; |
|
82 | + $param = [substr($arg, $pos)]; |
|
83 | 83 | |
84 | 84 | unset ($args[$id]); |
85 | - $args = array_values ($args); |
|
85 | + $args = array_values($args); |
|
86 | 86 | |
87 | 87 | try |
88 | 88 | { |
89 | - while (($altParam = $this->parse ($args)) !== $this->defaultValue) |
|
89 | + while (($altParam = $this->parse($args)) !== $this->defaultValue) |
|
90 | 90 | { |
91 | - if (is_array ($altParam)) |
|
92 | - $param = array_merge ($param, $altParam); |
|
91 | + if (is_array($altParam)) |
|
92 | + $param = array_merge($param, $altParam); |
|
93 | 93 | |
94 | 94 | else $param[] = $altParam; |
95 | 95 | } |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | |
98 | 98 | catch (\Throwable $e) {} |
99 | 99 | |
100 | - return sizeof ($param) == 1 ? |
|
100 | + return sizeof($param) == 1 ? |
|
101 | 101 | $param[0] : $param; |
102 | 102 | } |
103 | 103 | |
104 | 104 | if ($this->required) |
105 | - throw new \Exception (str_replace ('%param_name%', current ($this->names), $this->locale->undefined_param_exception)); |
|
105 | + throw new \Exception(str_replace('%param_name%', current($this->names), $this->locale->undefined_param_exception)); |
|
106 | 106 | |
107 | 107 | return $this->defaultValue; |
108 | 108 | } |
@@ -55,8 +55,9 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function addAliase (string $name) |
57 | 57 | { |
58 | - if (array_search ($name, $this->names) !== false) |
|
59 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
58 | + if (array_search ($name, $this->names) !== false) { |
|
59 | + throw new \Exception ($this->locale->aliase_exists_exception); |
|
60 | + } |
|
60 | 61 | |
61 | 62 | $this->names[] = $name; |
62 | 63 | |
@@ -75,11 +76,12 @@ discard block |
||
75 | 76 | $args = array_values ($args); |
76 | 77 | $l = strlen ($this->separator); |
77 | 78 | |
78 | - foreach ($this->names as $name) |
|
79 | - foreach ($args as $id => $arg) |
|
79 | + foreach ($this->names as $name) { |
|
80 | + foreach ($args as $id => $arg) |
|
80 | 81 | if (substr ($arg, 0, ($pos = strlen ($name) + $l)) == $name . $this->separator) |
81 | 82 | { |
82 | 83 | $param = [substr ($arg, $pos)]; |
84 | + } |
|
83 | 85 | |
84 | 86 | unset ($args[$id]); |
85 | 87 | $args = array_values ($args); |
@@ -88,21 +90,21 @@ discard block |
||
88 | 90 | { |
89 | 91 | while (($altParam = $this->parse ($args)) !== $this->defaultValue) |
90 | 92 | { |
91 | - if (is_array ($altParam)) |
|
92 | - $param = array_merge ($param, $altParam); |
|
93 | - |
|
94 | - else $param[] = $altParam; |
|
93 | + if (is_array ($altParam)) { |
|
94 | + $param = array_merge ($param, $altParam); |
|
95 | + } else { |
|
96 | + $param[] = $altParam; |
|
97 | + } |
|
95 | 98 | } |
96 | - } |
|
97 | - |
|
98 | - catch (\Throwable $e) {} |
|
99 | + } catch (\Throwable $e) {} |
|
99 | 100 | |
100 | 101 | return sizeof ($param) == 1 ? |
101 | 102 | $param[0] : $param; |
102 | 103 | } |
103 | 104 | |
104 | - if ($this->required) |
|
105 | - throw new \Exception (str_replace ('%param_name%', current ($this->names), $this->locale->undefined_param_exception)); |
|
105 | + if ($this->required) { |
|
106 | + throw new \Exception (str_replace ('%param_name%', current ($this->names), $this->locale->undefined_param_exception)); |
|
107 | + } |
|
106 | 108 | |
107 | 109 | return $this->defaultValue; |
108 | 110 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * [@param string $defaultValue = null] - значение параметра по умолчанию |
21 | 21 | * [@param bool $required = false] - обязательно ли указание параметра |
22 | 22 | */ |
23 | - public function __construct (string $name, string $defaultValue = null, bool $required = false) |
|
23 | + public function __construct(string $name, string $defaultValue = null, bool $required = false) |
|
24 | 24 | { |
25 | 25 | $this->names = [$name]; |
26 | 26 | $this->defaultValue = $defaultValue; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return Param - возвращает сам себя |
38 | 38 | */ |
39 | - public function setLocale (Locale $locale): Param |
|
39 | + public function setLocale(Locale $locale): Param |
|
40 | 40 | { |
41 | 41 | $this->locale = $locale; |
42 | 42 | |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return Param - возвращает сам себя |
52 | 52 | */ |
53 | - public function addAliase (string $name) |
|
53 | + public function addAliase(string $name) |
|
54 | 54 | { |
55 | - if (array_search ($name, $this->names) !== false) |
|
56 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
55 | + if (array_search($name, $this->names) !== false) |
|
56 | + throw new \Exception($this->locale->aliase_exists_exception); |
|
57 | 57 | |
58 | 58 | $this->names[] = $name; |
59 | 59 | |
@@ -67,27 +67,27 @@ discard block |
||
67 | 67 | * |
68 | 68 | * Возвращает найденый параметр или массив найдёных параметров, если их было указано несколько |
69 | 69 | */ |
70 | - public function parse (array &$args) |
|
70 | + public function parse(array &$args) |
|
71 | 71 | { |
72 | - $args = array_values ($args); |
|
72 | + $args = array_values($args); |
|
73 | 73 | |
74 | 74 | foreach ($this->names as $name) |
75 | - if (($key = array_search ($name, $args)) !== false) |
|
75 | + if (($key = array_search($name, $args)) !== false) |
|
76 | 76 | { |
77 | 77 | if (!isset ($args[$key + 1])) |
78 | - throw new \Exception ($this->locale->unselected_value_exception); |
|
78 | + throw new \Exception($this->locale->unselected_value_exception); |
|
79 | 79 | |
80 | 80 | $param = [$args[$key + 1]]; |
81 | 81 | |
82 | 82 | unset ($args[$key], $args[$key + 1]); |
83 | - $args = array_values ($args); |
|
83 | + $args = array_values($args); |
|
84 | 84 | |
85 | 85 | try |
86 | 86 | { |
87 | - while (($altParam = $this->parse ($args)) !== $this->defaultValue) |
|
87 | + while (($altParam = $this->parse($args)) !== $this->defaultValue) |
|
88 | 88 | { |
89 | - if (is_array ($altParam)) |
|
90 | - $param = array_merge ($param, $altParam); |
|
89 | + if (is_array($altParam)) |
|
90 | + $param = array_merge($param, $altParam); |
|
91 | 91 | |
92 | 92 | else $param[] = $altParam; |
93 | 93 | } |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | |
96 | 96 | catch (\Throwable $e) {} |
97 | 97 | |
98 | - return sizeof ($param) == 1 ? |
|
98 | + return sizeof($param) == 1 ? |
|
99 | 99 | $param[0] : $param; |
100 | 100 | } |
101 | 101 | |
102 | 102 | if ($this->required) |
103 | - throw new \Exception (str_replace ('%param_name%', current ($this->names), $this->locale->undefined_param_exception)); |
|
103 | + throw new \Exception(str_replace('%param_name%', current($this->names), $this->locale->undefined_param_exception)); |
|
104 | 104 | |
105 | 105 | return $this->defaultValue; |
106 | 106 | } |
@@ -52,8 +52,9 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function addAliase (string $name) |
54 | 54 | { |
55 | - if (array_search ($name, $this->names) !== false) |
|
56 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
55 | + if (array_search ($name, $this->names) !== false) { |
|
56 | + throw new \Exception ($this->locale->aliase_exists_exception); |
|
57 | + } |
|
57 | 58 | |
58 | 59 | $this->names[] = $name; |
59 | 60 | |
@@ -71,11 +72,12 @@ discard block |
||
71 | 72 | { |
72 | 73 | $args = array_values ($args); |
73 | 74 | |
74 | - foreach ($this->names as $name) |
|
75 | - if (($key = array_search ($name, $args)) !== false) |
|
75 | + foreach ($this->names as $name) { |
|
76 | + if (($key = array_search ($name, $args)) !== false) |
|
76 | 77 | { |
77 | 78 | if (!isset ($args[$key + 1])) |
78 | 79 | throw new \Exception ($this->locale->unselected_value_exception); |
80 | + } |
|
79 | 81 | |
80 | 82 | $param = [$args[$key + 1]]; |
81 | 83 | |
@@ -86,21 +88,21 @@ discard block |
||
86 | 88 | { |
87 | 89 | while (($altParam = $this->parse ($args)) !== $this->defaultValue) |
88 | 90 | { |
89 | - if (is_array ($altParam)) |
|
90 | - $param = array_merge ($param, $altParam); |
|
91 | - |
|
92 | - else $param[] = $altParam; |
|
91 | + if (is_array ($altParam)) { |
|
92 | + $param = array_merge ($param, $altParam); |
|
93 | + } else { |
|
94 | + $param[] = $altParam; |
|
95 | + } |
|
93 | 96 | } |
94 | - } |
|
95 | - |
|
96 | - catch (\Throwable $e) {} |
|
97 | + } catch (\Throwable $e) {} |
|
97 | 98 | |
98 | 99 | return sizeof ($param) == 1 ? |
99 | 100 | $param[0] : $param; |
100 | 101 | } |
101 | 102 | |
102 | - if ($this->required) |
|
103 | - throw new \Exception (str_replace ('%param_name%', current ($this->names), $this->locale->undefined_param_exception)); |
|
103 | + if ($this->required) { |
|
104 | + throw new \Exception (str_replace ('%param_name%', current ($this->names), $this->locale->undefined_param_exception)); |
|
105 | + } |
|
104 | 106 | |
105 | 107 | return $this->defaultValue; |
106 | 108 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param string $name - имя команды |
22 | 22 | * [@param \Closure $callable = null] - анонимная функция для выполнения |
23 | 23 | */ |
24 | - public function __construct (string $name, \Closure $callable = null) |
|
24 | + public function __construct(string $name, \Closure $callable = null) |
|
25 | 25 | { |
26 | 26 | $this->name = $name; |
27 | 27 | $this->locale = new Locale; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return Command - возвращает сам себя |
39 | 39 | */ |
40 | - public function setLocale (Locale $locale): Command |
|
40 | + public function setLocale(Locale $locale): Command |
|
41 | 41 | { |
42 | 42 | $this->locale = $locale; |
43 | 43 | |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return Command - возвращает сам себя |
53 | 53 | */ |
54 | - public function addParams (array $params): Command |
|
54 | + public function addParams(array $params): Command |
|
55 | 55 | { |
56 | 56 | foreach ($params as $param) |
57 | 57 | if ($param instanceof Parameter) |
58 | - $this->params[current ($param->names)] = $param; |
|
58 | + $this->params[current($param->names)] = $param; |
|
59 | 59 | |
60 | - else throw new \Exception ($this->locale->param_type_exception); |
|
60 | + else throw new \Exception($this->locale->param_type_exception); |
|
61 | 61 | |
62 | 62 | return $this; |
63 | 63 | } |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return Command - возвращает сам себя |
71 | 71 | */ |
72 | - public function addAliase (string $name) |
|
72 | + public function addAliase(string $name) |
|
73 | 73 | { |
74 | - if (array_search ($name, $this->aliases) !== false) |
|
75 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
74 | + if (array_search($name, $this->aliases) !== false) |
|
75 | + throw new \Exception($this->locale->aliase_exists_exception); |
|
76 | 76 | |
77 | 77 | $this->aliases[] = $name; |
78 | 78 | |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return array - возвращает ассоциативный массив [параметр] => [значение] |
88 | 88 | */ |
89 | - public function getParams (array &$args): array |
|
89 | + public function getParams(array &$args): array |
|
90 | 90 | { |
91 | - $params = array_combine (array_keys ($this->params), array_fill (0, sizeof ($this->params), null)); |
|
91 | + $params = array_combine(array_keys($this->params), array_fill(0, sizeof($this->params), null)); |
|
92 | 92 | |
93 | 93 | foreach ($this->params as $name => $param) |
94 | - $params[$name] = $param->parse ($args); |
|
94 | + $params[$name] = $param->parse($args); |
|
95 | 95 | |
96 | 96 | return $params; |
97 | 97 | } |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @param array &$args - аргументы команды |
103 | 103 | */ |
104 | - public function execute (array &$args) |
|
104 | + public function execute(array &$args) |
|
105 | 105 | { |
106 | 106 | if ($this->callable instanceof \Closure) |
107 | 107 | { |
108 | - $params = $this->getParams ($args); |
|
108 | + $params = $this->getParams($args); |
|
109 | 109 | |
110 | - return $this->callable->call ($this, array_values ($args), $params); |
|
110 | + return $this->callable->call($this, array_values($args), $params); |
|
111 | 111 | } |
112 | 112 | |
113 | - throw new \Exception ($this->locale->execution_error); |
|
113 | + throw new \Exception($this->locale->execution_error); |
|
114 | 114 | } |
115 | 115 | } |
@@ -26,8 +26,9 @@ discard block |
||
26 | 26 | $this->name = $name; |
27 | 27 | $this->locale = new Locale; |
28 | 28 | |
29 | - if ($callable !== null) |
|
30 | - $this->callable = $callable; |
|
29 | + if ($callable !== null) { |
|
30 | + $this->callable = $callable; |
|
31 | + } |
|
31 | 32 | } |
32 | 33 | |
33 | 34 | /** |
@@ -53,11 +54,14 @@ discard block |
||
53 | 54 | */ |
54 | 55 | public function addParams (array $params): Command |
55 | 56 | { |
56 | - foreach ($params as $param) |
|
57 | - if ($param instanceof Parameter) |
|
57 | + foreach ($params as $param) { |
|
58 | + if ($param instanceof Parameter) |
|
58 | 59 | $this->params[current ($param->names)] = $param; |
60 | + } |
|
59 | 61 | |
60 | - else throw new \Exception ($this->locale->param_type_exception); |
|
62 | + else { |
|
63 | + throw new \Exception ($this->locale->param_type_exception); |
|
64 | + } |
|
61 | 65 | |
62 | 66 | return $this; |
63 | 67 | } |
@@ -71,8 +75,9 @@ discard block |
||
71 | 75 | */ |
72 | 76 | public function addAliase (string $name) |
73 | 77 | { |
74 | - if (array_search ($name, $this->aliases) !== false) |
|
75 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
78 | + if (array_search ($name, $this->aliases) !== false) { |
|
79 | + throw new \Exception ($this->locale->aliase_exists_exception); |
|
80 | + } |
|
76 | 81 | |
77 | 82 | $this->aliases[] = $name; |
78 | 83 | |
@@ -90,8 +95,9 @@ discard block |
||
90 | 95 | { |
91 | 96 | $params = array_combine (array_keys ($this->params), array_fill (0, sizeof ($this->params), null)); |
92 | 97 | |
93 | - foreach ($this->params as $name => $param) |
|
94 | - $params[$name] = $param->parse ($args); |
|
98 | + foreach ($this->params as $name => $param) { |
|
99 | + $params[$name] = $param->parse ($args); |
|
100 | + } |
|
95 | 101 | |
96 | 102 | return $params; |
97 | 103 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | * |
14 | 14 | * [@param \Closure $callable = null] - анонимная функция для выполнения |
15 | 15 | */ |
16 | - public function __construct (\Closure $callable = null) |
|
16 | + public function __construct(\Closure $callable = null) |
|
17 | 17 | { |
18 | 18 | if ($callable !== null) |
19 | 19 | $this->callable = $callable; |
@@ -15,7 +15,8 @@ |
||
15 | 15 | */ |
16 | 16 | public function __construct (\Closure $callable = null) |
17 | 17 | { |
18 | - if ($callable !== null) |
|
19 | - $this->callable = $callable; |
|
18 | + if ($callable !== null) { |
|
19 | + $this->callable = $callable; |
|
20 | + } |
|
20 | 21 | } |
21 | 22 | } |
@@ -133,8 +133,8 @@ |
||
133 | 133 | return Builder::getReferences ($file, $parseExtensions); |
134 | 134 | } |
135 | 135 | |
136 | - public static function optimizeCode (string $code): string |
|
137 | - { |
|
138 | - return Builder::optimizeCode ($code); |
|
139 | - } |
|
136 | + public static function optimizeCode (string $code): string |
|
137 | + { |
|
138 | + return Builder::optimizeCode ($code); |
|
139 | + } |
|
140 | 140 | } |
@@ -6,23 +6,23 @@ discard block |
||
6 | 6 | |
7 | 7 | class VoidStudioBuilder |
8 | 8 | { |
9 | - public static function compileProject (string $save, string $enteringPoint, array $references, array $settings = [], bool $printSuccessCompile = false, bool $debug = false): array |
|
9 | + public static function compileProject(string $save, string $enteringPoint, array $references, array $settings = [], bool $printSuccessCompile = false, bool $debug = false): array |
|
10 | 10 | { |
11 | - $savePath = dirname ($save) .'/'. basenameNoExt ($save); |
|
12 | - $globalCode = file_get_contents (APP_DIR .'/system/presets/compile_parser_preset.cs') ."\n\n"; |
|
11 | + $savePath = dirname($save).'/'.basenameNoExt($save); |
|
12 | + $globalCode = file_get_contents(APP_DIR.'/system/presets/compile_parser_preset.cs')."\n\n"; |
|
13 | 13 | $objectsCode = ''; |
14 | 14 | $forms = []; |
15 | 15 | |
16 | 16 | for ($i = 0; $i < 5; ++$i) |
17 | - if (!isset ($settings[$i]) || !strlen (trim ($settings[$i]))) |
|
17 | + if (!isset ($settings[$i]) || !strlen(trim($settings[$i]))) |
|
18 | 18 | $settings[$i] = null; |
19 | 19 | |
20 | - $settings = array_slice ($settings, 0, 5); |
|
20 | + $settings = array_slice($settings, 0, 5); |
|
21 | 21 | |
22 | - foreach (VoidStudioAPI::getObjects ('main')['Designer__FormsList']->items->names as $id => $item) |
|
22 | + foreach (VoidStudioAPI::getObjects('main')['Designer__FormsList']->items->names as $id => $item) |
|
23 | 23 | { |
24 | - $designer = VoidStudioAPI::getObjects ('main')['Designer__'. $item .'Designer']; |
|
25 | - $globalCode .= self::appendDesignerData ($designer->getSharpCode ($item), $designer); |
|
24 | + $designer = VoidStudioAPI::getObjects('main')['Designer__'.$item.'Designer']; |
|
25 | + $globalCode .= self::appendDesignerData($designer->getSharpCode($item), $designer); |
|
26 | 26 | |
27 | 27 | $forms[] = $item; |
28 | 28 | |
@@ -30,111 +30,110 @@ discard block |
||
30 | 30 | VoidStudioAPI::$events[$item] = "class $item extends Form\n{}\n"; |
31 | 31 | |
32 | 32 | if (isset (VoidStudioAPI::$events[$item])) |
33 | - $objectsCode .= ClassWorker::applyClass (VoidStudioAPI::$events[$item], $item, substr ($voidCode = $designer->getVoidCode ($item, false), $pos = strpos ($voidCode, '{') + 1, strrpos ($voidCode, '}') - $pos - 1) ."\n") ."\n\n"; |
|
33 | + $objectsCode .= ClassWorker::applyClass(VoidStudioAPI::$events[$item], $item, substr($voidCode = $designer->getVoidCode($item, false), $pos = strpos($voidCode, '{') + 1, strrpos($voidCode, '}') - $pos - 1)."\n")."\n\n"; |
|
34 | 34 | } |
35 | 35 | |
36 | - dir_clean ($savePath); |
|
37 | - dir_copy (CORE_DIR, $savePath); |
|
36 | + dir_clean($savePath); |
|
37 | + dir_copy(CORE_DIR, $savePath); |
|
38 | 38 | |
39 | - unlink ($savePath .'/script.php'); |
|
40 | - unlink ($savePath .'/VoidCore.exe'); |
|
39 | + unlink($savePath.'/script.php'); |
|
40 | + unlink($savePath.'/VoidCore.exe'); |
|
41 | 41 | |
42 | - $errors = EngineAdditions::compile ($savePath .'/'. basename ($save), APP_DIR .'/system/icons/Icon.ico', self::optimizeCode (str_replace_assoc (file_get_contents (APP_DIR .'/system/presets/compile_main_preset.php'), [ |
|
43 | - '%VoidEngine%' => self::generateCode ($references), |
|
42 | + $errors = EngineAdditions::compile($savePath.'/'.basename($save), APP_DIR.'/system/icons/Icon.ico', self::optimizeCode(str_replace_assoc(file_get_contents(APP_DIR.'/system/presets/compile_main_preset.php'), [ |
|
43 | + '%VoidEngine%' => self::generateCode($references), |
|
44 | 44 | |
45 | - '%modules%' => (file_exists ($modulesFile = VoidStudioProjectManager::$projectPath .'/modules/Qero.json') && sizeof ($modules = json_decode (file_get_contents ($modulesFile))) ? "require 'qero-packages/autoload.php';\n\n" : "\n\n") . implode ("\n", array_map (function ($module) |
|
45 | + '%modules%' => (file_exists($modulesFile = VoidStudioProjectManager::$projectPath.'/modules/Qero.json') && sizeof($modules = json_decode(file_get_contents($modulesFile))) ? "require 'qero-packages/autoload.php';\n\n" : "\n\n").implode("\n", array_map(function($module) |
|
46 | 46 | { |
47 | - $module = trim (file_get_contents ($module)); |
|
47 | + $module = trim(file_get_contents($module)); |
|
48 | 48 | |
49 | - if (substr ($module, 0, 2) == '<?') |
|
50 | - $module = substr ($module, 2); |
|
49 | + if (substr($module, 0, 2) == '<?') |
|
50 | + $module = substr($module, 2); |
|
51 | 51 | |
52 | - if (substr ($module, 0, 3) == 'php') |
|
53 | - $module = substr ($module, 3); |
|
52 | + if (substr($module, 0, 3) == 'php') |
|
53 | + $module = substr($module, 3); |
|
54 | 54 | |
55 | - if (substr ($module, -2) == '?>') |
|
56 | - $module = substr ($module, 0, -2); |
|
55 | + if (substr($module, -2) == '?>') |
|
56 | + $module = substr($module, 0, -2); |
|
57 | 57 | |
58 | - return "\$module = <<<'__MODULE'\n". self::optimizeCode ($module) ."\n__MODULE;\n\neval (\$module);"; |
|
59 | - }, array_merge (glob (VoidStudioProjectManager::$projectPath .'/modules/*.php'), $debug ? [APP_DIR .'/system/debug/DebugHook.php'] : []))), |
|
58 | + return "\$module = <<<'__MODULE'\n".self::optimizeCode($module)."\n__MODULE;\n\neval (\$module);"; |
|
59 | + }, array_merge(glob(VoidStudioProjectManager::$projectPath.'/modules/*.php'), $debug ? [APP_DIR.'/system/debug/DebugHook.php'] : []))), |
|
60 | 60 | |
61 | - '%objects%' => trim ($objectsCode), |
|
62 | - '%forms%' => join ('\', \'', $forms), |
|
61 | + '%objects%' => trim($objectsCode), |
|
62 | + '%forms%' => join('\', \'', $forms), |
|
63 | 63 | '%entering_point%' => $enteringPoint, |
64 | - '%author_id%' => sha1 (shell_exec ('wmic csproduct')) |
|
64 | + '%author_id%' => sha1(shell_exec('wmic csproduct')) |
|
65 | 65 | ])), $settings[0], $settings[1], $settings[2], $settings[3], $settings[4], /*str_replace_assoc (file_get_contents (APP_DIR .'/system/presets/compile_main_preset.cs'), [ |
66 | 66 | '%forms%' => join ('", "', $forms) |
67 | 67 | ])*/'', $globalCode); |
68 | 68 | |
69 | - if (isset ($modules) && sizeof ($modules) > 0) |
|
69 | + if (isset ($modules) && sizeof($modules) > 0) |
|
70 | 70 | { |
71 | - dir_delete (APP_DIR .'/Qero/qero-packages'); |
|
71 | + dir_delete(APP_DIR.'/Qero/qero-packages'); |
|
72 | 72 | |
73 | 73 | $manager = new \Qero\PackagesManager\PackagesManager; |
74 | 74 | |
75 | 75 | foreach ($modules as $package) |
76 | - $manager->installPackage ($package); |
|
76 | + $manager->installPackage($package); |
|
77 | 77 | |
78 | - dir_copy (APP_DIR .'/Qero/qero-packages', $savePath .'/qero-packages'); |
|
79 | - dir_delete (APP_DIR .'/Qero/qero-packages'); |
|
78 | + dir_copy(APP_DIR.'/Qero/qero-packages', $savePath.'/qero-packages'); |
|
79 | + dir_delete(APP_DIR.'/Qero/qero-packages'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // pre ($errors); |
83 | 83 | // pre ($globalCode->toString ()); |
84 | 84 | |
85 | - $log = VoidStudioAPI::getObjects ('main')['ToolsPanel__LogList']; |
|
86 | - $log->items->add ('Проект скомпилирован по пути "'. $save .'". '. (($errorsCount = sizeof ($errors)) > 0 ? ('Обнаружено '. $errorsCount .' ошибок') : 'Ошибок не обнаружено')); |
|
85 | + $log = VoidStudioAPI::getObjects('main')['ToolsPanel__LogList']; |
|
86 | + $log->items->add('Проект скомпилирован по пути "'.$save.'". '.(($errorsCount = sizeof($errors)) > 0 ? ('Обнаружено '.$errorsCount.' ошибок') : 'Ошибок не обнаружено')); |
|
87 | 87 | |
88 | 88 | if ($errorsCount > 0) |
89 | 89 | { |
90 | - $log->items->addRange (array_map (function ($error) |
|
90 | + $log->items->addRange(array_map(function($error) |
|
91 | 91 | { |
92 | - return "\t". $error; |
|
92 | + return "\t".$error; |
|
93 | 93 | }, $errors)); |
94 | 94 | |
95 | - messageBox ('Обнаружено '. $errorsCount .' ошибок', 'Ошибка компиляции', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Error')); |
|
95 | + messageBox('Обнаружено '.$errorsCount.' ошибок', 'Ошибка компиляции', enum('System.Windows.Forms.MessageBoxButtons.OK'), enum('System.Windows.Forms.MessageBoxIcon.Error')); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | elseif ($printSuccessCompile) |
99 | - messageBox ('Проект успешно скомпилирован', 'Успешная компиляция', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Information')); |
|
99 | + messageBox('Проект успешно скомпилирован', 'Успешная компиляция', enum('System.Windows.Forms.MessageBoxButtons.OK'), enum('System.Windows.Forms.MessageBoxIcon.Information')); |
|
100 | 100 | |
101 | 101 | return $errors; |
102 | 102 | } |
103 | 103 | |
104 | - public static function appendDesignerData (string $code, VoidDesigner $designer): string |
|
104 | + public static function appendDesignerData(string $code, VoidDesigner $designer): string |
|
105 | 105 | { |
106 | 106 | $offset = 0; |
107 | 107 | |
108 | - while (($pos = strpos ($code, ')(resources.GetObject("', $offset)) !== false) |
|
108 | + while (($pos = strpos($code, ')(resources.GetObject("', $offset)) !== false) |
|
109 | 109 | { |
110 | 110 | $offset = $pos + 23; |
111 | - $property = explode ('.', substr ($code, $offset, ($end = strpos ($code, '")));', $offset)) - $offset)); |
|
111 | + $property = explode('.', substr($code, $offset, ($end = strpos($code, '")));', $offset)) - $offset)); |
|
112 | 112 | |
113 | 113 | $object = $property[0] == '$this' ? |
114 | - $designer->form->selector : |
|
115 | - $designer->getComponentByName ($property[0]); |
|
114 | + $designer->form->selector : $designer->getComponentByName($property[0]); |
|
116 | 115 | |
117 | - foreach (array_slice ($property, 1) as $path) |
|
118 | - $object = \VoidCore::getProperty ($object, $path); |
|
116 | + foreach (array_slice($property, 1) as $path) |
|
117 | + $object = \VoidCore::getProperty($object, $path); |
|
119 | 118 | |
120 | - $code = str_replace (substr ($code, $pos + 2, $end - $pos), 'WinForms_PHP.ZendProgram.getResource ("'. \VoidCore::exportObject ($object) .'")', $code); |
|
119 | + $code = str_replace(substr($code, $pos + 2, $end - $pos), 'WinForms_PHP.ZendProgram.getResource ("'.\VoidCore::exportObject($object).'")', $code); |
|
121 | 120 | } |
122 | 121 | |
123 | 122 | return $code; |
124 | 123 | } |
125 | 124 | |
126 | - public static function generateCode (array $references, bool $removeNamespaces = true): string |
|
125 | + public static function generateCode(array $references, bool $removeNamespaces = true): string |
|
127 | 126 | { |
128 | - return Builder::generateCode ($references, $removeNamespaces); |
|
127 | + return Builder::generateCode($references, $removeNamespaces); |
|
129 | 128 | } |
130 | 129 | |
131 | - public static function getReferences (string $file, bool $parseExtensions = true): array |
|
130 | + public static function getReferences(string $file, bool $parseExtensions = true): array |
|
132 | 131 | { |
133 | - return Builder::getReferences ($file, $parseExtensions); |
|
132 | + return Builder::getReferences($file, $parseExtensions); |
|
134 | 133 | } |
135 | 134 | |
136 | - public static function optimizeCode (string $code): string |
|
135 | + public static function optimizeCode(string $code): string |
|
137 | 136 | { |
138 | - return Builder::optimizeCode ($code); |
|
137 | + return Builder::optimizeCode($code); |
|
139 | 138 | } |
140 | 139 | } |
@@ -13,9 +13,10 @@ discard block |
||
13 | 13 | $objectsCode = ''; |
14 | 14 | $forms = []; |
15 | 15 | |
16 | - for ($i = 0; $i < 5; ++$i) |
|
17 | - if (!isset ($settings[$i]) || !strlen (trim ($settings[$i]))) |
|
18 | - $settings[$i] = null; |
|
16 | + for ($i = 0; $i < 5; ++$i) { |
|
17 | + if (!isset ($settings[$i]) || !strlen (trim ($settings[$i]))) |
|
18 | + $settings[$i] = null; |
|
19 | + } |
|
19 | 20 | |
20 | 21 | $settings = array_slice ($settings, 0, 5); |
21 | 22 | |
@@ -26,11 +27,13 @@ discard block |
||
26 | 27 | |
27 | 28 | $forms[] = $item; |
28 | 29 | |
29 | - if (!isset (VoidStudioAPI::$events[$item])) |
|
30 | - VoidStudioAPI::$events[$item] = "class $item extends Form\n{}\n"; |
|
30 | + if (!isset (VoidStudioAPI::$events[$item])) { |
|
31 | + VoidStudioAPI::$events[$item] = "class $item extends Form\n{}\n"; |
|
32 | + } |
|
31 | 33 | |
32 | - if (isset (VoidStudioAPI::$events[$item])) |
|
33 | - $objectsCode .= ClassWorker::applyClass (VoidStudioAPI::$events[$item], $item, substr ($voidCode = $designer->getVoidCode ($item, false), $pos = strpos ($voidCode, '{') + 1, strrpos ($voidCode, '}') - $pos - 1) ."\n") ."\n\n"; |
|
34 | + if (isset (VoidStudioAPI::$events[$item])) { |
|
35 | + $objectsCode .= ClassWorker::applyClass (VoidStudioAPI::$events[$item], $item, substr ($voidCode = $designer->getVoidCode ($item, false), $pos = strpos ($voidCode, '{') + 1, strrpos ($voidCode, '}') - $pos - 1) ."\n") ."\n\n"; |
|
36 | + } |
|
34 | 37 | } |
35 | 38 | |
36 | 39 | dir_clean ($savePath); |
@@ -46,14 +49,17 @@ discard block |
||
46 | 49 | { |
47 | 50 | $module = trim (file_get_contents ($module)); |
48 | 51 | |
49 | - if (substr ($module, 0, 2) == '<?') |
|
50 | - $module = substr ($module, 2); |
|
52 | + if (substr ($module, 0, 2) == '<?') { |
|
53 | + $module = substr ($module, 2); |
|
54 | + } |
|
51 | 55 | |
52 | - if (substr ($module, 0, 3) == 'php') |
|
53 | - $module = substr ($module, 3); |
|
56 | + if (substr ($module, 0, 3) == 'php') { |
|
57 | + $module = substr ($module, 3); |
|
58 | + } |
|
54 | 59 | |
55 | - if (substr ($module, -2) == '?>') |
|
56 | - $module = substr ($module, 0, -2); |
|
60 | + if (substr ($module, -2) == '?>') { |
|
61 | + $module = substr ($module, 0, -2); |
|
62 | + } |
|
57 | 63 | |
58 | 64 | return "\$module = <<<'__MODULE'\n". self::optimizeCode ($module) ."\n__MODULE;\n\neval (\$module);"; |
59 | 65 | }, array_merge (glob (VoidStudioProjectManager::$projectPath .'/modules/*.php'), $debug ? [APP_DIR .'/system/debug/DebugHook.php'] : []))), |
@@ -72,8 +78,9 @@ discard block |
||
72 | 78 | |
73 | 79 | $manager = new \Qero\PackagesManager\PackagesManager; |
74 | 80 | |
75 | - foreach ($modules as $package) |
|
76 | - $manager->installPackage ($package); |
|
81 | + foreach ($modules as $package) { |
|
82 | + $manager->installPackage ($package); |
|
83 | + } |
|
77 | 84 | |
78 | 85 | dir_copy (APP_DIR .'/Qero/qero-packages', $savePath .'/qero-packages'); |
79 | 86 | dir_delete (APP_DIR .'/Qero/qero-packages'); |
@@ -93,10 +100,9 @@ discard block |
||
93 | 100 | }, $errors)); |
94 | 101 | |
95 | 102 | messageBox ('Обнаружено '. $errorsCount .' ошибок', 'Ошибка компиляции', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Error')); |
96 | - } |
|
97 | - |
|
98 | - elseif ($printSuccessCompile) |
|
99 | - messageBox ('Проект успешно скомпилирован', 'Успешная компиляция', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Information')); |
|
103 | + } elseif ($printSuccessCompile) { |
|
104 | + messageBox ('Проект успешно скомпилирован', 'Успешная компиляция', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Information')); |
|
105 | + } |
|
100 | 106 | |
101 | 107 | return $errors; |
102 | 108 | } |
@@ -114,8 +120,9 @@ discard block |
||
114 | 120 | $designer->form->selector : |
115 | 121 | $designer->getComponentByName ($property[0]); |
116 | 122 | |
117 | - foreach (array_slice ($property, 1) as $path) |
|
118 | - $object = \VoidCore::getProperty ($object, $path); |
|
123 | + foreach (array_slice ($property, 1) as $path) { |
|
124 | + $object = \VoidCore::getProperty ($object, $path); |
|
125 | + } |
|
119 | 126 | |
120 | 127 | $code = str_replace (substr ($code, $pos + 2, $end - $pos), 'WinForms_PHP.ZendProgram.getResource ("'. \VoidCore::exportObject ($object) .'")', $code); |
121 | 128 | } |
@@ -78,40 +78,40 @@ discard block |
||
78 | 78 | { |
79 | 79 | $this->componentAddedEvent = function ($self, $args) |
80 | 80 | { |
81 | - if (!isset ($GLOBALS['new_component'])) |
|
82 | - { |
|
81 | + if (!isset ($GLOBALS['new_component'])) |
|
82 | + { |
|
83 | 83 | $name = $args->component->getType ()->toString (); |
84 | 84 | |
85 | 85 | // pre (\VoidCore::getProperty ($args->component->selector, 'Name')); |
86 | 86 | |
87 | - $GLOBALS['new_component'] = [$this->getComponentName ($args->component->selector), [$name, substr ($name, 0, strrpos ($name, '.'))]]; |
|
88 | - } |
|
87 | + $GLOBALS['new_component'] = [$this->getComponentName ($args->component->selector), [$name, substr ($name, 0, strrpos ($name, '.'))]]; |
|
88 | + } |
|
89 | 89 | |
90 | - $this->setComponentToHistory ($GLOBALS['new_component'][1], $GLOBALS['new_component'][0]); |
|
91 | - $components = VoidStudioAPI::getObjects ('main')['PropertiesPanel__SelectedComponent']; |
|
90 | + $this->setComponentToHistory ($GLOBALS['new_component'][1], $GLOBALS['new_component'][0]); |
|
91 | + $components = VoidStudioAPI::getObjects ('main')['PropertiesPanel__SelectedComponent']; |
|
92 | 92 | |
93 | - $components->items->clear (); |
|
94 | - $components->items->addRange (array_keys ($this->objects)); |
|
93 | + $components->items->clear (); |
|
94 | + $components->items->addRange (array_keys ($this->objects)); |
|
95 | 95 | |
96 | - $components->selectedItem = $GLOBALS['new_component'][0]; |
|
97 | - $this->setSelectedComponents ($args->component); |
|
96 | + $components->selectedItem = $GLOBALS['new_component'][0]; |
|
97 | + $this->setSelectedComponents ($args->component); |
|
98 | 98 | |
99 | - unset ($GLOBALS['new_component']); |
|
99 | + unset ($GLOBALS['new_component']); |
|
100 | 100 | }; |
101 | 101 | |
102 | - $this->componentRemovedEvent = function ($self, $args) |
|
103 | - { |
|
104 | - $name = $this->getComponentName ($args->component->selector); |
|
105 | - unset ($this->objects[$name]); |
|
102 | + $this->componentRemovedEvent = function ($self, $args) |
|
103 | + { |
|
104 | + $name = $this->getComponentName ($args->component->selector); |
|
105 | + unset ($this->objects[$name]); |
|
106 | 106 | |
107 | - foreach ($this->objects as $objectName => $object) |
|
108 | - if (!is_int ($this->getComponentByName ($objectName))) |
|
109 | - unset ($this->objects[$objectName]); |
|
107 | + foreach ($this->objects as $objectName => $object) |
|
108 | + if (!is_int ($this->getComponentByName ($objectName))) |
|
109 | + unset ($this->objects[$objectName]); |
|
110 | 110 | |
111 | - $this->currentSelectedItem->items->clear (); |
|
112 | - $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
|
113 | - $this->currentSelectedItem->selectedItem = $this->getComponentName ($this->getPrimarySelection ()->selector); |
|
114 | - }; |
|
111 | + $this->currentSelectedItem->items->clear (); |
|
112 | + $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
|
113 | + $this->currentSelectedItem->selectedItem = $this->getComponentName ($this->getPrimarySelection ()->selector); |
|
114 | + }; |
|
115 | 115 | |
116 | 116 | // ! Отредактировал что-то здесь? |
117 | 117 | // ! Не забудь отредактировать и в main.vlf |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | $menu->items->addRange (isset ($desItem) ? [ |
204 | 204 | $selectAllItem, $copyItem, $pasteItem, $cutItem, $delItem, '-', |
205 | 205 | $toFrontItem, $toBackItem, $desItem, '-', |
206 | - $undoItem, $redoItem, '-', |
|
206 | + $undoItem, $redoItem, '-', |
|
207 | 207 | $infoItem |
208 | 208 | ] : [ |
209 | 209 | $selectAllItem, $copyItem, $pasteItem, $cutItem, $delItem, '-', |
210 | 210 | $toFrontItem, $toBackItem, '-', |
211 | - $undoItem, $redoItem, '-', |
|
211 | + $undoItem, $redoItem, '-', |
|
212 | 212 | $infoItem |
213 | 213 | ]); |
214 | 214 |
@@ -12,20 +12,19 @@ discard block |
||
12 | 12 | protected $currentSelectedItem; |
13 | 13 | protected $formsList; |
14 | 14 | |
15 | - public function __construct (Component $parent, string $formName = 'form', PropertyGrid $propertyGrid, ComboBox $currentSelectedItem, TabControl $formsList, $form = null) |
|
15 | + public function __construct(Component $parent, string $formName = 'form', PropertyGrid $propertyGrid, ComboBox $currentSelectedItem, TabControl $formsList, $form = null) |
|
16 | 16 | { |
17 | - $this->form = $form === null ? new Form : |
|
18 | - EngineAdditions::coupleSelector ($form); |
|
17 | + $this->form = $form === null ? new Form : EngineAdditions::coupleSelector($form); |
|
19 | 18 | |
20 | - if (!is_object ($this->form)) |
|
21 | - throw new \Exception ('$form param in "VoidEngine\VoidDesigner" constructor must be instance of "VoidEngine\WFObject" ("VoidEngine\Form") or be object selector'); |
|
19 | + if (!is_object($this->form)) |
|
20 | + throw new \Exception('$form param in "VoidEngine\VoidDesigner" constructor must be instance of "VoidEngine\WFObject" ("VoidEngine\Form") or be object selector'); |
|
22 | 21 | |
23 | 22 | $this->propertyGrid = $propertyGrid; |
24 | 23 | $this->currentSelectedItem = $currentSelectedItem; |
25 | 24 | $this->formsList = $formsList; |
26 | 25 | |
27 | - $this->selector = \VoidCore::createObject ('WinForms_PHP.FormDesigner5', null, $this->form->selector, $formName); |
|
28 | - Components::addComponent ($this->selector, $this); |
|
26 | + $this->selector = \VoidCore::createObject('WinForms_PHP.FormDesigner5', null, $this->form->selector, $formName); |
|
27 | + Components::addComponent($this->selector, $this); |
|
29 | 28 | |
30 | 29 | $this->form->name = $formName; |
31 | 30 | |
@@ -35,172 +34,172 @@ discard block |
||
35 | 34 | $this->form->size = [400, 360]; |
36 | 35 | } |
37 | 36 | |
38 | - $this->control = $this->callMethod ('GetControl'); |
|
37 | + $this->control = $this->callMethod('GetControl'); |
|
39 | 38 | $this->objects[$formName] = ['System.Windows.Forms.Form', 'System.Windows.Forms']; |
40 | 39 | |
41 | - \VoidCore::setProperty ($this->control, 'Parent', $parent->selector); |
|
40 | + \VoidCore::setProperty($this->control, 'Parent', $parent->selector); |
|
42 | 41 | |
43 | - $this->selectionChangedEvent = function () |
|
42 | + $this->selectionChangedEvent = function() |
|
44 | 43 | { |
45 | - $object = $this->getPrimarySelection ()->selector; |
|
44 | + $object = $this->getPrimarySelection()->selector; |
|
46 | 45 | |
47 | 46 | $this->propertyGrid->selectedObject = $object; |
48 | - $this->currentSelectedItem->selectedItem = $this->getComponentName ($object); |
|
47 | + $this->currentSelectedItem->selectedItem = $this->getComponentName($object); |
|
49 | 48 | }; |
50 | 49 | |
51 | - $this->createUniqueMethodNameEvent = function ($self, $args) |
|
50 | + $this->createUniqueMethodNameEvent = function($self, $args) |
|
52 | 51 | { |
53 | - return $this->getComponentName ($args->component->selector) . '_' . $args->eventDescriptor->Name; |
|
52 | + return $this->getComponentName($args->component->selector).'_'.$args->eventDescriptor->Name; |
|
54 | 53 | }; |
55 | 54 | |
56 | - $this->getCompatibleMethodsEvent = function () |
|
55 | + $this->getCompatibleMethodsEvent = function() |
|
57 | 56 | { |
58 | 57 | $form = $this->formsList->selectedTab->text; |
59 | 58 | |
60 | - return getNetArray ('System.String', ClassWorker::getAvailableClassMethods (VoidStudioAPI::$events[$form] ?? '', $form))->selector; |
|
59 | + return getNetArray('System.String', ClassWorker::getAvailableClassMethods(VoidStudioAPI::$events[$form] ?? '', $form))->selector; |
|
61 | 60 | }; |
62 | 61 | |
63 | - $this->showCodeEvent = function ($self, $args) |
|
62 | + $this->showCodeEvent = function($self, $args) |
|
64 | 63 | { |
65 | - VoidStudioAPI::openEventEditor ($this->propertyGrid->selectedObject->selector, $args->methodName, $args->eventDescriptor, $form = c('Designer__FormsList')->selectedTab->text, VoidStudioAPI::getObjects ('main')['Designer__'. $form .'Designer']); |
|
64 | + VoidStudioAPI::openEventEditor($this->propertyGrid->selectedObject->selector, $args->methodName, $args->eventDescriptor, $form = c('Designer__FormsList')->selectedTab->text, VoidStudioAPI::getObjects('main')['Designer__'.$form.'Designer']); |
|
66 | 65 | }; |
67 | 66 | |
68 | - $this->freeMethodEvent = function ($self, $args) |
|
67 | + $this->freeMethodEvent = function($self, $args) |
|
69 | 68 | { |
70 | 69 | $object = $this->propertyGrid->selectedObject->selector; |
71 | 70 | |
72 | - Events::removeObjectEvent ($object, $method = $args->eventDescriptor->Name); |
|
71 | + Events::removeObjectEvent($object, $method = $args->eventDescriptor->Name); |
|
73 | 72 | unset (VoidStudioAPI::$events[$object][$method]); |
74 | 73 | }; |
75 | 74 | } |
76 | 75 | |
77 | - public function initDesigner (): void |
|
76 | + public function initDesigner(): void |
|
78 | 77 | { |
79 | - $this->componentAddedEvent = function ($self, $args) |
|
78 | + $this->componentAddedEvent = function($self, $args) |
|
80 | 79 | { |
81 | 80 | if (!isset ($GLOBALS['new_component'])) |
82 | 81 | { |
83 | - $name = $args->component->getType ()->toString (); |
|
82 | + $name = $args->component->getType()->toString(); |
|
84 | 83 | |
85 | 84 | // pre (\VoidCore::getProperty ($args->component->selector, 'Name')); |
86 | 85 | |
87 | - $GLOBALS['new_component'] = [$this->getComponentName ($args->component->selector), [$name, substr ($name, 0, strrpos ($name, '.'))]]; |
|
86 | + $GLOBALS['new_component'] = [$this->getComponentName($args->component->selector), [$name, substr($name, 0, strrpos($name, '.'))]]; |
|
88 | 87 | } |
89 | 88 | |
90 | - $this->setComponentToHistory ($GLOBALS['new_component'][1], $GLOBALS['new_component'][0]); |
|
91 | - $components = VoidStudioAPI::getObjects ('main')['PropertiesPanel__SelectedComponent']; |
|
89 | + $this->setComponentToHistory($GLOBALS['new_component'][1], $GLOBALS['new_component'][0]); |
|
90 | + $components = VoidStudioAPI::getObjects('main')['PropertiesPanel__SelectedComponent']; |
|
92 | 91 | |
93 | - $components->items->clear (); |
|
94 | - $components->items->addRange (array_keys ($this->objects)); |
|
92 | + $components->items->clear(); |
|
93 | + $components->items->addRange(array_keys($this->objects)); |
|
95 | 94 | |
96 | 95 | $components->selectedItem = $GLOBALS['new_component'][0]; |
97 | - $this->setSelectedComponents ($args->component); |
|
96 | + $this->setSelectedComponents($args->component); |
|
98 | 97 | |
99 | 98 | unset ($GLOBALS['new_component']); |
100 | 99 | }; |
101 | 100 | |
102 | - $this->componentRemovedEvent = function ($self, $args) |
|
101 | + $this->componentRemovedEvent = function($self, $args) |
|
103 | 102 | { |
104 | - $name = $this->getComponentName ($args->component->selector); |
|
103 | + $name = $this->getComponentName($args->component->selector); |
|
105 | 104 | unset ($this->objects[$name]); |
106 | 105 | |
107 | 106 | foreach ($this->objects as $objectName => $object) |
108 | - if (!is_int ($this->getComponentByName ($objectName))) |
|
107 | + if (!is_int($this->getComponentByName($objectName))) |
|
109 | 108 | unset ($this->objects[$objectName]); |
110 | 109 | |
111 | - $this->currentSelectedItem->items->clear (); |
|
112 | - $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
|
113 | - $this->currentSelectedItem->selectedItem = $this->getComponentName ($this->getPrimarySelection ()->selector); |
|
110 | + $this->currentSelectedItem->items->clear(); |
|
111 | + $this->currentSelectedItem->items->addRange(array_keys($this->objects)); |
|
112 | + $this->currentSelectedItem->selectedItem = $this->getComponentName($this->getPrimarySelection()->selector); |
|
114 | 113 | }; |
115 | 114 | |
116 | 115 | // ! Отредактировал что-то здесь? |
117 | 116 | // ! Не забудь отредактировать и в main.vlf |
118 | 117 | |
119 | - $this->rightClickEvent = function ($self, $args) |
|
118 | + $this->rightClickEvent = function($self, $args) |
|
120 | 119 | { |
121 | - $delItem = new ToolStripMenuItem ('Удалить'); |
|
122 | - $delItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Delete_16x.png'); |
|
120 | + $delItem = new ToolStripMenuItem('Удалить'); |
|
121 | + $delItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Delete_16x.png'); |
|
123 | 122 | $delItem->shortcutKeys = 46; |
124 | - $delItem->clickEvent = fn () => $this->removeSelected (); |
|
123 | + $delItem->clickEvent = fn() => $this->removeSelected(); |
|
125 | 124 | |
126 | - $toFrontItem = new ToolStripMenuItem ('На передний план'); |
|
127 | - $toFrontItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Front_16x.png'); |
|
125 | + $toFrontItem = new ToolStripMenuItem('На передний план'); |
|
126 | + $toFrontItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Front_16x.png'); |
|
128 | 127 | // $toFrontItem->shortcutKeys = 131142; |
129 | - $toFrontItem->clickEvent = fn () => $self->doAction ('bringToFront'); |
|
128 | + $toFrontItem->clickEvent = fn() => $self->doAction('bringToFront'); |
|
130 | 129 | |
131 | - $toBackItem = new ToolStripMenuItem ('На задний план'); |
|
132 | - $toBackItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Back_16x.png'); |
|
130 | + $toBackItem = new ToolStripMenuItem('На задний план'); |
|
131 | + $toBackItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Back_16x.png'); |
|
133 | 132 | // $toBackItem->shortcutKeys = 131138; |
134 | - $toBackItem->clickEvent = fn () => $self->doAction ('sendToBack'); |
|
133 | + $toBackItem->clickEvent = fn() => $self->doAction('sendToBack'); |
|
135 | 134 | |
136 | - if ((new WFObject (\VoidCore::typeof ('System.Windows.Forms.Control')))->isAssignableFrom ($this->propertyGrid->selectedObject->getType ())) |
|
135 | + if ((new WFObject(\VoidCore::typeof('System.Windows.Forms.Control')))->isAssignableFrom($this->propertyGrid->selectedObject->getType())) |
|
137 | 136 | { |
138 | - $locked = ($locker = (new WFClass ('System.ComponentModel.TypeDescriptor', 'System')) |
|
139 | - ->getProperties ($object = $this->propertyGrid->selectedObject->selector)['Locked']) |
|
140 | - ->getValue ($object); |
|
137 | + $locked = ($locker = (new WFClass('System.ComponentModel.TypeDescriptor', 'System')) |
|
138 | + ->getProperties($object = $this->propertyGrid->selectedObject->selector)['Locked']) |
|
139 | + ->getValue($object); |
|
141 | 140 | |
142 | - $desItem = new ToolStripMenuItem ($locked ? 'Разблокировать' : 'Заблокировать'); |
|
143 | - $desItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/'. ($locked ? 'Unlock' : 'Lock') .'_16x.png'); |
|
141 | + $desItem = new ToolStripMenuItem($locked ? 'Разблокировать' : 'Заблокировать'); |
|
142 | + $desItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/'.($locked ? 'Unlock' : 'Lock').'_16x.png'); |
|
144 | 143 | // $desItem->shortcutKeys = 131148; |
145 | - $desItem->clickEvent = function () use ($object, $locker, $locked) |
|
144 | + $desItem->clickEvent = function() use ($object, $locker, $locked) |
|
146 | 145 | { |
147 | - $locker->setValue ($object, !$locked); |
|
146 | + $locker->setValue($object, !$locked); |
|
148 | 147 | |
149 | - $this->propertyGrid->refresh (); |
|
148 | + $this->propertyGrid->refresh(); |
|
150 | 149 | }; |
151 | 150 | } |
152 | 151 | |
153 | - $selectAllItem = new ToolStripMenuItem ('Выделить всё'); |
|
154 | - $selectAllItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/SelectAll_16x.png'); |
|
152 | + $selectAllItem = new ToolStripMenuItem('Выделить всё'); |
|
153 | + $selectAllItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/SelectAll_16x.png'); |
|
155 | 154 | $selectAllItem->shortcutKeys = 131137; |
156 | - $selectAllItem->clickEvent = fn () => $self->doAction ('selectAll'); |
|
155 | + $selectAllItem->clickEvent = fn() => $self->doAction('selectAll'); |
|
157 | 156 | |
158 | - $cutItem = new ToolStripMenuItem ('Вырезать'); |
|
159 | - $cutItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Cut_16x.png'); |
|
157 | + $cutItem = new ToolStripMenuItem('Вырезать'); |
|
158 | + $cutItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Cut_16x.png'); |
|
160 | 159 | $cutItem->shortcutKeys = 131160; |
161 | - $cutItem->clickEvent = fn () => $self->doAction ('cut'); |
|
160 | + $cutItem->clickEvent = fn() => $self->doAction('cut'); |
|
162 | 161 | |
163 | - $copyItem = new ToolStripMenuItem ('Копировать'); |
|
164 | - $copyItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Copy_16x.png'); |
|
162 | + $copyItem = new ToolStripMenuItem('Копировать'); |
|
163 | + $copyItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Copy_16x.png'); |
|
165 | 164 | $copyItem->shortcutKeys = 131139; |
166 | - $copyItem->clickEvent = fn () => $self->doAction ('copy'); |
|
165 | + $copyItem->clickEvent = fn() => $self->doAction('copy'); |
|
167 | 166 | |
168 | - $pasteItem = new ToolStripMenuItem ('Вставить'); |
|
169 | - $pasteItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Paste_16x.png'); |
|
167 | + $pasteItem = new ToolStripMenuItem('Вставить'); |
|
168 | + $pasteItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Paste_16x.png'); |
|
170 | 169 | $pasteItem->shortcutKeys = 131158; |
171 | - $pasteItem->clickEvent = fn () => $self->doAction('paste'); |
|
170 | + $pasteItem->clickEvent = fn() => $self->doAction('paste'); |
|
172 | 171 | |
173 | - $undoItem = new ToolStripMenuItem ('Отменить'); |
|
174 | - $undoItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Undo_16x.png'); |
|
172 | + $undoItem = new ToolStripMenuItem('Отменить'); |
|
173 | + $undoItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Undo_16x.png'); |
|
175 | 174 | $undoItem->shortcutKeys = 131162; |
176 | - $undoItem->clickEvent = fn () => $self->undoEngine->undo (); |
|
175 | + $undoItem->clickEvent = fn() => $self->undoEngine->undo(); |
|
177 | 176 | |
178 | - $redoItem = new ToolStripMenuItem ('Повторить'); |
|
179 | - $redoItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Redo_16x.png'); |
|
177 | + $redoItem = new ToolStripMenuItem('Повторить'); |
|
178 | + $redoItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Redo_16x.png'); |
|
180 | 179 | $redoItem->shortcutKeys = 131161; |
181 | - $redoItem->clickEvent = fn () => $self->undoEngine->redo (); |
|
180 | + $redoItem->clickEvent = fn() => $self->undoEngine->redo(); |
|
182 | 181 | |
183 | - $infoItem = new ToolStripMenuItem ('Отладочная информация'); |
|
184 | - $infoItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Debug_16x.png'); |
|
185 | - $infoItem->clickEvent = function () use ($self) |
|
182 | + $infoItem = new ToolStripMenuItem('Отладочная информация'); |
|
183 | + $infoItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Debug_16x.png'); |
|
184 | + $infoItem->clickEvent = function() use ($self) |
|
186 | 185 | { |
187 | - $self->getSelectedComponents ()->foreach (function ($value) use ($self) |
|
186 | + $self->getSelectedComponents()->foreach(function($value) use ($self) |
|
188 | 187 | { |
189 | - pre ($value instanceof Component ? $value : $value->toString () ."\nSelector: ". $value->selector); |
|
188 | + pre($value instanceof Component ? $value : $value->toString()."\nSelector: ".$value->selector); |
|
190 | 189 | |
191 | - if ((new WFObject (\VoidCore::typeof ('System.Windows.Forms.Form')))->isAssignableFrom ($value->getType ())) |
|
190 | + if ((new WFObject(\VoidCore::typeof('System.Windows.Forms.Form')))->isAssignableFrom($value->getType())) |
|
192 | 191 | { |
193 | - $code = $self->getVoidCode ($self->form->name, false); |
|
192 | + $code = $self->getVoidCode($self->form->name, false); |
|
194 | 193 | |
195 | - pre ($self->getSharpCode ($self->form->name)); |
|
196 | - pre ('namespace VoidEngine;'. "\n\n" .'return new class' . substr ($code, 38) . ';'); |
|
194 | + pre($self->getSharpCode($self->form->name)); |
|
195 | + pre('namespace VoidEngine;'."\n\n".'return new class'.substr($code, 38).';'); |
|
197 | 196 | } |
198 | 197 | }); |
199 | 198 | }; |
200 | 199 | |
201 | 200 | $menu = new ContextMenuStrip; |
202 | 201 | |
203 | - $menu->items->addRange (isset ($desItem) ? [ |
|
202 | + $menu->items->addRange(isset ($desItem) ? [ |
|
204 | 203 | $selectAllItem, $copyItem, $pasteItem, $cutItem, $delItem, '-', |
205 | 204 | $toFrontItem, $toBackItem, $desItem, '-', |
206 | 205 | $undoItem, $redoItem, '-', |
@@ -212,91 +211,91 @@ discard block |
||
212 | 211 | $infoItem |
213 | 212 | ]); |
214 | 213 | |
215 | - $menu->show ($self->form, $self->form->pointToClient (\VoidCore::createObject ('System.Drawing.Point', false, $args->x, $args->y))); |
|
214 | + $menu->show($self->form, $self->form->pointToClient(\VoidCore::createObject('System.Drawing.Point', false, $args->x, $args->y))); |
|
216 | 215 | }; |
217 | 216 | |
218 | - VoidStudioAPI::addObjects ('main', ['Designer__'. $this->form->name .'Designer' => $this]); |
|
217 | + VoidStudioAPI::addObjects('main', ['Designer__'.$this->form->name.'Designer' => $this]); |
|
219 | 218 | } |
220 | 219 | |
221 | - public function focus (): void |
|
220 | + public function focus(): void |
|
222 | 221 | { |
223 | - $this->form->focus (); |
|
222 | + $this->form->focus(); |
|
224 | 223 | } |
225 | 224 | |
226 | - public function getSharpCode (string $formName): string |
|
225 | + public function getSharpCode(string $formName): string |
|
227 | 226 | { |
228 | - $code = $this->callMethod (['GetSharpCode', 'object'], $formName); |
|
227 | + $code = $this->callMethod(['GetSharpCode', 'object'], $formName); |
|
229 | 228 | |
230 | - $code = \VoidCore::callMethod ($code, ['Replace', 'object'], 'public class '. $this->form->name .' : '. $this->form->name, 'public class '. $this->form->name .' : System.Windows.Forms.Form'); |
|
231 | - $code = \VoidCore::callMethod ($code, ['Replace', 'object'], ' private ', ' public '); |
|
229 | + $code = \VoidCore::callMethod($code, ['Replace', 'object'], 'public class '.$this->form->name.' : '.$this->form->name, 'public class '.$this->form->name.' : System.Windows.Forms.Form'); |
|
230 | + $code = \VoidCore::callMethod($code, ['Replace', 'object'], ' private ', ' public '); |
|
232 | 231 | |
233 | - return \VoidCore::callMethod ($code, 'ToString'); |
|
232 | + return \VoidCore::callMethod($code, 'ToString'); |
|
234 | 233 | } |
235 | 234 | |
236 | - public function createComponent (array $component, string $componentName): int |
|
235 | + public function createComponent(array $component, string $componentName): int |
|
237 | 236 | { |
238 | 237 | $this->objects[$componentName] = $component; |
239 | - $selector = \VoidCore::createObject (...$component); |
|
238 | + $selector = \VoidCore::createObject(...$component); |
|
240 | 239 | |
241 | - $this->callMethod ('AddComponent', $selector, $componentName); |
|
240 | + $this->callMethod('AddComponent', $selector, $componentName); |
|
242 | 241 | |
243 | 242 | return $selector; |
244 | 243 | } |
245 | 244 | |
246 | - public function setComponentToHistory (array $component, string $componentName): void |
|
245 | + public function setComponentToHistory(array $component, string $componentName): void |
|
247 | 246 | { |
248 | 247 | $this->objects[$componentName] = $component; |
249 | 248 | } |
250 | 249 | |
251 | - public function addComponent (int $selector, string $componentName): void |
|
250 | + public function addComponent(int $selector, string $componentName): void |
|
252 | 251 | { |
253 | - $this->objects[$componentName] = [\VoidCore::callMethod (\VoidCore::callMethod ($selector, 'GetType'), 'ToString'), false]; |
|
252 | + $this->objects[$componentName] = [\VoidCore::callMethod(\VoidCore::callMethod($selector, 'GetType'), 'ToString'), false]; |
|
254 | 253 | |
255 | - $this->callMethod ('AddComponent', $selector, $componentName); |
|
254 | + $this->callMethod('AddComponent', $selector, $componentName); |
|
256 | 255 | } |
257 | 256 | |
258 | - public function removeComponent (int $component): void |
|
257 | + public function removeComponent(int $component): void |
|
259 | 258 | { |
260 | - unset ($this->objects[$this->getComponentName ($component)]); |
|
259 | + unset ($this->objects[$this->getComponentName($component)]); |
|
261 | 260 | |
262 | - $this->callMethod ('RemoveComponent', $component); |
|
261 | + $this->callMethod('RemoveComponent', $component); |
|
263 | 262 | } |
264 | 263 | |
265 | - public function removeComponentHistoryByName (string $name): void |
|
264 | + public function removeComponentHistoryByName(string $name): void |
|
266 | 265 | { |
267 | 266 | unset ($this->objects[$name]); |
268 | 267 | } |
269 | 268 | |
270 | - public function removeSelected (): void |
|
269 | + public function removeSelected(): void |
|
271 | 270 | { |
272 | 271 | $toUnset = []; |
273 | 272 | |
274 | - foreach ($this->getSelectedComponents ()->list as $object) |
|
273 | + foreach ($this->getSelectedComponents()->list as $object) |
|
275 | 274 | { |
276 | - if ($object->getType ()->toString () != 'System.Windows.Forms.Form') |
|
277 | - $toUnset[] = $this->getComponentName ($object->selector); |
|
275 | + if ($object->getType()->toString() != 'System.Windows.Forms.Form') |
|
276 | + $toUnset[] = $this->getComponentName($object->selector); |
|
278 | 277 | |
279 | 278 | else |
280 | 279 | { |
281 | 280 | if ($this->formsList->items->count > 1) |
282 | 281 | { |
283 | - if (messageBox ('Вы действительно хотите удалить форму "'. $this->form->name .'"?', 'Подтвердите действие', enum ('System.Windows.Forms.MessageBoxButtons.YesNo'), enum ('System.Windows.Forms.MessageBoxIcon.Question')) == 6) |
|
282 | + if (messageBox('Вы действительно хотите удалить форму "'.$this->form->name.'"?', 'Подтвердите действие', enum('System.Windows.Forms.MessageBoxButtons.YesNo'), enum('System.Windows.Forms.MessageBoxIcon.Question')) == 6) |
|
284 | 283 | { |
285 | 284 | foreach ($this->objects as $name => $obj) |
286 | 285 | unset ($this->objects[$name]); |
287 | 286 | |
288 | - unset ($this->formsList->items[array_flip ($this->formsList->items->names)[$form = $this->getComponentName ($object->selector)]]); |
|
287 | + unset ($this->formsList->items[array_flip($this->formsList->items->names)[$form = $this->getComponentName($object->selector)]]); |
|
289 | 288 | |
290 | 289 | /*$this->form->dispose (); |
291 | 290 | \VoidCore::callMethod ($this->control, 'Dispose');*/ |
292 | - $this->callMethod ('DeleteSelected'); |
|
291 | + $this->callMethod('DeleteSelected'); |
|
293 | 292 | |
294 | - $designer = VoidStudioAPI::getObjects ('main')['Designer__'. $this->formsList->selectedTab->text .'Designer']; |
|
293 | + $designer = VoidStudioAPI::getObjects('main')['Designer__'.$this->formsList->selectedTab->text.'Designer']; |
|
295 | 294 | |
296 | 295 | $designer->propertyGrid->selectedObject = $designer->form; |
297 | - $designer->setSelectedComponents ($designer->form); |
|
296 | + $designer->setSelectedComponents($designer->form); |
|
298 | 297 | |
299 | - unset (VoidStudioAPI::$objects['main']['Designer__'. $form .'Designer']); |
|
298 | + unset (VoidStudioAPI::$objects['main']['Designer__'.$form.'Designer']); |
|
300 | 299 | |
301 | 300 | return; |
302 | 301 | } |
@@ -304,7 +303,7 @@ discard block |
||
304 | 303 | |
305 | 304 | else |
306 | 305 | { |
307 | - messageBox ('Нельзя удалить единственную форму проекта', 'Ошибка удаления', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Error')); |
|
306 | + messageBox('Нельзя удалить единственную форму проекта', 'Ошибка удаления', enum('System.Windows.Forms.MessageBoxButtons.OK'), enum('System.Windows.Forms.MessageBoxIcon.Error')); |
|
308 | 307 | |
309 | 308 | return; |
310 | 309 | } |
@@ -314,52 +313,52 @@ discard block |
||
314 | 313 | foreach ($toUnset as $name) |
315 | 314 | unset ($this->objects[$name]); |
316 | 315 | |
317 | - $this->doAction ('delete'); |
|
316 | + $this->doAction('delete'); |
|
318 | 317 | |
319 | 318 | foreach ($this->objects as $objectName => $object) |
320 | - if (!is_int ($this->getComponentByName ($objectName))) |
|
319 | + if (!is_int($this->getComponentByName($objectName))) |
|
321 | 320 | unset ($this->objects[$objectName]); |
322 | 321 | |
323 | - $this->currentSelectedItem->items->clear (); |
|
324 | - $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
|
325 | - $this->currentSelectedItem->selectedItem = $this->getComponentName ($this->getPrimarySelection ()->selector); |
|
322 | + $this->currentSelectedItem->items->clear(); |
|
323 | + $this->currentSelectedItem->items->addRange(array_keys($this->objects)); |
|
324 | + $this->currentSelectedItem->selectedItem = $this->getComponentName($this->getPrimarySelection()->selector); |
|
326 | 325 | } |
327 | 326 | |
328 | - public function renameComponent (int $component, string $name, string $fromName = null): void |
|
327 | + public function renameComponent(int $component, string $name, string $fromName = null): void |
|
329 | 328 | { |
330 | 329 | if ($fromName === null) |
331 | - $fromName = $this->getComponentName ($component); |
|
330 | + $fromName = $this->getComponentName($component); |
|
332 | 331 | |
333 | 332 | $info = $this->objects[$fromName]; |
334 | 333 | unset ($this->objects[$fromName]); |
335 | 334 | $this->objects[$name] = $info; |
336 | 335 | |
337 | - $this->callMethod ('RenameComponent', $component, $name); |
|
336 | + $this->callMethod('RenameComponent', $component, $name); |
|
338 | 337 | } |
339 | 338 | |
340 | - public function getComponentName (int $component): string |
|
339 | + public function getComponentName(int $component): string |
|
341 | 340 | { |
342 | - return $this->callMethod ('GetComponentName', $component); |
|
341 | + return $this->callMethod('GetComponentName', $component); |
|
343 | 342 | } |
344 | 343 | |
345 | - public function getComponentByName (string $name) |
|
344 | + public function getComponentByName(string $name) |
|
346 | 345 | { |
347 | - return $this->callMethod ('GetComponentByName', $name); |
|
346 | + return $this->callMethod('GetComponentByName', $name); |
|
348 | 347 | } |
349 | 348 | |
350 | - public function getComponentClass (string $name) |
|
349 | + public function getComponentClass(string $name) |
|
351 | 350 | { |
352 | 351 | return isset ($this->objects[$name]) ? |
353 | 352 | $this->objects[$name] : false; |
354 | 353 | } |
355 | 354 | |
356 | - public function addProperty (int $selector, string $name, int $value, bool $readOnly, string $category, string $description, bool $visible) |
|
355 | + public function addProperty(int $selector, string $name, int $value, bool $readOnly, string $category, string $description, bool $visible) |
|
357 | 356 | { |
358 | - $this->callMethod ('AddProperty', $selector, $name, $value, $readOnly, $category, $description, $visible); |
|
357 | + $this->callMethod('AddProperty', $selector, $name, $value, $readOnly, $category, $description, $visible); |
|
359 | 358 | } |
360 | 359 | |
361 | - public function removeProperty (int $selector, string $name) |
|
360 | + public function removeProperty(int $selector, string $name) |
|
362 | 361 | { |
363 | - $this->callMethod ('RemoveProperty', $selector, $name); |
|
362 | + $this->callMethod('RemoveProperty', $selector, $name); |
|
364 | 363 | } |
365 | 364 | } |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | $this->form = $form === null ? new Form : |
18 | 18 | EngineAdditions::coupleSelector ($form); |
19 | 19 | |
20 | - if (!is_object ($this->form)) |
|
21 | - throw new \Exception ('$form param in "VoidEngine\VoidDesigner" constructor must be instance of "VoidEngine\WFObject" ("VoidEngine\Form") or be object selector'); |
|
20 | + if (!is_object ($this->form)) { |
|
21 | + throw new \Exception ('$form param in "VoidEngine\VoidDesigner" constructor must be instance of "VoidEngine\WFObject" ("VoidEngine\Form") or be object selector'); |
|
22 | + } |
|
22 | 23 | |
23 | 24 | $this->propertyGrid = $propertyGrid; |
24 | 25 | $this->currentSelectedItem = $currentSelectedItem; |
@@ -104,9 +105,10 @@ discard block |
||
104 | 105 | $name = $this->getComponentName ($args->component->selector); |
105 | 106 | unset ($this->objects[$name]); |
106 | 107 | |
107 | - foreach ($this->objects as $objectName => $object) |
|
108 | - if (!is_int ($this->getComponentByName ($objectName))) |
|
109 | - unset ($this->objects[$objectName]); |
|
108 | + foreach ($this->objects as $objectName => $object) { |
|
109 | + if (!is_int ($this->getComponentByName ($objectName))) |
|
110 | + unset ($this->objects[$objectName]); |
|
111 | + } |
|
110 | 112 | |
111 | 113 | $this->currentSelectedItem->items->clear (); |
112 | 114 | $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
@@ -273,17 +275,17 @@ discard block |
||
273 | 275 | |
274 | 276 | foreach ($this->getSelectedComponents ()->list as $object) |
275 | 277 | { |
276 | - if ($object->getType ()->toString () != 'System.Windows.Forms.Form') |
|
277 | - $toUnset[] = $this->getComponentName ($object->selector); |
|
278 | - |
|
279 | - else |
|
278 | + if ($object->getType ()->toString () != 'System.Windows.Forms.Form') { |
|
279 | + $toUnset[] = $this->getComponentName ($object->selector); |
|
280 | + } else |
|
280 | 281 | { |
281 | 282 | if ($this->formsList->items->count > 1) |
282 | 283 | { |
283 | 284 | if (messageBox ('Вы действительно хотите удалить форму "'. $this->form->name .'"?', 'Подтвердите действие', enum ('System.Windows.Forms.MessageBoxButtons.YesNo'), enum ('System.Windows.Forms.MessageBoxIcon.Question')) == 6) |
284 | 285 | { |
285 | - foreach ($this->objects as $name => $obj) |
|
286 | - unset ($this->objects[$name]); |
|
286 | + foreach ($this->objects as $name => $obj) { |
|
287 | + unset ($this->objects[$name]); |
|
288 | + } |
|
287 | 289 | |
288 | 290 | unset ($this->formsList->items[array_flip ($this->formsList->items->names)[$form = $this->getComponentName ($object->selector)]]); |
289 | 291 | |
@@ -300,9 +302,7 @@ discard block |
||
300 | 302 | |
301 | 303 | return; |
302 | 304 | } |
303 | - } |
|
304 | - |
|
305 | - else |
|
305 | + } else |
|
306 | 306 | { |
307 | 307 | messageBox ('Нельзя удалить единственную форму проекта', 'Ошибка удаления', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Error')); |
308 | 308 | |
@@ -311,14 +311,16 @@ discard block |
||
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | - foreach ($toUnset as $name) |
|
315 | - unset ($this->objects[$name]); |
|
314 | + foreach ($toUnset as $name) { |
|
315 | + unset ($this->objects[$name]); |
|
316 | + } |
|
316 | 317 | |
317 | 318 | $this->doAction ('delete'); |
318 | 319 | |
319 | - foreach ($this->objects as $objectName => $object) |
|
320 | - if (!is_int ($this->getComponentByName ($objectName))) |
|
321 | - unset ($this->objects[$objectName]); |
|
320 | + foreach ($this->objects as $objectName => $object) { |
|
321 | + if (!is_int ($this->getComponentByName ($objectName))) |
|
322 | + unset ($this->objects[$objectName]); |
|
323 | + } |
|
322 | 324 | |
323 | 325 | $this->currentSelectedItem->items->clear (); |
324 | 326 | $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
@@ -327,8 +329,9 @@ discard block |
||
327 | 329 | |
328 | 330 | public function renameComponent (int $component, string $name, string $fromName = null): void |
329 | 331 | { |
330 | - if ($fromName === null) |
|
331 | - $fromName = $this->getComponentName ($component); |
|
332 | + if ($fromName === null) { |
|
333 | + $fromName = $this->getComponentName ($component); |
|
334 | + } |
|
332 | 335 | |
333 | 336 | $info = $this->objects[$fromName]; |
334 | 337 | unset ($this->objects[$fromName]); |