@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -EngineAdditions::loadModule ('ScintillaNET.dll'); |
|
5 | +EngineAdditions::loadModule('ScintillaNET.dll'); |
|
6 | 6 | |
7 | 7 | class Scintilla extends NoVisual |
8 | 8 | { |
@@ -11,71 +11,71 @@ discard block |
||
11 | 11 | |
12 | 12 | protected $styles; |
13 | 13 | |
14 | - public function __construct (Component $parent = null) |
|
14 | + public function __construct(Component $parent = null) |
|
15 | 15 | { |
16 | - parent::__construct ($parent, $this->class); |
|
16 | + parent::__construct($parent, $this->class); |
|
17 | 17 | |
18 | - $this->styles = $this->getProperty ('Styles'); |
|
18 | + $this->styles = $this->getProperty('Styles'); |
|
19 | 19 | } |
20 | 20 | |
21 | - public function resetSyntax () |
|
21 | + public function resetSyntax() |
|
22 | 22 | { |
23 | - $this->callMethod ('StyleResetDefault'); |
|
23 | + $this->callMethod('StyleResetDefault'); |
|
24 | 24 | } |
25 | 25 | |
26 | - public function clearSyntax () |
|
26 | + public function clearSyntax() |
|
27 | 27 | { |
28 | - $this->callMethod ('StyleClearAll'); |
|
28 | + $this->callMethod('StyleClearAll'); |
|
29 | 29 | } |
30 | 30 | |
31 | - public function setKeywords (int $index, string $keywords) |
|
31 | + public function setKeywords(int $index, string $keywords) |
|
32 | 32 | { |
33 | - $this->callMethod ('SetKeywords', [$index, 'int'], [$keywords, 'string']); |
|
33 | + $this->callMethod('SetKeywords', [$index, 'int'], [$keywords, 'string']); |
|
34 | 34 | } |
35 | 35 | |
36 | - public function propertyInit (string $propertyName, $propertyValue) |
|
36 | + public function propertyInit(string $propertyName, $propertyValue) |
|
37 | 37 | { |
38 | - $this->callMethod ('SetProperty', [$propertyName, 'string'], [$propertyValue, 'string']); |
|
38 | + $this->callMethod('SetProperty', [$propertyName, 'string'], [$propertyValue, 'string']); |
|
39 | 39 | } |
40 | 40 | |
41 | - public function set_syntax ($syntax) |
|
41 | + public function set_syntax($syntax) |
|
42 | 42 | { |
43 | - if (file_exists ($syntax)) |
|
44 | - $syntax = file_get_contents ($syntax); |
|
43 | + if (file_exists($syntax)) |
|
44 | + $syntax = file_get_contents($syntax); |
|
45 | 45 | |
46 | - $syntax = json_decode ($syntax, true); |
|
46 | + $syntax = json_decode($syntax, true); |
|
47 | 47 | |
48 | 48 | if ( |
49 | - !is_array ($syntax['syntax']) || |
|
50 | - !is_array ($syntax['references']) || |
|
49 | + !is_array($syntax['syntax']) || |
|
50 | + !is_array($syntax['references']) || |
|
51 | 51 | !isset ($syntax['lexer']) |
52 | 52 | ) return false; |
53 | 53 | |
54 | 54 | else |
55 | 55 | { |
56 | - $this->resetSyntax (); |
|
57 | - $this->clearSyntax (); |
|
56 | + $this->resetSyntax(); |
|
57 | + $this->clearSyntax(); |
|
58 | 58 | |
59 | 59 | foreach ($syntax['references'] as $name => $value) |
60 | 60 | if (isset ($syntax['syntax'][$name])) |
61 | 61 | { |
62 | - $element = \VoidCore::getArrayValue ($this->styles, $value); |
|
62 | + $element = \VoidCore::getArrayValue($this->styles, $value); |
|
63 | 63 | $color = $syntax['syntax'][$name]; |
64 | 64 | |
65 | - if (defined ($color)) |
|
66 | - $color = constant ($color); |
|
65 | + if (defined($color)) |
|
66 | + $color = constant($color); |
|
67 | 67 | |
68 | - \VoidCore::setProperty ($element, 'ForeColor', [$color, 'color']); |
|
68 | + \VoidCore::setProperty($element, 'ForeColor', [$color, 'color']); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $this->lexer = $syntax['lexer']; |
72 | 72 | |
73 | - if (is_array ($syntax['keywords'])) |
|
73 | + if (is_array($syntax['keywords'])) |
|
74 | 74 | foreach ($syntax['keywords'] as $id => $keywords) |
75 | - $this->setKeywords ($id, $keywords); |
|
75 | + $this->setKeywords($id, $keywords); |
|
76 | 76 | |
77 | - $this->propertyInit ('fold', 1); |
|
78 | - $this->propertyInit ('fold.compact', 1); |
|
77 | + $this->propertyInit('fold', 1); |
|
78 | + $this->propertyInit('fold.compact', 1); |
|
79 | 79 | |
80 | 80 | return true; |
81 | 81 | } |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | |
41 | 41 | public function set_syntax ($syntax) |
42 | 42 | { |
43 | - if (file_exists ($syntax)) |
|
44 | - $syntax = file_get_contents ($syntax); |
|
43 | + if (file_exists ($syntax)) { |
|
44 | + $syntax = file_get_contents ($syntax); |
|
45 | + } |
|
45 | 46 | |
46 | 47 | $syntax = json_decode ($syntax, true); |
47 | 48 | |
@@ -49,30 +50,33 @@ discard block |
||
49 | 50 | !is_array ($syntax['syntax']) || |
50 | 51 | !is_array ($syntax['references']) || |
51 | 52 | !isset ($syntax['lexer']) |
52 | - ) return false; |
|
53 | - |
|
54 | - else |
|
53 | + ) { |
|
54 | + return false; |
|
55 | + } else |
|
55 | 56 | { |
56 | 57 | $this->resetSyntax (); |
57 | 58 | $this->clearSyntax (); |
58 | 59 | |
59 | - foreach ($syntax['references'] as $name => $value) |
|
60 | - if (isset ($syntax['syntax'][$name])) |
|
60 | + foreach ($syntax['references'] as $name => $value) { |
|
61 | + if (isset ($syntax['syntax'][$name])) |
|
61 | 62 | { |
62 | 63 | $element = \VoidCore::getArrayValue ($this->styles, $value); |
64 | + } |
|
63 | 65 | $color = $syntax['syntax'][$name]; |
64 | 66 | |
65 | - if (defined ($color)) |
|
66 | - $color = constant ($color); |
|
67 | + if (defined ($color)) { |
|
68 | + $color = constant ($color); |
|
69 | + } |
|
67 | 70 | |
68 | 71 | \VoidCore::setProperty ($element, 'ForeColor', [$color, 'color']); |
69 | 72 | } |
70 | 73 | |
71 | 74 | $this->lexer = $syntax['lexer']; |
72 | 75 | |
73 | - if (is_array ($syntax['keywords'])) |
|
74 | - foreach ($syntax['keywords'] as $id => $keywords) |
|
76 | + if (is_array ($syntax['keywords'])) { |
|
77 | + foreach ($syntax['keywords'] as $id => $keywords) |
|
75 | 78 | $this->setKeywords ($id, $keywords); |
79 | + } |
|
76 | 80 | |
77 | 81 | $this->propertyInit ('fold', 1); |
78 | 82 | $this->propertyInit ('fold.compact', 1); |
@@ -11,9 +11,7 @@ |
||
11 | 11 | try |
12 | 12 | { |
13 | 13 | $node = $this->selectedNode; |
14 | - } |
|
15 | - |
|
16 | - catch (\WinFormsException $e) |
|
14 | + } catch (\WinFormsException $e) |
|
17 | 15 | { |
18 | 16 | return false; |
19 | 17 | } |
@@ -24,8 +24,8 @@ |
||
24 | 24 | $this->text = $caption; |
25 | 25 | } |
26 | 26 | |
27 | - public function set_font ($font): void |
|
28 | - { |
|
27 | + public function set_font ($font): void |
|
28 | + { |
|
29 | 29 | if (is_array ($font)) |
30 | 30 | { |
31 | 31 | $font = array_values ($font); |
@@ -6,101 +6,100 @@ discard block |
||
6 | 6 | { |
7 | 7 | public $class = 'System.Windows.Forms.Control'; |
8 | 8 | |
9 | - public function __construct (Component $parent = null, $className = null, ...$args) |
|
9 | + public function __construct(Component $parent = null, $className = null, ...$args) |
|
10 | 10 | { |
11 | - parent::__construct ($className, ...$args); |
|
11 | + parent::__construct($className, ...$args); |
|
12 | 12 | |
13 | 13 | if ($parent) |
14 | 14 | $this->parent = $parent; |
15 | 15 | } |
16 | 16 | |
17 | - public function get_caption (): string |
|
17 | + public function get_caption(): string |
|
18 | 18 | { |
19 | 19 | return $this->text; |
20 | 20 | } |
21 | 21 | |
22 | - public function set_caption (string $caption) |
|
22 | + public function set_caption(string $caption) |
|
23 | 23 | { |
24 | 24 | $this->text = $caption; |
25 | 25 | } |
26 | 26 | |
27 | - public function set_font ($font): void |
|
27 | + public function set_font($font): void |
|
28 | 28 | { |
29 | - if (is_array ($font)) |
|
29 | + if (is_array($font)) |
|
30 | 30 | { |
31 | - $font = array_values ($font); |
|
31 | + $font = array_values($font); |
|
32 | 32 | |
33 | 33 | $obj = isset ($font[2]) ? |
34 | - \VoidCore::createObject ('System.Drawing.Font', 'System.Drawing', $font[0], $font[1], [$font[2], 'System.Drawing.FontStyle, System.Drawing']) : |
|
35 | - \VoidCore::createObject ('System.Drawing.Font', 'System.Drawing', $font[0], $font[1]); |
|
34 | + \VoidCore::createObject('System.Drawing.Font', 'System.Drawing', $font[0], $font[1], [$font[2], 'System.Drawing.FontStyle, System.Drawing']) : \VoidCore::createObject('System.Drawing.Font', 'System.Drawing', $font[0], $font[1]); |
|
36 | 35 | |
37 | - $this->setProperty ('Font', $obj); |
|
36 | + $this->setProperty('Font', $obj); |
|
38 | 37 | } |
39 | 38 | |
40 | - else $this->setProperty ('Font', EngineAdditions::uncoupleSelector ($font)); |
|
39 | + else $this->setProperty('Font', EngineAdditions::uncoupleSelector($font)); |
|
41 | 40 | } |
42 | 41 | |
43 | - public function get_backgroundColor () |
|
42 | + public function get_backgroundColor() |
|
44 | 43 | { |
45 | - return $this->getProperty (['BackColor', 'color']); |
|
44 | + return $this->getProperty(['BackColor', 'color']); |
|
46 | 45 | } |
47 | 46 | |
48 | - public function set_backgroundColor ($color) |
|
47 | + public function set_backgroundColor($color) |
|
49 | 48 | { |
50 | - $this->setProperty ('BackColor', $color); |
|
49 | + $this->setProperty('BackColor', $color); |
|
51 | 50 | } |
52 | 51 | |
53 | - public function get_foregroundColor () |
|
52 | + public function get_foregroundColor() |
|
54 | 53 | { |
55 | - return $this->getProperty (['ForeColor', 'color']); |
|
54 | + return $this->getProperty(['ForeColor', 'color']); |
|
56 | 55 | } |
57 | 56 | |
58 | - public function set_foregroundColor ($color) |
|
57 | + public function set_foregroundColor($color) |
|
59 | 58 | { |
60 | - $this->setProperty ('ForeColor', $color); |
|
59 | + $this->setProperty('ForeColor', $color); |
|
61 | 60 | } |
62 | 61 | |
63 | - public function get_w (): int |
|
62 | + public function get_w(): int |
|
64 | 63 | { |
65 | 64 | return $this->width; |
66 | 65 | } |
67 | 66 | |
68 | - public function set_w (int $w) |
|
67 | + public function set_w(int $w) |
|
69 | 68 | { |
70 | 69 | $this->width = $w; |
71 | 70 | } |
72 | 71 | |
73 | - public function get_h (): int |
|
72 | + public function get_h(): int |
|
74 | 73 | { |
75 | 74 | return $this->height; |
76 | 75 | } |
77 | 76 | |
78 | - public function set_h (int $h) |
|
77 | + public function set_h(int $h) |
|
79 | 78 | { |
80 | 79 | $this->height = $h; |
81 | 80 | } |
82 | 81 | |
83 | - public function get_x (): int |
|
82 | + public function get_x(): int |
|
84 | 83 | { |
85 | 84 | return $this->left; |
86 | 85 | } |
87 | 86 | |
88 | - public function set_x (int $x) |
|
87 | + public function set_x(int $x) |
|
89 | 88 | { |
90 | 89 | $this->left = $x; |
91 | 90 | } |
92 | 91 | |
93 | - public function get_y (): int |
|
92 | + public function get_y(): int |
|
94 | 93 | { |
95 | 94 | return $this->top; |
96 | 95 | } |
97 | 96 | |
98 | - public function set_y (int $y) |
|
97 | + public function set_y(int $y) |
|
99 | 98 | { |
100 | 99 | $this->top = $y; |
101 | 100 | } |
102 | 101 | |
103 | - public function get_bounds (): array |
|
102 | + public function get_bounds(): array |
|
104 | 103 | { |
105 | 104 | return [ |
106 | 105 | $this->left, |
@@ -110,11 +109,11 @@ discard block |
||
110 | 109 | ]; |
111 | 110 | } |
112 | 111 | |
113 | - public function set_bounds ($bounds) |
|
112 | + public function set_bounds($bounds) |
|
114 | 113 | { |
115 | - if (is_array ($bounds)) |
|
114 | + if (is_array($bounds)) |
|
116 | 115 | { |
117 | - $bounds = array_values ($bounds); |
|
116 | + $bounds = array_values($bounds); |
|
118 | 117 | |
119 | 118 | $this->left = (int) $bounds[0]; |
120 | 119 | $this->top = (int) $bounds[1]; |
@@ -122,10 +121,10 @@ discard block |
||
122 | 121 | $this->height = (int) $bounds[3]; |
123 | 122 | } |
124 | 123 | |
125 | - else $this->setProperty ('Bounds', EngineAdditions::uncoupleSelector ($bounds)); |
|
124 | + else $this->setProperty('Bounds', EngineAdditions::uncoupleSelector($bounds)); |
|
126 | 125 | } |
127 | 126 | |
128 | - public function get_location (): array |
|
127 | + public function get_location(): array |
|
129 | 128 | { |
130 | 129 | return [ |
131 | 130 | $this->left, |
@@ -133,20 +132,20 @@ discard block |
||
133 | 132 | ]; |
134 | 133 | } |
135 | 134 | |
136 | - public function set_location ($location) |
|
135 | + public function set_location($location) |
|
137 | 136 | { |
138 | - if (is_array ($location)) |
|
137 | + if (is_array($location)) |
|
139 | 138 | { |
140 | - $location = array_values ($location); |
|
139 | + $location = array_values($location); |
|
141 | 140 | |
142 | 141 | $this->left = $location[0]; |
143 | 142 | $this->top = $location[1]; |
144 | 143 | } |
145 | 144 | |
146 | - else $this->setProperty ('Location', EngineAdditions::uncoupleSelector ($location)); |
|
145 | + else $this->setProperty('Location', EngineAdditions::uncoupleSelector($location)); |
|
147 | 146 | } |
148 | 147 | |
149 | - public function get_size (): array |
|
148 | + public function get_size(): array |
|
150 | 149 | { |
151 | 150 | return [ |
152 | 151 | $this->width, |
@@ -154,42 +153,42 @@ discard block |
||
154 | 153 | ]; |
155 | 154 | } |
156 | 155 | |
157 | - public function set_size ($size) |
|
156 | + public function set_size($size) |
|
158 | 157 | { |
159 | - if (is_array ($size)) |
|
158 | + if (is_array($size)) |
|
160 | 159 | { |
161 | - $size = array_values ($size); |
|
160 | + $size = array_values($size); |
|
162 | 161 | |
163 | 162 | $this->width = (int) $size[0]; |
164 | 163 | $this->height = (int) $size[1]; |
165 | 164 | } |
166 | 165 | |
167 | - else $this->setProperty ('Size', EngineAdditions::uncoupleSelector ($size)); |
|
166 | + else $this->setProperty('Size', EngineAdditions::uncoupleSelector($size)); |
|
168 | 167 | } |
169 | 168 | |
170 | - public function setBounds (int $x, int $y, int $w, int $h) |
|
169 | + public function setBounds(int $x, int $y, int $w, int $h) |
|
171 | 170 | { |
172 | - $this->set_bounds ([$x, $y, $w, $h]); |
|
171 | + $this->set_bounds([$x, $y, $w, $h]); |
|
173 | 172 | } |
174 | 173 | |
175 | - public function setLocation (int $x, int $y) |
|
174 | + public function setLocation(int $x, int $y) |
|
176 | 175 | { |
177 | - $this->set_location ([$x, $y]); |
|
176 | + $this->set_location([$x, $y]); |
|
178 | 177 | } |
179 | 178 | |
180 | - public function setSize (int $w, int $h) |
|
179 | + public function setSize(int $w, int $h) |
|
181 | 180 | { |
182 | - $this->set_size ([$w, $h]); |
|
181 | + $this->set_size([$w, $h]); |
|
183 | 182 | } |
184 | 183 | |
185 | - public function toBack () |
|
184 | + public function toBack() |
|
186 | 185 | { |
187 | - $this->callMethod ('SendToBack'); |
|
186 | + $this->callMethod('SendToBack'); |
|
188 | 187 | } |
189 | 188 | |
190 | - public function toFront () |
|
189 | + public function toFront() |
|
191 | 190 | { |
192 | - $this->callMethod ('BringToFront'); |
|
191 | + $this->callMethod('BringToFront'); |
|
193 | 192 | } |
194 | 193 | } |
195 | 194 |
@@ -10,8 +10,9 @@ discard block |
||
10 | 10 | { |
11 | 11 | parent::__construct ($className, ...$args); |
12 | 12 | |
13 | - if ($parent) |
|
14 | - $this->parent = $parent; |
|
13 | + if ($parent) { |
|
14 | + $this->parent = $parent; |
|
15 | + } |
|
15 | 16 | } |
16 | 17 | |
17 | 18 | public function get_caption (): string |
@@ -35,9 +36,9 @@ discard block |
||
35 | 36 | \VoidCore::createObject ('System.Drawing.Font', 'System.Drawing', $font[0], $font[1]); |
36 | 37 | |
37 | 38 | $this->setProperty ('Font', $obj); |
39 | + } else { |
|
40 | + $this->setProperty ('Font', EngineAdditions::uncoupleSelector ($font)); |
|
38 | 41 | } |
39 | - |
|
40 | - else $this->setProperty ('Font', EngineAdditions::uncoupleSelector ($font)); |
|
41 | 42 | } |
42 | 43 | |
43 | 44 | public function get_backgroundColor () |
@@ -120,9 +121,9 @@ discard block |
||
120 | 121 | $this->top = (int) $bounds[1]; |
121 | 122 | $this->width = (int) $bounds[2]; |
122 | 123 | $this->height = (int) $bounds[3]; |
124 | + } else { |
|
125 | + $this->setProperty ('Bounds', EngineAdditions::uncoupleSelector ($bounds)); |
|
123 | 126 | } |
124 | - |
|
125 | - else $this->setProperty ('Bounds', EngineAdditions::uncoupleSelector ($bounds)); |
|
126 | 127 | } |
127 | 128 | |
128 | 129 | public function get_location (): array |
@@ -141,9 +142,9 @@ discard block |
||
141 | 142 | |
142 | 143 | $this->left = $location[0]; |
143 | 144 | $this->top = $location[1]; |
145 | + } else { |
|
146 | + $this->setProperty ('Location', EngineAdditions::uncoupleSelector ($location)); |
|
144 | 147 | } |
145 | - |
|
146 | - else $this->setProperty ('Location', EngineAdditions::uncoupleSelector ($location)); |
|
147 | 148 | } |
148 | 149 | |
149 | 150 | public function get_size (): array |
@@ -162,9 +163,9 @@ discard block |
||
162 | 163 | |
163 | 164 | $this->width = (int) $size[0]; |
164 | 165 | $this->height = (int) $size[1]; |
166 | + } else { |
|
167 | + $this->setProperty ('Size', EngineAdditions::uncoupleSelector ($size)); |
|
165 | 168 | } |
166 | - |
|
167 | - else $this->setProperty ('Size', EngineAdditions::uncoupleSelector ($size)); |
|
168 | 169 | } |
169 | 170 | |
170 | 171 | public function setBounds (int $x, int $y, int $w, int $h) |
@@ -4,48 +4,48 @@ |
||
4 | 4 | |
5 | 5 | class PictureBox extends Control |
6 | 6 | { |
7 | - public $class = 'System.Windows.Forms.PictureBox'; |
|
7 | + public $class = 'System.Windows.Forms.PictureBox'; |
|
8 | 8 | |
9 | - protected $image; |
|
9 | + protected $image; |
|
10 | 10 | |
11 | - public function __construct (Component $parent = null) |
|
12 | - { |
|
11 | + public function __construct (Component $parent = null) |
|
12 | + { |
|
13 | 13 | parent::__construct ($parent, $this->class); |
14 | 14 | |
15 | - $this->image = new PictureBoxImage ($this->selector); |
|
16 | - } |
|
15 | + $this->image = new PictureBoxImage ($this->selector); |
|
16 | + } |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | class PictureBoxImage |
20 | 20 | { |
21 | - protected $selector; |
|
21 | + protected $selector; |
|
22 | 22 | protected $pictureBoxSelector; |
23 | 23 | protected $clipboard; |
24 | 24 | |
25 | - public function __construct (int $pictureBoxSelector) |
|
26 | - { |
|
27 | - $this->pictureBoxSelector = $pictureBoxSelector; |
|
28 | - $this->selector = \VoidCore::getProperty ($pictureBoxSelector, 'Image'); |
|
29 | - $this->clipboard = new WFClass ('System.Windows.Forms.Clipboard'); |
|
30 | - } |
|
25 | + public function __construct (int $pictureBoxSelector) |
|
26 | + { |
|
27 | + $this->pictureBoxSelector = $pictureBoxSelector; |
|
28 | + $this->selector = \VoidCore::getProperty ($pictureBoxSelector, 'Image'); |
|
29 | + $this->clipboard = new WFClass ('System.Windows.Forms.Clipboard'); |
|
30 | + } |
|
31 | 31 | |
32 | - public function loadFromFile (string $file) |
|
33 | - { |
|
32 | + public function loadFromFile (string $file) |
|
33 | + { |
|
34 | 34 | \VoidCore::setProperty ($this->pictureBoxSelector, 'Image', (new Image ())->loadFromFile ($file)->selector); |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - public function saveToFile (string $file) |
|
38 | - { |
|
39 | - \VoidCore::callMethod ($this->selector, 'Save', $file); |
|
40 | - } |
|
37 | + public function saveToFile (string $file) |
|
38 | + { |
|
39 | + \VoidCore::callMethod ($this->selector, 'Save', $file); |
|
40 | + } |
|
41 | 41 | |
42 | - public function loadFromClipboard () |
|
43 | - { |
|
44 | - \VoidCore::setProperty ($this->pictureBoxSelector, 'Image', $this->clipboard->getImage ()); |
|
45 | - } |
|
42 | + public function loadFromClipboard () |
|
43 | + { |
|
44 | + \VoidCore::setProperty ($this->pictureBoxSelector, 'Image', $this->clipboard->getImage ()); |
|
45 | + } |
|
46 | 46 | |
47 | - public function saveToClipboard () |
|
48 | - { |
|
49 | - $this->clipboard->setImage (\VoidCore::getProperty ($this->pictureBoxSelector, 'Image')); |
|
50 | - } |
|
47 | + public function saveToClipboard () |
|
48 | + { |
|
49 | + $this->clipboard->setImage (\VoidCore::getProperty ($this->pictureBoxSelector, 'Image')); |
|
50 | + } |
|
51 | 51 | } |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | |
9 | 9 | protected $image; |
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->image = new PictureBoxImage ($this->selector); |
|
15 | + $this->image = new PictureBoxImage($this->selector); |
|
16 | 16 | } |
17 | 17 | } |
18 | 18 | |
@@ -22,30 +22,30 @@ discard block |
||
22 | 22 | protected $pictureBoxSelector; |
23 | 23 | protected $clipboard; |
24 | 24 | |
25 | - public function __construct (int $pictureBoxSelector) |
|
25 | + public function __construct(int $pictureBoxSelector) |
|
26 | 26 | { |
27 | 27 | $this->pictureBoxSelector = $pictureBoxSelector; |
28 | - $this->selector = \VoidCore::getProperty ($pictureBoxSelector, 'Image'); |
|
29 | - $this->clipboard = new WFClass ('System.Windows.Forms.Clipboard'); |
|
28 | + $this->selector = \VoidCore::getProperty($pictureBoxSelector, 'Image'); |
|
29 | + $this->clipboard = new WFClass('System.Windows.Forms.Clipboard'); |
|
30 | 30 | } |
31 | 31 | |
32 | - public function loadFromFile (string $file) |
|
32 | + public function loadFromFile(string $file) |
|
33 | 33 | { |
34 | - \VoidCore::setProperty ($this->pictureBoxSelector, 'Image', (new Image ())->loadFromFile ($file)->selector); |
|
34 | + \VoidCore::setProperty($this->pictureBoxSelector, 'Image', (new Image())->loadFromFile($file)->selector); |
|
35 | 35 | } |
36 | 36 | |
37 | - public function saveToFile (string $file) |
|
37 | + public function saveToFile(string $file) |
|
38 | 38 | { |
39 | - \VoidCore::callMethod ($this->selector, 'Save', $file); |
|
39 | + \VoidCore::callMethod($this->selector, 'Save', $file); |
|
40 | 40 | } |
41 | 41 | |
42 | - public function loadFromClipboard () |
|
42 | + public function loadFromClipboard() |
|
43 | 43 | { |
44 | - \VoidCore::setProperty ($this->pictureBoxSelector, 'Image', $this->clipboard->getImage ()); |
|
44 | + \VoidCore::setProperty($this->pictureBoxSelector, 'Image', $this->clipboard->getImage()); |
|
45 | 45 | } |
46 | 46 | |
47 | - public function saveToClipboard () |
|
47 | + public function saveToClipboard() |
|
48 | 48 | { |
49 | - $this->clipboard->setImage (\VoidCore::getProperty ($this->pictureBoxSelector, 'Image')); |
|
49 | + $this->clipboard->setImage(\VoidCore::getProperty($this->pictureBoxSelector, 'Image')); |
|
50 | 50 | } |
51 | 51 | } |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | const ENGINE_VERSION = '3.5.8 build-2019/09/22'; |
37 | 37 | const ENGINE_DIR = __DIR__; |
38 | 38 | |
39 | -chdir (ENGINE_DIR); |
|
39 | +chdir(ENGINE_DIR); |
|
40 | 40 | |
41 | 41 | $GLOBALS['__debug'] = [ |
42 | - 'start_time' => microtime (true), |
|
42 | + 'start_time' => microtime(true), |
|
43 | 43 | 'error_status' => true |
44 | 44 | ]; |
45 | 45 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | require 'common/Others.php'; |
50 | 50 | require 'common/Events.php'; |
51 | 51 | |
52 | -define ('VoidEngine\CORE_VERSION', $APPLICATION->productVersion); |
|
52 | +define('VoidEngine\CORE_VERSION', $APPLICATION->productVersion); |
|
53 | 53 | |
54 | 54 | require 'components/Component.php'; |
55 | 55 | require 'components/Control.php'; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | require 'components/FastColoredTextBox.php'; |
97 | 97 | require 'components/Scintilla.php'; |
98 | 98 | |
99 | -if (is_dir ('extensions')) |
|
100 | - foreach (scandir ('extensions') as $ext) |
|
101 | - if (is_dir ('extensions/'. $ext) && file_exists ($ext = 'extensions/'. $ext .'/main.php')) |
|
99 | +if (is_dir('extensions')) |
|
100 | + foreach (scandir('extensions') as $ext) |
|
101 | + if (is_dir('extensions/'.$ext) && file_exists($ext = 'extensions/'.$ext.'/main.php')) |
|
102 | 102 | require $ext; |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | * @return array - возвращает список созданных объектов |
21 | 21 | */ |
22 | 22 | |
23 | - public static function run ($syntaxTree, string $resourcesDir = null, array $parent = null): array |
|
23 | + public static function run($syntaxTree, string $resourcesDir = null, array $parent = null): array |
|
24 | 24 | { |
25 | 25 | if ($syntaxTree instanceof VLFParser) |
26 | 26 | $syntaxTree = $syntaxTree->tree; |
27 | 27 | |
28 | - elseif (!is_array ($syntaxTree) && self::$throw_errors) |
|
29 | - throw new \Exception ('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
28 | + elseif (!is_array($syntaxTree) && self::$throw_errors) |
|
29 | + throw new \Exception('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
30 | 30 | |
31 | 31 | foreach ($syntaxTree as $id => $syntaxInfo) |
32 | 32 | if (isset ($syntaxInfo['type'])) |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | $args = $syntaxInfo['info']['arguments']; |
44 | 44 | |
45 | 45 | foreach ($args as $arg_id => $arg) |
46 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
46 | + if (is_object($arg) && $arg instanceof VLFLink) |
|
47 | 47 | $args[$arg_id] = isset (self::$objects[$arg->name]) ? |
48 | - self::formatLine ($arg->name, self::$objects) : null; |
|
48 | + self::formatLine($arg->name, self::$objects) : null; |
|
49 | 49 | |
50 | - else $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
50 | + else $args[$arg_id] = self::formatLine($arg, self::$objects); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | try |
54 | 54 | { |
55 | - self::$objects[$name] = eval ("namespace VoidEngine; return new $class (". implode (', ', $args) .");"); |
|
55 | + self::$objects[$name] = eval ("namespace VoidEngine; return new $class (".implode(', ', $args).");"); |
|
56 | 56 | |
57 | 57 | try |
58 | 58 | { |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | catch (\Throwable $e) |
66 | 66 | { |
67 | 67 | if (self::$throw_errors) |
68 | - throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
68 | + throw new \Exception('Interpeter couldn\'t create object "'.$class.'" with name "'.$name.'" at line "'.$syntaxInfo['line'].'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
69 | 69 | } |
70 | 70 | break; |
71 | 71 | |
72 | 72 | case VLF_SUBOBJECT_DEFINITION: |
73 | - self::$objects = self::run ((new VLFParser ($syntaxInfo['info']['object_vlf_info']))->tree, null, $syntaxInfo); |
|
73 | + self::$objects = self::run((new VLFParser($syntaxInfo['info']['object_vlf_info']))->tree, null, $syntaxInfo); |
|
74 | 74 | break; |
75 | 75 | |
76 | 76 | case VLF_PROPERTY_SET: |
@@ -80,34 +80,34 @@ discard block |
||
80 | 80 | $propertyValue = $syntaxInfo['info']['property_value']; |
81 | 81 | $preset = ''; |
82 | 82 | |
83 | - if (is_object ($propertyValue) && $propertyValue instanceof VLFLink) |
|
83 | + if (is_object($propertyValue) && $propertyValue instanceof VLFLink) |
|
84 | 84 | $propertyValue = isset (self::$objects[$propertyValue->name]) ? |
85 | - self::formatLine ($propertyValue->name, self::$objects) : null; |
|
85 | + self::formatLine($propertyValue->name, self::$objects) : null; |
|
86 | 86 | |
87 | - elseif (preg_match ('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
87 | + elseif (preg_match('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
88 | 88 | { |
89 | - $use = substr ($propertyValue, strpos ($propertyValue, 'use')); |
|
90 | - $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos); |
|
91 | - $use = explode (' ', $use); |
|
89 | + $use = substr($propertyValue, strpos($propertyValue, 'use')); |
|
90 | + $use = $ouse = substr($use, ($pos = strpos($use, '(') + 1), strpos($use, ')') - $pos); |
|
91 | + $use = explode(' ', $use); |
|
92 | 92 | |
93 | 93 | foreach ($use as $id => $useParam) |
94 | 94 | if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
95 | 95 | { |
96 | 96 | $fname = $use[$id + 1]; |
97 | 97 | |
98 | - if (substr ($fname, strlen ($fname) - 1) == ',') |
|
99 | - $fname = substr ($fname, 0, -1); |
|
98 | + if (substr($fname, strlen($fname) - 1) == ',') |
|
99 | + $fname = substr($fname, 0, -1); |
|
100 | 100 | |
101 | 101 | $preset .= "$fname = $useParam; "; |
102 | 102 | |
103 | 103 | unset ($use[$id]); |
104 | 104 | } |
105 | 105 | |
106 | - $preset = self::formatLine ($preset, self::$objects); |
|
107 | - $propertyValue = self::formatLine (str_replace ($ouse, join (' ', $use), $propertyValue), self::$objects); |
|
106 | + $preset = self::formatLine($preset, self::$objects); |
|
107 | + $propertyValue = self::formatLine(str_replace($ouse, join(' ', $use), $propertyValue), self::$objects); |
|
108 | 108 | } |
109 | 109 | |
110 | - else $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
110 | + else $propertyValue = self::formatLine($propertyValue, self::$objects); |
|
111 | 111 | |
112 | 112 | try |
113 | 113 | { |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | { |
121 | 121 | $propertyValue = $syntaxInfo['info']['property_raw_value']; |
122 | 122 | |
123 | - if (strpos ($propertyName, '->') !== false) |
|
124 | - eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';'); |
|
123 | + if (strpos($propertyName, '->') !== false) |
|
124 | + eval ('namespace VoidEngine; '.$preset.' _c('.self::$objects[$name]->selector.')->'.$propertyName.' = '.$propertyValue.';'); |
|
125 | 125 | |
126 | 126 | else self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
127 | 127 | } |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | catch (\Throwable $e) |
130 | 130 | { |
131 | 131 | if (self::$throw_errors) |
132 | - throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
132 | + throw new \Exception('Interpeter couldn\'t set property "'.$propertyName.'" with value "'.$propertyValue.'" at line "'.$syntaxInfo['line'].'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | 137 | elseif (self::$throw_errors) |
138 | - throw new \Exception ('Setting property to an non-object at line "'. $syntaxInfo['line']); |
|
138 | + throw new \Exception('Setting property to an non-object at line "'.$syntaxInfo['line']); |
|
139 | 139 | break; |
140 | 140 | |
141 | 141 | case VLF_METHOD_CALL: |
@@ -145,61 +145,61 @@ discard block |
||
145 | 145 | $methodArgs = $syntaxInfo['info']['method_arguments']; |
146 | 146 | |
147 | 147 | foreach ($methodArgs as $arg_id => $arg) |
148 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
148 | + if (is_object($arg) && $arg instanceof VLFLink) |
|
149 | 149 | $methodArgs[$arg_id] = isset (self::$objects[$arg->name]) ? |
150 | - self::formatLine ($arg->name, self::$objects) : null; |
|
150 | + self::formatLine($arg->name, self::$objects) : null; |
|
151 | 151 | |
152 | - else $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
152 | + else $methodArgs[$arg_id] = self::formatLine($arg, self::$objects); |
|
153 | 153 | |
154 | 154 | try |
155 | 155 | { |
156 | - if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
157 | - eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
156 | + if (strpos($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
157 | + eval ('namespace VoidEngine; _c('.self::$objects[$name]->selector.')->'.$methodName.' ('.implode(', ', $methodArgs).');'); |
|
158 | 158 | |
159 | - elseif (sizeof ($methodArgs) > 0) |
|
160 | - self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
159 | + elseif (sizeof($methodArgs) > 0) |
|
160 | + self::$objects[$name]->$methodName(...eval ('namespace VoidEngine; return ['.implode(', ', $methodArgs).'];')); |
|
161 | 161 | |
162 | - else self::$objects[$name]->$methodName (); |
|
162 | + else self::$objects[$name]->$methodName(); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | catch (\Throwable $e) |
166 | 166 | { |
167 | 167 | if (self::$throw_errors) |
168 | - throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
168 | + throw new \Exception('Interpeter couldn\'t call method "'.$methodName.'" with arguments '.json_encode($methodArgs).' at line "'.$syntaxInfo['line'].'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | 172 | elseif (self::$throw_errors) |
173 | - throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
173 | + throw new \Exception('Calling method to an non-object at line "'.$syntaxInfo['line'].'"'); |
|
174 | 174 | break; |
175 | 175 | |
176 | 176 | case VLF_RUNTIME_EXECUTABLE: |
177 | - eval (self::formatLine ($syntaxInfo['info']['code'], self::$objects)); |
|
177 | + eval (self::formatLine($syntaxInfo['info']['code'], self::$objects)); |
|
178 | 178 | break; |
179 | 179 | } |
180 | 180 | |
181 | - if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) |
|
182 | - self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
181 | + if (isset ($syntaxInfo['syntax_nodes']) && sizeof($syntaxInfo['syntax_nodes']) > 0) |
|
182 | + self::$objects = self::run($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
183 | 183 | } |
184 | 184 | |
185 | - else throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
185 | + else throw new \Exception('Catched unknown syntax node: "'.json_encode($syntaxInfo).'"'); |
|
186 | 186 | |
187 | - if (is_dir ($resourcesDir)) |
|
188 | - foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
187 | + if (is_dir($resourcesDir)) |
|
188 | + foreach (glob($resourcesDir.'/*.vrsf') as $id => $dir) |
|
189 | 189 | { |
190 | - $baseName = basenameNoExt ($dir); |
|
191 | - $info = explode ('.', $baseName); |
|
190 | + $baseName = basenameNoExt($dir); |
|
191 | + $info = explode('.', $baseName); |
|
192 | 192 | |
193 | 193 | if (isset (self::$objects[$info[0]])) |
194 | 194 | { |
195 | 195 | if (isset ($info[2])) |
196 | 196 | { |
197 | - $collection = \VoidCore::getProperty (self::$objects[$info[0]]->selector, $info[1]); |
|
197 | + $collection = \VoidCore::getProperty(self::$objects[$info[0]]->selector, $info[1]); |
|
198 | 198 | |
199 | - \VoidCore::callMethod ($collection, 'Add', [\VoidCore::importObject (base64_encode (file_get_contents ($dir))), 'object']); |
|
199 | + \VoidCore::callMethod($collection, 'Add', [\VoidCore::importObject(base64_encode(file_get_contents($dir))), 'object']); |
|
200 | 200 | } |
201 | 201 | |
202 | - else \VoidCore::setProperty (self::$objects[$info[0]]->selector, $info[1], \VoidCore::importObject (base64_encode (file_get_contents ($dir)))); |
|
202 | + else \VoidCore::setProperty(self::$objects[$info[0]]->selector, $info[1], \VoidCore::importObject(base64_encode(file_get_contents($dir)))); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
@@ -216,26 +216,25 @@ discard block |
||
216 | 216 | * @return string - возвращает форматированную строку |
217 | 217 | */ |
218 | 218 | |
219 | - public static function formatLine (string $line, array $objects = []): string |
|
219 | + public static function formatLine(string $line, array $objects = []): string |
|
220 | 220 | { |
221 | - if (sizeof ($objects) > 0) |
|
221 | + if (sizeof($objects) > 0) |
|
222 | 222 | { |
223 | - $len = strlen ($line); |
|
223 | + $len = strlen($line); |
|
224 | 224 | $newLine = ''; |
225 | 225 | |
226 | - $replacement = array_map (function ($object) |
|
226 | + $replacement = array_map(function($object) |
|
227 | 227 | { |
228 | - return Components::componentExists ($object->selector) !== false ? |
|
229 | - '\VoidEngine\_c('. $object->selector .')' : |
|
230 | - 'unserialize (\''. serialize ($object) .'\')'; |
|
228 | + return Components::componentExists($object->selector) !== false ? |
|
229 | + '\VoidEngine\_c('.$object->selector.')' : 'unserialize (\''.serialize($object).'\')'; |
|
231 | 230 | }, $objects); |
232 | 231 | |
233 | - $replacement = array_map (function ($name) |
|
232 | + $replacement = array_map(function($name) |
|
234 | 233 | { |
235 | - return strlen ($name = trim ($name)) + substr_count ($name, '_'); |
|
236 | - }, $omap = array_flip ($replacement)); |
|
234 | + return strlen($name = trim($name)) + substr_count($name, '_'); |
|
235 | + }, $omap = array_flip($replacement)); |
|
237 | 236 | |
238 | - arsort ($replacement); |
|
237 | + arsort($replacement); |
|
239 | 238 | |
240 | 239 | $nReplacement = []; |
241 | 240 | |
@@ -243,14 +242,14 @@ discard block |
||
243 | 242 | $nReplacement[$omap[$replaceTo]] = $replaceTo; |
244 | 243 | |
245 | 244 | $replacement = $nReplacement; |
246 | - $blacklist = array_flip (['\'', '"', '$']); |
|
245 | + $blacklist = array_flip(['\'', '"', '$']); |
|
247 | 246 | |
248 | 247 | for ($i = 0; $i < $len; ++$i) |
249 | 248 | { |
250 | 249 | $replaced = false; |
251 | 250 | |
252 | 251 | foreach ($replacement as $name => $replaceAt) |
253 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
252 | + if (substr($line, $i, ($l = strlen($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
254 | 253 | { |
255 | 254 | $newLine .= $replaceAt; |
256 | 255 |
@@ -22,19 +22,20 @@ discard block |
||
22 | 22 | |
23 | 23 | public static function run ($syntaxTree, string $resourcesDir = null, array $parent = null): array |
24 | 24 | { |
25 | - if ($syntaxTree instanceof VLFParser) |
|
26 | - $syntaxTree = $syntaxTree->tree; |
|
27 | - |
|
28 | - elseif (!is_array ($syntaxTree) && self::$throw_errors) |
|
29 | - throw new \Exception ('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
25 | + if ($syntaxTree instanceof VLFParser) { |
|
26 | + $syntaxTree = $syntaxTree->tree; |
|
27 | + } elseif (!is_array ($syntaxTree) && self::$throw_errors) { |
|
28 | + throw new \Exception ('$syntaxTree argument must be instance of VoidEngine\VLFParser or contains Abstract Syntax Tree - multi-dimensional array'); |
|
29 | + } |
|
30 | 30 | |
31 | - foreach ($syntaxTree as $id => $syntaxInfo) |
|
32 | - if (isset ($syntaxInfo['type'])) |
|
31 | + foreach ($syntaxTree as $id => $syntaxInfo) { |
|
32 | + if (isset ($syntaxInfo['type'])) |
|
33 | 33 | { |
34 | 34 | switch ($syntaxInfo['type']) |
35 | 35 | { |
36 | 36 | case VLF_OBJECT_DEFINITION: |
37 | 37 | $class = $syntaxInfo['info']['object_class']; |
38 | + } |
|
38 | 39 | $name = $syntaxInfo['info']['object_name']; |
39 | 40 | $args = []; |
40 | 41 | |
@@ -42,12 +43,15 @@ discard block |
||
42 | 43 | { |
43 | 44 | $args = $syntaxInfo['info']['arguments']; |
44 | 45 | |
45 | - foreach ($args as $arg_id => $arg) |
|
46 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
46 | + foreach ($args as $arg_id => $arg) { |
|
47 | + if (is_object ($arg) && $arg instanceof VLFLink) |
|
47 | 48 | $args[$arg_id] = isset (self::$objects[$arg->name]) ? |
48 | 49 | self::formatLine ($arg->name, self::$objects) : null; |
50 | + } |
|
49 | 51 | |
50 | - else $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
52 | + else { |
|
53 | + $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
54 | + } |
|
51 | 55 | } |
52 | 56 | |
53 | 57 | try |
@@ -57,15 +61,12 @@ discard block |
||
57 | 61 | try |
58 | 62 | { |
59 | 63 | self::$objects[$name]->name = $name; |
60 | - } |
|
61 | - |
|
62 | - catch (\Throwable $e) {} |
|
63 | - } |
|
64 | - |
|
65 | - catch (\Throwable $e) |
|
64 | + } catch (\Throwable $e) {} |
|
65 | + } catch (\Throwable $e) |
|
66 | 66 | { |
67 | - if (self::$throw_errors) |
|
68 | - throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
67 | + if (self::$throw_errors) { |
|
68 | + throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
69 | + } |
|
69 | 70 | } |
70 | 71 | break; |
71 | 72 | |
@@ -80,23 +81,24 @@ discard block |
||
80 | 81 | $propertyValue = $syntaxInfo['info']['property_value']; |
81 | 82 | $preset = ''; |
82 | 83 | |
83 | - if (is_object ($propertyValue) && $propertyValue instanceof VLFLink) |
|
84 | - $propertyValue = isset (self::$objects[$propertyValue->name]) ? |
|
84 | + if (is_object ($propertyValue) && $propertyValue instanceof VLFLink) { |
|
85 | + $propertyValue = isset (self::$objects[$propertyValue->name]) ? |
|
85 | 86 | self::formatLine ($propertyValue->name, self::$objects) : null; |
86 | - |
|
87 | - elseif (preg_match ('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
87 | + } elseif (preg_match ('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
88 | 88 | { |
89 | 89 | $use = substr ($propertyValue, strpos ($propertyValue, 'use')); |
90 | 90 | $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos); |
91 | 91 | $use = explode (' ', $use); |
92 | 92 | |
93 | - foreach ($use as $id => $useParam) |
|
94 | - if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
|
93 | + foreach ($use as $id => $useParam) { |
|
94 | + if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
|
95 | 95 | { |
96 | 96 | $fname = $use[$id + 1]; |
97 | + } |
|
97 | 98 | |
98 | - if (substr ($fname, strlen ($fname) - 1) == ',') |
|
99 | - $fname = substr ($fname, 0, -1); |
|
99 | + if (substr ($fname, strlen ($fname) - 1) == ',') { |
|
100 | + $fname = substr ($fname, 0, -1); |
|
101 | + } |
|
100 | 102 | |
101 | 103 | $preset .= "$fname = $useParam; "; |
102 | 104 | |
@@ -105,37 +107,34 @@ discard block |
||
105 | 107 | |
106 | 108 | $preset = self::formatLine ($preset, self::$objects); |
107 | 109 | $propertyValue = self::formatLine (str_replace ($ouse, join (' ', $use), $propertyValue), self::$objects); |
110 | + } else { |
|
111 | + $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
108 | 112 | } |
109 | 113 | |
110 | - else $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
111 | - |
|
112 | 114 | try |
113 | 115 | { |
114 | 116 | self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
115 | - } |
|
116 | - |
|
117 | - catch (\Throwable $e) |
|
117 | + } catch (\Throwable $e) |
|
118 | 118 | { |
119 | 119 | try |
120 | 120 | { |
121 | 121 | $propertyValue = $syntaxInfo['info']['property_raw_value']; |
122 | 122 | |
123 | - if (strpos ($propertyName, '->') !== false) |
|
124 | - eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';'); |
|
125 | - |
|
126 | - else self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
|
127 | - } |
|
128 | - |
|
129 | - catch (\Throwable $e) |
|
123 | + if (strpos ($propertyName, '->') !== false) { |
|
124 | + eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';'); |
|
125 | + } else { |
|
126 | + self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
|
127 | + } |
|
128 | + } catch (\Throwable $e) |
|
130 | 129 | { |
131 | - if (self::$throw_errors) |
|
132 | - throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
130 | + if (self::$throw_errors) { |
|
131 | + throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
132 | + } |
|
133 | 133 | } |
134 | 134 | } |
135 | + } elseif (self::$throw_errors) { |
|
136 | + throw new \Exception ('Setting property to an non-object at line "'. $syntaxInfo['line']); |
|
135 | 137 | } |
136 | - |
|
137 | - elseif (self::$throw_errors) |
|
138 | - throw new \Exception ('Setting property to an non-object at line "'. $syntaxInfo['line']); |
|
139 | 138 | break; |
140 | 139 | |
141 | 140 | case VLF_METHOD_CALL: |
@@ -144,33 +143,34 @@ discard block |
||
144 | 143 | $methodName = $syntaxInfo['info']['method_name']; |
145 | 144 | $methodArgs = $syntaxInfo['info']['method_arguments']; |
146 | 145 | |
147 | - foreach ($methodArgs as $arg_id => $arg) |
|
148 | - if (is_object ($arg) && $arg instanceof VLFLink) |
|
146 | + foreach ($methodArgs as $arg_id => $arg) { |
|
147 | + if (is_object ($arg) && $arg instanceof VLFLink) |
|
149 | 148 | $methodArgs[$arg_id] = isset (self::$objects[$arg->name]) ? |
150 | 149 | self::formatLine ($arg->name, self::$objects) : null; |
150 | + } |
|
151 | 151 | |
152 | - else $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
152 | + else { |
|
153 | + $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
154 | + } |
|
153 | 155 | |
154 | 156 | try |
155 | 157 | { |
156 | - if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
157 | - eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
158 | - |
|
159 | - elseif (sizeof ($methodArgs) > 0) |
|
160 | - self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
161 | - |
|
162 | - else self::$objects[$name]->$methodName (); |
|
163 | - } |
|
164 | - |
|
165 | - catch (\Throwable $e) |
|
158 | + if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) { |
|
159 | + eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
160 | + } elseif (sizeof ($methodArgs) > 0) { |
|
161 | + self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
162 | + } else { |
|
163 | + self::$objects[$name]->$methodName (); |
|
164 | + } |
|
165 | + } catch (\Throwable $e) |
|
166 | 166 | { |
167 | - if (self::$throw_errors) |
|
168 | - throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
167 | + if (self::$throw_errors) { |
|
168 | + throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $syntaxInfo['line'] .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
169 | + } |
|
169 | 170 | } |
171 | + } elseif (self::$throw_errors) { |
|
172 | + throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
170 | 173 | } |
171 | - |
|
172 | - elseif (self::$throw_errors) |
|
173 | - throw new \Exception ('Calling method to an non-object at line "'. $syntaxInfo['line'] .'"'); |
|
174 | 174 | break; |
175 | 175 | |
176 | 176 | case VLF_RUNTIME_EXECUTABLE: |
@@ -178,16 +178,18 @@ discard block |
||
178 | 178 | break; |
179 | 179 | } |
180 | 180 | |
181 | - if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) |
|
182 | - self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
181 | + if (isset ($syntaxInfo['syntax_nodes']) && sizeof ($syntaxInfo['syntax_nodes']) > 0) { |
|
182 | + self::$objects = self::run ($syntaxInfo['syntax_nodes'], null, $syntaxInfo); |
|
183 | + } |
|
184 | + } else { |
|
185 | + throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
183 | 186 | } |
184 | 187 | |
185 | - else throw new \Exception ('Catched unknown syntax node: "'. json_encode ($syntaxInfo) .'"'); |
|
186 | - |
|
187 | - if (is_dir ($resourcesDir)) |
|
188 | - foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
188 | + if (is_dir ($resourcesDir)) { |
|
189 | + foreach (glob ($resourcesDir .'/*.vrsf') as $id => $dir) |
|
189 | 190 | { |
190 | 191 | $baseName = basenameNoExt ($dir); |
192 | + } |
|
191 | 193 | $info = explode ('.', $baseName); |
192 | 194 | |
193 | 195 | if (isset (self::$objects[$info[0]])) |
@@ -197,9 +199,9 @@ discard block |
||
197 | 199 | $collection = \VoidCore::getProperty (self::$objects[$info[0]]->selector, $info[1]); |
198 | 200 | |
199 | 201 | \VoidCore::callMethod ($collection, 'Add', [\VoidCore::importObject (base64_encode (file_get_contents ($dir))), 'object']); |
202 | + } else { |
|
203 | + \VoidCore::setProperty (self::$objects[$info[0]]->selector, $info[1], \VoidCore::importObject (base64_encode (file_get_contents ($dir)))); |
|
200 | 204 | } |
201 | - |
|
202 | - else \VoidCore::setProperty (self::$objects[$info[0]]->selector, $info[1], \VoidCore::importObject (base64_encode (file_get_contents ($dir)))); |
|
203 | 205 | } |
204 | 206 | } |
205 | 207 | |
@@ -239,8 +241,9 @@ discard block |
||
239 | 241 | |
240 | 242 | $nReplacement = []; |
241 | 243 | |
242 | - foreach ($replacement as $replaceTo => $nLn) |
|
243 | - $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
244 | + foreach ($replacement as $replaceTo => $nLn) { |
|
245 | + $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
246 | + } |
|
244 | 247 | |
245 | 248 | $replacement = $nReplacement; |
246 | 249 | $blacklist = array_flip (['\'', '"', '$']); |
@@ -249,10 +252,11 @@ discard block |
||
249 | 252 | { |
250 | 253 | $replaced = false; |
251 | 254 | |
252 | - foreach ($replacement as $name => $replaceAt) |
|
253 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
255 | + foreach ($replacement as $name => $replaceAt) { |
|
256 | + if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
254 | 257 | { |
255 | 258 | $newLine .= $replaceAt; |
259 | + } |
|
256 | 260 | |
257 | 261 | $i += $l - 1; |
258 | 262 | $replaced = true; |
@@ -260,8 +264,9 @@ discard block |
||
260 | 264 | break; |
261 | 265 | } |
262 | 266 | |
263 | - if (!$replaced) |
|
264 | - $newLine .= $line[$i]; |
|
267 | + if (!$replaced) { |
|
268 | + $newLine .= $line[$i]; |
|
269 | + } |
|
265 | 270 | } |
266 | 271 | |
267 | 272 | $line = $newLine; |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | * @param string $content - VLF разметка или путь до файла разметки |
24 | 24 | * [@param array $settings = []] - список настроек и их значений (настройка => значение) |
25 | 25 | */ |
26 | - public function __construct (string $content, array $settings = []) |
|
26 | + public function __construct(string $content, array $settings = []) |
|
27 | 27 | { |
28 | - if (file_exists ($content)) |
|
29 | - $content = file_get_contents ($content); |
|
28 | + if (file_exists($content)) |
|
29 | + $content = file_get_contents($content); |
|
30 | 30 | |
31 | 31 | // Зачем? Так надо! |
32 | 32 | $content = "# VLF begin\n\n$content\n\n# VLF end"; |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | if (isset ($this->$name)) |
37 | 37 | $this->$name = $setting; |
38 | 38 | |
39 | - else throw new \Exception ('Trying to setting up undefined property "'. $name .'"'); |
|
39 | + else throw new \Exception('Trying to setting up undefined property "'.$name.'"'); |
|
40 | 40 | } |
41 | 41 | |
42 | - if ($this->use_caching && file_exists ($file = VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache')) |
|
42 | + if ($this->use_caching && file_exists($file = VLF_EXT_DIR.'/cache/'.sha1($content).'.cache')) |
|
43 | 43 | { |
44 | - $info = unserialize (gzinflate (file_get_contents ($file))); |
|
44 | + $info = unserialize(gzinflate(file_get_contents($file))); |
|
45 | 45 | |
46 | - if ($info[0] == sha1 (file_get_contents (__FILE__))) |
|
46 | + if ($info[0] == sha1(file_get_contents(__FILE__))) |
|
47 | 47 | { |
48 | 48 | $this->tree = $info[1][0]; |
49 | 49 | $this->links = $info[1][1]; |
@@ -51,20 +51,20 @@ discard block |
||
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | - else unlink ($file); |
|
54 | + else unlink($file); |
|
55 | 55 | } |
56 | 56 | |
57 | - $info = $this->generateSyntaxTree ($content); |
|
57 | + $info = $this->generateSyntaxTree($content); |
|
58 | 58 | |
59 | 59 | $this->tree = $info[0]; |
60 | 60 | $this->links = $info[1]; |
61 | 61 | |
62 | 62 | if ($this->use_caching) |
63 | 63 | { |
64 | - if (!is_dir (dirname (__DIR__) .'/cache')) |
|
65 | - mkdir (dirname (__DIR__) .'/cache'); |
|
64 | + if (!is_dir(dirname(__DIR__).'/cache')) |
|
65 | + mkdir(dirname(__DIR__).'/cache'); |
|
66 | 66 | |
67 | - file_put_contents (VLF_EXT_DIR .'/cache/'. sha1 ($content) .'.cache', gzdeflate (serialize ([sha1 (file_get_contents (__FILE__)), $info]))); |
|
67 | + file_put_contents(VLF_EXT_DIR.'/cache/'.sha1($content).'.cache', gzdeflate(serialize([sha1(file_get_contents(__FILE__)), $info]))); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return array - возвращает АСД |
78 | 78 | */ |
79 | - protected function generateSyntaxTree (string $content): array |
|
79 | + protected function generateSyntaxTree(string $content): array |
|
80 | 80 | { |
81 | - $lines = $this->linesFilter ($untouched_lines = explode ($this->divider, $content)); |
|
81 | + $lines = $this->linesFilter($untouched_lines = explode($this->divider, $content)); |
|
82 | 82 | $current_object = null; |
83 | 83 | $parent_objects = []; |
84 | 84 | $skip_at = -1; |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | $links = []; |
87 | 87 | |
88 | 88 | if ($this->debug_mode) |
89 | - pre ($lines); |
|
89 | + pre($lines); |
|
90 | 90 | |
91 | 91 | foreach ($lines as $id => $line) |
92 | 92 | { |
93 | 93 | if ($skip_at > $id) |
94 | 94 | continue; |
95 | 95 | |
96 | - $height = $this->getLineHeight ($line); |
|
97 | - $words = $this->linesFilter (explode (' ', $line)); |
|
96 | + $height = $this->getLineHeight($line); |
|
97 | + $words = $this->linesFilter(explode(' ', $line)); |
|
98 | 98 | |
99 | 99 | if ($this->debug_mode) |
100 | - pre ($words); |
|
100 | + pre($words); |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Высокоинтеллектуальный фикс |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $updated = false; |
120 | 120 | |
121 | 121 | if ($this->debug_mode) |
122 | - pre ($current_object); |
|
122 | + pre($current_object); |
|
123 | 123 | |
124 | 124 | while (isset ($tree[$current_object]['info']['subparent_link']) && $tree[$link = $tree[$current_object]['info']['subparent_link']->link]['hard'] < $tree[$current_object]['hard']) |
125 | 125 | { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $updated = true; |
128 | 128 | |
129 | 129 | if ($this->debug_mode) |
130 | - pre ($current_object); |
|
130 | + pre($current_object); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | if ( |
@@ -142,16 +142,16 @@ discard block |
||
142 | 142 | break; |
143 | 143 | |
144 | 144 | if ($this->debug_mode) |
145 | - pre ($current_object); |
|
145 | + pre($current_object); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Button ... |
150 | 150 | */ |
151 | - if (class_exists ($words[0]) || class_exists ('\VoidEngine\\'. $words[0])) |
|
151 | + if (class_exists($words[0]) || class_exists('\VoidEngine\\'.$words[0])) |
|
152 | 152 | { |
153 | 153 | if (!isset ($words[1])) |
154 | - throw new \Exception ('Object name mustn\'t be empty at line "'. $line .'"'); |
|
154 | + throw new \Exception('Object name mustn\'t be empty at line "'.$line.'"'); |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Button NewButton |
@@ -197,40 +197,39 @@ discard block |
||
197 | 197 | 'syntax_nodes' => [] |
198 | 198 | ]; |
199 | 199 | |
200 | - if (($begin = strpos ($line, '(')) !== false) |
|
200 | + if (($begin = strpos($line, '(')) !== false) |
|
201 | 201 | { |
202 | 202 | ++$begin; |
203 | 203 | |
204 | - $end = strrpos ($line, ')'); |
|
204 | + $end = strrpos($line, ')'); |
|
205 | 205 | |
206 | 206 | if ($end === false) |
207 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
207 | + throw new \Exception('Line "'.$line.'" have arguments list initialization, but not have list ending'); |
|
208 | 208 | |
209 | 209 | elseif ($begin < $end) |
210 | 210 | { |
211 | 211 | $arguments = []; |
212 | 212 | // $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
213 | - $parsed = $this->parseArguments (substr ($line, $begin, $end - $begin)); |
|
213 | + $parsed = $this->parseArguments(substr($line, $begin, $end - $begin)); |
|
214 | 214 | |
215 | 215 | foreach ($parsed as $argument_id => $argument) |
216 | 216 | { |
217 | - $argument = trim ($argument); |
|
217 | + $argument = trim($argument); |
|
218 | 218 | |
219 | - if (strlen ($argument) > 0) |
|
219 | + if (strlen($argument) > 0) |
|
220 | 220 | $arguments[] = isset ($links[$argument]) ? |
221 | - new VLFLink ($argument, $links[$argument]) : |
|
222 | - $argument; |
|
221 | + new VLFLink($argument, $links[$argument]) : $argument; |
|
223 | 222 | |
224 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
223 | + else throw new \Exception('Argument '.($argument_id + 1).' mustn\'t have zero length at line "'.$line.'"'); |
|
225 | 224 | } |
226 | 225 | |
227 | 226 | $tree[$id]['info']['arguments'] = $arguments; |
228 | 227 | |
229 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
230 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
228 | + if (!$this->ignore_postobject_info && trim(substr($line, $end)) > 0) |
|
229 | + throw new \Exception('You mustn\'t write any chars after arguments definition'); |
|
231 | 230 | } |
232 | 231 | |
233 | - $tree[$id]['info']['subparent_link'] = new VLFLink ($tree[$current_object]['info']['object_name'], $current_object); |
|
232 | + $tree[$id]['info']['subparent_link'] = new VLFLink($tree[$current_object]['info']['object_name'], $current_object); |
|
234 | 233 | } |
235 | 234 | |
236 | 235 | /** |
@@ -240,7 +239,7 @@ discard block |
||
240 | 239 | elseif ($current_object !== null && $tree[$current_object]['hard'] < $height) |
241 | 240 | { |
242 | 241 | $tree[$id]['info']['arguments'] = [ |
243 | - new VLFLink ($tree[$current_object]['info']['object_name'], $current_object) |
|
242 | + new VLFLink($tree[$current_object]['info']['object_name'], $current_object) |
|
244 | 243 | ]; |
245 | 244 | |
246 | 245 | $parent_objects[$id] = $current_object; |
@@ -287,17 +286,17 @@ discard block |
||
287 | 286 | { |
288 | 287 | if ($words[0][1] == '^') |
289 | 288 | { |
290 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
289 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
291 | 290 | |
292 | 291 | $comment .= $parsed[0]; |
293 | 292 | $skip_at = $parsed[1]; |
294 | 293 | } |
295 | 294 | |
296 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
295 | + else throw new \Exception('Unknown char founded after syntax-control symbol at line "'.$line.'"'); |
|
297 | 296 | } |
298 | 297 | |
299 | 298 | if ($this->debug_mode) |
300 | - pre ("Comment:\n\n$comment"); |
|
299 | + pre("Comment:\n\n$comment"); |
|
301 | 300 | } |
302 | 301 | |
303 | 302 | /** |
@@ -309,19 +308,19 @@ discard block |
||
309 | 308 | */ |
310 | 309 | elseif ($words[0][0] == '%') |
311 | 310 | { |
312 | - $code = substr ($line, strlen ($words[0])); |
|
311 | + $code = substr($line, strlen($words[0])); |
|
313 | 312 | |
314 | 313 | if (isset ($words[0][1])) |
315 | 314 | { |
316 | 315 | if ($words[0][1] == '^') |
317 | 316 | { |
318 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
317 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
319 | 318 | |
320 | 319 | $code .= $parsed[0]; |
321 | 320 | $skip_at = $parsed[1]; |
322 | 321 | } |
323 | 322 | |
324 | - else throw new \Exception ('Unknown char founded after syntax-control symbol at line "'. $line .'"'); |
|
323 | + else throw new \Exception('Unknown char founded after syntax-control symbol at line "'.$line.'"'); |
|
325 | 324 | } |
326 | 325 | |
327 | 326 | $tree[$id] = [ |
@@ -346,7 +345,7 @@ discard block |
||
346 | 345 | * Form MyForm |
347 | 346 | * Button MyButton |
348 | 347 | */ |
349 | - elseif (is_int ($current_object) && isset ($tree[$current_object]['hard'])) |
|
348 | + elseif (is_int($current_object) && isset ($tree[$current_object]['hard'])) |
|
350 | 349 | { |
351 | 350 | if ($height <= $tree[$current_object]['hard'] && isset ($parent_objects[$current_object])) |
352 | 351 | { |
@@ -372,16 +371,16 @@ discard block |
||
372 | 371 | /** |
373 | 372 | * property_name: property_value |
374 | 373 | */ |
375 | - $postChar = substr ($words[0], strlen ($words[0]) - 1); |
|
374 | + $postChar = substr($words[0], strlen($words[0]) - 1); |
|
376 | 375 | |
377 | 376 | if ($postChar == ':' || $postChar == '^') |
378 | 377 | { |
379 | 378 | if (!isset ($words[1])) |
380 | - throw new \Exception ('Property value mustn\'t be empty at line "'. $line .'"'); |
|
379 | + throw new \Exception('Property value mustn\'t be empty at line "'.$line.'"'); |
|
381 | 380 | |
382 | - $propertyName = substr ($words[0], 0, -1); |
|
383 | - $propertyValue = implode (' ', array_slice ($words, 1)); |
|
384 | - $propertyRawValue = ltrim (substr ($line, strlen ($words[0]))); |
|
381 | + $propertyName = substr($words[0], 0, -1); |
|
382 | + $propertyValue = implode(' ', array_slice($words, 1)); |
|
383 | + $propertyRawValue = ltrim(substr($line, strlen($words[0]))); |
|
385 | 384 | |
386 | 385 | /** |
387 | 386 | * property_name:^ property_value_1 |
@@ -389,10 +388,10 @@ discard block |
||
389 | 388 | */ |
390 | 389 | if ($postChar == '^') |
391 | 390 | { |
392 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
391 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
393 | 392 | |
394 | 393 | $skip_at = $parsed[1]; |
395 | - $propertyName = substr ($propertyName, 0, -1); |
|
394 | + $propertyName = substr($propertyName, 0, -1); |
|
396 | 395 | $propertyRawValue .= $parsed[0]; |
397 | 396 | $propertyValue = $propertyRawValue; |
398 | 397 | } |
@@ -413,7 +412,7 @@ discard block |
||
413 | 412 | ]; |
414 | 413 | |
415 | 414 | if (isset ($links[$info['info']['property_value']])) |
416 | - $info['info']['property_value'] = new VLFLink ($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
415 | + $info['info']['property_value'] = new VLFLink($info['info']['property_value'], $links[$info['info']['property_value']]); |
|
417 | 416 | |
418 | 417 | $tree[$current_object]['syntax_nodes'][] = $info; |
419 | 418 | } |
@@ -421,38 +420,37 @@ discard block |
||
421 | 420 | /** |
422 | 421 | * ->method_name ([method_arguments]) |
423 | 422 | */ |
424 | - elseif (substr ($words[0], 0, 2) == '->') |
|
423 | + elseif (substr($words[0], 0, 2) == '->') |
|
425 | 424 | { |
426 | 425 | $arguments = []; |
427 | 426 | |
428 | - if (($begin = strpos ($line, '(')) !== false) |
|
427 | + if (($begin = strpos($line, '(')) !== false) |
|
429 | 428 | { |
430 | 429 | ++$begin; |
431 | 430 | |
432 | - $end = strrpos ($line, ')'); |
|
431 | + $end = strrpos($line, ')'); |
|
433 | 432 | |
434 | 433 | if ($end === false) |
435 | - throw new \Exception ('Line "'. $line .'" have arguments list initialization, but not have list ending'); |
|
434 | + throw new \Exception('Line "'.$line.'" have arguments list initialization, but not have list ending'); |
|
436 | 435 | |
437 | 436 | elseif ($begin < $end) |
438 | 437 | { |
439 | 438 | // $parsed = explode (',', substr ($line, $begin, $end - $begin)); |
440 | - $parsed = $this->parseArguments (substr ($line, $begin, $end - $begin)); |
|
439 | + $parsed = $this->parseArguments(substr($line, $begin, $end - $begin)); |
|
441 | 440 | |
442 | 441 | foreach ($parsed as $argument_id => $argument) |
443 | 442 | { |
444 | - $argument = trim ($argument); |
|
443 | + $argument = trim($argument); |
|
445 | 444 | |
446 | - if (strlen ($argument) > 0) |
|
445 | + if (strlen($argument) > 0) |
|
447 | 446 | $arguments[] = isset ($links[$argument]) ? |
448 | - new VLFLink ($argument, $links[$argument]) : |
|
449 | - $argument; |
|
447 | + new VLFLink($argument, $links[$argument]) : $argument; |
|
450 | 448 | |
451 | - else throw new \Exception ('Argument '. ($argument_id + 1) .' mustn\'t have zero length at line "'. $line .'"'); |
|
449 | + else throw new \Exception('Argument '.($argument_id + 1).' mustn\'t have zero length at line "'.$line.'"'); |
|
452 | 450 | } |
453 | 451 | |
454 | - if (!$this->ignore_postobject_info && trim (substr ($line, $end)) > 0) |
|
455 | - throw new \Exception ('You mustn\'t write any chars after arguments definition'); |
|
452 | + if (!$this->ignore_postobject_info && trim(substr($line, $end)) > 0) |
|
453 | + throw new \Exception('You mustn\'t write any chars after arguments definition'); |
|
456 | 454 | } |
457 | 455 | } |
458 | 456 | |
@@ -460,7 +458,7 @@ discard block |
||
460 | 458 | * ->show |
461 | 459 | */ |
462 | 460 | elseif (!$this->ignore_unexpected_method_args) |
463 | - throw new \Exception ('Unexpected method arguments list at line "'. $line .'"'); |
|
461 | + throw new \Exception('Unexpected method arguments list at line "'.$line.'"'); |
|
464 | 462 | |
465 | 463 | $tree[$current_object]['syntax_nodes'][] = [ |
466 | 464 | 'type' => VLF_METHOD_CALL, |
@@ -469,7 +467,7 @@ discard block |
||
469 | 467 | 'words' => $words, |
470 | 468 | |
471 | 469 | 'info' => [ |
472 | - 'method_name' => substr ($words[0], 2), |
|
470 | + 'method_name' => substr($words[0], 2), |
|
473 | 471 | 'method_arguments' => $arguments |
474 | 472 | ], |
475 | 473 | |
@@ -492,7 +490,7 @@ discard block |
||
492 | 490 | */ |
493 | 491 | else |
494 | 492 | { |
495 | - $parsed = $this->parseSubText ($untouched_lines, $id, $height); |
|
493 | + $parsed = $this->parseSubText($untouched_lines, $id, $height); |
|
496 | 494 | $skip_at = $parsed[1]; |
497 | 495 | |
498 | 496 | $tree[$id] = [ |
@@ -502,7 +500,7 @@ discard block |
||
502 | 500 | 'words' => $words, |
503 | 501 | |
504 | 502 | 'info' => [ |
505 | - 'object_vlf_info' => $line ."\n". $parsed[0] |
|
503 | + 'object_vlf_info' => $line."\n".$parsed[0] |
|
506 | 504 | ], |
507 | 505 | |
508 | 506 | 'syntax_nodes' => [] |
@@ -513,7 +511,7 @@ discard block |
||
513 | 511 | /** |
514 | 512 | * Что-то загадочное, таинственное, неизвестное человечеству |
515 | 513 | */ |
516 | - else throw new \Exception ('Unknown structures founded at line "'. $line .'"'); |
|
514 | + else throw new \Exception('Unknown structures founded at line "'.$line.'"'); |
|
517 | 515 | } |
518 | 516 | |
519 | 517 | return [$tree, $links]; |
@@ -529,7 +527,7 @@ discard block |
||
529 | 527 | * |
530 | 528 | * @return array - возвращает спарсенные подстроки |
531 | 529 | */ |
532 | - protected function parseSubText (array $lines, $begin_id, int $down_height): array |
|
530 | + protected function parseSubText(array $lines, $begin_id, int $down_height): array |
|
533 | 531 | { |
534 | 532 | $parsed = "\n"; |
535 | 533 | |
@@ -538,17 +536,17 @@ discard block |
||
538 | 536 | if ($line_id <= $begin_id) |
539 | 537 | continue; |
540 | 538 | |
541 | - if (!(bool)(trim ($line))) |
|
539 | + if (!(bool) (trim($line))) |
|
542 | 540 | { |
543 | 541 | $parsed .= "\n"; |
544 | 542 | |
545 | 543 | continue; |
546 | 544 | } |
547 | 545 | |
548 | - $height = $this->getLineHeight ($line); |
|
546 | + $height = $this->getLineHeight($line); |
|
549 | 547 | |
550 | 548 | if ($this->debug_mode) |
551 | - pre ("$height, $down_height, $line"); |
|
549 | + pre("$height, $down_height, $line"); |
|
552 | 550 | |
553 | 551 | if ($height > $down_height) |
554 | 552 | $parsed .= "$line\n"; |
@@ -559,7 +557,7 @@ discard block |
||
559 | 557 | return [$parsed, $line_id]; |
560 | 558 | } |
561 | 559 | |
562 | - public function __get ($name) // Возвращалка переменных парсера |
|
560 | + public function __get($name) // Возвращалка переменных парсера |
|
563 | 561 | { |
564 | 562 | return isset ($this->$name) ? |
565 | 563 | $this->$name : false; |
@@ -573,14 +571,14 @@ discard block |
||
573 | 571 | * |
574 | 572 | * @return int - высота строки |
575 | 573 | */ |
576 | - protected function getLineHeight (string &$line): int |
|
574 | + protected function getLineHeight(string &$line): int |
|
577 | 575 | { |
578 | 576 | $i = 0; |
579 | 577 | |
580 | 578 | while (isset ($line[$i]) && $line[$i] == "\t") |
581 | 579 | ++$i; |
582 | 580 | |
583 | - return strlen ($line = str_repeat (' ', $i) . substr ($line, $i)) - strlen ($line = trim ($line)); |
|
581 | + return strlen($line = str_repeat(' ', $i).substr($line, $i)) - strlen($line = trim($line)); |
|
584 | 582 | } |
585 | 583 | |
586 | 584 | /** |
@@ -591,18 +589,18 @@ discard block |
||
591 | 589 | * |
592 | 590 | * @return array - возвращает очищенный массив |
593 | 591 | */ |
594 | - protected function linesFilter (array $segments): array |
|
592 | + protected function linesFilter(array $segments): array |
|
595 | 593 | { |
596 | - return array_filter ($segments, function ($text) |
|
594 | + return array_filter($segments, function($text) |
|
597 | 595 | { |
598 | - if ($this->strong_line_parser && preg_match ('/[^a-z0-9]/i', $text)) |
|
599 | - throw new \Exception ('Line "'. $text .'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
596 | + if ($this->strong_line_parser && preg_match('/[^a-z0-9]/i', $text)) |
|
597 | + throw new \Exception('Line "'.$text.'" mustn\'t have any not-alphabet or not-numeric characters'); |
|
600 | 598 | |
601 | - return strlen (trim ($text)) > 0; |
|
599 | + return strlen(trim($text)) > 0; |
|
602 | 600 | }); |
603 | 601 | } |
604 | 602 | |
605 | - protected function parseArguments (string $arguments): array |
|
603 | + protected function parseArguments(string $arguments): array |
|
606 | 604 | { |
607 | 605 | $args = []; |
608 | 606 | |
@@ -611,7 +609,7 @@ discard block |
||
611 | 609 | |
612 | 610 | $t = ''; |
613 | 611 | |
614 | - for ($i = 0, $len = strlen ($arguments); $i < $len; ++$i) |
|
612 | + for ($i = 0, $len = strlen($arguments); $i < $len; ++$i) |
|
615 | 613 | { |
616 | 614 | $t .= $arguments[$i]; |
617 | 615 | |
@@ -628,7 +626,7 @@ discard block |
||
628 | 626 | |
629 | 627 | elseif (!$split1 && !$split2 && $arguments[$i] == ',') |
630 | 628 | { |
631 | - $args[] = substr ($t, 0, -1); |
|
629 | + $args[] = substr($t, 0, -1); |
|
632 | 630 | $t = ''; |
633 | 631 | } |
634 | 632 | } |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | if (!isset ($argv)) |
15 | 15 | { |
16 | - $params = json_decode (file_get_contents (__DIR__ .'/params.json'), true); |
|
17 | - $oargv = [__FILE__]; |
|
16 | + $params = json_decode (file_get_contents (__DIR__ .'/params.json'), true); |
|
17 | + $oargv = [__FILE__]; |
|
18 | 18 | |
19 | - unlink (__DIR__ .'/params.json'); |
|
19 | + unlink (__DIR__ .'/params.json'); |
|
20 | 20 | |
21 | 21 | foreach ($params as $name => $param) |
22 | 22 | { |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | if (!defined ('VoidBuilder\CORE_DIR')) |
38 | 38 | define ('VoidBuilder\CORE_DIR', dirname (ENGINE_DIR) .'/core'); |
39 | 39 | |
40 | - define ('VoidEngine\CORE_DIR', dirname (ENGINE_DIR) .'/core'); |
|
40 | + define ('VoidEngine\CORE_DIR', dirname (ENGINE_DIR) .'/core'); |
|
41 | 41 | |
42 | 42 | require $params['--engine-dir'] .'/VoidEngine.php'; |
43 | 43 | |
44 | - $argv = $oargv; |
|
44 | + $argv = $oargv; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | try |
@@ -13,103 +13,103 @@ |
||
13 | 13 | |
14 | 14 | if (!isset ($argv)) |
15 | 15 | { |
16 | - $params = json_decode (file_get_contents (__DIR__ .'/params.json'), true); |
|
16 | + $params = json_decode(file_get_contents(__DIR__.'/params.json'), true); |
|
17 | 17 | $oargv = [__FILE__]; |
18 | 18 | |
19 | - unlink (__DIR__ .'/params.json'); |
|
19 | + unlink(__DIR__.'/params.json'); |
|
20 | 20 | |
21 | 21 | foreach ($params as $name => $param) |
22 | 22 | { |
23 | - if (!is_array ($param)) |
|
23 | + if (!is_array($param)) |
|
24 | 24 | $param = [$param]; |
25 | 25 | |
26 | 26 | foreach ($param as $arg) |
27 | - if (strlen ($arg) > 0) |
|
27 | + if (strlen($arg) > 0) |
|
28 | 28 | { |
29 | 29 | $oargv[] = $name; |
30 | 30 | $oargv[] = $arg; |
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | - if (!defined ('VoidBuilder\ENGINE_DIR')) |
|
35 | - define ('VoidBuilder\ENGINE_DIR', $params['--engine-dir']); |
|
34 | + if (!defined('VoidBuilder\ENGINE_DIR')) |
|
35 | + define('VoidBuilder\ENGINE_DIR', $params['--engine-dir']); |
|
36 | 36 | |
37 | - if (!defined ('VoidBuilder\CORE_DIR')) |
|
38 | - define ('VoidBuilder\CORE_DIR', dirname (ENGINE_DIR) .'/core'); |
|
37 | + if (!defined('VoidBuilder\CORE_DIR')) |
|
38 | + define('VoidBuilder\CORE_DIR', dirname(ENGINE_DIR).'/core'); |
|
39 | 39 | |
40 | - define ('VoidEngine\CORE_DIR', dirname (ENGINE_DIR) .'/core'); |
|
40 | + define('VoidEngine\CORE_DIR', dirname(ENGINE_DIR).'/core'); |
|
41 | 41 | |
42 | - require $params['--engine-dir'] .'/VoidEngine.php'; |
|
42 | + require $params['--engine-dir'].'/VoidEngine.php'; |
|
43 | 43 | |
44 | 44 | $argv = $oargv; |
45 | 45 | } |
46 | 46 | |
47 | 47 | try |
48 | 48 | { |
49 | - (new Manager ([], (new DefaultCommand (function ($args, $params) |
|
49 | + (new Manager([], (new DefaultCommand(function($args, $params) |
|
50 | 50 | { |
51 | 51 | foreach (['--app-dir', '--output-dir', '--icon-path'] as $param) |
52 | - if (is_array ($params[$param])) |
|
53 | - $params[$param] = end ($params[$param]); |
|
52 | + if (is_array($params[$param])) |
|
53 | + $params[$param] = end($params[$param]); |
|
54 | 54 | |
55 | - if (!file_exists (dirname ($params['--app-dir']) .'/qero-packages/winforms-php/VoidFramework/core/VoidCore.exe')) |
|
55 | + if (!file_exists(dirname($params['--app-dir']).'/qero-packages/winforms-php/VoidFramework/core/VoidCore.exe')) |
|
56 | 56 | die ("\n Incorrect VoidFramework app path\n"); |
57 | 57 | |
58 | - if (class_exists ('VoidEngine\WFObject')) |
|
58 | + if (class_exists('VoidEngine\WFObject')) |
|
59 | 59 | { |
60 | - $errors = (new Builder ($params['--app-dir'])) |
|
61 | - ->build ($params['--output-dir'], $params['--icon-path'], !$params['--no-compress']); |
|
60 | + $errors = (new Builder($params['--app-dir'])) |
|
61 | + ->build($params['--output-dir'], $params['--icon-path'], !$params['--no-compress']); |
|
62 | 62 | |
63 | - if (sizeof ($errors) > 0) |
|
64 | - print_r ($errors); |
|
63 | + if (sizeof($errors) > 0) |
|
64 | + print_r($errors); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | else |
68 | 68 | { |
69 | 69 | echo PHP_EOL; |
70 | - echo ' Building ['. dirname (str_replace (dirname ($params['--app-dir'], 2) .'\\', '', $params['--app-dir'])) .']...'. PHP_EOL . PHP_EOL; |
|
70 | + echo ' Building ['.dirname(str_replace(dirname($params['--app-dir'], 2).'\\', '', $params['--app-dir'])).']...'.PHP_EOL.PHP_EOL; |
|
71 | 71 | |
72 | - $begin = microtime (true); |
|
72 | + $begin = microtime(true); |
|
73 | 73 | |
74 | - $params['--engine-dir'] = dirname ($params['--app-dir']) .'/qero-packages/winforms-php/VoidFramework/engine'; |
|
75 | - file_put_contents ('params.json', json_encode ($params, JSON_PRETTY_PRINT)); |
|
74 | + $params['--engine-dir'] = dirname($params['--app-dir']).'/qero-packages/winforms-php/VoidFramework/engine'; |
|
75 | + file_put_contents('params.json', json_encode($params, JSON_PRETTY_PRINT)); |
|
76 | 76 | |
77 | - shell_exec ('"'. dirname ($params['--app-dir']) .'/qero-packages/winforms-php/VoidFramework/core/VoidCore.exe" "'. __FILE__ .'"'); |
|
77 | + shell_exec('"'.dirname($params['--app-dir']).'/qero-packages/winforms-php/VoidFramework/core/VoidCore.exe" "'.__FILE__.'"'); |
|
78 | 78 | |
79 | - echo ' Building completed after '. round (microtime (true) - $begin, 6) .' seconds'. PHP_EOL; |
|
80 | - echo ' Saved at '. $params['--output-dir'] .'/build'. PHP_EOL . PHP_EOL; |
|
79 | + echo ' Building completed after '.round(microtime(true) - $begin, 6).' seconds'.PHP_EOL; |
|
80 | + echo ' Saved at '.$params['--output-dir'].'/build'.PHP_EOL.PHP_EOL; |
|
81 | 81 | |
82 | 82 | if (isset ($params['--join'])) |
83 | 83 | { |
84 | - if (!is_array ($params['--join'])) |
|
84 | + if (!is_array($params['--join'])) |
|
85 | 85 | $params['--join'] = [$params['--join']]; |
86 | 86 | |
87 | - if (($size = sizeof ($params['--join'])) > 0) |
|
87 | + if (($size = sizeof($params['--join'])) > 0) |
|
88 | 88 | { |
89 | - echo ' Union '. $size .' files...'. PHP_EOL; |
|
89 | + echo ' Union '.$size.' files...'.PHP_EOL; |
|
90 | 90 | |
91 | - $begin = microtime (true); |
|
92 | - $joiner = new Joiner ($params['--output-dir'] .'/build/app.exe', $params['--output-dir'] .'/app.exe'); |
|
91 | + $begin = microtime(true); |
|
92 | + $joiner = new Joiner($params['--output-dir'].'/build/app.exe', $params['--output-dir'].'/app.exe'); |
|
93 | 93 | |
94 | 94 | foreach ($params['--join'] as $file) |
95 | - $joiner->add (file_exists ($file) ? $file : $params['--output-dir'] .'/build/'. $file); |
|
95 | + $joiner->add(file_exists($file) ? $file : $params['--output-dir'].'/build/'.$file); |
|
96 | 96 | |
97 | - echo str_replace ("\n", "\n ", $joiner->join ()) . PHP_EOL; |
|
98 | - echo ' Union completed after '. round (microtime (true) - $begin, 6) .' seconds'. PHP_EOL; |
|
99 | - echo ' Saved at '. $params['--output-dir'] . PHP_EOL; |
|
97 | + echo str_replace("\n", "\n ", $joiner->join()).PHP_EOL; |
|
98 | + echo ' Union completed after '.round(microtime(true) - $begin, 6).' seconds'.PHP_EOL; |
|
99 | + echo ' Saved at '.$params['--output-dir'].PHP_EOL; |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
103 | - }))->addParams ([ |
|
104 | - (new Param ('--app-dir', null, true))->addAliase ('-d'), |
|
105 | - (new Param ('--output-dir', __DIR__ .'/build'))->addAliase ('-o'), |
|
106 | - (new Param ('--icon-path', __DIR__ .'/system/Icon.ico'))->addAliase ('-i'), |
|
107 | - (new Param ('--join'))->addAliase ('-j'), |
|
108 | - (new Flag ('--no-compress'))->addAliase ('-nc') |
|
109 | - ])))->execute ($argv); |
|
103 | + }))->addParams([ |
|
104 | + (new Param('--app-dir', null, true))->addAliase('-d'), |
|
105 | + (new Param('--output-dir', __DIR__.'/build'))->addAliase('-o'), |
|
106 | + (new Param('--icon-path', __DIR__.'/system/Icon.ico'))->addAliase('-i'), |
|
107 | + (new Param('--join'))->addAliase('-j'), |
|
108 | + (new Flag('--no-compress'))->addAliase('-nc') |
|
109 | + ])))->execute($argv); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | catch (\Exception $e) |
113 | 113 | { |
114 | - die ("\n ". $e->getMessage () ."\n"); |
|
114 | + die ("\n ".$e->getMessage()."\n"); |
|
115 | 115 | } |
@@ -20,22 +20,26 @@ discard block |
||
20 | 20 | |
21 | 21 | foreach ($params as $name => $param) |
22 | 22 | { |
23 | - if (!is_array ($param)) |
|
24 | - $param = [$param]; |
|
23 | + if (!is_array ($param)) { |
|
24 | + $param = [$param]; |
|
25 | + } |
|
25 | 26 | |
26 | - foreach ($param as $arg) |
|
27 | - if (strlen ($arg) > 0) |
|
27 | + foreach ($param as $arg) { |
|
28 | + if (strlen ($arg) > 0) |
|
28 | 29 | { |
29 | 30 | $oargv[] = $name; |
31 | + } |
|
30 | 32 | $oargv[] = $arg; |
31 | 33 | } |
32 | 34 | } |
33 | 35 | |
34 | - if (!defined ('VoidBuilder\ENGINE_DIR')) |
|
35 | - define ('VoidBuilder\ENGINE_DIR', $params['--engine-dir']); |
|
36 | + if (!defined ('VoidBuilder\ENGINE_DIR')) { |
|
37 | + define ('VoidBuilder\ENGINE_DIR', $params['--engine-dir']); |
|
38 | + } |
|
36 | 39 | |
37 | - if (!defined ('VoidBuilder\CORE_DIR')) |
|
38 | - define ('VoidBuilder\CORE_DIR', dirname (ENGINE_DIR) .'/core'); |
|
40 | + if (!defined ('VoidBuilder\CORE_DIR')) { |
|
41 | + define ('VoidBuilder\CORE_DIR', dirname (ENGINE_DIR) .'/core'); |
|
42 | + } |
|
39 | 43 | |
40 | 44 | define ('VoidEngine\CORE_DIR', dirname (ENGINE_DIR) .'/core'); |
41 | 45 | |
@@ -48,23 +52,24 @@ discard block |
||
48 | 52 | { |
49 | 53 | (new Manager ([], (new DefaultCommand (function ($args, $params) |
50 | 54 | { |
51 | - foreach (['--app-dir', '--output-dir', '--icon-path'] as $param) |
|
52 | - if (is_array ($params[$param])) |
|
55 | + foreach (['--app-dir', '--output-dir', '--icon-path'] as $param) { |
|
56 | + if (is_array ($params[$param])) |
|
53 | 57 | $params[$param] = end ($params[$param]); |
58 | + } |
|
54 | 59 | |
55 | - if (!file_exists (dirname ($params['--app-dir']) .'/qero-packages/winforms-php/VoidFramework/core/VoidCore.exe')) |
|
56 | - die ("\n Incorrect VoidFramework app path\n"); |
|
60 | + if (!file_exists (dirname ($params['--app-dir']) .'/qero-packages/winforms-php/VoidFramework/core/VoidCore.exe')) { |
|
61 | + die ("\n Incorrect VoidFramework app path\n"); |
|
62 | + } |
|
57 | 63 | |
58 | 64 | if (class_exists ('VoidEngine\WFObject')) |
59 | 65 | { |
60 | 66 | $errors = (new Builder ($params['--app-dir'])) |
61 | 67 | ->build ($params['--output-dir'], $params['--icon-path'], !$params['--no-compress']); |
62 | 68 | |
63 | - if (sizeof ($errors) > 0) |
|
64 | - print_r ($errors); |
|
65 | - } |
|
66 | - |
|
67 | - else |
|
69 | + if (sizeof ($errors) > 0) { |
|
70 | + print_r ($errors); |
|
71 | + } |
|
72 | + } else |
|
68 | 73 | { |
69 | 74 | echo PHP_EOL; |
70 | 75 | echo ' Building ['. dirname (str_replace (dirname ($params['--app-dir'], 2) .'\\', '', $params['--app-dir'])) .']...'. PHP_EOL . PHP_EOL; |
@@ -81,8 +86,9 @@ discard block |
||
81 | 86 | |
82 | 87 | if (isset ($params['--join'])) |
83 | 88 | { |
84 | - if (!is_array ($params['--join'])) |
|
85 | - $params['--join'] = [$params['--join']]; |
|
89 | + if (!is_array ($params['--join'])) { |
|
90 | + $params['--join'] = [$params['--join']]; |
|
91 | + } |
|
86 | 92 | |
87 | 93 | if (($size = sizeof ($params['--join'])) > 0) |
88 | 94 | { |
@@ -91,8 +97,9 @@ discard block |
||
91 | 97 | $begin = microtime (true); |
92 | 98 | $joiner = new Joiner ($params['--output-dir'] .'/build/app.exe', $params['--output-dir'] .'/app.exe'); |
93 | 99 | |
94 | - foreach ($params['--join'] as $file) |
|
95 | - $joiner->add (file_exists ($file) ? $file : $params['--output-dir'] .'/build/'. $file); |
|
100 | + foreach ($params['--join'] as $file) { |
|
101 | + $joiner->add (file_exists ($file) ? $file : $params['--output-dir'] .'/build/'. $file); |
|
102 | + } |
|
96 | 103 | |
97 | 104 | echo str_replace ("\n", "\n ", $joiner->join ()) . PHP_EOL; |
98 | 105 | echo ' Union completed after '. round (microtime (true) - $begin, 6) .' seconds'. PHP_EOL; |
@@ -107,9 +114,7 @@ discard block |
||
107 | 114 | (new Param ('--join'))->addAliase ('-j'), |
108 | 115 | (new Flag ('--no-compress'))->addAliase ('-nc') |
109 | 116 | ])))->execute ($argv); |
110 | -} |
|
111 | - |
|
112 | -catch (\Exception $e) |
|
117 | +} catch (\Exception $e) |
|
113 | 118 | { |
114 | 119 | die ("\n ". $e->getMessage () ."\n"); |
115 | 120 | } |
@@ -2,65 +2,65 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidBuilder; |
4 | 4 | |
5 | -if (!defined ('VoidBuilder\ENGINE_DIR') && defined ('VoidEngine\ENGINE_DIR')) |
|
6 | - define ('VoidBuilder\ENGINE_DIR', \VoidEngine\ENGINE_DIR); |
|
5 | +if (!defined('VoidBuilder\ENGINE_DIR') && defined('VoidEngine\ENGINE_DIR')) |
|
6 | + define('VoidBuilder\ENGINE_DIR', \VoidEngine\ENGINE_DIR); |
|
7 | 7 | |
8 | 8 | class Builder |
9 | 9 | { |
10 | 10 | public $appDir; |
11 | 11 | |
12 | - public function __construct (string $appDir) |
|
12 | + public function __construct(string $appDir) |
|
13 | 13 | { |
14 | - if (!is_dir ($appDir)) |
|
15 | - throw new \Exception ('Wrong $appDir param'); |
|
14 | + if (!is_dir($appDir)) |
|
15 | + throw new \Exception('Wrong $appDir param'); |
|
16 | 16 | |
17 | 17 | $this->appDir = $appDir; |
18 | 18 | } |
19 | 19 | |
20 | - public function build (string $outputDir, string $iconPath = null, bool $union = true): array |
|
20 | + public function build(string $outputDir, string $iconPath = null, bool $union = true): array |
|
21 | 21 | { |
22 | - \VoidEngine\dir_clean ($outputDir .'/build'); |
|
23 | - \VoidEngine\dir_copy (CORE_DIR, $outputDir .'/build'); |
|
22 | + \VoidEngine\dir_clean($outputDir.'/build'); |
|
23 | + \VoidEngine\dir_copy(CORE_DIR, $outputDir.'/build'); |
|
24 | 24 | |
25 | - unlink ($outputDir .'/build/script.php'); |
|
26 | - unlink ($outputDir .'/build/VoidCore.exe'); |
|
25 | + unlink($outputDir.'/build/script.php'); |
|
26 | + unlink($outputDir.'/build/VoidCore.exe'); |
|
27 | 27 | |
28 | - \VoidEngine\dir_clean ($outputDir .'/build/qero-packages'); |
|
29 | - \VoidEngine\dir_copy (dirname ($this->appDir) .'/qero-packages', $outputDir .'/build/qero-packages'); |
|
30 | - \VoidEngine\dir_delete ($outputDir .'/build/qero-packages/winforms-php/VoidFramework'); |
|
28 | + \VoidEngine\dir_clean($outputDir.'/build/qero-packages'); |
|
29 | + \VoidEngine\dir_copy(dirname($this->appDir).'/qero-packages', $outputDir.'/build/qero-packages'); |
|
30 | + \VoidEngine\dir_delete($outputDir.'/build/qero-packages/winforms-php/VoidFramework'); |
|
31 | 31 | |
32 | - return \VoidEngine\EngineAdditions::compile ($outputDir .'/build/app.exe', $iconPath ?? dirname (__DIR__) .'/system/Icon.ico', self::optimizeCode (\VoidEngine\str_replace_assoc (file_get_contents (dirname (__DIR__) .'/system/preset.php'), [ |
|
33 | - '%VoidEngine%' => self::generateCode (self::getReferences (ENGINE_DIR .'/VoidEngine.php')), |
|
34 | - '%APP%' => base64_encode (gzdeflate (serialize ($union ? self::getFiles ($this->appDir) : []), 9)) |
|
32 | + return \VoidEngine\EngineAdditions::compile($outputDir.'/build/app.exe', $iconPath ?? dirname(__DIR__).'/system/Icon.ico', self::optimizeCode(\VoidEngine\str_replace_assoc(file_get_contents(dirname(__DIR__).'/system/preset.php'), [ |
|
33 | + '%VoidEngine%' => self::generateCode(self::getReferences(ENGINE_DIR.'/VoidEngine.php')), |
|
34 | + '%APP%' => base64_encode(gzdeflate(serialize($union ? self::getFiles($this->appDir) : []), 9)) |
|
35 | 35 | ]))/*, null, null, null, null, null, '', '', null, null*/); |
36 | 36 | } |
37 | 37 | |
38 | - public static function generateCode (array $references, bool $removeNamespaces = true): string |
|
38 | + public static function generateCode(array $references, bool $removeNamespaces = true): string |
|
39 | 39 | { |
40 | - $code = "/*\n\n\t". join ("\n\t", explode ("\n", file_get_contents (dirname (ENGINE_DIR) .'/license.txt'))) ."\n\n*/\n\n"; |
|
40 | + $code = "/*\n\n\t".join("\n\t", explode("\n", file_get_contents(dirname(ENGINE_DIR).'/license.txt')))."\n\n*/\n\n"; |
|
41 | 41 | |
42 | 42 | foreach ($references as $path) |
43 | - $code .= join (array_slice (array_map (function ($line) |
|
43 | + $code .= join(array_slice(array_map(function($line) |
|
44 | 44 | { |
45 | - return substr ($line, 0, 7) != 'require' ? $line : ''; |
|
46 | - }, file ($path)), 1)); |
|
45 | + return substr($line, 0, 7) != 'require' ? $line : ''; |
|
46 | + }, file($path)), 1)); |
|
47 | 47 | |
48 | 48 | return $removeNamespaces ? |
49 | - preg_replace ('/'. "\n" .'namespace [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*;'. "\n" .'/', "\n\n", $code) : $code; |
|
49 | + preg_replace ('/'."\n".'namespace [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*;'."\n".'/', "\n\n", $code) : $code; |
|
50 | 50 | } |
51 | 51 | |
52 | - public static function getReferences (string $file, bool $parseExtensions = true): array |
|
52 | + public static function getReferences(string $file, bool $parseExtensions = true): array |
|
53 | 53 | { |
54 | 54 | $references = []; |
55 | 55 | |
56 | - foreach (file ($file) as $line) |
|
57 | - if (substr ($line, 0, 7) == 'require') |
|
56 | + foreach (file($file) as $line) |
|
57 | + if (substr($line, 0, 7) == 'require') |
|
58 | 58 | try |
59 | 59 | { |
60 | - $begin = strpos ($line, "'"); |
|
61 | - $end = strrpos ($line, "'") - $begin + 1; |
|
60 | + $begin = strpos($line, "'"); |
|
61 | + $end = strrpos($line, "'") - $begin + 1; |
|
62 | 62 | |
63 | - $references = array_merge ($references, self::getReferences (dirname ($file) .'/'. eval ('namespace VoidEngine; return '. substr ($line, $begin, $end) .';'), false)); |
|
63 | + $references = array_merge($references, self::getReferences(dirname($file).'/'.eval ('namespace VoidEngine; return '.substr($line, $begin, $end).';'), false)); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | catch (\Throwable $e) |
@@ -69,42 +69,42 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | if ($parseExtensions) |
72 | - if (is_dir (ENGINE_DIR .'/extensions') && is_array ($exts = scandir (ENGINE_DIR .'/extensions'))) |
|
72 | + if (is_dir(ENGINE_DIR.'/extensions') && is_array($exts = scandir(ENGINE_DIR.'/extensions'))) |
|
73 | 73 | foreach ($exts as $ext) |
74 | - if (is_dir (ENGINE_DIR .'/extensions/'. $ext) && file_exists ($ext = ENGINE_DIR .'/extensions/'. $ext .'/main.php')) |
|
75 | - $references = array_merge ($references, self::getReferences ($ext, false)); |
|
74 | + if (is_dir(ENGINE_DIR.'/extensions/'.$ext) && file_exists($ext = ENGINE_DIR.'/extensions/'.$ext.'/main.php')) |
|
75 | + $references = array_merge($references, self::getReferences($ext, false)); |
|
76 | 76 | |
77 | 77 | $references[] = $file; |
78 | 78 | |
79 | 79 | return $references; |
80 | 80 | } |
81 | 81 | |
82 | - public static function getFiles (string $path, string $prefixBlacklist = null, array $files = [], int $originalPathLength = -1): array |
|
82 | + public static function getFiles(string $path, string $prefixBlacklist = null, array $files = [], int $originalPathLength = -1): array |
|
83 | 83 | { |
84 | 84 | if ($originalPathLength == -1) |
85 | - $originalPathLength = strlen (dirname ($path)) + 1; |
|
85 | + $originalPathLength = strlen(dirname($path)) + 1; |
|
86 | 86 | |
87 | - $len = strlen ($prefixBlacklist); |
|
87 | + $len = strlen($prefixBlacklist); |
|
88 | 88 | |
89 | - foreach (array_slice (scandir ($path), 2) as $name) |
|
90 | - if ($prefixBlacklist === null || substr ($path .'/'. $name, $originalPathLength, $len) != $prefixBlacklist) |
|
89 | + foreach (array_slice(scandir($path), 2) as $name) |
|
90 | + if ($prefixBlacklist === null || substr($path.'/'.$name, $originalPathLength, $len) != $prefixBlacklist) |
|
91 | 91 | { |
92 | - if (is_dir ($file = $path .'/'. $name)) |
|
93 | - $files = self::getFiles ($file, $prefixBlacklist, $files, $originalPathLength); |
|
92 | + if (is_dir($file = $path.'/'.$name)) |
|
93 | + $files = self::getFiles($file, $prefixBlacklist, $files, $originalPathLength); |
|
94 | 94 | |
95 | - else $files[substr ($file, $originalPathLength)] = file_get_contents ($file); |
|
95 | + else $files[substr($file, $originalPathLength)] = file_get_contents($file); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return $files; |
99 | 99 | } |
100 | 100 | |
101 | - public static function optimizeCode (string $code): string |
|
101 | + public static function optimizeCode(string $code): string |
|
102 | 102 | { |
103 | - $tokens = token_get_all ('<?php '. $code); |
|
103 | + $tokens = token_get_all('<?php '.$code); |
|
104 | 104 | $return = ''; |
105 | 105 | |
106 | 106 | foreach ($tokens as $id => $token) |
107 | - if (is_string ($token)) |
|
107 | + if (is_string($token)) |
|
108 | 108 | $return .= $token; |
109 | 109 | |
110 | 110 | else |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | break; |
119 | 119 | |
120 | 120 | case T_WHITESPACE: |
121 | - if (!isset ($tokens[$id + 1]) || !is_array ($tokens[$id + 1]) || $tokens[$id + 1][0] != T_WHITESPACE) |
|
121 | + if (!isset ($tokens[$id + 1]) || !is_array($tokens[$id + 1]) || $tokens[$id + 1][0] != T_WHITESPACE) |
|
122 | 122 | $return .= ' '; |
123 | 123 | |
124 | 124 | break; |
@@ -130,6 +130,6 @@ discard block |
||
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | - return substr ($return, 6); |
|
133 | + return substr($return, 6); |
|
134 | 134 | } |
135 | 135 | } |
@@ -2,8 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidBuilder; |
4 | 4 | |
5 | -if (!defined ('VoidBuilder\ENGINE_DIR') && defined ('VoidEngine\ENGINE_DIR')) |
|
5 | +if (!defined ('VoidBuilder\ENGINE_DIR') && defined ('VoidEngine\ENGINE_DIR')) { |
|
6 | 6 | define ('VoidBuilder\ENGINE_DIR', \VoidEngine\ENGINE_DIR); |
7 | +} |
|
7 | 8 | |
8 | 9 | class Builder |
9 | 10 | { |
@@ -11,8 +12,9 @@ discard block |
||
11 | 12 | |
12 | 13 | public function __construct (string $appDir) |
13 | 14 | { |
14 | - if (!is_dir ($appDir)) |
|
15 | - throw new \Exception ('Wrong $appDir param'); |
|
15 | + if (!is_dir ($appDir)) { |
|
16 | + throw new \Exception ('Wrong $appDir param'); |
|
17 | + } |
|
16 | 18 | |
17 | 19 | $this->appDir = $appDir; |
18 | 20 | } |
@@ -39,10 +41,11 @@ discard block |
||
39 | 41 | { |
40 | 42 | $code = "/*\n\n\t". join ("\n\t", explode ("\n", file_get_contents (dirname (ENGINE_DIR) .'/license.txt'))) ."\n\n*/\n\n"; |
41 | 43 | |
42 | - foreach ($references as $path) |
|
43 | - $code .= join (array_slice (array_map (function ($line) |
|
44 | + foreach ($references as $path) { |
|
45 | + $code .= join (array_slice (array_map (function ($line) |
|
44 | 46 | { |
45 | 47 | return substr ($line, 0, 7) != 'require' ? $line : ''; |
48 | + } |
|
46 | 49 | }, file ($path)), 1)); |
47 | 50 | |
48 | 51 | return $removeNamespaces ? |
@@ -53,26 +56,26 @@ discard block |
||
53 | 56 | { |
54 | 57 | $references = []; |
55 | 58 | |
56 | - foreach (file ($file) as $line) |
|
57 | - if (substr ($line, 0, 7) == 'require') |
|
59 | + foreach (file ($file) as $line) { |
|
60 | + if (substr ($line, 0, 7) == 'require') |
|
58 | 61 | try |
59 | 62 | { |
60 | 63 | $begin = strpos ($line, "'"); |
64 | + } |
|
61 | 65 | $end = strrpos ($line, "'") - $begin + 1; |
62 | 66 | |
63 | 67 | $references = array_merge ($references, self::getReferences (dirname ($file) .'/'. eval ('namespace VoidEngine; return '. substr ($line, $begin, $end) .';'), false)); |
64 | - } |
|
65 | - |
|
66 | - catch (\Throwable $e) |
|
68 | + } catch (\Throwable $e) |
|
67 | 69 | { |
68 | 70 | continue; |
69 | 71 | } |
70 | 72 | |
71 | - if ($parseExtensions) |
|
72 | - if (is_dir (ENGINE_DIR .'/extensions') && is_array ($exts = scandir (ENGINE_DIR .'/extensions'))) |
|
73 | + if ($parseExtensions) { |
|
74 | + if (is_dir (ENGINE_DIR .'/extensions') && is_array ($exts = scandir (ENGINE_DIR .'/extensions'))) |
|
73 | 75 | foreach ($exts as $ext) |
74 | 76 | if (is_dir (ENGINE_DIR .'/extensions/'. $ext) && file_exists ($ext = ENGINE_DIR .'/extensions/'. $ext .'/main.php')) |
75 | 77 | $references = array_merge ($references, self::getReferences ($ext, false)); |
78 | + } |
|
76 | 79 | |
77 | 80 | $references[] = $file; |
78 | 81 | |
@@ -81,18 +84,22 @@ discard block |
||
81 | 84 | |
82 | 85 | public static function getFiles (string $path, string $prefixBlacklist = null, array $files = [], int $originalPathLength = -1): array |
83 | 86 | { |
84 | - if ($originalPathLength == -1) |
|
85 | - $originalPathLength = strlen (dirname ($path)) + 1; |
|
87 | + if ($originalPathLength == -1) { |
|
88 | + $originalPathLength = strlen (dirname ($path)) + 1; |
|
89 | + } |
|
86 | 90 | |
87 | 91 | $len = strlen ($prefixBlacklist); |
88 | 92 | |
89 | - foreach (array_slice (scandir ($path), 2) as $name) |
|
90 | - if ($prefixBlacklist === null || substr ($path .'/'. $name, $originalPathLength, $len) != $prefixBlacklist) |
|
93 | + foreach (array_slice (scandir ($path), 2) as $name) { |
|
94 | + if ($prefixBlacklist === null || substr ($path .'/'. $name, $originalPathLength, $len) != $prefixBlacklist) |
|
91 | 95 | { |
92 | 96 | if (is_dir ($file = $path .'/'. $name)) |
93 | 97 | $files = self::getFiles ($file, $prefixBlacklist, $files, $originalPathLength); |
98 | + } |
|
94 | 99 | |
95 | - else $files[substr ($file, $originalPathLength)] = file_get_contents ($file); |
|
100 | + else { |
|
101 | + $files[substr ($file, $originalPathLength)] = file_get_contents ($file); |
|
102 | + } |
|
96 | 103 | } |
97 | 104 | |
98 | 105 | return $files; |
@@ -103,9 +110,10 @@ discard block |
||
103 | 110 | $tokens = token_get_all ('<?php '. $code); |
104 | 111 | $return = ''; |
105 | 112 | |
106 | - foreach ($tokens as $id => $token) |
|
107 | - if (is_string ($token)) |
|
113 | + foreach ($tokens as $id => $token) { |
|
114 | + if (is_string ($token)) |
|
108 | 115 | $return .= $token; |
116 | + } |
|
109 | 117 | |
110 | 118 | else |
111 | 119 | { |
@@ -118,8 +126,9 @@ discard block |
||
118 | 126 | break; |
119 | 127 | |
120 | 128 | case T_WHITESPACE: |
121 | - if (!isset ($tokens[$id + 1]) || !is_array ($tokens[$id + 1]) || $tokens[$id + 1][0] != T_WHITESPACE) |
|
122 | - $return .= ' '; |
|
129 | + if (!isset ($tokens[$id + 1]) || !is_array ($tokens[$id + 1]) || $tokens[$id + 1][0] != T_WHITESPACE) { |
|
130 | + $return .= ' '; |
|
131 | + } |
|
123 | 132 | |
124 | 133 | break; |
125 | 134 |