@@ -4,17 +4,22 @@ |
||
4 | 4 | |
5 | 5 | function dir_copy (string $from, string $to): bool |
6 | 6 | { |
7 | - if (!is_dir ($from)) |
|
8 | - return false; |
|
7 | + if (!is_dir ($from)) { |
|
8 | + return false; |
|
9 | + } |
|
9 | 10 | |
10 | - if (!is_dir ($to)) |
|
11 | - dir_create ($to); |
|
11 | + if (!is_dir ($to)) { |
|
12 | + dir_create ($to); |
|
13 | + } |
|
12 | 14 | |
13 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
14 | - if (is_dir ($f = $from .'/'. $file)) |
|
15 | + foreach (array_slice (scandir ($from), 2) as $file) { |
|
16 | + if (is_dir ($f = $from .'/'. $file)) |
|
15 | 17 | dir_copy ($f, $to .'/'. $file); |
18 | + } |
|
16 | 19 | |
17 | - else copy ($f, $to .'/'. $file); |
|
20 | + else { |
|
21 | + copy ($f, $to .'/'. $file); |
|
22 | + } |
|
18 | 23 | |
19 | 24 | return true; |
20 | 25 | } |
@@ -40,4 +40,4 @@ |
||
40 | 40 | unlink (__FILE__); |
41 | 41 | |
42 | 42 | echo ' Configuration completed'. PHP_EOL . |
43 | - ' Thank for installing winforms-php/VoidFramework!'. PHP_EOL . PHP_EOL; |
|
43 | + ' Thank for installing winforms-php/VoidFramework!'. PHP_EOL . PHP_EOL; |
@@ -1,44 +1,44 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -echo ' Configuring VoidFramework...'. PHP_EOL; |
|
3 | +echo ' Configuring VoidFramework...'.PHP_EOL; |
|
4 | 4 | |
5 | -function dir_copy (string $from, string $to): bool |
|
5 | +function dir_copy(string $from, string $to): bool |
|
6 | 6 | { |
7 | - if (!is_dir ($from)) |
|
7 | + if (!is_dir($from)) |
|
8 | 8 | return false; |
9 | 9 | |
10 | - if (!is_dir ($to)) |
|
11 | - dir_create ($to); |
|
10 | + if (!is_dir($to)) |
|
11 | + dir_create($to); |
|
12 | 12 | |
13 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
14 | - if (is_dir ($f = $from .'/'. $file)) |
|
15 | - dir_copy ($f, $to .'/'. $file); |
|
13 | + foreach (array_slice(scandir($from), 2) as $file) |
|
14 | + if (is_dir($f = $from.'/'.$file)) |
|
15 | + dir_copy($f, $to.'/'.$file); |
|
16 | 16 | |
17 | - else copy ($f, $to .'/'. $file); |
|
17 | + else copy($f, $to.'/'.$file); |
|
18 | 18 | |
19 | 19 | return true; |
20 | 20 | } |
21 | 21 | |
22 | -$info = file_exists (QERO_DIR .'/qero-info.json') ? |
|
23 | - json_decode (file_get_contents (QERO_DIR .'/qero-info.json'), true) : array (); |
|
22 | +$info = file_exists(QERO_DIR.'/qero-info.json') ? |
|
23 | + json_decode (file_get_contents(QERO_DIR.'/qero-info.json'), true) : array(); |
|
24 | 24 | |
25 | 25 | $info['scripts']['start'] = '"qero-packages/winforms-php/VoidFramework/core/VoidCore.exe" "app/start.php"'; |
26 | 26 | |
27 | -file_put_contents (QERO_DIR .'/qero-info.json', json_encode ($info, defined ('JSON_PRETTY_PRINT') ? |
|
27 | +file_put_contents(QERO_DIR.'/qero-info.json', json_encode($info, defined('JSON_PRETTY_PRINT') ? |
|
28 | 28 | constant ('JSON_PRETTY_PRINT') : 0)); |
29 | -file_put_contents (QERO_DIR .'/start.bat', '@echo off |
|
29 | +file_put_contents(QERO_DIR.'/start.bat', '@echo off |
|
30 | 30 | '. $info['scripts']['start']); |
31 | 31 | |
32 | -if (!is_dir (QERO_DIR .'/app')) |
|
32 | +if (!is_dir(QERO_DIR.'/app')) |
|
33 | 33 | { |
34 | - echo ' Configuring application...'. PHP_EOL; |
|
34 | + echo ' Configuring application...'.PHP_EOL; |
|
35 | 35 | |
36 | - mkdir (QERO_DIR .'/app'); |
|
37 | - dir_copy (__DIR__ .'/app_bundle', QERO_DIR .'/app'); |
|
36 | + mkdir(QERO_DIR.'/app'); |
|
37 | + dir_copy(__DIR__.'/app_bundle', QERO_DIR.'/app'); |
|
38 | 38 | } |
39 | 39 | |
40 | -Qero\dir_delete (__DIR__ .'/app_bundle'); |
|
41 | -unlink (__FILE__); |
|
40 | +Qero\dir_delete(__DIR__.'/app_bundle'); |
|
41 | +unlink(__FILE__); |
|
42 | 42 | |
43 | -echo ' Configuration completed'. PHP_EOL . |
|
44 | - ' Thank for installing winforms-php/VoidFramework!'. PHP_EOL . PHP_EOL; |
|
43 | +echo ' Configuration completed'.PHP_EOL. |
|
44 | + ' Thank for installing winforms-php/VoidFramework!'.PHP_EOL.PHP_EOL; |
@@ -338,8 +338,9 @@ |
||
338 | 338 | 'clLight' => $converter->fromHtml ('#EEEEEE') |
339 | 339 | ]; |
340 | 340 | |
341 | -foreach ($constants as $name => $value) |
|
341 | +foreach ($constants as $name => $value) { |
|
342 | 342 | define ($name, $value); |
343 | +} |
|
343 | 344 | |
344 | 345 | $argv = START_PARAMS; |
345 | 346 | $argc = sizeof ($argv); |
@@ -8,338 +8,338 @@ |
||
8 | 8 | $converter = new NetClass ('System.Drawing.ColorTranslator'); |
9 | 9 | |
10 | 10 | $constants = [ |
11 | - # Информация об окружении |
|
11 | + # Информация об окружении |
|
12 | 12 | |
13 | - 'EXE_NAME' => $APPLICATION->executablePath, |
|
14 | - 'DOC_ROOT' => dirname ($APPLICATION->executablePath), |
|
15 | - 'IS_ADMIN' => is_writable (getenv ('SystemRoot')), |
|
16 | - 'START_PARAMS' => $params, |
|
17 | - 'USERNAME' => $env->username, |
|
13 | + 'EXE_NAME' => $APPLICATION->executablePath, |
|
14 | + 'DOC_ROOT' => dirname ($APPLICATION->executablePath), |
|
15 | + 'IS_ADMIN' => is_writable (getenv ('SystemRoot')), |
|
16 | + 'START_PARAMS' => $params, |
|
17 | + 'USERNAME' => $env->username, |
|
18 | 18 | |
19 | - # Константы MessageBox'а |
|
19 | + # Константы MessageBox'а |
|
20 | 20 | |
21 | - 'MB_YESNO' => 4, |
|
22 | - 'MB_YESNOCANCEL' => 3, |
|
23 | - 'MB_OK' => 0, |
|
24 | - 'MB_OKCANCEL' => 1, |
|
25 | - 'MB_RETRYCANCEL' => 5, |
|
26 | - 'MB_ABORTRETRYIGNORE' => 2, |
|
27 | - 'MBI_ASTERISK' => 64, |
|
28 | - 'MBI_ERROR' => 16, |
|
29 | - 'MBI_EXCLAMATION' => 48, |
|
30 | - 'MBI_HAND' => 16, |
|
31 | - 'MBI_INFORMATION' => 64, |
|
32 | - 'MBI_NONE' => 0, |
|
33 | - 'MBI_QUESTION' => 32, |
|
34 | - 'MBI_STOP' => 16, |
|
35 | - 'MBI_WARNING' => 48, |
|
36 | - 'MBDB_1' => 0, |
|
37 | - 'MBDB_2' => 256, |
|
38 | - 'MBDB_3' => 512, |
|
21 | + 'MB_YESNO' => 4, |
|
22 | + 'MB_YESNOCANCEL' => 3, |
|
23 | + 'MB_OK' => 0, |
|
24 | + 'MB_OKCANCEL' => 1, |
|
25 | + 'MB_RETRYCANCEL' => 5, |
|
26 | + 'MB_ABORTRETRYIGNORE' => 2, |
|
27 | + 'MBI_ASTERISK' => 64, |
|
28 | + 'MBI_ERROR' => 16, |
|
29 | + 'MBI_EXCLAMATION' => 48, |
|
30 | + 'MBI_HAND' => 16, |
|
31 | + 'MBI_INFORMATION' => 64, |
|
32 | + 'MBI_NONE' => 0, |
|
33 | + 'MBI_QUESTION' => 32, |
|
34 | + 'MBI_STOP' => 16, |
|
35 | + 'MBI_WARNING' => 48, |
|
36 | + 'MBDB_1' => 0, |
|
37 | + 'MBDB_2' => 256, |
|
38 | + 'MBDB_3' => 512, |
|
39 | 39 | |
40 | - # Константы DialogResult |
|
40 | + # Константы DialogResult |
|
41 | 41 | |
42 | - 'drOk' => 1, |
|
43 | - 'drYes' => 6, |
|
44 | - 'drNo' => 7, |
|
45 | - 'drCancel' => 2, |
|
46 | - 'drRetry' => 4, |
|
47 | - 'drAbort' => 3, |
|
48 | - 'drIgnore' => 5, |
|
49 | - 'drNone' => 0, |
|
42 | + 'drOk' => 1, |
|
43 | + 'drYes' => 6, |
|
44 | + 'drNo' => 7, |
|
45 | + 'drCancel' => 2, |
|
46 | + 'drRetry' => 4, |
|
47 | + 'drAbort' => 3, |
|
48 | + 'drIgnore' => 5, |
|
49 | + 'drNone' => 0, |
|
50 | 50 | |
51 | - # Константы форм |
|
51 | + # Константы форм |
|
52 | 52 | |
53 | - 'fbsNone' => 0, |
|
54 | - 'fbsSingle' => 1, |
|
55 | - 'fbs3D' => 2, |
|
56 | - 'fbsDialog' => 3, |
|
57 | - 'fbsSizable' => 4, |
|
58 | - 'fbsToolWindow' => 5, |
|
59 | - 'fbsSizableToolWindow' => 6, |
|
60 | - |
|
61 | - 'fwsNormal' => 0, |
|
62 | - 'fwsMinimized' => 1, |
|
63 | - 'fwsMaximized' => 2, |
|
64 | - |
|
65 | - 'fspManual' => 0, |
|
66 | - 'fspCenterScreen' => 1, |
|
67 | - 'fspWindowsDefaultLocation' => 2, |
|
68 | - 'fspWindowsDefaultBounds' => 3, |
|
69 | - 'fspCenterParent' => 4, |
|
70 | - |
|
71 | - # Константы стиля оконтовки |
|
72 | - |
|
73 | - 'bsNone' => 0, |
|
74 | - 'bsFixedSingle' => 1, |
|
75 | - 'bsFixed3D' => 2, |
|
76 | - |
|
77 | - # Константы выравнивания |
|
78 | - |
|
79 | - 'alTopLeft' => 1, |
|
80 | - 'alTopCenter' => 2, |
|
81 | - 'alTopRight' => 4, |
|
82 | - 'alMiddleLeft' => 16, |
|
83 | - 'alMiddleCenter' => 32, |
|
84 | - 'alMiddleRight' => 64, |
|
85 | - 'alBottomLeft' => 256, |
|
86 | - 'alBottomCenter' => 512, |
|
87 | - 'alBottomRight' => 1024, |
|
88 | - |
|
89 | - # Константы притягивания (Anchor) |
|
90 | - |
|
91 | - 'acNone' => 0, |
|
92 | - 'acTop' => 1, |
|
93 | - 'acBottom' => 2, |
|
94 | - 'acLeft' => 4, |
|
95 | - 'acRight' => 8, |
|
96 | - |
|
97 | - # Константы SizeMode-параметра PictureBox'а |
|
98 | - |
|
99 | - 'smNormal' => 0, |
|
100 | - 'smStretchImage' => 1, |
|
101 | - 'smAutoSize' => 2, |
|
102 | - 'smCenterImage' => 3, |
|
103 | - 'smZoom' => 4, |
|
104 | - |
|
105 | - # Константы View-параметра ListView'а |
|
53 | + 'fbsNone' => 0, |
|
54 | + 'fbsSingle' => 1, |
|
55 | + 'fbs3D' => 2, |
|
56 | + 'fbsDialog' => 3, |
|
57 | + 'fbsSizable' => 4, |
|
58 | + 'fbsToolWindow' => 5, |
|
59 | + 'fbsSizableToolWindow' => 6, |
|
60 | + |
|
61 | + 'fwsNormal' => 0, |
|
62 | + 'fwsMinimized' => 1, |
|
63 | + 'fwsMaximized' => 2, |
|
64 | + |
|
65 | + 'fspManual' => 0, |
|
66 | + 'fspCenterScreen' => 1, |
|
67 | + 'fspWindowsDefaultLocation' => 2, |
|
68 | + 'fspWindowsDefaultBounds' => 3, |
|
69 | + 'fspCenterParent' => 4, |
|
70 | + |
|
71 | + # Константы стиля оконтовки |
|
72 | + |
|
73 | + 'bsNone' => 0, |
|
74 | + 'bsFixedSingle' => 1, |
|
75 | + 'bsFixed3D' => 2, |
|
76 | + |
|
77 | + # Константы выравнивания |
|
78 | + |
|
79 | + 'alTopLeft' => 1, |
|
80 | + 'alTopCenter' => 2, |
|
81 | + 'alTopRight' => 4, |
|
82 | + 'alMiddleLeft' => 16, |
|
83 | + 'alMiddleCenter' => 32, |
|
84 | + 'alMiddleRight' => 64, |
|
85 | + 'alBottomLeft' => 256, |
|
86 | + 'alBottomCenter' => 512, |
|
87 | + 'alBottomRight' => 1024, |
|
88 | + |
|
89 | + # Константы притягивания (Anchor) |
|
90 | + |
|
91 | + 'acNone' => 0, |
|
92 | + 'acTop' => 1, |
|
93 | + 'acBottom' => 2, |
|
94 | + 'acLeft' => 4, |
|
95 | + 'acRight' => 8, |
|
96 | + |
|
97 | + # Константы SizeMode-параметра PictureBox'а |
|
98 | + |
|
99 | + 'smNormal' => 0, |
|
100 | + 'smStretchImage' => 1, |
|
101 | + 'smAutoSize' => 2, |
|
102 | + 'smCenterImage' => 3, |
|
103 | + 'smZoom' => 4, |
|
104 | + |
|
105 | + # Константы View-параметра ListView'а |
|
106 | 106 | |
107 | - 'vwLargeIcon' => 0, |
|
108 | - 'vwDetails' => 1, |
|
109 | - 'vwSmallIcon' => 2, |
|
110 | - 'vwList' => 3, |
|
111 | - 'vwTile' => 4, |
|
107 | + 'vwLargeIcon' => 0, |
|
108 | + 'vwDetails' => 1, |
|
109 | + 'vwSmallIcon' => 2, |
|
110 | + 'vwList' => 3, |
|
111 | + 'vwTile' => 4, |
|
112 | 112 | |
113 | - # Константы dropDownStyle компонента ComboBox |
|
113 | + # Константы dropDownStyle компонента ComboBox |
|
114 | 114 | |
115 | - 'ddSimple' => 0, |
|
116 | - 'ddDropDown' => 1, |
|
117 | - 'ddDropDownList' => 2, |
|
115 | + 'ddSimple' => 0, |
|
116 | + 'ddDropDown' => 1, |
|
117 | + 'ddDropDownList' => 2, |
|
118 | 118 | |
119 | - # Константы причины закрытия формы |
|
119 | + # Константы причины закрытия формы |
|
120 | 120 | |
121 | - 'fcrNone' => 0, |
|
122 | - 'fcrWindowsShutDown' => 1, |
|
123 | - 'fcrMdiFormClosing' => 2, |
|
124 | - 'fcrUserClosing' => 3, |
|
125 | - 'fcrTaskManagerClosing' => 4, |
|
126 | - 'fcrFormOwnerClosing' => 5, |
|
127 | - 'fcrApplicationExitCall' => 6, |
|
121 | + 'fcrNone' => 0, |
|
122 | + 'fcrWindowsShutDown' => 1, |
|
123 | + 'fcrMdiFormClosing' => 2, |
|
124 | + 'fcrUserClosing' => 3, |
|
125 | + 'fcrTaskManagerClosing' => 4, |
|
126 | + 'fcrFormOwnerClosing' => 5, |
|
127 | + 'fcrApplicationExitCall' => 6, |
|
128 | 128 | |
129 | - # Константы дока |
|
129 | + # Константы дока |
|
130 | 130 | |
131 | - 'dsBottom' => 2, |
|
132 | - 'dsFill' => 5, |
|
133 | - 'dsLeft' => 3, |
|
134 | - 'dsNone' => 0, |
|
135 | - 'dsRight' => 4, |
|
136 | - 'dsTop' => 1, |
|
131 | + 'dsBottom' => 2, |
|
132 | + 'dsFill' => 5, |
|
133 | + 'dsLeft' => 3, |
|
134 | + 'dsNone' => 0, |
|
135 | + 'dsRight' => 4, |
|
136 | + 'dsTop' => 1, |
|
137 | 137 | |
138 | - # Константы FCTB.Language |
|
138 | + # Константы FCTB.Language |
|
139 | 139 | |
140 | - 'langCSharp' => 1, |
|
141 | - 'langCustom' => 2, |
|
142 | - 'langHTML' => 3, |
|
143 | - 'langJS' => 4, |
|
144 | - 'langLua' => 5, |
|
145 | - 'langPHP' => 6, |
|
146 | - 'langSQL' => 7, |
|
147 | - 'langVB' => 8, |
|
148 | - 'langXML' => 9, |
|
140 | + 'langCSharp' => 1, |
|
141 | + 'langCustom' => 2, |
|
142 | + 'langHTML' => 3, |
|
143 | + 'langJS' => 4, |
|
144 | + 'langLua' => 5, |
|
145 | + 'langPHP' => 6, |
|
146 | + 'langSQL' => 7, |
|
147 | + 'langVB' => 8, |
|
148 | + 'langXML' => 9, |
|
149 | 149 | |
150 | - # Константы видимости окна процесса |
|
150 | + # Константы видимости окна процесса |
|
151 | 151 | |
152 | - 'pwsHidden' => 0, |
|
153 | - 'pwsMaximized' => 3, |
|
154 | - 'pwsMinimized' => 2, |
|
155 | - 'pwsNormal' => 1, |
|
152 | + 'pwsHidden' => 0, |
|
153 | + 'pwsMaximized' => 3, |
|
154 | + 'pwsMinimized' => 2, |
|
155 | + 'pwsNormal' => 1, |
|
156 | 156 | |
157 | - # Константы запуска |
|
157 | + # Константы запуска |
|
158 | 158 | |
159 | - 'runNo' => 0, |
|
160 | - 'runYes' => 1, |
|
161 | - 'runThread' => 2, |
|
159 | + 'runNo' => 0, |
|
160 | + 'runYes' => 1, |
|
161 | + 'runThread' => 2, |
|
162 | 162 | |
163 | - # Константы стиля ProgressBar'а |
|
163 | + # Константы стиля ProgressBar'а |
|
164 | 164 | |
165 | - 'pbBlocks' => 0, |
|
166 | - 'pbContinuous' => 1, |
|
167 | - 'pbMarquee' => 2, |
|
165 | + 'pbBlocks' => 0, |
|
166 | + 'pbContinuous' => 1, |
|
167 | + 'pbMarquee' => 2, |
|
168 | 168 | |
169 | - # Константы свойства FlatStyle |
|
169 | + # Константы свойства FlatStyle |
|
170 | 170 | |
171 | - 'flFlat' => 0, |
|
172 | - 'flPopup' => 1, |
|
173 | - 'flStandard' => 2, |
|
174 | - 'flSystem' => 3, |
|
171 | + 'flFlat' => 0, |
|
172 | + 'flPopup' => 1, |
|
173 | + 'flStandard' => 2, |
|
174 | + 'flSystem' => 3, |
|
175 | 175 | |
176 | - # Константы свойства DrawMode |
|
176 | + # Константы свойства DrawMode |
|
177 | 177 | |
178 | - 'dwNormal' => 0, |
|
179 | - 'dwOwnerDrawFixed' => 1, |
|
180 | - 'dwOwnerDrawVariable' => 2, |
|
178 | + 'dwNormal' => 0, |
|
179 | + 'dwOwnerDrawFixed' => 1, |
|
180 | + 'dwOwnerDrawVariable' => 2, |
|
181 | 181 | |
182 | - # Константы свойства SizeMode PictureBox'а |
|
182 | + # Константы свойства SizeMode PictureBox'а |
|
183 | 183 | |
184 | - 'smNormal' => 0, |
|
185 | - 'smStretchImage' => 1, |
|
186 | - 'smAutoSize' => 2, |
|
187 | - 'smCenterImage' => 3, |
|
188 | - 'smZoom' => 4, |
|
184 | + 'smNormal' => 0, |
|
185 | + 'smStretchImage' => 1, |
|
186 | + 'smAutoSize' => 2, |
|
187 | + 'smCenterImage' => 3, |
|
188 | + 'smZoom' => 4, |
|
189 | 189 | |
190 | - # Цветовые константы |
|
190 | + # Цветовые константы |
|
191 | 191 | |
192 | - 'clAliceBlue' => 0xFFF0F8FF, |
|
193 | - 'clAntiqueWhite' => 0xFFFAEBD7, |
|
194 | - 'clAqua' => 0xFF00FFFF, |
|
195 | - 'clAquamarine' => 0xFF7FFFD4, |
|
196 | - 'clAzure' => 0xFFF0FFFF, |
|
197 | - 'clBeige' => 0xFFF5F5DC, |
|
198 | - 'clBisque' => 0xFFFFE4C4, |
|
199 | - 'clBlack' => 0xFF000000, |
|
200 | - 'clBlanchedAlmond' => 0xFFFFEBCD, |
|
201 | - 'clBlue' => 0xFF0000FF, |
|
202 | - 'clBlueViolet' => 0xFF8A2BE2, |
|
203 | - 'clBrown' => 0xFFA52A2A, |
|
204 | - 'clBurlyWood' => 0xFFDEB887, |
|
205 | - 'clCadetBlue' => 0xFF5F9EA0, |
|
206 | - 'clChartreuse' => 0xFF7FFF00, |
|
207 | - 'clChocolate' => 0xFFD2691E, |
|
208 | - 'clCoral' => 0xFFFF7F50, |
|
209 | - 'clCornflowerBlue' => 0xFF6495ED, |
|
210 | - 'clCornsilk' => 0xFFFFF8DC, |
|
211 | - 'clCrimson' => 0xFFDC143C, |
|
212 | - 'clCyan' => 0xFF00FFFF, |
|
213 | - 'clDarkBlue' => 0xFF00008B, |
|
214 | - 'clDarkCyan' => 0xFF008B8B, |
|
215 | - 'clDarkGoldenrod' => 0xFFB8860B, |
|
216 | - 'clDarkGray' => 0xFFA9A9A9, |
|
217 | - 'clDarkGreen' => 0xFF006400, |
|
218 | - 'clDarkKhaki' => 0xFFBDB76B, |
|
219 | - 'clDarkMagenta' => 0xFF8B008B, |
|
220 | - 'clDarkOliveGreen' => 0xFF556B2F, |
|
221 | - 'clDarkOrange' => 0xFFFF8C00, |
|
222 | - 'clDarkOrchid' => 0xFF9932CC, |
|
223 | - 'clDarkRed' => 0xFF8B0000, |
|
224 | - 'clDarkSalmon' => 0xFFE9967A, |
|
225 | - 'clDarkSeaGreen' => 0xFF8FBC8F, |
|
226 | - 'clDarkSlateBlue' => 0xFF483D8B, |
|
227 | - 'clDarkSlateGray' => 0xFF2F4F4F, |
|
228 | - 'clDarkTurquoise' => 0xFF00CED1, |
|
229 | - 'clDarkViolet' => 0xFF9400D3, |
|
230 | - 'clDeepPink' => 0xFFFF1493, |
|
231 | - 'clDeepSkyBlue' => 0xFF00BFFF, |
|
232 | - 'clDimGray' => 0xFF696969, |
|
233 | - 'clDodgerBlue' => 0xFF1E90FF, |
|
234 | - 'clFirebrick' => 0xFFB22222, |
|
235 | - 'clFloralWhite' => 0xFFFFFAF0, |
|
236 | - 'clForestGreen' => 0xFF228B22, |
|
237 | - 'clFuchsia' => 0xFFFF00FF, |
|
238 | - 'clGainsboro' => 0xFFDCDCDC, |
|
239 | - 'clGhostWhite' => 0xFFF8F8FF, |
|
240 | - 'clGold' => 0xFFFFD700, |
|
241 | - 'clGoldenrod' => 0xFFDAA520, |
|
242 | - 'clGray' => 0xFF808080, |
|
243 | - 'clGreen' => 0xFF008000, |
|
244 | - 'clGreenYellow' => 0xFFADFF2F, |
|
245 | - 'clHoneydew' => 0xFFF0FFF0, |
|
246 | - 'clHotPink' => 0xFFFF69B4, |
|
247 | - 'clIndianRed' => 0xFFCD5C5C, |
|
248 | - 'clIndigo' => 0xFF4B0082, |
|
249 | - 'clIvory' => 0xFFFFFFF0, |
|
250 | - 'clKhaki' => 0xFFF0E68C, |
|
251 | - 'clLavender' => 0xFFE6E6FA, |
|
252 | - 'clLavenderBlush' => 0xFFFFF0F5, |
|
253 | - 'clLawnGreen' => 0xFF7CFC00, |
|
254 | - 'clLemonChiffon' => 0xFFFFFACD, |
|
255 | - 'clLightBlue' => 0xFFADD8E6, |
|
256 | - 'clLightCoral' => 0xFFF08080, |
|
257 | - 'clLightCyan' => 0xFFE0FFFF, |
|
258 | - 'clLightGoldenrodYellow' => 0xFFFAFAD2, |
|
259 | - 'clLightGray' => 0xFFD3D3D3, |
|
260 | - 'clLightGreen' => 0xFF90EE90, |
|
261 | - 'clLightPink' => 0xFFFFB6C1, |
|
262 | - 'clLightSalmon' => 0xFFFFA07A, |
|
263 | - 'clLightSeaGreen' => 0xFF20B2AA, |
|
264 | - 'clLightSkyBlue' => 0xFF87CEFA, |
|
265 | - 'clLightSlateGray' => 0xFF778899, |
|
266 | - 'clLightSteelBlue' => 0xFFB0C4DE, |
|
267 | - 'clLightYellow' => 0xFFFFFFE0, |
|
268 | - 'clLime' => 0xFF00FF00, |
|
269 | - 'clLimeGreen' => 0xFF32CD32, |
|
270 | - 'clLinen' => 0xFFFAF0E6, |
|
271 | - 'clMagenta' => 0xFFFF00FF, |
|
272 | - 'clMaroon' => 0xFF800000, |
|
273 | - 'clMediumAquamarine' => 0xFF66CDAA, |
|
274 | - 'clMediumBlue' => 0xFF0000CD, |
|
275 | - 'clMediumOrchid' => 0xFFBA55D3, |
|
276 | - 'clMediumPurple' => 0xFF9370DB, |
|
277 | - 'clMediumSeaGreen' => 0xFF3CB371, |
|
278 | - 'clMediumSlateBlue' => 0xFF7B68EE, |
|
279 | - 'clMediumSpringGreen' => 0xFF00FA9A, |
|
280 | - 'clMediumTurquoise' => 0xFF48D1CC, |
|
281 | - 'clMediumVioletRed' => 0xFFC71585, |
|
282 | - 'clMidnightBlue' => 0xFF191970, |
|
283 | - 'clMintCream' => 0xFFF5FFFA, |
|
284 | - 'clMistyRose' => 0xFFFFE4E1, |
|
285 | - 'clMoccasin' => 0xFFFFE4B5, |
|
286 | - 'clNavajoWhite' => 0xFFFFDEAD, |
|
287 | - 'clNavy' => 0xFF000080, |
|
288 | - 'clOldLace' => 0xFFFDF5E6, |
|
289 | - 'clOlive' => 0xFF808000, |
|
290 | - 'clOliveDrab' => 0xFF6B8E23, |
|
291 | - 'clOrange' => 0xFFFFA500, |
|
292 | - 'clOrangeRed' => 0xFFFF4500, |
|
293 | - 'clOrchid' => 0xFFDA70D6, |
|
294 | - 'clPaleGoldenrod' => 0xFFEEE8AA, |
|
295 | - 'clPaleGreen' => 0xFF98FB98, |
|
296 | - 'clPaleTurquoise' => 0xFFAFEEEE, |
|
297 | - 'clPaleVioletRed' => 0xFFDB7093, |
|
298 | - 'clPapayaWhip' => 0xFFFFEFD5, |
|
299 | - 'clPeachPuff' => 0xFFFFDAB9, |
|
300 | - 'clPeru' => 0xFFCD853F, |
|
301 | - 'clPink' => 0xFFFFC0CB, |
|
302 | - 'clPlum' => 0xFFDDA0DD, |
|
303 | - 'clPowderBlue' => 0xFFB0E0E6, |
|
304 | - 'clPurple' => 0xFF800080, |
|
305 | - 'clRed' => 0xFFFF0000, |
|
306 | - 'clRosyBrown' => 0xFFBC8F8F, |
|
307 | - 'clRoyalBlue' => 0xFF4169E1, |
|
308 | - 'clSaddleBrown' => 0xFF8B4513, |
|
309 | - 'clSalmon' => 0xFFFA8072, |
|
310 | - 'clSandyBrown' => 0xFFF4A460, |
|
311 | - 'clSeaGreen' => 0xFF2E8B57, |
|
312 | - 'clSeaShell' => 0xFFFFF5EE, |
|
313 | - 'clSienna' => 0xFFA0522D, |
|
314 | - 'clSilver' => 0xFFC0C0C0, |
|
315 | - 'clSkyBlue' => 0xFF87CEEB, |
|
316 | - 'clSlateBlue' => 0xFF6A5ACD, |
|
317 | - 'clSlateGray' => 0xFF708090, |
|
318 | - 'clSnow' => 0xFFFFFAFA, |
|
319 | - 'clSpringGreen' => 0xFF00FF7F, |
|
320 | - 'clSteelBlue' => 0xFF4682B4, |
|
321 | - 'clTan' => 0xFFD2B48C, |
|
322 | - 'clTeal' => 0xFF008080, |
|
323 | - 'clThistle' => 0xFFD8BFD8, |
|
324 | - 'clTomato' => 0xFFFF6347, |
|
325 | - 'clTurquoise' => 0xFF40E0D0, |
|
326 | - 'clViolet' => 0xFFEE82EE, |
|
327 | - 'clWheat' => 0xFFF5DEB3, |
|
328 | - 'clWhite' => 0xFFFFFFFF, |
|
329 | - 'clWhiteSmoke' => 0xFFF5F5F5, |
|
330 | - 'clYellow' => 0xFFFFFF00, |
|
331 | - 'clYellowGreen' => 0xFF9ACD32, |
|
332 | - |
|
333 | - # Моя подборка цветов |
|
334 | - |
|
335 | - 'clDark' => $converter->fromHtml ('#0D0F12'), |
|
336 | - 'clDark2' => $converter->fromHtml ('#121416'), |
|
337 | - 'clTurquoise' => $converter->fromHtml ('#00ADB5'), |
|
338 | - 'clLight' => $converter->fromHtml ('#EEEEEE') |
|
192 | + 'clAliceBlue' => 0xFFF0F8FF, |
|
193 | + 'clAntiqueWhite' => 0xFFFAEBD7, |
|
194 | + 'clAqua' => 0xFF00FFFF, |
|
195 | + 'clAquamarine' => 0xFF7FFFD4, |
|
196 | + 'clAzure' => 0xFFF0FFFF, |
|
197 | + 'clBeige' => 0xFFF5F5DC, |
|
198 | + 'clBisque' => 0xFFFFE4C4, |
|
199 | + 'clBlack' => 0xFF000000, |
|
200 | + 'clBlanchedAlmond' => 0xFFFFEBCD, |
|
201 | + 'clBlue' => 0xFF0000FF, |
|
202 | + 'clBlueViolet' => 0xFF8A2BE2, |
|
203 | + 'clBrown' => 0xFFA52A2A, |
|
204 | + 'clBurlyWood' => 0xFFDEB887, |
|
205 | + 'clCadetBlue' => 0xFF5F9EA0, |
|
206 | + 'clChartreuse' => 0xFF7FFF00, |
|
207 | + 'clChocolate' => 0xFFD2691E, |
|
208 | + 'clCoral' => 0xFFFF7F50, |
|
209 | + 'clCornflowerBlue' => 0xFF6495ED, |
|
210 | + 'clCornsilk' => 0xFFFFF8DC, |
|
211 | + 'clCrimson' => 0xFFDC143C, |
|
212 | + 'clCyan' => 0xFF00FFFF, |
|
213 | + 'clDarkBlue' => 0xFF00008B, |
|
214 | + 'clDarkCyan' => 0xFF008B8B, |
|
215 | + 'clDarkGoldenrod' => 0xFFB8860B, |
|
216 | + 'clDarkGray' => 0xFFA9A9A9, |
|
217 | + 'clDarkGreen' => 0xFF006400, |
|
218 | + 'clDarkKhaki' => 0xFFBDB76B, |
|
219 | + 'clDarkMagenta' => 0xFF8B008B, |
|
220 | + 'clDarkOliveGreen' => 0xFF556B2F, |
|
221 | + 'clDarkOrange' => 0xFFFF8C00, |
|
222 | + 'clDarkOrchid' => 0xFF9932CC, |
|
223 | + 'clDarkRed' => 0xFF8B0000, |
|
224 | + 'clDarkSalmon' => 0xFFE9967A, |
|
225 | + 'clDarkSeaGreen' => 0xFF8FBC8F, |
|
226 | + 'clDarkSlateBlue' => 0xFF483D8B, |
|
227 | + 'clDarkSlateGray' => 0xFF2F4F4F, |
|
228 | + 'clDarkTurquoise' => 0xFF00CED1, |
|
229 | + 'clDarkViolet' => 0xFF9400D3, |
|
230 | + 'clDeepPink' => 0xFFFF1493, |
|
231 | + 'clDeepSkyBlue' => 0xFF00BFFF, |
|
232 | + 'clDimGray' => 0xFF696969, |
|
233 | + 'clDodgerBlue' => 0xFF1E90FF, |
|
234 | + 'clFirebrick' => 0xFFB22222, |
|
235 | + 'clFloralWhite' => 0xFFFFFAF0, |
|
236 | + 'clForestGreen' => 0xFF228B22, |
|
237 | + 'clFuchsia' => 0xFFFF00FF, |
|
238 | + 'clGainsboro' => 0xFFDCDCDC, |
|
239 | + 'clGhostWhite' => 0xFFF8F8FF, |
|
240 | + 'clGold' => 0xFFFFD700, |
|
241 | + 'clGoldenrod' => 0xFFDAA520, |
|
242 | + 'clGray' => 0xFF808080, |
|
243 | + 'clGreen' => 0xFF008000, |
|
244 | + 'clGreenYellow' => 0xFFADFF2F, |
|
245 | + 'clHoneydew' => 0xFFF0FFF0, |
|
246 | + 'clHotPink' => 0xFFFF69B4, |
|
247 | + 'clIndianRed' => 0xFFCD5C5C, |
|
248 | + 'clIndigo' => 0xFF4B0082, |
|
249 | + 'clIvory' => 0xFFFFFFF0, |
|
250 | + 'clKhaki' => 0xFFF0E68C, |
|
251 | + 'clLavender' => 0xFFE6E6FA, |
|
252 | + 'clLavenderBlush' => 0xFFFFF0F5, |
|
253 | + 'clLawnGreen' => 0xFF7CFC00, |
|
254 | + 'clLemonChiffon' => 0xFFFFFACD, |
|
255 | + 'clLightBlue' => 0xFFADD8E6, |
|
256 | + 'clLightCoral' => 0xFFF08080, |
|
257 | + 'clLightCyan' => 0xFFE0FFFF, |
|
258 | + 'clLightGoldenrodYellow' => 0xFFFAFAD2, |
|
259 | + 'clLightGray' => 0xFFD3D3D3, |
|
260 | + 'clLightGreen' => 0xFF90EE90, |
|
261 | + 'clLightPink' => 0xFFFFB6C1, |
|
262 | + 'clLightSalmon' => 0xFFFFA07A, |
|
263 | + 'clLightSeaGreen' => 0xFF20B2AA, |
|
264 | + 'clLightSkyBlue' => 0xFF87CEFA, |
|
265 | + 'clLightSlateGray' => 0xFF778899, |
|
266 | + 'clLightSteelBlue' => 0xFFB0C4DE, |
|
267 | + 'clLightYellow' => 0xFFFFFFE0, |
|
268 | + 'clLime' => 0xFF00FF00, |
|
269 | + 'clLimeGreen' => 0xFF32CD32, |
|
270 | + 'clLinen' => 0xFFFAF0E6, |
|
271 | + 'clMagenta' => 0xFFFF00FF, |
|
272 | + 'clMaroon' => 0xFF800000, |
|
273 | + 'clMediumAquamarine' => 0xFF66CDAA, |
|
274 | + 'clMediumBlue' => 0xFF0000CD, |
|
275 | + 'clMediumOrchid' => 0xFFBA55D3, |
|
276 | + 'clMediumPurple' => 0xFF9370DB, |
|
277 | + 'clMediumSeaGreen' => 0xFF3CB371, |
|
278 | + 'clMediumSlateBlue' => 0xFF7B68EE, |
|
279 | + 'clMediumSpringGreen' => 0xFF00FA9A, |
|
280 | + 'clMediumTurquoise' => 0xFF48D1CC, |
|
281 | + 'clMediumVioletRed' => 0xFFC71585, |
|
282 | + 'clMidnightBlue' => 0xFF191970, |
|
283 | + 'clMintCream' => 0xFFF5FFFA, |
|
284 | + 'clMistyRose' => 0xFFFFE4E1, |
|
285 | + 'clMoccasin' => 0xFFFFE4B5, |
|
286 | + 'clNavajoWhite' => 0xFFFFDEAD, |
|
287 | + 'clNavy' => 0xFF000080, |
|
288 | + 'clOldLace' => 0xFFFDF5E6, |
|
289 | + 'clOlive' => 0xFF808000, |
|
290 | + 'clOliveDrab' => 0xFF6B8E23, |
|
291 | + 'clOrange' => 0xFFFFA500, |
|
292 | + 'clOrangeRed' => 0xFFFF4500, |
|
293 | + 'clOrchid' => 0xFFDA70D6, |
|
294 | + 'clPaleGoldenrod' => 0xFFEEE8AA, |
|
295 | + 'clPaleGreen' => 0xFF98FB98, |
|
296 | + 'clPaleTurquoise' => 0xFFAFEEEE, |
|
297 | + 'clPaleVioletRed' => 0xFFDB7093, |
|
298 | + 'clPapayaWhip' => 0xFFFFEFD5, |
|
299 | + 'clPeachPuff' => 0xFFFFDAB9, |
|
300 | + 'clPeru' => 0xFFCD853F, |
|
301 | + 'clPink' => 0xFFFFC0CB, |
|
302 | + 'clPlum' => 0xFFDDA0DD, |
|
303 | + 'clPowderBlue' => 0xFFB0E0E6, |
|
304 | + 'clPurple' => 0xFF800080, |
|
305 | + 'clRed' => 0xFFFF0000, |
|
306 | + 'clRosyBrown' => 0xFFBC8F8F, |
|
307 | + 'clRoyalBlue' => 0xFF4169E1, |
|
308 | + 'clSaddleBrown' => 0xFF8B4513, |
|
309 | + 'clSalmon' => 0xFFFA8072, |
|
310 | + 'clSandyBrown' => 0xFFF4A460, |
|
311 | + 'clSeaGreen' => 0xFF2E8B57, |
|
312 | + 'clSeaShell' => 0xFFFFF5EE, |
|
313 | + 'clSienna' => 0xFFA0522D, |
|
314 | + 'clSilver' => 0xFFC0C0C0, |
|
315 | + 'clSkyBlue' => 0xFF87CEEB, |
|
316 | + 'clSlateBlue' => 0xFF6A5ACD, |
|
317 | + 'clSlateGray' => 0xFF708090, |
|
318 | + 'clSnow' => 0xFFFFFAFA, |
|
319 | + 'clSpringGreen' => 0xFF00FF7F, |
|
320 | + 'clSteelBlue' => 0xFF4682B4, |
|
321 | + 'clTan' => 0xFFD2B48C, |
|
322 | + 'clTeal' => 0xFF008080, |
|
323 | + 'clThistle' => 0xFFD8BFD8, |
|
324 | + 'clTomato' => 0xFFFF6347, |
|
325 | + 'clTurquoise' => 0xFF40E0D0, |
|
326 | + 'clViolet' => 0xFFEE82EE, |
|
327 | + 'clWheat' => 0xFFF5DEB3, |
|
328 | + 'clWhite' => 0xFFFFFFFF, |
|
329 | + 'clWhiteSmoke' => 0xFFF5F5F5, |
|
330 | + 'clYellow' => 0xFFFFFF00, |
|
331 | + 'clYellowGreen' => 0xFF9ACD32, |
|
332 | + |
|
333 | + # Моя подборка цветов |
|
334 | + |
|
335 | + 'clDark' => $converter->fromHtml ('#0D0F12'), |
|
336 | + 'clDark2' => $converter->fromHtml ('#121416'), |
|
337 | + 'clTurquoise' => $converter->fromHtml ('#00ADB5'), |
|
338 | + 'clLight' => $converter->fromHtml ('#EEEEEE') |
|
339 | 339 | ]; |
340 | 340 | |
341 | 341 | foreach ($constants as $name => $value) |
342 | - define ($name, $value); |
|
342 | + define ($name, $value); |
|
343 | 343 | |
344 | 344 | $argv = START_PARAMS; |
345 | 345 | $argc = sizeof ($argv); |
@@ -2,17 +2,17 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -$env = new NetClass ('System.Environment', 'mscorlib'); |
|
6 | -$params = $env->getCommandLineArgs ()->list; |
|
5 | +$env = new NetClass('System.Environment', 'mscorlib'); |
|
6 | +$params = $env->getCommandLineArgs()->list; |
|
7 | 7 | |
8 | -$converter = new NetClass ('System.Drawing.ColorTranslator'); |
|
8 | +$converter = new NetClass('System.Drawing.ColorTranslator'); |
|
9 | 9 | |
10 | 10 | $constants = [ |
11 | 11 | # Информация об окружении |
12 | 12 | |
13 | 13 | 'EXE_NAME' => $APPLICATION->executablePath, |
14 | - 'DOC_ROOT' => dirname ($APPLICATION->executablePath), |
|
15 | - 'IS_ADMIN' => is_writable (getenv ('SystemRoot')), |
|
14 | + 'DOC_ROOT' => dirname($APPLICATION->executablePath), |
|
15 | + 'IS_ADMIN' => is_writable(getenv('SystemRoot')), |
|
16 | 16 | 'START_PARAMS' => $params, |
17 | 17 | 'USERNAME' => $env->username, |
18 | 18 | |
@@ -332,17 +332,17 @@ discard block |
||
332 | 332 | |
333 | 333 | # Моя подборка цветов |
334 | 334 | |
335 | - 'clDark' => $converter->fromHtml ('#0D0F12'), |
|
336 | - 'clDark2' => $converter->fromHtml ('#121416'), |
|
337 | - 'clTurquoise' => $converter->fromHtml ('#00ADB5'), |
|
338 | - 'clLight' => $converter->fromHtml ('#EEEEEE') |
|
335 | + 'clDark' => $converter->fromHtml('#0D0F12'), |
|
336 | + 'clDark2' => $converter->fromHtml('#121416'), |
|
337 | + 'clTurquoise' => $converter->fromHtml('#00ADB5'), |
|
338 | + 'clLight' => $converter->fromHtml('#EEEEEE') |
|
339 | 339 | ]; |
340 | 340 | |
341 | 341 | foreach ($constants as $name => $value) |
342 | - define ($name, $value); |
|
342 | + define($name, $value); |
|
343 | 343 | |
344 | 344 | $argv = START_PARAMS; |
345 | -$argc = sizeof ($argv); |
|
345 | +$argc = sizeof($argv); |
|
346 | 346 | |
347 | -\VoidCore::removeObjects ($converter->selector); |
|
347 | +\VoidCore::removeObjects($converter->selector); |
|
348 | 348 | unset ($constants, $env, $params, $converter); |
@@ -9,8 +9,8 @@ |
||
9 | 9 | |
10 | 10 | # Подгружаем PHP расширения |
11 | 11 | foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext) |
12 | - if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
13 | - load_extension ($ext); |
|
12 | + if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
13 | + load_extension ($ext); |
|
14 | 14 | |
15 | 15 | # Подгружаем Qero-пакеты |
16 | 16 | require __DIR__ .'/../qero-packages/autoload.php'; |
@@ -8,9 +8,10 @@ |
||
8 | 8 | define ('VoidEngine\CORE_DIR', dirname (__DIR__) .'/qero-packages/winforms-php/VoidFramework/core'); |
9 | 9 | |
10 | 10 | # Подгружаем PHP расширения |
11 | -foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext) |
|
11 | +foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext) { |
|
12 | 12 | if (!extension_loaded (substr (basename ($ext), 4, -4))) |
13 | 13 | load_extension ($ext); |
14 | +} |
|
14 | 15 | |
15 | 16 | # Подгружаем Qero-пакеты |
16 | 17 | require __DIR__ .'/../qero-packages/autoload.php'; |
@@ -15,22 +15,22 @@ |
||
15 | 15 | # Объявление констант |
16 | 16 | const APP_DIR = __DIR__; |
17 | 17 | |
18 | -define ('VoidEngine\CORE_DIR', dirname (__DIR__) .'/qero-packages/winforms-php/VoidFramework/core'); |
|
18 | +define('VoidEngine\CORE_DIR', dirname(__DIR__).'/qero-packages/winforms-php/VoidFramework/core'); |
|
19 | 19 | |
20 | 20 | # Подгружаем PHP расширения |
21 | -foreach (glob (CORE_DIR .'/ext/php_*.dll') as $ext) |
|
22 | - if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
23 | - load_extension ($ext); |
|
21 | +foreach (glob(CORE_DIR.'/ext/php_*.dll') as $ext) |
|
22 | + if (!extension_loaded(substr(basename($ext), 4, -4))) |
|
23 | + load_extension($ext); |
|
24 | 24 | |
25 | 25 | # Подгружаем Qero-пакеты |
26 | -require __DIR__ .'/../qero-packages/autoload.php'; |
|
26 | +require __DIR__.'/../qero-packages/autoload.php'; |
|
27 | 27 | |
28 | -chdir (APP_DIR); // Меняем стандартную директорию на директорию приложения |
|
28 | +chdir(APP_DIR); // Меняем стандартную директорию на директорию приложения |
|
29 | 29 | |
30 | 30 | # Парсим стили main.vst |
31 | -VSTInterpreter::run (VSTParser::parse ('main.vst')); |
|
31 | +VSTInterpreter::run(VSTParser::parse('main.vst')); |
|
32 | 32 | |
33 | 33 | # Парсим разметку app.vlf и запускаем приложение |
34 | -$objects = VLFInterpreter::run (VLFParser::parse ('app.vlf')); |
|
34 | +$objects = VLFInterpreter::run(VLFParser::parse('app.vlf')); |
|
35 | 35 | |
36 | -$APPLICATION->run ($objects['MainForm']); |
|
36 | +$APPLICATION->run($objects['MainForm']); |
@@ -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 | abstract class Control extends Component |
8 | 8 | { |
9 | - public function __construct (NetObject $parent = null, ...$args) |
|
9 | + public function __construct(NetObject $parent = null, ...$args) |
|
10 | 10 | { |
11 | - parent::__construct (...$args); |
|
11 | + parent::__construct(...$args); |
|
12 | 12 | |
13 | 13 | if ($parent !== null) |
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): void |
|
22 | + public function set_caption(string $caption): void |
|
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', VC_COLOR]); |
|
44 | + return $this->getProperty(['BackColor', VC_COLOR]); |
|
46 | 45 | } |
47 | 46 | |
48 | - public function set_backgroundColor ($color): void |
|
47 | + public function set_backgroundColor($color): void |
|
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', VC_COLOR]); |
|
54 | + return $this->getProperty(['ForeColor', VC_COLOR]); |
|
56 | 55 | } |
57 | 56 | |
58 | - public function set_foregroundColor ($color): void |
|
57 | + public function set_foregroundColor($color): void |
|
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): void |
|
67 | + public function set_w(int $w): void |
|
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): void |
|
77 | + public function set_h(int $h): void |
|
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): void |
|
87 | + public function set_x(int $x): void |
|
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): void |
|
97 | + public function set_y(int $y): void |
|
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): void |
|
112 | + public function set_bounds($bounds): void |
|
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,41 +153,41 @@ discard block |
||
154 | 153 | ]; |
155 | 154 | } |
156 | 155 | |
157 | - public function set_size ($size): void |
|
156 | + public function set_size($size): void |
|
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): void |
|
169 | + public function setBounds(int $x, int $y, int $w, int $h): void |
|
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): void |
|
174 | + public function setLocation(int $x, int $y): void |
|
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): void |
|
179 | + public function setSize(int $w, int $h): void |
|
181 | 180 | { |
182 | - $this->set_size ([$w, $h]); |
|
181 | + $this->set_size([$w, $h]); |
|
183 | 182 | } |
184 | 183 | |
185 | - public function toBack (): void |
|
184 | + public function toBack(): void |
|
186 | 185 | { |
187 | - $this->callMethod ('SendToBack'); |
|
186 | + $this->callMethod('SendToBack'); |
|
188 | 187 | } |
189 | 188 | |
190 | - public function toFront (): void |
|
189 | + public function toFront(): void |
|
191 | 190 | { |
192 | - $this->callMethod ('BringToFront'); |
|
191 | + $this->callMethod('BringToFront'); |
|
193 | 192 | } |
194 | 193 | } |
@@ -10,8 +10,9 @@ discard block |
||
10 | 10 | { |
11 | 11 | parent::__construct (...$args); |
12 | 12 | |
13 | - if ($parent !== null) |
|
14 | - $this->parent = $parent; |
|
13 | + if ($parent !== null) { |
|
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): void |
@@ -6,17 +6,17 @@ |
||
6 | 6 | chdir (CORE_DIR); |
7 | 7 | |
8 | 8 | foreach (glob ('ext/php_*.dll') as $ext) |
9 | - if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
10 | - load_extension ($ext); |
|
9 | + if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
10 | + load_extension ($ext); |
|
11 | 11 | |
12 | 12 | if (file_exists ('../engine/VoidEngine.php')) |
13 | - require '../engine/VoidEngine.php'; |
|
13 | + require '../engine/VoidEngine.php'; |
|
14 | 14 | |
15 | 15 | else message ('VoidEngine not founded'); |
16 | 16 | |
17 | 17 | $app = '../../app/start.php'; |
18 | 18 | |
19 | 19 | if (file_exists ($app)) |
20 | - require $app; |
|
20 | + require $app; |
|
21 | 21 | |
22 | 22 | else \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm'), 'ShowDialog'); |
@@ -3,20 +3,20 @@ |
||
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | 5 | const CORE_DIR = __DIR__; |
6 | -chdir (CORE_DIR); |
|
6 | +chdir(CORE_DIR); |
|
7 | 7 | |
8 | -foreach (glob ('ext/php_*.dll') as $ext) |
|
9 | - if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
10 | - load_extension ($ext); |
|
8 | +foreach (glob('ext/php_*.dll') as $ext) |
|
9 | + if (!extension_loaded(substr(basename($ext), 4, -4))) |
|
10 | + load_extension($ext); |
|
11 | 11 | |
12 | -if (file_exists ('../engine/VoidEngine.php')) |
|
12 | +if (file_exists('../engine/VoidEngine.php')) |
|
13 | 13 | require '../engine/VoidEngine.php'; |
14 | 14 | |
15 | -else message ('VoidEngine not founded'); |
|
15 | +else message('VoidEngine not founded'); |
|
16 | 16 | |
17 | 17 | $app = '../../app/start.php'; |
18 | 18 | |
19 | -if (file_exists ($app)) |
|
19 | +if (file_exists($app)) |
|
20 | 20 | require $app; |
21 | 21 | |
22 | -else \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm'), 'ShowDialog'); |
|
22 | +else \VoidCore::callMethod(\VoidCore::createObject('WinForms_PHP.DebugForm'), 'ShowDialog'); |
@@ -5,18 +5,21 @@ |
||
5 | 5 | const CORE_DIR = __DIR__; |
6 | 6 | chdir (CORE_DIR); |
7 | 7 | |
8 | -foreach (glob ('ext/php_*.dll') as $ext) |
|
8 | +foreach (glob ('ext/php_*.dll') as $ext) { |
|
9 | 9 | if (!extension_loaded (substr (basename ($ext), 4, -4))) |
10 | 10 | load_extension ($ext); |
11 | +} |
|
11 | 12 | |
12 | -if (file_exists ('../engine/VoidEngine.php')) |
|
13 | +if (file_exists ('../engine/VoidEngine.php')) { |
|
13 | 14 | require '../engine/VoidEngine.php'; |
14 | - |
|
15 | -else message ('VoidEngine not founded'); |
|
15 | +} else { |
|
16 | + message ('VoidEngine not founded'); |
|
17 | +} |
|
16 | 18 | |
17 | 19 | $app = '../../app/start.php'; |
18 | 20 | |
19 | -if (file_exists ($app)) |
|
21 | +if (file_exists ($app)) { |
|
20 | 22 | require $app; |
21 | - |
|
22 | -else \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm'), 'ShowDialog'); |
|
23 | +} else { |
|
24 | + \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm'), 'ShowDialog'); |
|
25 | +} |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @return AST - возвращает AST дерево разметки |
19 | 19 | */ |
20 | - public static function parse (string $vlf): AST |
|
20 | + public static function parse(string $vlf): AST |
|
21 | 21 | { |
22 | 22 | $tree = new AST; |
23 | 23 | $objects = new Stack; |
24 | 24 | |
25 | - if (file_exists ($vlf)) |
|
26 | - $vlf = file_get_contents ($vlf); |
|
25 | + if (file_exists($vlf)) |
|
26 | + $vlf = file_get_contents($vlf); |
|
27 | 27 | |
28 | - $lines = explode (self::$divider, $vlf); |
|
28 | + $lines = explode(self::$divider, $vlf); |
|
29 | 29 | $skip_at = -1; |
30 | 30 | |
31 | 31 | foreach ($lines as $line_num => $line) |
32 | 32 | { |
33 | 33 | // \VoidEngine\pre ($line_num .', '. ($skip_at > $line_num ? 'skip' : 'not skip') .': '. $line); |
34 | 34 | |
35 | - if ($skip_at > $line_num || !self::filter ($line)) |
|
35 | + if ($skip_at > $line_num || !self::filter($line)) |
|
36 | 36 | continue; |
37 | 37 | |
38 | - $height = self::getHeight ($line); |
|
39 | - $words = array_filter (explode (' ', $line), 'VLF\Parser::filter'); |
|
38 | + $height = self::getHeight($line); |
|
39 | + $words = array_filter(explode(' ', $line), 'VLF\Parser::filter'); |
|
40 | 40 | $poped = false; |
41 | 41 | |
42 | 42 | # Очищаем стек объектов |
43 | - while ($objects->size () > 0) |
|
44 | - if ($objects->current ()->height >= $height) |
|
43 | + while ($objects->size() > 0) |
|
44 | + if ($objects->current()->height >= $height) |
|
45 | 45 | { |
46 | - $objects->pop (); |
|
46 | + $objects->pop(); |
|
47 | 47 | |
48 | 48 | $poped = true; |
49 | 49 | } |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | else break; |
52 | 52 | |
53 | 53 | # Создаём новую ссылку на объект |
54 | - if ($poped && $objects->size () > 0) |
|
54 | + if ($poped && $objects->size() > 0) |
|
55 | 55 | { |
56 | - $object = $objects->pop (); |
|
56 | + $object = $objects->pop(); |
|
57 | 57 | |
58 | - $objects->push (new Node (array_merge ($object->export (), ['nodes' => []]))); |
|
59 | - $tree->push ($objects->current ()); |
|
58 | + $objects->push(new Node(array_merge($object->export(), ['nodes' => []]))); |
|
59 | + $tree->push($objects->current()); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -64,16 +64,16 @@ discard block |
||
64 | 64 | */ |
65 | 65 | if ($words[0] == 'import') |
66 | 66 | { |
67 | - $imports = substr ($line, strlen ($words[0])); |
|
68 | - $parsed = self::parseSubtext ($lines, $line_num, $height); |
|
67 | + $imports = substr($line, strlen($words[0])); |
|
68 | + $parsed = self::parseSubtext($lines, $line_num, $height); |
|
69 | 69 | |
70 | 70 | $imports .= $parsed[0]; |
71 | 71 | $skip_at = $parsed[1]; |
72 | 72 | |
73 | - $imports = self::filter ($imports) ? |
|
74 | - array_map ('trim', self::parseArguments ($imports)) : []; |
|
73 | + $imports = self::filter($imports) ? |
|
74 | + array_map ('trim', self::parseArguments($imports)) : []; |
|
75 | 75 | |
76 | - $tree->push (new Node ([ |
|
76 | + $tree->push(new Node([ |
|
77 | 77 | 'type' => STYLES_IMPORTING, |
78 | 78 | 'line' => $line, |
79 | 79 | 'words' => $words, |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | if (isset ($words[0][1])) |
97 | 97 | { |
98 | 98 | if ($words[0][1] == '^') |
99 | - $skip_at = self::parseSubtext ($lines, $line_num, $height)[1]; |
|
99 | + $skip_at = self::parseSubtext($lines, $line_num, $height)[1]; |
|
100 | 100 | |
101 | - else throw new \Exception ('Unknown char founded after comment definition at line '. ($line_num + 1)); |
|
101 | + else throw new \Exception('Unknown char founded after comment definition at line '.($line_num + 1)); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | continue; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | elseif ($words[0][0] == '%') |
111 | 111 | { |
112 | - $code = substr ($line, strlen ($words[0])); |
|
112 | + $code = substr($line, strlen($words[0])); |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * Обработка многострочного кода |
@@ -118,16 +118,16 @@ discard block |
||
118 | 118 | { |
119 | 119 | if ($words[0][1] == '^') |
120 | 120 | { |
121 | - $parsed = self::parseSubtext ($lines, $line_num, $height); |
|
121 | + $parsed = self::parseSubtext($lines, $line_num, $height); |
|
122 | 122 | |
123 | 123 | $code .= $parsed[0]; |
124 | 124 | $skip_at = $parsed[1]; |
125 | 125 | } |
126 | 126 | |
127 | - else throw new \Exception ('Unknown char founded after runtime execution definition at line '. ($line_num + 1)); |
|
127 | + else throw new \Exception('Unknown char founded after runtime execution definition at line '.($line_num + 1)); |
|
128 | 128 | } |
129 | 129 | |
130 | - $tree->push (new Node ([ |
|
130 | + $tree->push(new Node([ |
|
131 | 131 | 'type' => RUNTIME_EXECUTION, |
132 | 132 | 'line' => $line, |
133 | 133 | 'words' => $words, |
@@ -142,29 +142,29 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * Установка свойства |
144 | 144 | */ |
145 | - elseif (($pos = strpos ($line, ':')) !== false) |
|
145 | + elseif (($pos = strpos($line, ':')) !== false) |
|
146 | 146 | { |
147 | - if ($objects->size () == 0) |
|
148 | - throw new \Exception ('Trying to set property to unknown object at line '. ($line_num + 1)); |
|
147 | + if ($objects->size() == 0) |
|
148 | + throw new \Exception('Trying to set property to unknown object at line '.($line_num + 1)); |
|
149 | 149 | |
150 | 150 | if (!isset ($words[1])) |
151 | - throw new \Exception ('Trying to set void property value at line '. ($line_num + 1)); |
|
151 | + throw new \Exception('Trying to set void property value at line '.($line_num + 1)); |
|
152 | 152 | |
153 | - $propertyName = substr ($line, 0, $pos); |
|
154 | - $propertyValue = substr ($line, $pos + 1); |
|
153 | + $propertyName = substr($line, 0, $pos); |
|
154 | + $propertyValue = substr($line, $pos + 1); |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Обработка многострочных свойств |
158 | 158 | */ |
159 | 159 | if ($line[$pos + 1] == '^') |
160 | 160 | { |
161 | - $parsed = self::parseSubtext ($lines, $line_num, $height); |
|
161 | + $parsed = self::parseSubtext($lines, $line_num, $height); |
|
162 | 162 | |
163 | - $propertyValue = substr ($propertyValue, 1) . $parsed[0]; |
|
163 | + $propertyValue = substr($propertyValue, 1).$parsed[0]; |
|
164 | 164 | $skip_at = $parsed[1]; |
165 | 165 | } |
166 | 166 | |
167 | - $objects->current ()->push (new Node ([ |
|
167 | + $objects->current()->push(new Node([ |
|
168 | 168 | 'type' => PROPERTY_SET, |
169 | 169 | 'line' => $line, |
170 | 170 | 'words' => $words, |
@@ -182,26 +182,26 @@ discard block |
||
182 | 182 | */ |
183 | 183 | elseif (isset ($words[0][1]) && $words[0][0] == '-' && $words[0][1] == '>') |
184 | 184 | { |
185 | - if ($objects->size () == 0) |
|
186 | - throw new \Exception ('Trying to call method from unknown object at line '. ($line_num + 1)); |
|
185 | + if ($objects->size() == 0) |
|
186 | + throw new \Exception('Trying to call method from unknown object at line '.($line_num + 1)); |
|
187 | 187 | |
188 | 188 | $methodArgs = []; |
189 | 189 | |
190 | - if (($pos = strpos ($line, '(')) !== false) |
|
190 | + if (($pos = strpos($line, '(')) !== false) |
|
191 | 191 | { |
192 | - if (($end = strrpos ($line, ')', $pos)) === false) |
|
193 | - throw new \Exception ('Incorrect method arguments syntax at line '. ($line_num + 1)); |
|
192 | + if (($end = strrpos($line, ')', $pos)) === false) |
|
193 | + throw new \Exception('Incorrect method arguments syntax at line '.($line_num + 1)); |
|
194 | 194 | |
195 | - $methodArgs = substr ($line, $pos + 1, $end - $pos - 1); |
|
195 | + $methodArgs = substr($line, $pos + 1, $end - $pos - 1); |
|
196 | 196 | |
197 | - $methodName = trim (substr ($line, 2, $pos - 2)); |
|
198 | - $methodArgs = self::filter ($methodArgs) ? |
|
199 | - self::parseArguments ($methodArgs) : []; |
|
197 | + $methodName = trim(substr($line, 2, $pos - 2)); |
|
198 | + $methodArgs = self::filter($methodArgs) ? |
|
199 | + self::parseArguments($methodArgs) : []; |
|
200 | 200 | } |
201 | 201 | |
202 | - else $methodName = trim (substr ($line, 2)); |
|
202 | + else $methodName = trim(substr($line, 2)); |
|
203 | 203 | |
204 | - $objects->current ()->push (new Node ([ |
|
204 | + $objects->current()->push(new Node([ |
|
205 | 205 | 'type' => METHOD_CALL, |
206 | 206 | 'line' => $line, |
207 | 207 | 'words' => $words, |
@@ -217,39 +217,39 @@ discard block |
||
217 | 217 | /** |
218 | 218 | * Объявление объекта |
219 | 219 | */ |
220 | - elseif (sizeof ($words) > 1) |
|
220 | + elseif (sizeof($words) > 1) |
|
221 | 221 | { |
222 | 222 | $class = $words[0]; |
223 | 223 | $name = $words[1]; |
224 | 224 | $args = []; |
225 | 225 | $styles = []; |
226 | 226 | |
227 | - if ($objects->size () > 0 && $objects->current ()->height < $height) |
|
228 | - $args[] = $objects->current ()->args['name']; |
|
227 | + if ($objects->size() > 0 && $objects->current()->height < $height) |
|
228 | + $args[] = $objects->current()->args['name']; |
|
229 | 229 | |
230 | - if (($pos = strpos ($line, '(')) !== false) |
|
230 | + if (($pos = strpos($line, '(')) !== false) |
|
231 | 231 | { |
232 | - if (($end = strrpos ($line, ')', $pos)) === false) |
|
233 | - throw new \Exception ('Incorrect class constructor arguments syntax at line '. ($line_num + 1)); |
|
232 | + if (($end = strrpos($line, ')', $pos)) === false) |
|
233 | + throw new \Exception('Incorrect class constructor arguments syntax at line '.($line_num + 1)); |
|
234 | 234 | |
235 | - $args = substr ($line, $pos + 1, $end - $pos - 1); |
|
235 | + $args = substr($line, $pos + 1, $end - $pos - 1); |
|
236 | 236 | |
237 | - $name = substr ($line, $len = strlen ($class), $pos - $len); |
|
238 | - $args = self::filter ($args) ? |
|
239 | - self::parseArguments ($args) : []; |
|
237 | + $name = substr($line, $len = strlen($class), $pos - $len); |
|
238 | + $args = self::filter($args) ? |
|
239 | + self::parseArguments($args) : []; |
|
240 | 240 | } |
241 | 241 | |
242 | - if (($end = strpos ($line, '>')) !== false) |
|
242 | + if (($end = strpos($line, '>')) !== false) |
|
243 | 243 | { |
244 | - $styles = trim (substr ($line, $end + 1)); |
|
244 | + $styles = trim(substr($line, $end + 1)); |
|
245 | 245 | |
246 | - if (strlen ($styles) == 0) |
|
247 | - throw new \Exception ('Trying to set empty style to object'); |
|
246 | + if (strlen($styles) == 0) |
|
247 | + throw new \Exception('Trying to set empty style to object'); |
|
248 | 248 | |
249 | - $styles = array_map ('trim', explode (',', $styles)); |
|
249 | + $styles = array_map('trim', explode(',', $styles)); |
|
250 | 250 | } |
251 | 251 | |
252 | - $objects->push (new Node ([ |
|
252 | + $objects->push(new Node([ |
|
253 | 253 | 'type' => OBJECT_DEFINITION, |
254 | 254 | 'line' => $line, |
255 | 255 | 'words' => $words, |
@@ -257,19 +257,19 @@ discard block |
||
257 | 257 | |
258 | 258 | 'args' => [ |
259 | 259 | 'class' => $class, |
260 | - 'name' => trim ($name), |
|
260 | + 'name' => trim($name), |
|
261 | 261 | 'args' => $args, |
262 | 262 | 'styles' => $styles |
263 | 263 | ] |
264 | 264 | ])); |
265 | 265 | |
266 | - $tree->push ($objects->current ()); |
|
266 | + $tree->push($objects->current()); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
270 | 270 | * Неопознанная структура |
271 | 271 | */ |
272 | - else throw new \Exception ('Unsupported structure founded at line '. ($line_num + 1)); |
|
272 | + else throw new \Exception('Unsupported structure founded at line '.($line_num + 1)); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $tree; |
@@ -282,12 +282,12 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return int - возвращает её высоту |
284 | 284 | */ |
285 | - protected static function getHeight (string &$line): int |
|
285 | + protected static function getHeight(string &$line): int |
|
286 | 286 | { |
287 | 287 | $i = 0; |
288 | 288 | $height = 0; |
289 | 289 | |
290 | - while (isset ($line[$i]) && ctype_space ($line[$i])) |
|
290 | + while (isset ($line[$i]) && ctype_space($line[$i])) |
|
291 | 291 | { |
292 | 292 | ++$height; |
293 | 293 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | ++$i; |
298 | 298 | } |
299 | 299 | |
300 | - $line = substr ($line, $i); |
|
300 | + $line = substr($line, $i); |
|
301 | 301 | |
302 | 302 | return $height; |
303 | 303 | } |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @return bool - возвращает true если строка не пустая |
311 | 311 | */ |
312 | - protected static function filter (string $line): bool |
|
312 | + protected static function filter(string $line): bool |
|
313 | 313 | { |
314 | - return strlen (trim ($line)) > 0; |
|
314 | + return strlen(trim($line)) > 0; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @return array - возвращает массив [текст, конечный индекс] |
325 | 325 | */ |
326 | - protected static function parseSubtext (array $lines, $begin_id, int $down_height): array |
|
326 | + protected static function parseSubtext(array $lines, $begin_id, int $down_height): array |
|
327 | 327 | { |
328 | 328 | $parsed = "\n"; |
329 | 329 | |
@@ -332,17 +332,17 @@ discard block |
||
332 | 332 | if ($line_id <= $begin_id) |
333 | 333 | continue; |
334 | 334 | |
335 | - if (!self::filter ($line)) |
|
335 | + if (!self::filter($line)) |
|
336 | 336 | { |
337 | 337 | $parsed .= "\n"; |
338 | 338 | |
339 | 339 | continue; |
340 | 340 | } |
341 | 341 | |
342 | - $height = self::getHeight ($line); |
|
342 | + $height = self::getHeight($line); |
|
343 | 343 | |
344 | 344 | if ($height > $down_height) |
345 | - $parsed .= str_repeat (' ', $height - $down_height) ."$line\n"; |
|
345 | + $parsed .= str_repeat(' ', $height - $down_height)."$line\n"; |
|
346 | 346 | |
347 | 347 | else return [$parsed, $line_id]; |
348 | 348 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @return array - возвращает массив аргументов |
359 | 359 | */ |
360 | - protected static function parseArguments (string $arguments): array |
|
360 | + protected static function parseArguments(string $arguments): array |
|
361 | 361 | { |
362 | 362 | $args = []; |
363 | 363 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | $t = ''; |
368 | 368 | |
369 | - for ($i = 0, $len = strlen ($arguments); $i < $len; ++$i) |
|
369 | + for ($i = 0, $len = strlen($arguments); $i < $len; ++$i) |
|
370 | 370 | { |
371 | 371 | $t .= $arguments[$i]; |
372 | 372 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | |
384 | 384 | elseif (!$split1 && !$split2 && $arguments[$i] == ',') |
385 | 385 | { |
386 | - $args[] = substr ($t, 0, -1); |
|
386 | + $args[] = substr($t, 0, -1); |
|
387 | 387 | $t = ''; |
388 | 388 | } |
389 | 389 | } |
@@ -22,8 +22,9 @@ discard block |
||
22 | 22 | $tree = new AST; |
23 | 23 | $objects = new Stack; |
24 | 24 | |
25 | - if (file_exists ($vlf)) |
|
26 | - $vlf = file_get_contents ($vlf); |
|
25 | + if (file_exists ($vlf)) { |
|
26 | + $vlf = file_get_contents ($vlf); |
|
27 | + } |
|
27 | 28 | |
28 | 29 | $lines = explode (self::$divider, $vlf); |
29 | 30 | $skip_at = -1; |
@@ -32,24 +33,26 @@ discard block |
||
32 | 33 | { |
33 | 34 | // \VoidEngine\pre ($line_num .', '. ($skip_at > $line_num ? 'skip' : 'not skip') .': '. $line); |
34 | 35 | |
35 | - if ($skip_at > $line_num || !self::filter ($line)) |
|
36 | - continue; |
|
36 | + if ($skip_at > $line_num || !self::filter ($line)) { |
|
37 | + continue; |
|
38 | + } |
|
37 | 39 | |
38 | 40 | $height = self::getHeight ($line); |
39 | 41 | $words = array_filter (explode (' ', $line), 'VLF\Parser::filter'); |
40 | 42 | $poped = false; |
41 | 43 | |
42 | 44 | # Очищаем стек объектов |
43 | - while ($objects->size () > 0) |
|
44 | - if ($objects->current ()->height >= $height) |
|
45 | + while ($objects->size () > 0) { |
|
46 | + if ($objects->current ()->height >= $height) |
|
45 | 47 | { |
46 | 48 | $objects->pop (); |
49 | + } |
|
47 | 50 | |
48 | 51 | $poped = true; |
52 | + } else { |
|
53 | + break; |
|
49 | 54 | } |
50 | 55 | |
51 | - else break; |
|
52 | - |
|
53 | 56 | # Создаём новую ссылку на объект |
54 | 57 | if ($poped && $objects->size () > 0) |
55 | 58 | { |
@@ -95,10 +98,11 @@ discard block |
||
95 | 98 | */ |
96 | 99 | if (isset ($words[0][1])) |
97 | 100 | { |
98 | - if ($words[0][1] == '^') |
|
99 | - $skip_at = self::parseSubtext ($lines, $line_num, $height)[1]; |
|
100 | - |
|
101 | - else throw new \Exception ('Unknown char founded after comment definition at line '. ($line_num + 1)); |
|
101 | + if ($words[0][1] == '^') { |
|
102 | + $skip_at = self::parseSubtext ($lines, $line_num, $height)[1]; |
|
103 | + } else { |
|
104 | + throw new \Exception ('Unknown char founded after comment definition at line '. ($line_num + 1)); |
|
105 | + } |
|
102 | 106 | } |
103 | 107 | |
104 | 108 | continue; |
@@ -122,9 +126,9 @@ discard block |
||
122 | 126 | |
123 | 127 | $code .= $parsed[0]; |
124 | 128 | $skip_at = $parsed[1]; |
129 | + } else { |
|
130 | + throw new \Exception ('Unknown char founded after runtime execution definition at line '. ($line_num + 1)); |
|
125 | 131 | } |
126 | - |
|
127 | - else throw new \Exception ('Unknown char founded after runtime execution definition at line '. ($line_num + 1)); |
|
128 | 132 | } |
129 | 133 | |
130 | 134 | $tree->push (new Node ([ |
@@ -144,11 +148,13 @@ discard block |
||
144 | 148 | */ |
145 | 149 | elseif (($pos = strpos ($line, ':')) !== false) |
146 | 150 | { |
147 | - if ($objects->size () == 0) |
|
148 | - throw new \Exception ('Trying to set property to unknown object at line '. ($line_num + 1)); |
|
151 | + if ($objects->size () == 0) { |
|
152 | + throw new \Exception ('Trying to set property to unknown object at line '. ($line_num + 1)); |
|
153 | + } |
|
149 | 154 | |
150 | - if (!isset ($words[1])) |
|
151 | - throw new \Exception ('Trying to set void property value at line '. ($line_num + 1)); |
|
155 | + if (!isset ($words[1])) { |
|
156 | + throw new \Exception ('Trying to set void property value at line '. ($line_num + 1)); |
|
157 | + } |
|
152 | 158 | |
153 | 159 | $propertyName = substr ($line, 0, $pos); |
154 | 160 | $propertyValue = substr ($line, $pos + 1); |
@@ -182,25 +188,27 @@ discard block |
||
182 | 188 | */ |
183 | 189 | elseif (isset ($words[0][1]) && $words[0][0] == '-' && $words[0][1] == '>') |
184 | 190 | { |
185 | - if ($objects->size () == 0) |
|
186 | - throw new \Exception ('Trying to call method from unknown object at line '. ($line_num + 1)); |
|
191 | + if ($objects->size () == 0) { |
|
192 | + throw new \Exception ('Trying to call method from unknown object at line '. ($line_num + 1)); |
|
193 | + } |
|
187 | 194 | |
188 | 195 | $methodArgs = []; |
189 | 196 | |
190 | 197 | if (($pos = strpos ($line, '(')) !== false) |
191 | 198 | { |
192 | - if (($end = strrpos ($line, ')', $pos)) === false) |
|
193 | - throw new \Exception ('Incorrect method arguments syntax at line '. ($line_num + 1)); |
|
199 | + if (($end = strrpos ($line, ')', $pos)) === false) { |
|
200 | + throw new \Exception ('Incorrect method arguments syntax at line '. ($line_num + 1)); |
|
201 | + } |
|
194 | 202 | |
195 | 203 | $methodArgs = substr ($line, $pos + 1, $end - $pos - 1); |
196 | 204 | |
197 | 205 | $methodName = trim (substr ($line, 2, $pos - 2)); |
198 | 206 | $methodArgs = self::filter ($methodArgs) ? |
199 | 207 | self::parseArguments ($methodArgs) : []; |
208 | + } else { |
|
209 | + $methodName = trim (substr ($line, 2)); |
|
200 | 210 | } |
201 | 211 | |
202 | - else $methodName = trim (substr ($line, 2)); |
|
203 | - |
|
204 | 212 | $objects->current ()->push (new Node ([ |
205 | 213 | 'type' => METHOD_CALL, |
206 | 214 | 'line' => $line, |
@@ -224,13 +232,15 @@ discard block |
||
224 | 232 | $args = []; |
225 | 233 | $styles = []; |
226 | 234 | |
227 | - if ($objects->size () > 0 && $objects->current ()->height < $height) |
|
228 | - $args[] = $objects->current ()->args['name']; |
|
235 | + if ($objects->size () > 0 && $objects->current ()->height < $height) { |
|
236 | + $args[] = $objects->current ()->args['name']; |
|
237 | + } |
|
229 | 238 | |
230 | 239 | if (($pos = strpos ($line, '(')) !== false) |
231 | 240 | { |
232 | - if (($end = strrpos ($line, ')', $pos)) === false) |
|
233 | - throw new \Exception ('Incorrect class constructor arguments syntax at line '. ($line_num + 1)); |
|
241 | + if (($end = strrpos ($line, ')', $pos)) === false) { |
|
242 | + throw new \Exception ('Incorrect class constructor arguments syntax at line '. ($line_num + 1)); |
|
243 | + } |
|
234 | 244 | |
235 | 245 | $args = substr ($line, $pos + 1, $end - $pos - 1); |
236 | 246 | |
@@ -243,8 +253,9 @@ discard block |
||
243 | 253 | { |
244 | 254 | $styles = trim (substr ($line, $end + 1)); |
245 | 255 | |
246 | - if (strlen ($styles) == 0) |
|
247 | - throw new \Exception ('Trying to set empty style to object'); |
|
256 | + if (strlen ($styles) == 0) { |
|
257 | + throw new \Exception ('Trying to set empty style to object'); |
|
258 | + } |
|
248 | 259 | |
249 | 260 | $styles = array_map ('trim', explode (',', $styles)); |
250 | 261 | } |
@@ -269,7 +280,9 @@ discard block |
||
269 | 280 | /** |
270 | 281 | * Неопознанная структура |
271 | 282 | */ |
272 | - else throw new \Exception ('Unsupported structure founded at line '. ($line_num + 1)); |
|
283 | + else { |
|
284 | + throw new \Exception ('Unsupported structure founded at line '. ($line_num + 1)); |
|
285 | + } |
|
273 | 286 | } |
274 | 287 | |
275 | 288 | return $tree; |
@@ -291,8 +304,9 @@ discard block |
||
291 | 304 | { |
292 | 305 | ++$height; |
293 | 306 | |
294 | - if ($line[$i] == "\t") |
|
295 | - $height += 3; |
|
307 | + if ($line[$i] == "\t") { |
|
308 | + $height += 3; |
|
309 | + } |
|
296 | 310 | |
297 | 311 | ++$i; |
298 | 312 | } |
@@ -329,8 +343,9 @@ discard block |
||
329 | 343 | |
330 | 344 | foreach ($lines as $line_id => $line) |
331 | 345 | { |
332 | - if ($line_id <= $begin_id) |
|
333 | - continue; |
|
346 | + if ($line_id <= $begin_id) { |
|
347 | + continue; |
|
348 | + } |
|
334 | 349 | |
335 | 350 | if (!self::filter ($line)) |
336 | 351 | { |
@@ -341,10 +356,11 @@ discard block |
||
341 | 356 | |
342 | 357 | $height = self::getHeight ($line); |
343 | 358 | |
344 | - if ($height > $down_height) |
|
345 | - $parsed .= str_repeat (' ', $height - $down_height) ."$line\n"; |
|
346 | - |
|
347 | - else return [$parsed, $line_id]; |
|
359 | + if ($height > $down_height) { |
|
360 | + $parsed .= str_repeat (' ', $height - $down_height) ."$line\n"; |
|
361 | + } else { |
|
362 | + return [$parsed, $line_id]; |
|
363 | + } |
|
348 | 364 | } |
349 | 365 | |
350 | 366 | return [$parsed, $line_id + 1]; |
@@ -370,18 +386,15 @@ discard block |
||
370 | 386 | { |
371 | 387 | $t .= $arguments[$i]; |
372 | 388 | |
373 | - if ($arguments[$i] == '\\') |
|
374 | - $canSplit = $i + 1; |
|
375 | - |
|
376 | - elseif ($canSplit < $i) |
|
389 | + if ($arguments[$i] == '\\') { |
|
390 | + $canSplit = $i + 1; |
|
391 | + } elseif ($canSplit < $i) |
|
377 | 392 | { |
378 | - if ($arguments[$i] == '\'' && !$split2) |
|
379 | - $split1 = !$split1; |
|
380 | - |
|
381 | - elseif ($arguments[$i] == '"' && !$split1) |
|
382 | - $split2 = !$split2; |
|
383 | - |
|
384 | - elseif (!$split1 && !$split2 && $arguments[$i] == ',') |
|
393 | + if ($arguments[$i] == '\'' && !$split2) { |
|
394 | + $split1 = !$split1; |
|
395 | + } elseif ($arguments[$i] == '"' && !$split1) { |
|
396 | + $split2 = !$split2; |
|
397 | + } elseif (!$split1 && !$split2 && $arguments[$i] == ',') |
|
385 | 398 | { |
386 | 399 | $args[] = substr ($t, 0, -1); |
387 | 400 | $t = ''; |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return array - возвращает список созданных объектов |
22 | 22 | */ |
23 | - public static function run (AST $tree, Node $parent = null): array |
|
23 | + public static function run(AST $tree, Node $parent = null): array |
|
24 | 24 | { |
25 | - foreach ($tree->getNodes () as $id => $node) |
|
25 | + foreach ($tree->getNodes() as $id => $node) |
|
26 | 26 | { |
27 | 27 | switch ($node->type) |
28 | 28 | { |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | $args = $node->args['args']; |
40 | 40 | |
41 | 41 | foreach ($args as $arg_id => $arg) |
42 | - $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
42 | + $args[$arg_id] = self::formatLine($arg, self::$objects); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | try |
46 | 46 | { |
47 | - self::$objects[$name] = eval ("namespace VoidEngine; return new $class (". implode (', ', $args) .");"); |
|
47 | + self::$objects[$name] = eval ("namespace VoidEngine; return new $class (".implode(', ', $args).");"); |
|
48 | 48 | |
49 | 49 | try |
50 | 50 | { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | catch (\Throwable $e) |
58 | 58 | { |
59 | 59 | if (self::$throw_errors) |
60 | - throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
60 | + throw new \Exception('Interpeter couldn\'t create object "'.$class.'" with name "'.$name.'" at line "'.$node->line.'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
61 | 61 | } |
62 | 62 | break; |
63 | 63 | |
@@ -70,30 +70,30 @@ discard block |
||
70 | 70 | $propertyValue = $node->args['value']; |
71 | 71 | $preset = ''; |
72 | 72 | |
73 | - if (preg_match ('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
73 | + if (preg_match('/function \((.*)\) use \((.*)\)/', $propertyValue)) |
|
74 | 74 | { |
75 | - $use = substr ($propertyValue, strpos ($propertyValue, 'use')); |
|
76 | - $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos); |
|
77 | - $use = explode (' ', $use); |
|
75 | + $use = substr($propertyValue, strpos($propertyValue, 'use')); |
|
76 | + $use = $ouse = substr($use, ($pos = strpos($use, '(') + 1), strpos($use, ')') - $pos); |
|
77 | + $use = explode(' ', $use); |
|
78 | 78 | |
79 | 79 | foreach ($use as $id => $useParam) |
80 | 80 | if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
81 | 81 | { |
82 | 82 | $fname = $use[$id + 1]; |
83 | 83 | |
84 | - if (substr ($fname, strlen ($fname) - 1) == ',') |
|
85 | - $fname = substr ($fname, 0, -1); |
|
84 | + if (substr($fname, strlen($fname) - 1) == ',') |
|
85 | + $fname = substr($fname, 0, -1); |
|
86 | 86 | |
87 | 87 | $preset .= "$fname = $useParam; "; |
88 | 88 | |
89 | 89 | unset ($use[$id]); |
90 | 90 | } |
91 | 91 | |
92 | - $preset = self::formatLine ($preset, self::$objects); |
|
93 | - $propertyValue = self::formatLine (str_replace ($ouse, implode (' ', $use), $propertyValue), self::$objects); |
|
92 | + $preset = self::formatLine($preset, self::$objects); |
|
93 | + $propertyValue = self::formatLine(str_replace($ouse, implode(' ', $use), $propertyValue), self::$objects); |
|
94 | 94 | } |
95 | 95 | |
96 | - else $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
96 | + else $propertyValue = self::formatLine($propertyValue, self::$objects); |
|
97 | 97 | |
98 | 98 | try |
99 | 99 | { |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | catch (\Throwable $e) |
104 | 104 | { |
105 | 105 | if (self::$throw_errors) |
106 | - throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
106 | + throw new \Exception('Interpeter couldn\'t set property "'.$propertyName.'" with value "'.$propertyValue.'" at line "'.$node->line.'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | 110 | elseif (self::$throw_errors) |
111 | - throw new \Exception ('Setting property to an non-object at line "'. $node->line); |
|
111 | + throw new \Exception('Setting property to an non-object at line "'.$node->line); |
|
112 | 112 | break; |
113 | 113 | |
114 | 114 | case METHOD_CALL: |
@@ -120,58 +120,58 @@ discard block |
||
120 | 120 | $methodArgs = $node->args['args']; |
121 | 121 | |
122 | 122 | foreach ($methodArgs as $arg_id => $arg) |
123 | - $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
123 | + $methodArgs[$arg_id] = self::formatLine($arg, self::$objects); |
|
124 | 124 | |
125 | 125 | try |
126 | 126 | { |
127 | - if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
128 | - eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
127 | + if (strpos($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
128 | + eval ('namespace VoidEngine; _c('.self::$objects[$name]->selector.')->'.$methodName.' ('.implode(', ', $methodArgs).');'); |
|
129 | 129 | |
130 | - elseif (sizeof ($methodArgs) > 0) |
|
131 | - self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
130 | + elseif (sizeof($methodArgs) > 0) |
|
131 | + self::$objects[$name]->$methodName(...eval ('namespace VoidEngine; return ['.implode(', ', $methodArgs).'];')); |
|
132 | 132 | |
133 | - else self::$objects[$name]->$methodName (); |
|
133 | + else self::$objects[$name]->$methodName(); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | catch (\Throwable $e) |
137 | 137 | { |
138 | 138 | if (self::$throw_errors) |
139 | - throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
139 | + throw new \Exception('Interpeter couldn\'t call method "'.$methodName.'" with arguments '.json_encode($methodArgs).' at line "'.$node->line.'". Exception info:'."\n\n".(string) $e, 0, $e); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | 143 | elseif (self::$throw_errors) |
144 | - throw new \Exception ('Calling method to an non-object at line "'. $node->line .'"'); |
|
144 | + throw new \Exception('Calling method to an non-object at line "'.$node->line.'"'); |
|
145 | 145 | break; |
146 | 146 | |
147 | 147 | case STYLES_IMPORTING: |
148 | 148 | foreach ($node->args['imports'] as $style) |
149 | 149 | { |
150 | - $path = eval ('namespace VoidEngine; return '. self::formatLine ($style, self::$objects) .';'); |
|
150 | + $path = eval ('namespace VoidEngine; return '.self::formatLine($style, self::$objects).';'); |
|
151 | 151 | |
152 | - if (!file_exists ($path)) |
|
153 | - throw new \Exception ('Trying to import nonexistent style at line "'. $node->line .'"'); |
|
152 | + if (!file_exists($path)) |
|
153 | + throw new \Exception('Trying to import nonexistent style at line "'.$node->line.'"'); |
|
154 | 154 | |
155 | - \VLF\VST\Interpreter::run (\VLF\VST\Parser::parse (file_get_contents ($path))); |
|
155 | + \VLF\VST\Interpreter::run(\VLF\VST\Parser::parse(file_get_contents($path))); |
|
156 | 156 | } |
157 | 157 | break; |
158 | 158 | |
159 | 159 | case RUNTIME_EXECUTION: |
160 | - eval (self::formatLine ($node->args['code'], self::$objects)); |
|
160 | + eval (self::formatLine($node->args['code'], self::$objects)); |
|
161 | 161 | break; |
162 | 162 | } |
163 | 163 | |
164 | - $nodes = $node->getNodes (); |
|
164 | + $nodes = $node->getNodes(); |
|
165 | 165 | |
166 | 166 | if (isset ($node->args['styles'])) |
167 | 167 | foreach ($node->args['styles'] as $style) |
168 | 168 | if (isset (\VLF\VST\Interpreter::$styles[$style])) |
169 | - $nodes = array_merge ($nodes, \VLF\VST\Interpreter::$styles[$style]); |
|
169 | + $nodes = array_merge($nodes, \VLF\VST\Interpreter::$styles[$style]); |
|
170 | 170 | |
171 | - else throw new \Exception ('Trying to set undefined style to object at line "'. $node->line .'"'); |
|
171 | + else throw new \Exception('Trying to set undefined style to object at line "'.$node->line.'"'); |
|
172 | 172 | |
173 | - self::$objects = self::run (new AST (array_map ( |
|
174 | - fn ($node) => $node->export (), $nodes)), $node); |
|
173 | + self::$objects = self::run(new AST(array_map( |
|
174 | + fn($node) => $node->export(), $nodes)), $node); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return self::$objects; |
@@ -185,26 +185,25 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return string - возвращает форматированную строку |
187 | 187 | */ |
188 | - public static function formatLine (string $line, array $objects = []): string |
|
188 | + public static function formatLine(string $line, array $objects = []): string |
|
189 | 189 | { |
190 | - if (sizeof ($objects) > 0) |
|
190 | + if (sizeof($objects) > 0) |
|
191 | 191 | { |
192 | - $len = strlen ($line); |
|
192 | + $len = strlen($line); |
|
193 | 193 | $newLine = ''; |
194 | 194 | |
195 | - $replacement = array_map (function ($object) |
|
195 | + $replacement = array_map(function($object) |
|
196 | 196 | { |
197 | - return \VoidEngine\Components::exists ($object->selector) !== false ? |
|
198 | - '\VoidEngine\_c('. $object->selector .')' : |
|
199 | - 'unserialize (\''. serialize ($object) .'\')'; |
|
197 | + return \VoidEngine\Components::exists($object->selector) !== false ? |
|
198 | + '\VoidEngine\_c('.$object->selector.')' : 'unserialize (\''.serialize($object).'\')'; |
|
200 | 199 | }, $objects); |
201 | 200 | |
202 | - $replacement = array_map (function ($name) |
|
201 | + $replacement = array_map(function($name) |
|
203 | 202 | { |
204 | - return strlen ($name = trim ($name)) + substr_count ($name, '_'); |
|
205 | - }, $omap = array_flip ($replacement)); |
|
203 | + return strlen($name = trim($name)) + substr_count($name, '_'); |
|
204 | + }, $omap = array_flip($replacement)); |
|
206 | 205 | |
207 | - arsort ($replacement); |
|
206 | + arsort($replacement); |
|
208 | 207 | |
209 | 208 | $nReplacement = []; |
210 | 209 | |
@@ -212,14 +211,14 @@ discard block |
||
212 | 211 | $nReplacement[$omap[$replaceTo]] = $replaceTo; |
213 | 212 | |
214 | 213 | $replacement = $nReplacement; |
215 | - $blacklist = array_flip (['\'', '"', '$']); |
|
214 | + $blacklist = array_flip(['\'', '"', '$']); |
|
216 | 215 | |
217 | 216 | for ($i = 0; $i < $len; ++$i) |
218 | 217 | { |
219 | 218 | $replaced = false; |
220 | 219 | |
221 | 220 | foreach ($replacement as $name => $replaceAt) |
222 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
221 | + if (substr($line, $i, ($l = strlen($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
223 | 222 | { |
224 | 223 | $newLine .= $replaceAt; |
225 | 224 |
@@ -31,15 +31,17 @@ discard block |
||
31 | 31 | $name = $node->args['name']; |
32 | 32 | $args = []; |
33 | 33 | |
34 | - if (isset (self::$objects[$name])) |
|
35 | - break; |
|
34 | + if (isset (self::$objects[$name])) { |
|
35 | + break; |
|
36 | + } |
|
36 | 37 | |
37 | 38 | if (isset ($node->args['args'])) |
38 | 39 | { |
39 | 40 | $args = $node->args['args']; |
40 | 41 | |
41 | - foreach ($args as $arg_id => $arg) |
|
42 | - $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
42 | + foreach ($args as $arg_id => $arg) { |
|
43 | + $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | |
45 | 47 | try |
@@ -49,15 +51,12 @@ discard block |
||
49 | 51 | try |
50 | 52 | { |
51 | 53 | self::$objects[$name]->name = $name; |
52 | - } |
|
53 | - |
|
54 | - catch (\Throwable $e) {} |
|
55 | - } |
|
56 | - |
|
57 | - catch (\Throwable $e) |
|
54 | + } catch (\Throwable $e) {} |
|
55 | + } catch (\Throwable $e) |
|
58 | 56 | { |
59 | - if (self::$throw_errors) |
|
60 | - throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
57 | + if (self::$throw_errors) { |
|
58 | + throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
59 | + } |
|
61 | 60 | } |
62 | 61 | break; |
63 | 62 | |
@@ -76,13 +75,15 @@ discard block |
||
76 | 75 | $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos); |
77 | 76 | $use = explode (' ', $use); |
78 | 77 | |
79 | - foreach ($use as $id => $useParam) |
|
80 | - if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
|
78 | + foreach ($use as $id => $useParam) { |
|
79 | + if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
|
81 | 80 | { |
82 | 81 | $fname = $use[$id + 1]; |
82 | + } |
|
83 | 83 | |
84 | - if (substr ($fname, strlen ($fname) - 1) == ',') |
|
85 | - $fname = substr ($fname, 0, -1); |
|
84 | + if (substr ($fname, strlen ($fname) - 1) == ',') { |
|
85 | + $fname = substr ($fname, 0, -1); |
|
86 | + } |
|
86 | 87 | |
87 | 88 | $preset .= "$fname = $useParam; "; |
88 | 89 | |
@@ -91,24 +92,22 @@ discard block |
||
91 | 92 | |
92 | 93 | $preset = self::formatLine ($preset, self::$objects); |
93 | 94 | $propertyValue = self::formatLine (str_replace ($ouse, implode (' ', $use), $propertyValue), self::$objects); |
95 | + } else { |
|
96 | + $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
94 | 97 | } |
95 | 98 | |
96 | - else $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
97 | - |
|
98 | 99 | try |
99 | 100 | { |
100 | 101 | self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
101 | - } |
|
102 | - |
|
103 | - catch (\Throwable $e) |
|
102 | + } catch (\Throwable $e) |
|
104 | 103 | { |
105 | - if (self::$throw_errors) |
|
106 | - throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
104 | + if (self::$throw_errors) { |
|
105 | + throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
106 | + } |
|
107 | 107 | } |
108 | + } elseif (self::$throw_errors) { |
|
109 | + throw new \Exception ('Setting property to an non-object at line "'. $node->line); |
|
108 | 110 | } |
109 | - |
|
110 | - elseif (self::$throw_errors) |
|
111 | - throw new \Exception ('Setting property to an non-object at line "'. $node->line); |
|
112 | 111 | break; |
113 | 112 | |
114 | 113 | case METHOD_CALL: |
@@ -119,29 +118,28 @@ discard block |
||
119 | 118 | $methodName = $node->args['name']; |
120 | 119 | $methodArgs = $node->args['args']; |
121 | 120 | |
122 | - foreach ($methodArgs as $arg_id => $arg) |
|
123 | - $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
121 | + foreach ($methodArgs as $arg_id => $arg) { |
|
122 | + $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
123 | + } |
|
124 | 124 | |
125 | 125 | try |
126 | 126 | { |
127 | - if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
128 | - eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
129 | - |
|
130 | - elseif (sizeof ($methodArgs) > 0) |
|
131 | - self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
132 | - |
|
133 | - else self::$objects[$name]->$methodName (); |
|
134 | - } |
|
135 | - |
|
136 | - catch (\Throwable $e) |
|
127 | + if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) { |
|
128 | + eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
129 | + } elseif (sizeof ($methodArgs) > 0) { |
|
130 | + self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
131 | + } else { |
|
132 | + self::$objects[$name]->$methodName (); |
|
133 | + } |
|
134 | + } catch (\Throwable $e) |
|
137 | 135 | { |
138 | - if (self::$throw_errors) |
|
139 | - throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
136 | + if (self::$throw_errors) { |
|
137 | + throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
138 | + } |
|
140 | 139 | } |
140 | + } elseif (self::$throw_errors) { |
|
141 | + throw new \Exception ('Calling method to an non-object at line "'. $node->line .'"'); |
|
141 | 142 | } |
142 | - |
|
143 | - elseif (self::$throw_errors) |
|
144 | - throw new \Exception ('Calling method to an non-object at line "'. $node->line .'"'); |
|
145 | 143 | break; |
146 | 144 | |
147 | 145 | case STYLES_IMPORTING: |
@@ -149,8 +147,9 @@ discard block |
||
149 | 147 | { |
150 | 148 | $path = eval ('namespace VoidEngine; return '. self::formatLine ($style, self::$objects) .';'); |
151 | 149 | |
152 | - if (!file_exists ($path)) |
|
153 | - throw new \Exception ('Trying to import nonexistent style at line "'. $node->line .'"'); |
|
150 | + if (!file_exists ($path)) { |
|
151 | + throw new \Exception ('Trying to import nonexistent style at line "'. $node->line .'"'); |
|
152 | + } |
|
154 | 153 | |
155 | 154 | \VLF\VST\Interpreter::run (\VLF\VST\Parser::parse (file_get_contents ($path))); |
156 | 155 | } |
@@ -163,12 +162,13 @@ discard block |
||
163 | 162 | |
164 | 163 | $nodes = $node->getNodes (); |
165 | 164 | |
166 | - if (isset ($node->args['styles'])) |
|
167 | - foreach ($node->args['styles'] as $style) |
|
165 | + if (isset ($node->args['styles'])) { |
|
166 | + foreach ($node->args['styles'] as $style) |
|
168 | 167 | if (isset (\VLF\VST\Interpreter::$styles[$style])) |
169 | 168 | $nodes = array_merge ($nodes, \VLF\VST\Interpreter::$styles[$style]); |
170 | - |
|
171 | - else throw new \Exception ('Trying to set undefined style to object at line "'. $node->line .'"'); |
|
169 | + } else { |
|
170 | + throw new \Exception ('Trying to set undefined style to object at line "'. $node->line .'"'); |
|
171 | + } |
|
172 | 172 | |
173 | 173 | self::$objects = self::run (new AST (array_map ( |
174 | 174 | fn ($node) => $node->export (), $nodes)), $node); |
@@ -208,8 +208,9 @@ discard block |
||
208 | 208 | |
209 | 209 | $nReplacement = []; |
210 | 210 | |
211 | - foreach ($replacement as $replaceTo => $nLn) |
|
212 | - $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
211 | + foreach ($replacement as $replaceTo => $nLn) { |
|
212 | + $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
213 | + } |
|
213 | 214 | |
214 | 215 | $replacement = $nReplacement; |
215 | 216 | $blacklist = array_flip (['\'', '"', '$']); |
@@ -218,10 +219,11 @@ discard block |
||
218 | 219 | { |
219 | 220 | $replaced = false; |
220 | 221 | |
221 | - foreach ($replacement as $name => $replaceAt) |
|
222 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
222 | + foreach ($replacement as $name => $replaceAt) { |
|
223 | + if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
223 | 224 | { |
224 | 225 | $newLine .= $replaceAt; |
226 | + } |
|
225 | 227 | |
226 | 228 | $i += $l - 1; |
227 | 229 | $replaced = true; |
@@ -229,8 +231,9 @@ discard block |
||
229 | 231 | break; |
230 | 232 | } |
231 | 233 | |
232 | - if (!$replaced) |
|
233 | - $newLine .= $line[$i]; |
|
234 | + if (!$replaced) { |
|
235 | + $newLine .= $line[$i]; |
|
236 | + } |
|
234 | 237 | } |
235 | 238 | |
236 | 239 | $line = $newLine; |
@@ -4,25 +4,25 @@ discard block |
||
4 | 4 | |
5 | 5 | class Translator |
6 | 6 | { |
7 | - public static function translate (AST $tree): string |
|
7 | + public static function translate(AST $tree): string |
|
8 | 8 | { |
9 | 9 | $code = "<?php\n\nnamespace VoidEngine;\n\n"; |
10 | 10 | $definedObjects = []; |
11 | 11 | |
12 | - foreach ($tree->getNodes () as $node) |
|
13 | - $code .= self::translateNode ($node, null, $definedObjects) ."\n"; |
|
12 | + foreach ($tree->getNodes() as $node) |
|
13 | + $code .= self::translateNode($node, null, $definedObjects)."\n"; |
|
14 | 14 | |
15 | 15 | return $code; |
16 | 16 | } |
17 | 17 | |
18 | - protected static function translateNode (Node $node, Node $owner = null, array &$definedObjects = []): string |
|
18 | + protected static function translateNode(Node $node, Node $owner = null, array &$definedObjects = []): string |
|
19 | 19 | { |
20 | 20 | $code = ''; |
21 | 21 | |
22 | 22 | switch ($node->type) |
23 | 23 | { |
24 | 24 | case RUNTIME_EXECUTION: |
25 | - $code .= self::formatLine ($node->args['code'], $definedObjects) ."\n\n"; |
|
25 | + $code .= self::formatLine($node->args['code'], $definedObjects)."\n\n"; |
|
26 | 26 | |
27 | 27 | break; |
28 | 28 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | if (isset ($definedObjects[$node->args['name']])) |
31 | 31 | break; |
32 | 32 | |
33 | - $code .= '$'. $node->args['name'] .' = new '. $node->args['class'] .' ('. implode (', ', self::processArgs ($node->args['args'], $definedObjects)) .');' ."\n". '$'. $node->args['name'] .'->name = \''. $node->args['name'] .'\';' ."\n"; |
|
33 | + $code .= '$'.$node->args['name'].' = new '.$node->args['class'].' ('.implode(', ', self::processArgs($node->args['args'], $definedObjects)).');'."\n".'$'.$node->args['name'].'->name = \''.$node->args['name'].'\';'."\n"; |
|
34 | 34 | |
35 | 35 | $definedObjects[$node->args['name']] = $node->args['name']; |
36 | 36 | |
@@ -39,74 +39,74 @@ discard block |
||
39 | 39 | case PROPERTY_SET: |
40 | 40 | $preset = ''; |
41 | 41 | |
42 | - if (preg_match ('/function \((.*)\) use \((.*)\)/', $node->args['property_value'])) |
|
42 | + if (preg_match('/function \((.*)\) use \((.*)\)/', $node->args['property_value'])) |
|
43 | 43 | { |
44 | - $use = substr ($node->args['property_value'], strpos ($node->args['property_value'], 'use')); |
|
45 | - $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos); |
|
46 | - $use = explode (' ', $use); |
|
44 | + $use = substr($node->args['property_value'], strpos($node->args['property_value'], 'use')); |
|
45 | + $use = $ouse = substr($use, ($pos = strpos($use, '(') + 1), strpos($use, ')') - $pos); |
|
46 | + $use = explode(' ', $use); |
|
47 | 47 | |
48 | 48 | foreach ($use as $id => $useParam) |
49 | 49 | if (isset ($definedObjects[$useParam]) && $use[$id + 1][0] == '$') |
50 | 50 | { |
51 | 51 | $fname = $use[$id + 1]; |
52 | 52 | |
53 | - if (substr ($fname, strlen ($fname) - 1) == ',') |
|
54 | - $fname = substr ($fname, 0, -1); |
|
53 | + if (substr($fname, strlen($fname) - 1) == ',') |
|
54 | + $fname = substr($fname, 0, -1); |
|
55 | 55 | |
56 | 56 | $preset .= "$fname = $useParam; "; |
57 | 57 | |
58 | 58 | unset ($use[$id]); |
59 | 59 | } |
60 | 60 | |
61 | - $preset = self::formatLine ($preset, $definedObjects) ."\n"; |
|
61 | + $preset = self::formatLine($preset, $definedObjects)."\n"; |
|
62 | 62 | |
63 | - $node->args['property_value'] = self::formatLine (str_replace ($ouse, join (' ', $use), $node->args['property_value']), $definedObjects); |
|
63 | + $node->args['property_value'] = self::formatLine(str_replace($ouse, join(' ', $use), $node->args['property_value']), $definedObjects); |
|
64 | 64 | } |
65 | 65 | |
66 | - $code .= $preset .'$'. $owner->args['name'] .'->'. $node->args['property_name'] .' = '. self::formatLine ($node->args['property_value'], $definedObjects) .';' ."\n"; |
|
66 | + $code .= $preset.'$'.$owner->args['name'].'->'.$node->args['property_name'].' = '.self::formatLine($node->args['property_value'], $definedObjects).';'."\n"; |
|
67 | 67 | |
68 | 68 | break; |
69 | 69 | |
70 | 70 | case METHOD_CALL: |
71 | - $code .= '$'. $owner->args['name'] .'->'. $node->args['method_name'] .' ('. implode (', ', self::processArgs ($node->args['method_args'], $definedObjects)) .');' ."\n"; |
|
71 | + $code .= '$'.$owner->args['name'].'->'.$node->args['method_name'].' ('.implode(', ', self::processArgs($node->args['method_args'], $definedObjects)).');'."\n"; |
|
72 | 72 | |
73 | 73 | break; |
74 | 74 | } |
75 | 75 | |
76 | - foreach ($node->getNodes () as $subnode) |
|
77 | - $code .= self::translateNode ($subnode, $node, $definedObjects); |
|
76 | + foreach ($node->getNodes() as $subnode) |
|
77 | + $code .= self::translateNode($subnode, $node, $definedObjects); |
|
78 | 78 | |
79 | 79 | return $code; |
80 | 80 | } |
81 | 81 | |
82 | - protected static function processArgs (array $args, array $definedObjects = []): array |
|
82 | + protected static function processArgs(array $args, array $definedObjects = []): array |
|
83 | 83 | { |
84 | 84 | $newArgs = []; |
85 | 85 | |
86 | 86 | foreach ($args as $arg) |
87 | - $newArgs[] = self::formatLine ($arg, $definedObjects); |
|
87 | + $newArgs[] = self::formatLine($arg, $definedObjects); |
|
88 | 88 | |
89 | 89 | return $newArgs; |
90 | 90 | } |
91 | 91 | |
92 | - protected static function formatLine (string $line, array $objects = []): string |
|
92 | + protected static function formatLine(string $line, array $objects = []): string |
|
93 | 93 | { |
94 | - if (sizeof ($objects) > 0) |
|
94 | + if (sizeof($objects) > 0) |
|
95 | 95 | { |
96 | - $len = strlen ($line); |
|
96 | + $len = strlen($line); |
|
97 | 97 | $newLine = ''; |
98 | 98 | |
99 | - $replacement = array_map (function ($object) |
|
99 | + $replacement = array_map(function($object) |
|
100 | 100 | { |
101 | - return '$'. $object; |
|
101 | + return '$'.$object; |
|
102 | 102 | }, $objects); |
103 | 103 | |
104 | - $replacement = array_map (function ($name) |
|
104 | + $replacement = array_map(function($name) |
|
105 | 105 | { |
106 | - return strlen ($name = trim ($name)) + substr_count ($name, '_'); |
|
107 | - }, $omap = array_flip ($replacement)); |
|
106 | + return strlen($name = trim($name)) + substr_count($name, '_'); |
|
107 | + }, $omap = array_flip($replacement)); |
|
108 | 108 | |
109 | - arsort ($replacement); |
|
109 | + arsort($replacement); |
|
110 | 110 | |
111 | 111 | $nReplacement = []; |
112 | 112 | |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | $nReplacement[$omap[$replaceTo]] = $replaceTo; |
115 | 115 | |
116 | 116 | $replacement = $nReplacement; |
117 | - $blacklist = array_flip (['\'', '"', '$']); |
|
117 | + $blacklist = array_flip(['\'', '"', '$']); |
|
118 | 118 | |
119 | 119 | for ($i = 0; $i < $len; ++$i) |
120 | 120 | { |
121 | 121 | $replaced = false; |
122 | 122 | |
123 | 123 | foreach ($replacement as $name => $replaceAt) |
124 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
124 | + if (substr($line, $i, ($l = strlen($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
125 | 125 | { |
126 | 126 | $newLine .= $replaceAt; |
127 | 127 |
@@ -9,8 +9,9 @@ discard block |
||
9 | 9 | $code = "<?php\n\nnamespace VoidEngine;\n\n"; |
10 | 10 | $definedObjects = []; |
11 | 11 | |
12 | - foreach ($tree->getNodes () as $node) |
|
13 | - $code .= self::translateNode ($node, null, $definedObjects) ."\n"; |
|
12 | + foreach ($tree->getNodes () as $node) { |
|
13 | + $code .= self::translateNode ($node, null, $definedObjects) ."\n"; |
|
14 | + } |
|
14 | 15 | |
15 | 16 | return $code; |
16 | 17 | } |
@@ -27,8 +28,9 @@ discard block |
||
27 | 28 | break; |
28 | 29 | |
29 | 30 | case OBJECT_DEFINITION: |
30 | - if (isset ($definedObjects[$node->args['name']])) |
|
31 | - break; |
|
31 | + if (isset ($definedObjects[$node->args['name']])) { |
|
32 | + break; |
|
33 | + } |
|
32 | 34 | |
33 | 35 | $code .= '$'. $node->args['name'] .' = new '. $node->args['class'] .' ('. implode (', ', self::processArgs ($node->args['args'], $definedObjects)) .');' ."\n". '$'. $node->args['name'] .'->name = \''. $node->args['name'] .'\';' ."\n"; |
34 | 36 | |
@@ -45,13 +47,15 @@ discard block |
||
45 | 47 | $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos); |
46 | 48 | $use = explode (' ', $use); |
47 | 49 | |
48 | - foreach ($use as $id => $useParam) |
|
49 | - if (isset ($definedObjects[$useParam]) && $use[$id + 1][0] == '$') |
|
50 | + foreach ($use as $id => $useParam) { |
|
51 | + if (isset ($definedObjects[$useParam]) && $use[$id + 1][0] == '$') |
|
50 | 52 | { |
51 | 53 | $fname = $use[$id + 1]; |
54 | + } |
|
52 | 55 | |
53 | - if (substr ($fname, strlen ($fname) - 1) == ',') |
|
54 | - $fname = substr ($fname, 0, -1); |
|
56 | + if (substr ($fname, strlen ($fname) - 1) == ',') { |
|
57 | + $fname = substr ($fname, 0, -1); |
|
58 | + } |
|
55 | 59 | |
56 | 60 | $preset .= "$fname = $useParam; "; |
57 | 61 | |
@@ -73,8 +77,9 @@ discard block |
||
73 | 77 | break; |
74 | 78 | } |
75 | 79 | |
76 | - foreach ($node->getNodes () as $subnode) |
|
77 | - $code .= self::translateNode ($subnode, $node, $definedObjects); |
|
80 | + foreach ($node->getNodes () as $subnode) { |
|
81 | + $code .= self::translateNode ($subnode, $node, $definedObjects); |
|
82 | + } |
|
78 | 83 | |
79 | 84 | return $code; |
80 | 85 | } |
@@ -83,8 +88,9 @@ discard block |
||
83 | 88 | { |
84 | 89 | $newArgs = []; |
85 | 90 | |
86 | - foreach ($args as $arg) |
|
87 | - $newArgs[] = self::formatLine ($arg, $definedObjects); |
|
91 | + foreach ($args as $arg) { |
|
92 | + $newArgs[] = self::formatLine ($arg, $definedObjects); |
|
93 | + } |
|
88 | 94 | |
89 | 95 | return $newArgs; |
90 | 96 | } |
@@ -110,8 +116,9 @@ discard block |
||
110 | 116 | |
111 | 117 | $nReplacement = []; |
112 | 118 | |
113 | - foreach ($replacement as $replaceTo => $nLn) |
|
114 | - $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
119 | + foreach ($replacement as $replaceTo => $nLn) { |
|
120 | + $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
121 | + } |
|
115 | 122 | |
116 | 123 | $replacement = $nReplacement; |
117 | 124 | $blacklist = array_flip (['\'', '"', '$']); |
@@ -120,10 +127,11 @@ discard block |
||
120 | 127 | { |
121 | 128 | $replaced = false; |
122 | 129 | |
123 | - foreach ($replacement as $name => $replaceAt) |
|
124 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
130 | + foreach ($replacement as $name => $replaceAt) { |
|
131 | + if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
125 | 132 | { |
126 | 133 | $newLine .= $replaceAt; |
134 | + } |
|
127 | 135 | |
128 | 136 | $i += $l - 1; |
129 | 137 | $replaced = true; |
@@ -131,8 +139,9 @@ discard block |
||
131 | 139 | break; |
132 | 140 | } |
133 | 141 | |
134 | - if (!$replaced) |
|
135 | - $newLine .= $line[$i]; |
|
142 | + if (!$replaced) { |
|
143 | + $newLine .= $line[$i]; |
|
144 | + } |
|
136 | 145 | } |
137 | 146 | |
138 | 147 | $line = $newLine; |
@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | class Node |
9 | 9 | { |
10 | 10 | public ?string $line = null; // Строка |
11 | - public array $words = []; // Список слов |
|
12 | - public int $height = 0; // Высота строки |
|
13 | - public int $type = 0; // Тип ноды |
|
14 | - public array $args = []; // Аргументы ноды |
|
11 | + public array $words = []; // Список слов |
|
12 | + public int $height = 0; // Высота строки |
|
13 | + public int $type = 0; // Тип ноды |
|
14 | + public array $args = []; // Аргументы ноды |
|
15 | 15 | |
16 | 16 | protected array $nodes = []; // Ветви ноды |
17 | 17 | |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | * |
21 | 21 | * [@param array $node = null] - массив для импорта ноды |
22 | 22 | */ |
23 | - public function __construct (array $node = null) |
|
23 | + public function __construct(array $node = null) |
|
24 | 24 | { |
25 | 25 | if ($node !== null) |
26 | - $this->import ($node); |
|
26 | + $this->import($node); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return Node - возвращает саму себя |
35 | 35 | */ |
36 | - public function import (array $node): Node |
|
36 | + public function import(array $node): Node |
|
37 | 37 | { |
38 | 38 | $this->line = $node['line'] ?? null; |
39 | 39 | $this->words = $node['words'] ?? []; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $this->type = $node['type'] ?? 0; |
42 | 42 | $this->args = $node['args'] ?? []; |
43 | 43 | |
44 | - $this->nodes = array_map (fn (array $t) => new Node ($t), $node['nodes'] ?? []); |
|
44 | + $this->nodes = array_map(fn(array $t) => new Node($t), $node['nodes'] ?? []); |
|
45 | 45 | |
46 | 46 | return $this; |
47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return array - возвращает массив экспортированной ноды |
53 | 53 | */ |
54 | - public function export (): array |
|
54 | + public function export(): array |
|
55 | 55 | { |
56 | 56 | return [ |
57 | 57 | 'line' => $this->line, |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'type' => $this->type, |
61 | 61 | 'args' => $this->args, |
62 | 62 | |
63 | - 'nodes' => array_map (fn (Node $node) => $node->export (), $this->nodes) |
|
63 | + 'nodes' => array_map(fn(Node $node) => $node->export(), $this->nodes) |
|
64 | 64 | ]; |
65 | 65 | } |
66 | 66 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return Node - возвращает саму себя |
73 | 73 | */ |
74 | - public function push (Node $node): Node |
|
74 | + public function push(Node $node): Node |
|
75 | 75 | { |
76 | 76 | $this->nodes[] = $node; |
77 | 77 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return array - возвращает список ветвей |
85 | 85 | */ |
86 | - public function getNodes (): array |
|
86 | + public function getNodes(): array |
|
87 | 87 | { |
88 | 88 | return $this->nodes; |
89 | 89 | } |
@@ -22,8 +22,9 @@ |
||
22 | 22 | */ |
23 | 23 | public function __construct (array $node = null) |
24 | 24 | { |
25 | - if ($node !== null) |
|
26 | - $this->import ($node); |
|
25 | + if ($node !== null) { |
|
26 | + $this->import ($node); |
|
27 | + } |
|
27 | 28 | } |
28 | 29 | |
29 | 30 | /** |