@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | protected $WinAPI; |
| 31 | 31 | |
| 32 | - public function __construct () |
|
| 32 | + public function __construct() |
|
| 33 | 33 | { |
| 34 | 34 | /** |
| 35 | 35 | * Большинство функций было взято из класса "WinAPI" проекта "DevelStudio XL" |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | - $this->WinAPI = \FFI::cdef (' |
|
| 43 | + $this->WinAPI = \FFI::cdef(' |
|
| 44 | 44 | struct LPCTSTR |
| 45 | 45 | { |
| 46 | 46 | char string; |
@@ -76,25 +76,25 @@ discard block |
||
| 76 | 76 | ', 'User32.dll'); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public function __call ($method, $args) |
|
| 79 | + public function __call($method, $args) |
|
| 80 | 80 | { |
| 81 | - if (method_exists ($this, $method)) |
|
| 82 | - return $this->$method (...$args); |
|
| 81 | + if (method_exists($this, $method)) |
|
| 82 | + return $this->$method(...$args); |
|
| 83 | 83 | |
| 84 | 84 | else try |
| 85 | 85 | { |
| 86 | - return $this->WinAPI->$method (...$args); |
|
| 86 | + return $this->WinAPI->$method(...$args); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | catch (\Throwable $e) |
| 90 | 90 | { |
| 91 | - throw new \Exception ('Method "'. $method .'" not found or return an exception. Exception info: '. "\n\n". (string) $e); |
|
| 91 | + throw new \Exception('Method "'.$method.'" not found or return an exception. Exception info: '."\n\n".(string) $e); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function findWindow (string $caption, string $class = null): ?int |
|
| 95 | + public function findWindow(string $caption, string $class = null): ?int |
|
| 96 | 96 | { |
| 97 | - return $this->FindWindowA ($class, $caption); |
|
| 97 | + return $this->FindWindowA($class, $caption); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /*public function getWindowCaption (int $handle) |
@@ -78,15 +78,14 @@ |
||
| 78 | 78 | |
| 79 | 79 | public function __call ($method, $args) |
| 80 | 80 | { |
| 81 | - if (method_exists ($this, $method)) |
|
| 82 | - return $this->$method (...$args); |
|
| 83 | - |
|
| 84 | - else try |
|
| 81 | + if (method_exists ($this, $method)) { |
|
| 82 | + return $this->$method (...$args); |
|
| 83 | + } else { |
|
| 84 | + try |
|
| 85 | 85 | { |
| 86 | 86 | return $this->WinAPI->$method (...$args); |
| 87 | 87 | } |
| 88 | - |
|
| 89 | - catch (\Throwable $e) |
|
| 88 | + } catch (\Throwable $e) |
|
| 90 | 89 | { |
| 91 | 90 | throw new \Exception ('Method "'. $method .'" not found or return an exception. Exception info: '. "\n\n". (string) $e); |
| 92 | 91 | } |
@@ -8,20 +8,20 @@ |
||
| 8 | 8 | chdir (CORE_DIR); |
| 9 | 9 | |
| 10 | 10 | foreach (glob ('ext/php_*.dll') as $ext) |
| 11 | - if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
| 12 | - load_extension ($ext); |
|
| 11 | + if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
| 12 | + load_extension ($ext); |
|
| 13 | 13 | |
| 14 | 14 | if (file_exists ('../engine/VoidEngine.php')) |
| 15 | - require '../engine/VoidEngine.php'; |
|
| 15 | + require '../engine/VoidEngine.php'; |
|
| 16 | 16 | |
| 17 | 17 | elseif (file_exists (FRAMEWORK_DIR .'/engine/VoidEngine.php')) |
| 18 | - require FRAMEWORK_DIR .'/engine/VoidEngine.php'; |
|
| 18 | + require FRAMEWORK_DIR .'/engine/VoidEngine.php'; |
|
| 19 | 19 | |
| 20 | 20 | else message ('VoidEngine not founded'); |
| 21 | 21 | |
| 22 | 22 | $app = '../../app/start.php'; |
| 23 | 23 | |
| 24 | 24 | if (file_exists ($app)) |
| 25 | - require $app; |
|
| 25 | + require $app; |
|
| 26 | 26 | |
| 27 | 27 | else \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm', null), 'ShowDialog'); |
@@ -2,26 +2,26 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace VoidEngine; |
| 4 | 4 | |
| 5 | -define ('VoidEngine\FRAMEWORK_DIR', getenv ('AppData') .'\VoidFramework'); |
|
| 5 | +define('VoidEngine\FRAMEWORK_DIR', getenv('AppData').'\VoidFramework'); |
|
| 6 | 6 | |
| 7 | 7 | const CORE_DIR = __DIR__; |
| 8 | -chdir (CORE_DIR); |
|
| 8 | +chdir(CORE_DIR); |
|
| 9 | 9 | |
| 10 | -foreach (glob ('ext/php_*.dll') as $ext) |
|
| 11 | - if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
| 12 | - load_extension ($ext); |
|
| 10 | +foreach (glob('ext/php_*.dll') as $ext) |
|
| 11 | + if (!extension_loaded(substr(basename($ext), 4, -4))) |
|
| 12 | + load_extension($ext); |
|
| 13 | 13 | |
| 14 | -if (file_exists ('../engine/VoidEngine.php')) |
|
| 14 | +if (file_exists('../engine/VoidEngine.php')) |
|
| 15 | 15 | require '../engine/VoidEngine.php'; |
| 16 | 16 | |
| 17 | -elseif (file_exists (FRAMEWORK_DIR .'/engine/VoidEngine.php')) |
|
| 18 | - require FRAMEWORK_DIR .'/engine/VoidEngine.php'; |
|
| 17 | +elseif (file_exists(FRAMEWORK_DIR.'/engine/VoidEngine.php')) |
|
| 18 | + require FRAMEWORK_DIR.'/engine/VoidEngine.php'; |
|
| 19 | 19 | |
| 20 | -else message ('VoidEngine not founded'); |
|
| 20 | +else message('VoidEngine not founded'); |
|
| 21 | 21 | |
| 22 | 22 | $app = '../../app/start.php'; |
| 23 | 23 | |
| 24 | -if (file_exists ($app)) |
|
| 24 | +if (file_exists($app)) |
|
| 25 | 25 | require $app; |
| 26 | 26 | |
| 27 | -else \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm', null), 'ShowDialog'); |
|
| 27 | +else \VoidCore::callMethod(\VoidCore::createObject('WinForms_PHP.DebugForm', null), 'ShowDialog'); |
|
@@ -7,21 +7,23 @@ |
||
| 7 | 7 | const CORE_DIR = __DIR__; |
| 8 | 8 | chdir (CORE_DIR); |
| 9 | 9 | |
| 10 | -foreach (glob ('ext/php_*.dll') as $ext) |
|
| 10 | +foreach (glob ('ext/php_*.dll') as $ext) { |
|
| 11 | 11 | if (!extension_loaded (substr (basename ($ext), 4, -4))) |
| 12 | 12 | load_extension ($ext); |
| 13 | +} |
|
| 13 | 14 | |
| 14 | -if (file_exists ('../engine/VoidEngine.php')) |
|
| 15 | +if (file_exists ('../engine/VoidEngine.php')) { |
|
| 15 | 16 | require '../engine/VoidEngine.php'; |
| 16 | - |
|
| 17 | -elseif (file_exists (FRAMEWORK_DIR .'/engine/VoidEngine.php')) |
|
| 17 | +} elseif (file_exists (FRAMEWORK_DIR .'/engine/VoidEngine.php')) { |
|
| 18 | 18 | require FRAMEWORK_DIR .'/engine/VoidEngine.php'; |
| 19 | - |
|
| 20 | -else message ('VoidEngine not founded'); |
|
| 19 | +} else { |
|
| 20 | + message ('VoidEngine not founded'); |
|
| 21 | +} |
|
| 21 | 22 | |
| 22 | 23 | $app = '../../app/start.php'; |
| 23 | 24 | |
| 24 | -if (file_exists ($app)) |
|
| 25 | +if (file_exists ($app)) { |
|
| 25 | 26 | require $app; |
| 26 | - |
|
| 27 | -else \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm', null), 'ShowDialog'); |
|
| 27 | +} else { |
|
| 28 | + \VoidCore::callMethod (\VoidCore::createObject ('WinForms_PHP.DebugForm', null), 'ShowDialog'); |
|
| 29 | +} |
|
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | /** |
| 46 | 46 | * Парсер значений |
| 47 | 47 | */ |
| 48 | - public function parse (array &$args); |
|
| 48 | + public function parse(array &$args); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @param string $name - имя флага |
| 64 | 64 | */ |
| 65 | - public function __construct (string $name) |
|
| 65 | + public function __construct(string $name) |
|
| 66 | 66 | {
|
| 67 | 67 | $this->names = [$name]; |
| 68 | 68 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return Flag - возвращает сам себя |
| 76 | 76 | */ |
| 77 | - public function setLocale (Locale $locale): Param |
|
| 77 | + public function setLocale(Locale $locale): Param |
|
| 78 | 78 | {
|
| 79 | 79 | $this->locale = $locale; |
| 80 | 80 | |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return Flag - возвращает сам себя |
| 90 | 90 | */ |
| 91 | - public function addAliase (string $name) |
|
| 91 | + public function addAliase(string $name) |
|
| 92 | 92 | {
|
| 93 | - if (array_search ($name, $this->names) !== false) |
|
| 94 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
| 93 | + if (array_search($name, $this->names) !== false) |
|
| 94 | + throw new \Exception($this->locale->aliase_exists_exception); |
|
| 95 | 95 | |
| 96 | 96 | $this->names[] = $name; |
| 97 | 97 | |
@@ -105,17 +105,17 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * Возвращает состояние флага |
| 107 | 107 | */ |
| 108 | - public function parse (array &$args) |
|
| 108 | + public function parse(array &$args) |
|
| 109 | 109 | {
|
| 110 | - $args = array_values ($args); |
|
| 110 | + $args = array_values($args); |
|
| 111 | 111 | |
| 112 | 112 | foreach ($this->names as $name) |
| 113 | - if (($key = array_search ($name, $args)) !== false) |
|
| 113 | + if (($key = array_search($name, $args)) !== false) |
|
| 114 | 114 | {
|
| 115 | 115 | unset ($args[$key]); |
| 116 | - $args = array_values ($args); |
|
| 116 | + $args = array_values($args); |
|
| 117 | 117 | |
| 118 | - while ($this->parse ($args) !== false); |
|
| 118 | + while ($this->parse($args) !== false); |
|
| 119 | 119 | |
| 120 | 120 | return true; |
| 121 | 121 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * [@param string $defaultValue = null] - значение параметра по умолчанию |
| 143 | 143 | * [@param bool $required = false] - обязательно ли указание параметра |
| 144 | 144 | */ |
| 145 | - public function __construct (string $name, string $defaultValue = null, bool $required = false) |
|
| 145 | + public function __construct(string $name, string $defaultValue = null, bool $required = false) |
|
| 146 | 146 | {
|
| 147 | 147 | $this->names = [$name]; |
| 148 | 148 | $this->defaultValue = $defaultValue; |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return Param - возвращает сам себя |
| 160 | 160 | */ |
| 161 | - public function setLocale (Locale $locale): Param |
|
| 161 | + public function setLocale(Locale $locale): Param |
|
| 162 | 162 | {
|
| 163 | 163 | $this->locale = $locale; |
| 164 | 164 | |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return Param - возвращает сам себя |
| 174 | 174 | */ |
| 175 | - public function addAliase (string $name) |
|
| 175 | + public function addAliase(string $name) |
|
| 176 | 176 | {
|
| 177 | - if (array_search ($name, $this->names) !== false) |
|
| 178 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
| 177 | + if (array_search($name, $this->names) !== false) |
|
| 178 | + throw new \Exception($this->locale->aliase_exists_exception); |
|
| 179 | 179 | |
| 180 | 180 | $this->names[] = $name; |
| 181 | 181 | |
@@ -189,27 +189,27 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * Возвращает найденый параметр или массив найдёных параметров, если их было указано несколько |
| 191 | 191 | */ |
| 192 | - public function parse (array &$args) |
|
| 192 | + public function parse(array &$args) |
|
| 193 | 193 | {
|
| 194 | - $args = array_values ($args); |
|
| 194 | + $args = array_values($args); |
|
| 195 | 195 | |
| 196 | 196 | foreach ($this->names as $name) |
| 197 | - if (($key = array_search ($name, $args)) !== false) |
|
| 197 | + if (($key = array_search($name, $args)) !== false) |
|
| 198 | 198 | {
|
| 199 | 199 | if (!isset ($args[$key + 1])) |
| 200 | - throw new \Exception ($this->locale->unselected_value_exception); |
|
| 200 | + throw new \Exception($this->locale->unselected_value_exception); |
|
| 201 | 201 | |
| 202 | 202 | $param = [$args[$key + 1]]; |
| 203 | 203 | |
| 204 | 204 | unset ($args[$key], $args[$key + 1]); |
| 205 | - $args = array_values ($args); |
|
| 205 | + $args = array_values($args); |
|
| 206 | 206 | |
| 207 | 207 | try |
| 208 | 208 | {
|
| 209 | - while (($altParam = $this->parse ($args)) !== $this->defaultValue) |
|
| 209 | + while (($altParam = $this->parse($args)) !== $this->defaultValue) |
|
| 210 | 210 | {
|
| 211 | - if (is_array ($altParam)) |
|
| 212 | - $param = array_merge ($param, $altParam); |
|
| 211 | + if (is_array($altParam)) |
|
| 212 | + $param = array_merge($param, $altParam); |
|
| 213 | 213 | |
| 214 | 214 | else $param[] = $altParam; |
| 215 | 215 | } |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | catch (\Throwable $e) {}
|
| 219 | 219 | |
| 220 | - return sizeof ($param) == 1 ? |
|
| 220 | + return sizeof($param) == 1 ? |
|
| 221 | 221 | $param[0] : $param; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | if ($this->required) |
| 225 | - throw new \Exception ($this->locale->undefined_param_exception); |
|
| 225 | + throw new \Exception($this->locale->undefined_param_exception); |
|
| 226 | 226 | |
| 227 | 227 | return $this->defaultValue; |
| 228 | 228 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * [@param string $defaultValue = null] - значение сеттера по умолчанию |
| 249 | 249 | * [@param bool $required = false] - обязательно ли указание сеттера |
| 250 | 250 | */ |
| 251 | - public function __construct (string $name, string $separator = '=', string $defaultValue = null, bool $required = false) |
|
| 251 | + public function __construct(string $name, string $separator = '=', string $defaultValue = null, bool $required = false) |
|
| 252 | 252 | {
|
| 253 | 253 | $this->names = [$name]; |
| 254 | 254 | $this->separator = $separator; |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @return Param - возвращает сам себя |
| 267 | 267 | */ |
| 268 | - public function setLocale (Locale $locale): Param |
|
| 268 | + public function setLocale(Locale $locale): Param |
|
| 269 | 269 | {
|
| 270 | 270 | $this->locale = $locale; |
| 271 | 271 | |
@@ -279,10 +279,10 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @return Param - возвращает сам себя |
| 281 | 281 | */ |
| 282 | - public function addAliase (string $name) |
|
| 282 | + public function addAliase(string $name) |
|
| 283 | 283 | {
|
| 284 | - if (array_search ($name, $this->names) !== false) |
|
| 285 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
| 284 | + if (array_search($name, $this->names) !== false) |
|
| 285 | + throw new \Exception($this->locale->aliase_exists_exception); |
|
| 286 | 286 | |
| 287 | 287 | $this->names[] = $name; |
| 288 | 288 | |
@@ -296,26 +296,26 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * Возвращает найденый параметр или массив найдёных параметров, если их было указано несколько |
| 298 | 298 | */ |
| 299 | - public function parse (array &$args) |
|
| 299 | + public function parse(array &$args) |
|
| 300 | 300 | {
|
| 301 | - $args = array_values ($args); |
|
| 302 | - $l = strlen ($this->separator); |
|
| 301 | + $args = array_values($args); |
|
| 302 | + $l = strlen($this->separator); |
|
| 303 | 303 | |
| 304 | 304 | foreach ($this->names as $name) |
| 305 | 305 | foreach ($args as $id => $arg) |
| 306 | - if (substr ($arg, 0, ($pos = strlen ($name) + $l)) == $name . $this->separator) |
|
| 306 | + if (substr($arg, 0, ($pos = strlen($name) + $l)) == $name.$this->separator) |
|
| 307 | 307 | {
|
| 308 | - $param = [substr ($arg, $pos)]; |
|
| 308 | + $param = [substr($arg, $pos)]; |
|
| 309 | 309 | |
| 310 | 310 | unset ($args[$id]); |
| 311 | - $args = array_values ($args); |
|
| 311 | + $args = array_values($args); |
|
| 312 | 312 | |
| 313 | 313 | try |
| 314 | 314 | {
|
| 315 | - while (($altParam = $this->parse ($args)) !== $this->defaultValue) |
|
| 315 | + while (($altParam = $this->parse($args)) !== $this->defaultValue) |
|
| 316 | 316 | {
|
| 317 | - if (is_array ($altParam)) |
|
| 318 | - $param = array_merge ($param, $altParam); |
|
| 317 | + if (is_array($altParam)) |
|
| 318 | + $param = array_merge($param, $altParam); |
|
| 319 | 319 | |
| 320 | 320 | else $param[] = $altParam; |
| 321 | 321 | } |
@@ -323,12 +323,12 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | catch (\Throwable $e) {}
|
| 325 | 325 | |
| 326 | - return sizeof ($param) == 1 ? |
|
| 326 | + return sizeof($param) == 1 ? |
|
| 327 | 327 | $param[0] : $param; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | if ($this->required) |
| 331 | - throw new \Exception ($this->locale->undefined_param_exception); |
|
| 331 | + throw new \Exception($this->locale->undefined_param_exception); |
|
| 332 | 332 | |
| 333 | 333 | return $this->defaultValue; |
| 334 | 334 | } |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | * @param string $name - имя команды |
| 353 | 353 | * [@param \Closure $callable = null] - анонимная функция для выполнения |
| 354 | 354 | */ |
| 355 | - public function __construct (string $name, \Closure $callable = null) |
|
| 355 | + public function __construct(string $name, \Closure $callable = null) |
|
| 356 | 356 | {
|
| 357 | 357 | $this->name = $name; |
| 358 | 358 | $this->locale = new Locale; |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | * |
| 369 | 369 | * @return Command - возвращает сам себя |
| 370 | 370 | */ |
| 371 | - public function setLocale (Locale $locale): Command |
|
| 371 | + public function setLocale(Locale $locale): Command |
|
| 372 | 372 | {
|
| 373 | 373 | $this->locale = $locale; |
| 374 | 374 | |
@@ -382,13 +382,13 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @return Command - возвращает сам себя |
| 384 | 384 | */ |
| 385 | - public function addParams (array $params): Command |
|
| 385 | + public function addParams(array $params): Command |
|
| 386 | 386 | {
|
| 387 | 387 | foreach ($params as $param) |
| 388 | 388 | if ($param instanceof Parameter) |
| 389 | - $this->params[current ($param->names)] = $param; |
|
| 389 | + $this->params[current($param->names)] = $param; |
|
| 390 | 390 | |
| 391 | - else throw new \Exception ($this->locale->param_type_exception); |
|
| 391 | + else throw new \Exception($this->locale->param_type_exception); |
|
| 392 | 392 | |
| 393 | 393 | return $this; |
| 394 | 394 | } |
@@ -400,12 +400,12 @@ discard block |
||
| 400 | 400 | * |
| 401 | 401 | * @return array - возвращает ассоциативный массив [параметр] => [значение] |
| 402 | 402 | */ |
| 403 | - public function getParams (array &$args): array |
|
| 403 | + public function getParams(array &$args): array |
|
| 404 | 404 | {
|
| 405 | - $params = array_combine (array_keys ($this->params), array_fill (0, sizeof ($this->params), null)); |
|
| 405 | + $params = array_combine(array_keys($this->params), array_fill(0, sizeof($this->params), null)); |
|
| 406 | 406 | |
| 407 | 407 | foreach ($this->params as $name => $param) |
| 408 | - $params[$name] = $param->parse ($args); |
|
| 408 | + $params[$name] = $param->parse($args); |
|
| 409 | 409 | |
| 410 | 410 | return $params; |
| 411 | 411 | } |
@@ -415,16 +415,16 @@ discard block |
||
| 415 | 415 | * |
| 416 | 416 | * @param array &$args - аргументы команды |
| 417 | 417 | */ |
| 418 | - public function execute (array &$args) |
|
| 418 | + public function execute(array &$args) |
|
| 419 | 419 | {
|
| 420 | 420 | if ($this->callable instanceof \Closure) |
| 421 | 421 | {
|
| 422 | - $params = $this->getParams ($args); |
|
| 422 | + $params = $this->getParams($args); |
|
| 423 | 423 | |
| 424 | - return $this->callable->call ($this, array_values ($args), $params); |
|
| 424 | + return $this->callable->call($this, array_values($args), $params); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - throw new \Exception ($this->locale->execution_error); |
|
| 427 | + throw new \Exception($this->locale->execution_error); |
|
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | * |
| 440 | 440 | * [@param \Closure $callable = null] - анонимная функция для выполнения |
| 441 | 441 | */ |
| 442 | - public function __construct (\Closure $callable = null) |
|
| 442 | + public function __construct(\Closure $callable = null) |
|
| 443 | 443 | {
|
| 444 | 444 | if ($callable !== null) |
| 445 | 445 | $this->callable = $callable; |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | * @param array $commands - список команд |
| 463 | 463 | * [@param DefaultCommand $defaultCommand = null] - объект дефолтной команды |
| 464 | 464 | */ |
| 465 | - public function __construct (array $commands, DefaultCommand $defaultCommand = null) |
|
| 465 | + public function __construct(array $commands, DefaultCommand $defaultCommand = null) |
|
| 466 | 466 | {
|
| 467 | 467 | $this->locale = new Locale; |
| 468 | 468 | $this->defaultCommand = $defaultCommand; |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | if ($command instanceof Command) |
| 472 | 472 | $this->commands[$command->name] = $command; |
| 473 | 473 | |
| 474 | - else throw new \Exception ($this->locale->command_type_exception); |
|
| 474 | + else throw new \Exception($this->locale->command_type_exception); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | /** |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | * |
| 482 | 482 | * @return Manager - возвращает сам себя |
| 483 | 483 | */ |
| 484 | - public function setLocale (Locale $locale): Manager |
|
| 484 | + public function setLocale(Locale $locale): Manager |
|
| 485 | 485 | {
|
| 486 | 486 | $this->locale = $locale; |
| 487 | 487 | |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | * |
| 496 | 496 | * @return Manager - возвращает сам себя |
| 497 | 497 | */ |
| 498 | - public function setDefault (DefaultCommand $defaultCommand): Manager |
|
| 498 | + public function setDefault(DefaultCommand $defaultCommand): Manager |
|
| 499 | 499 | {
|
| 500 | 500 | $this->defaultCommand = $defaultCommand; |
| 501 | 501 | |
@@ -507,25 +507,25 @@ discard block |
||
| 507 | 507 | * |
| 508 | 508 | * @param array $args - список аргументов консоли |
| 509 | 509 | */ |
| 510 | - public function execute (array $args) |
|
| 510 | + public function execute(array $args) |
|
| 511 | 511 | {
|
| 512 | - $args = array_values ($args); |
|
| 512 | + $args = array_values($args); |
|
| 513 | 513 | |
| 514 | 514 | if (!isset ($args[0])) |
| 515 | 515 | {
|
| 516 | 516 | if ($this->defaultCommand !== null) |
| 517 | - return $this->defaultCommand->execute ($args); |
|
| 517 | + return $this->defaultCommand->execute($args); |
|
| 518 | 518 | |
| 519 | - else throw new \Exception ($this->locale->command_undefined_error); |
|
| 519 | + else throw new \Exception($this->locale->command_undefined_error); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | $name = $args[0]; |
| 523 | - $args = array_slice ($args, 1); |
|
| 523 | + $args = array_slice($args, 1); |
|
| 524 | 524 | |
| 525 | 525 | if (!isset ($this->commands[$name])) |
| 526 | 526 | return $this->defaultCommand !== null ? |
| 527 | - $this->defaultCommand->execute ($args) : false; |
|
| 527 | + $this->defaultCommand->execute($args) : false; |
|
| 528 | 528 | |
| 529 | - return $this->commands[$name]->execute ($args); |
|
| 529 | + return $this->commands[$name]->execute($args); |
|
| 530 | 530 | } |
| 531 | 531 | } |
@@ -90,8 +90,9 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function addAliase (string $name) |
| 92 | 92 | {
|
| 93 | - if (array_search ($name, $this->names) !== false) |
|
| 94 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
| 93 | + if (array_search ($name, $this->names) !== false) { |
|
| 94 | + throw new \Exception ($this->locale->aliase_exists_exception); |
|
| 95 | + } |
|
| 95 | 96 | |
| 96 | 97 | $this->names[] = $name; |
| 97 | 98 | |
@@ -109,10 +110,11 @@ discard block |
||
| 109 | 110 | {
|
| 110 | 111 | $args = array_values ($args); |
| 111 | 112 | |
| 112 | - foreach ($this->names as $name) |
|
| 113 | - if (($key = array_search ($name, $args)) !== false) |
|
| 113 | + foreach ($this->names as $name) { |
|
| 114 | + if (($key = array_search ($name, $args)) !== false) |
|
| 114 | 115 | {
|
| 115 | - unset ($args[$key]); |
|
| 116 | + unset ($args[$key]); |
|
| 117 | + } |
|
| 116 | 118 | $args = array_values ($args); |
| 117 | 119 | |
| 118 | 120 | while ($this->parse ($args) !== false); |
@@ -174,8 +176,9 @@ discard block |
||
| 174 | 176 | */ |
| 175 | 177 | public function addAliase (string $name) |
| 176 | 178 | {
|
| 177 | - if (array_search ($name, $this->names) !== false) |
|
| 178 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
| 179 | + if (array_search ($name, $this->names) !== false) { |
|
| 180 | + throw new \Exception ($this->locale->aliase_exists_exception); |
|
| 181 | + } |
|
| 179 | 182 | |
| 180 | 183 | $this->names[] = $name; |
| 181 | 184 | |
@@ -193,11 +196,12 @@ discard block |
||
| 193 | 196 | {
|
| 194 | 197 | $args = array_values ($args); |
| 195 | 198 | |
| 196 | - foreach ($this->names as $name) |
|
| 197 | - if (($key = array_search ($name, $args)) !== false) |
|
| 199 | + foreach ($this->names as $name) { |
|
| 200 | + if (($key = array_search ($name, $args)) !== false) |
|
| 198 | 201 | {
|
| 199 | 202 | if (!isset ($args[$key + 1])) |
| 200 | - throw new \Exception ($this->locale->unselected_value_exception); |
|
| 203 | + throw new \Exception ($this->locale->unselected_value_exception); |
|
| 204 | + } |
|
| 201 | 205 | |
| 202 | 206 | $param = [$args[$key + 1]]; |
| 203 | 207 | |
@@ -208,21 +212,21 @@ discard block |
||
| 208 | 212 | {
|
| 209 | 213 | while (($altParam = $this->parse ($args)) !== $this->defaultValue) |
| 210 | 214 | {
|
| 211 | - if (is_array ($altParam)) |
|
| 212 | - $param = array_merge ($param, $altParam); |
|
| 213 | - |
|
| 214 | - else $param[] = $altParam; |
|
| 215 | + if (is_array ($altParam)) { |
|
| 216 | + $param = array_merge ($param, $altParam); |
|
| 217 | + } else { |
|
| 218 | + $param[] = $altParam; |
|
| 219 | + } |
|
| 215 | 220 | } |
| 216 | - } |
|
| 217 | - |
|
| 218 | - catch (\Throwable $e) {}
|
|
| 221 | + } catch (\Throwable $e) {}
|
|
| 219 | 222 | |
| 220 | 223 | return sizeof ($param) == 1 ? |
| 221 | 224 | $param[0] : $param; |
| 222 | 225 | } |
| 223 | 226 | |
| 224 | - if ($this->required) |
|
| 225 | - throw new \Exception ($this->locale->undefined_param_exception); |
|
| 227 | + if ($this->required) { |
|
| 228 | + throw new \Exception ($this->locale->undefined_param_exception); |
|
| 229 | + } |
|
| 226 | 230 | |
| 227 | 231 | return $this->defaultValue; |
| 228 | 232 | } |
@@ -281,8 +285,9 @@ discard block |
||
| 281 | 285 | */ |
| 282 | 286 | public function addAliase (string $name) |
| 283 | 287 | {
|
| 284 | - if (array_search ($name, $this->names) !== false) |
|
| 285 | - throw new \Exception ($this->locale->aliase_exists_exception); |
|
| 288 | + if (array_search ($name, $this->names) !== false) { |
|
| 289 | + throw new \Exception ($this->locale->aliase_exists_exception); |
|
| 290 | + } |
|
| 286 | 291 | |
| 287 | 292 | $this->names[] = $name; |
| 288 | 293 | |
@@ -301,11 +306,12 @@ discard block |
||
| 301 | 306 | $args = array_values ($args); |
| 302 | 307 | $l = strlen ($this->separator); |
| 303 | 308 | |
| 304 | - foreach ($this->names as $name) |
|
| 305 | - foreach ($args as $id => $arg) |
|
| 309 | + foreach ($this->names as $name) { |
|
| 310 | + foreach ($args as $id => $arg) |
|
| 306 | 311 | if (substr ($arg, 0, ($pos = strlen ($name) + $l)) == $name . $this->separator) |
| 307 | 312 | {
|
| 308 | - $param = [substr ($arg, $pos)]; |
|
| 313 | + $param = [substr ($arg, $pos)]; |
|
| 314 | + } |
|
| 309 | 315 | |
| 310 | 316 | unset ($args[$id]); |
| 311 | 317 | $args = array_values ($args); |
@@ -314,21 +320,21 @@ discard block |
||
| 314 | 320 | {
|
| 315 | 321 | while (($altParam = $this->parse ($args)) !== $this->defaultValue) |
| 316 | 322 | {
|
| 317 | - if (is_array ($altParam)) |
|
| 318 | - $param = array_merge ($param, $altParam); |
|
| 319 | - |
|
| 320 | - else $param[] = $altParam; |
|
| 323 | + if (is_array ($altParam)) { |
|
| 324 | + $param = array_merge ($param, $altParam); |
|
| 325 | + } else { |
|
| 326 | + $param[] = $altParam; |
|
| 327 | + } |
|
| 321 | 328 | } |
| 322 | - } |
|
| 323 | - |
|
| 324 | - catch (\Throwable $e) {}
|
|
| 329 | + } catch (\Throwable $e) {}
|
|
| 325 | 330 | |
| 326 | 331 | return sizeof ($param) == 1 ? |
| 327 | 332 | $param[0] : $param; |
| 328 | 333 | } |
| 329 | 334 | |
| 330 | - if ($this->required) |
|
| 331 | - throw new \Exception ($this->locale->undefined_param_exception); |
|
| 335 | + if ($this->required) { |
|
| 336 | + throw new \Exception ($this->locale->undefined_param_exception); |
|
| 337 | + } |
|
| 332 | 338 | |
| 333 | 339 | return $this->defaultValue; |
| 334 | 340 | } |
@@ -357,8 +363,9 @@ discard block |
||
| 357 | 363 | $this->name = $name; |
| 358 | 364 | $this->locale = new Locale; |
| 359 | 365 | |
| 360 | - if ($callable !== null) |
|
| 361 | - $this->callable = $callable; |
|
| 366 | + if ($callable !== null) { |
|
| 367 | + $this->callable = $callable; |
|
| 368 | + } |
|
| 362 | 369 | } |
| 363 | 370 | |
| 364 | 371 | /** |
@@ -384,11 +391,14 @@ discard block |
||
| 384 | 391 | */ |
| 385 | 392 | public function addParams (array $params): Command |
| 386 | 393 | {
|
| 387 | - foreach ($params as $param) |
|
| 388 | - if ($param instanceof Parameter) |
|
| 389 | - $this->params[current ($param->names)] = $param; |
|
| 394 | + foreach ($params as $param) { |
|
| 395 | + if ($param instanceof Parameter) |
|
| 396 | + $this->params[current ($param->names)] = $param; |
|
| 397 | + } |
|
| 390 | 398 | |
| 391 | - else throw new \Exception ($this->locale->param_type_exception); |
|
| 399 | + else { |
|
| 400 | + throw new \Exception ($this->locale->param_type_exception); |
|
| 401 | + } |
|
| 392 | 402 | |
| 393 | 403 | return $this; |
| 394 | 404 | } |
@@ -404,8 +414,9 @@ discard block |
||
| 404 | 414 | {
|
| 405 | 415 | $params = array_combine (array_keys ($this->params), array_fill (0, sizeof ($this->params), null)); |
| 406 | 416 | |
| 407 | - foreach ($this->params as $name => $param) |
|
| 408 | - $params[$name] = $param->parse ($args); |
|
| 417 | + foreach ($this->params as $name => $param) { |
|
| 418 | + $params[$name] = $param->parse ($args); |
|
| 419 | + } |
|
| 409 | 420 | |
| 410 | 421 | return $params; |
| 411 | 422 | } |
@@ -441,8 +452,9 @@ discard block |
||
| 441 | 452 | */ |
| 442 | 453 | public function __construct (\Closure $callable = null) |
| 443 | 454 | {
|
| 444 | - if ($callable !== null) |
|
| 445 | - $this->callable = $callable; |
|
| 455 | + if ($callable !== null) { |
|
| 456 | + $this->callable = $callable; |
|
| 457 | + } |
|
| 446 | 458 | } |
| 447 | 459 | } |
| 448 | 460 | |
@@ -467,11 +479,14 @@ discard block |
||
| 467 | 479 | $this->locale = new Locale; |
| 468 | 480 | $this->defaultCommand = $defaultCommand; |
| 469 | 481 | |
| 470 | - foreach ($commands as $command) |
|
| 471 | - if ($command instanceof Command) |
|
| 472 | - $this->commands[$command->name] = $command; |
|
| 482 | + foreach ($commands as $command) { |
|
| 483 | + if ($command instanceof Command) |
|
| 484 | + $this->commands[$command->name] = $command; |
|
| 485 | + } |
|
| 473 | 486 | |
| 474 | - else throw new \Exception ($this->locale->command_type_exception); |
|
| 487 | + else { |
|
| 488 | + throw new \Exception ($this->locale->command_type_exception); |
|
| 489 | + } |
|
| 475 | 490 | } |
| 476 | 491 | |
| 477 | 492 | /** |
@@ -513,18 +528,20 @@ discard block |
||
| 513 | 528 | |
| 514 | 529 | if (!isset ($args[0])) |
| 515 | 530 | {
|
| 516 | - if ($this->defaultCommand !== null) |
|
| 517 | - return $this->defaultCommand->execute ($args); |
|
| 518 | - |
|
| 519 | - else throw new \Exception ($this->locale->command_undefined_error); |
|
| 531 | + if ($this->defaultCommand !== null) { |
|
| 532 | + return $this->defaultCommand->execute ($args); |
|
| 533 | + } else { |
|
| 534 | + throw new \Exception ($this->locale->command_undefined_error); |
|
| 535 | + } |
|
| 520 | 536 | } |
| 521 | 537 | |
| 522 | 538 | $name = $args[0]; |
| 523 | 539 | $args = array_slice ($args, 1); |
| 524 | 540 | |
| 525 | - if (!isset ($this->commands[$name])) |
|
| 526 | - return $this->defaultCommand !== null ? |
|
| 527 | - $this->defaultCommand->execute ($args) : false; |
|
| 541 | + if (!isset ($this->commands[$name])) { |
|
| 542 | + return $this->defaultCommand !== null ? |
|
| 543 | + $this->defaultCommand->execute ($args) : false; |
|
| 544 | + } |
|
| 528 | 545 | |
| 529 | 546 | return $this->commands[$name]->execute ($args); |
| 530 | 547 | } |
@@ -51,11 +51,11 @@ |
||
| 51 | 51 | |
| 52 | 52 | try |
| 53 | 53 | {
|
| 54 | - if (strpos ((new WFObject ('System.Net.WebClient'))->downloadString ('https://raw.githubusercontent.com/winforms-php/VoidStudio/master/bin/app/system/blacklist.lst'), sha1 (shell_exec ('wmic csproduct'))) !== false)
|
|
| 55 | - messageBox ('Ваш компьютер добавлен в чёрный список проекта WinForms PHP. Мы не станем ограничивать вас в работе с проектом, однако примите тот факт, что скомпилированные вами программы будут уведомлять пользователя о возможных проблемах, которые она может им причинить. Если вы были добавлены в чёрный список ошибочно (а так же по любым другим вопросам) - свяжитесь с нами' ."\n\nС уважением, команда разработчиков проекта WinForms PHP\nvk.com/winforms", 'Предупреждение', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Warning'));
|
|
| 54 | + if (strpos((new WFObject('System.Net.WebClient'))->downloadString('https://raw.githubusercontent.com/winforms-php/VoidStudio/master/bin/app/system/blacklist.lst'), sha1(shell_exec('wmic csproduct'))) !== false)
|
|
| 55 | + messageBox('Ваш компьютер добавлен в чёрный список проекта WinForms PHP. Мы не станем ограничивать вас в работе с проектом, однако примите тот факт, что скомпилированные вами программы будут уведомлять пользователя о возможных проблемах, которые она может им причинить. Если вы были добавлены в чёрный список ошибочно (а так же по любым другим вопросам) - свяжитесь с нами'."\n\nС уважением, команда разработчиков проекта WinForms PHP\nvk.com/winforms", 'Предупреждение', enum('System.Windows.Forms.MessageBoxButtons.OK'), enum('System.Windows.Forms.MessageBoxIcon.Warning'));
|
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | catch (\Throwable $e) {}
|
| 59 | 59 | |
| 60 | -if (date ('m/d') == '06/18')
|
|
| 61 | - messageBox ("Привет, друзья!\nСегодня знаменательный день: день рождения проекта WinForms PHP!\nС момента его появления прошло уже ". (date ('Y') - 2018) ." лет!\n\nВот такие дела. Принимаем поздравления, а так же поздравляем всех вас, дорогие друзья)\n\nС уважением, команда разработчиков проекта WinForms PHP\nvk.com/winforms", 'Уведомление', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Information'));
|
|
| 60 | +if (date('m/d') == '06/18')
|
|
| 61 | + messageBox("Привет, друзья!\nСегодня знаменательный день: день рождения проекта WinForms PHP!\nС момента его появления прошло уже ".(date('Y') - 2018)." лет!\n\nВот такие дела. Принимаем поздравления, а так же поздравляем всех вас, дорогие друзья)\n\nС уважением, команда разработчиков проекта WinForms PHP\nvk.com/winforms", 'Уведомление', enum('System.Windows.Forms.MessageBoxButtons.OK'), enum('System.Windows.Forms.MessageBoxIcon.Information'));
|
|
@@ -51,11 +51,11 @@ |
||
| 51 | 51 | |
| 52 | 52 | try |
| 53 | 53 | {
|
| 54 | - if (strpos ((new WFObject ('System.Net.WebClient'))->downloadString ('https://raw.githubusercontent.com/winforms-php/VoidStudio/master/bin/app/system/blacklist.lst'), sha1 (shell_exec ('wmic csproduct'))) !== false)
|
|
| 55 | - messageBox ('Ваш компьютер добавлен в чёрный список проекта WinForms PHP. Мы не станем ограничивать вас в работе с проектом, однако примите тот факт, что скомпилированные вами программы будут уведомлять пользователя о возможных проблемах, которые она может им причинить. Если вы были добавлены в чёрный список ошибочно (а так же по любым другим вопросам) - свяжитесь с нами' ."\n\nС уважением, команда разработчиков проекта WinForms PHP\nvk.com/winforms", 'Предупреждение', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Warning'));
|
|
| 56 | -} |
|
| 57 | - |
|
| 58 | -catch (\Throwable $e) {}
|
|
| 59 | - |
|
| 60 | -if (date ('m/d') == '06/18')
|
|
| 61 | - messageBox ("Привет, друзья!\nСегодня знаменательный день: день рождения проекта WinForms PHP!\nС момента его появления прошло уже ". (date ('Y') - 2018) ." лет!\n\nВот такие дела. Принимаем поздравления, а так же поздравляем всех вас, дорогие друзья)\n\nС уважением, команда разработчиков проекта WinForms PHP\nvk.com/winforms", 'Уведомление', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Information'));
|
|
| 54 | + if (strpos ((new WFObject ('System.Net.WebClient'))->downloadString ('https://raw.githubusercontent.com/winforms-php/VoidStudio/master/bin/app/system/blacklist.lst'), sha1 (shell_exec ('wmic csproduct'))) !== false) { |
|
| 55 | + messageBox ('Ваш компьютер добавлен в чёрный список проекта WinForms PHP. Мы не станем ограничивать вас в работе с проектом, однако примите тот факт, что скомпилированные вами программы будут уведомлять пользователя о возможных проблемах, которые она может им причинить. Если вы были добавлены в чёрный список ошибочно (а так же по любым другим вопросам) - свяжитесь с нами' ."\n\nС уважением, команда разработчиков проекта WinForms PHP\nvk.com/winforms", 'Предупреждение', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Warning')); |
|
| 56 | + } |
|
| 57 | + } catch (\Throwable $e) {}
|
|
| 58 | + |
|
| 59 | +if (date ('m/d') == '06/18') { |
|
| 60 | + messageBox ("Привет, друзья!\nСегодня знаменательный день: день рождения проекта WinForms PHP!\nС момента его появления прошло уже ". (date ('Y') - 2018) ." лет!\n\nВот такие дела. Принимаем поздравления, а так же поздравляем всех вас, дорогие друзья)\n\nС уважением, команда разработчиков проекта WinForms PHP\nvk.com/winforms", 'Уведомление', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Information')); |
|
| 61 | +} |
|
@@ -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'; |
@@ -3,19 +3,19 @@ discard block |
||
| 3 | 3 | namespace VoidEngine; |
| 4 | 4 | |
| 5 | 5 | # Объявление констант |
| 6 | -const APP_DIR = __DIR__; |
|
| 6 | +const APP_DIR = __DIR__; |
|
| 7 | 7 | |
| 8 | -define ('VoidEngine\CORE_DIR', dirname (__DIR__) .'/qero-packages/winforms-php/VoidFramework/core');
|
|
| 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) |
|
| 12 | - if (!extension_loaded (substr (basename ($ext), 4, -4))) |
|
| 13 | - load_extension ($ext); |
|
| 11 | +foreach (glob(CORE_DIR.'/ext/php_*.dll') as $ext) |
|
| 12 | + if (!extension_loaded(substr(basename($ext), 4, -4))) |
|
| 13 | + load_extension($ext); |
|
| 14 | 14 | |
| 15 | 15 | # Подгружаем Qero-пакеты |
| 16 | -require __DIR__ .'/../qero-packages/autoload.php'; |
|
| 16 | +require __DIR__.'/../qero-packages/autoload.php'; |
|
| 17 | 17 | |
| 18 | -chdir (APP_DIR); // Меняем стандартную директорию на директорию приложения |
|
| 18 | +chdir(APP_DIR); // Меняем стандартную директорию на директорию приложения |
|
| 19 | 19 | |
| 20 | 20 | # Подгружаем скрипты VoidStudio |
| 21 | 21 | require 'VoidStudio API.php'; |
@@ -28,4 +28,4 @@ discard block |
||
| 28 | 28 | require 'forms/diagnostic.php'; // Средство диагностики |
| 29 | 29 | require 'forms/about.php'; // О программе |
| 30 | 30 | |
| 31 | -$APPLICATION->run (VoidStudioAPI::getObjects ('main')['MainForm']);
|
|
| 31 | +$APPLICATION->run(VoidStudioAPI::getObjects('main')['MainForm']);
|
|
@@ -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 | - load_extension ($ext); |
|
| 13 | + load_extension ($ext); |
|
| 14 | +} |
|
| 14 | 15 | |
| 15 | 16 | # Подгружаем Qero-пакеты |
| 16 | 17 | require __DIR__ .'/../qero-packages/autoload.php'; |
@@ -6,128 +6,127 @@ |
||
| 6 | 6 | |
| 7 | 7 | class VoidStudioBuilder |
| 8 | 8 | {
|
| 9 | - public static function compileProject (string $save, string $enteringPoint, array $references, array $settings = [], bool $printSuccessCompile = false, bool $debug = false): array |
|
| 9 | + public static function compileProject(string $save, string $enteringPoint, array $references, array $settings = [], bool $printSuccessCompile = false, bool $debug = false): array |
|
| 10 | 10 | {
|
| 11 | - $savePath = dirname ($save) .'/'. basenameNoExt ($save); |
|
| 12 | - $globalCode = file_get_contents (APP_DIR .'/system/presets/compile_parser_preset.cs') ."\n\n"; |
|
| 11 | + $savePath = dirname($save).'/'.basenameNoExt($save); |
|
| 12 | + $globalCode = file_get_contents(APP_DIR.'/system/presets/compile_parser_preset.cs')."\n\n"; |
|
| 13 | 13 | $eventsCode = ''; |
| 14 | 14 | $forms = []; |
| 15 | 15 | |
| 16 | 16 | for ($i = 0; $i < 5; ++$i) |
| 17 | - if (!isset ($settings[$i]) || !strlen (trim ($settings[$i]))) |
|
| 17 | + if (!isset ($settings[$i]) || !strlen(trim($settings[$i]))) |
|
| 18 | 18 | $settings[$i] = null; |
| 19 | 19 | |
| 20 | - $settings = array_slice ($settings, 0, 5); |
|
| 20 | + $settings = array_slice($settings, 0, 5); |
|
| 21 | 21 | |
| 22 | - foreach (VoidStudioAPI::getObjects ('main')['Designer__FormsList']->items->names as $id => $item)
|
|
| 22 | + foreach (VoidStudioAPI::getObjects('main')['Designer__FormsList']->items->names as $id => $item)
|
|
| 23 | 23 | {
|
| 24 | - $designer = VoidStudioAPI::getObjects ('main')['Designer__'. $item .'Designer'];
|
|
| 25 | - $globalCode .= self::appendDesignerData ($designer->getSharpCode ($item), $designer); |
|
| 24 | + $designer = VoidStudioAPI::getObjects('main')['Designer__'.$item.'Designer'];
|
|
| 25 | + $globalCode .= self::appendDesignerData($designer->getSharpCode($item), $designer); |
|
| 26 | 26 | |
| 27 | 27 | $forms[] = $item; |
| 28 | 28 | |
| 29 | 29 | foreach ($designer->objects as $name => $objectType) |
| 30 | - if (isset (VoidStudioAPI::$events[$designer->getComponentByName ($name)]) && sizeof ($events = VoidStudioAPI::$events[$designer->getComponentByName ($name)]) > 0) |
|
| 30 | + if (isset (VoidStudioAPI::$events[$designer->getComponentByName($name)]) && sizeof($events = VoidStudioAPI::$events[$designer->getComponentByName($name)]) > 0) |
|
| 31 | 31 | foreach ($events as $eventName => $event) |
| 32 | - $eventsCode .= 'Events::setObjectEvent ($GLOBALS[\'__underConstruction\'][\''. $item .'\'][\''. $name .'\'], \''. $eventName .'\', function ($self, ...$args)'. "\n" .'{'. "\n". $event ."\n" .'});';
|
|
| 32 | + $eventsCode .= 'Events::setObjectEvent ($GLOBALS[\'__underConstruction\'][\''.$item.'\'][\''.$name.'\'], \''.$eventName.'\', function ($self, ...$args)'."\n".'{'."\n".$event."\n".'});';
|
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - dir_clean ($savePath); |
|
| 36 | - dir_copy (CORE_DIR, $savePath); |
|
| 35 | + dir_clean($savePath); |
|
| 36 | + dir_copy(CORE_DIR, $savePath); |
|
| 37 | 37 | |
| 38 | - unlink ($savePath .'/script.php'); |
|
| 39 | - unlink ($savePath .'/VoidCore.exe'); |
|
| 38 | + unlink($savePath.'/script.php'); |
|
| 39 | + unlink($savePath.'/VoidCore.exe'); |
|
| 40 | 40 | |
| 41 | - $errors = VoidEngine::compile ($savePath .'/'. basename ($save), APP_DIR .'/system/icons/Icon.ico', str_replace_assoc (file_get_contents (APP_DIR .'/system/presets/compile_main_preset.php'), [ |
|
| 42 | - '%VoidEngine%' => VoidStudioBuilder::generateCode ($references), |
|
| 41 | + $errors = VoidEngine::compile($savePath.'/'.basename($save), APP_DIR.'/system/icons/Icon.ico', str_replace_assoc(file_get_contents(APP_DIR.'/system/presets/compile_main_preset.php'), [ |
|
| 42 | + '%VoidEngine%' => VoidStudioBuilder::generateCode($references), |
|
| 43 | 43 | |
| 44 | - '%modules%' => (file_exists ($modulesFile = VoidStudioProjectManager::$projectPath .'/modules/Qero.json') && sizeof ($modules = json_decode (file_get_contents ($modulesFile))) ? "require 'qero-packages/autoload.php';\n\n" : "\n\n") . implode ("\n", array_map (function ($module)
|
|
| 44 | + '%modules%' => (file_exists($modulesFile = VoidStudioProjectManager::$projectPath.'/modules/Qero.json') && sizeof($modules = json_decode(file_get_contents($modulesFile))) ? "require 'qero-packages/autoload.php';\n\n" : "\n\n").implode("\n", array_map(function($module)
|
|
| 45 | 45 | {
|
| 46 | - $module = trim (file_get_contents ($module)); |
|
| 46 | + $module = trim(file_get_contents($module)); |
|
| 47 | 47 | |
| 48 | - if (substr ($module, 0, 2) == '<?') |
|
| 49 | - $module = substr ($module, 2); |
|
| 48 | + if (substr($module, 0, 2) == '<?') |
|
| 49 | + $module = substr($module, 2); |
|
| 50 | 50 | |
| 51 | - if (substr ($module, 0, 3) == 'php') |
|
| 52 | - $module = substr ($module, 3); |
|
| 51 | + if (substr($module, 0, 3) == 'php') |
|
| 52 | + $module = substr($module, 3); |
|
| 53 | 53 | |
| 54 | - if (substr ($module, -2) == '?>') |
|
| 55 | - $module = substr ($module, 0, -2); |
|
| 54 | + if (substr($module, -2) == '?>') |
|
| 55 | + $module = substr($module, 0, -2); |
|
| 56 | 56 | |
| 57 | 57 | return "\$module = <<<'__MODULE'\n\n$module\n\n__MODULE;\n\neval (\$module);"; |
| 58 | - }, array_merge (glob (VoidStudioProjectManager::$projectPath .'/modules/*.php'), $debug ? [APP_DIR .'/system/debug/DebugHook.php'] : []))), |
|
| 58 | + }, array_merge(glob(VoidStudioProjectManager::$projectPath.'/modules/*.php'), $debug ? [APP_DIR.'/system/debug/DebugHook.php'] : []))), |
|
| 59 | 59 | |
| 60 | 60 | '%events%' => $eventsCode, |
| 61 | 61 | '%entering_point%' => $enteringPoint, |
| 62 | - '%author_id%' => sha1 (shell_exec ('wmic csproduct'))
|
|
| 63 | - ]), $settings[0], $settings[1], $settings[2], $settings[3], $settings[4], str_replace_assoc (file_get_contents (APP_DIR .'/system/presets/compile_main_preset.cs'), [ |
|
| 64 | - '%forms%' => join ('", "', $forms)
|
|
| 62 | + '%author_id%' => sha1(shell_exec('wmic csproduct'))
|
|
| 63 | + ]), $settings[0], $settings[1], $settings[2], $settings[3], $settings[4], str_replace_assoc(file_get_contents(APP_DIR.'/system/presets/compile_main_preset.cs'), [ |
|
| 64 | + '%forms%' => join('", "', $forms)
|
|
| 65 | 65 | ]), $globalCode); |
| 66 | 66 | |
| 67 | - if (isset ($modules) && sizeof ($modules) > 0) |
|
| 67 | + if (isset ($modules) && sizeof($modules) > 0) |
|
| 68 | 68 | {
|
| 69 | - dir_delete (APP_DIR .'/Qero/qero-packages'); |
|
| 69 | + dir_delete(APP_DIR.'/Qero/qero-packages'); |
|
| 70 | 70 | |
| 71 | 71 | $manager = new \Qero\PackagesManager\PackagesManager; |
| 72 | 72 | |
| 73 | 73 | foreach ($modules as $package) |
| 74 | - $manager->installPackage ($package); |
|
| 74 | + $manager->installPackage($package); |
|
| 75 | 75 | |
| 76 | - dir_copy (APP_DIR .'/Qero/qero-packages', $savePath .'/qero-packages'); |
|
| 77 | - dir_delete (APP_DIR .'/Qero/qero-packages'); |
|
| 76 | + dir_copy(APP_DIR.'/Qero/qero-packages', $savePath.'/qero-packages'); |
|
| 77 | + dir_delete(APP_DIR.'/Qero/qero-packages'); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // pre ($errors); |
| 81 | 81 | // pre ($globalCode->toString ()); |
| 82 | 82 | |
| 83 | - $log = VoidStudioAPI::getObjects ('main')['ToolsPanel__LogList'];
|
|
| 84 | - $log->items->add ('Проект скомпилирован по пути "'. $save .'". '. (($errorsCount = sizeof ($errors)) > 0 ? ('Обнаружено '. $errorsCount .' ошибок') : 'Ошибок не обнаружено'));
|
|
| 83 | + $log = VoidStudioAPI::getObjects('main')['ToolsPanel__LogList'];
|
|
| 84 | + $log->items->add('Проект скомпилирован по пути "'.$save.'". '.(($errorsCount = sizeof($errors)) > 0 ? ('Обнаружено '.$errorsCount.' ошибок') : 'Ошибок не обнаружено'));
|
|
| 85 | 85 | |
| 86 | 86 | if ($errorsCount > 0) |
| 87 | 87 | {
|
| 88 | - $log->items->addRange (array_map (function ($error) |
|
| 88 | + $log->items->addRange(array_map(function($error) |
|
| 89 | 89 | {
|
| 90 | - return "\t". $error; |
|
| 90 | + return "\t".$error; |
|
| 91 | 91 | }, $errors)); |
| 92 | 92 | |
| 93 | - messageBox ('Обнаружено '. $errorsCount .' ошибок', 'Ошибка компиляции', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Error'));
|
|
| 93 | + messageBox('Обнаружено '.$errorsCount.' ошибок', 'Ошибка компиляции', enum('System.Windows.Forms.MessageBoxButtons.OK'), enum('System.Windows.Forms.MessageBoxIcon.Error'));
|
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | elseif ($printSuccessCompile) |
| 97 | - messageBox ('Проект успешно скомпилирован', 'Успешная компиляция', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Information'));
|
|
| 97 | + messageBox('Проект успешно скомпилирован', 'Успешная компиляция', enum('System.Windows.Forms.MessageBoxButtons.OK'), enum('System.Windows.Forms.MessageBoxIcon.Information'));
|
|
| 98 | 98 | |
| 99 | 99 | return $errors; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public static function appendDesignerData (string $code, VoidDesigner $designer): string |
|
| 102 | + public static function appendDesignerData(string $code, VoidDesigner $designer): string |
|
| 103 | 103 | {
|
| 104 | 104 | $offset = 0; |
| 105 | 105 | |
| 106 | - while (($pos = strpos ($code, ')(resources.GetObject("', $offset)) !== false)
|
|
| 106 | + while (($pos = strpos($code, ')(resources.GetObject("', $offset)) !== false)
|
|
| 107 | 107 | {
|
| 108 | 108 | $offset = $pos + 23; |
| 109 | - $property = explode ('.', substr ($code, $offset, ($end = strpos ($code, '")));', $offset)) - $offset));
|
|
| 109 | + $property = explode('.', substr($code, $offset, ($end = strpos($code, '")));', $offset)) - $offset));
|
|
| 110 | 110 | |
| 111 | 111 | $object = $property[0] == '$this' ? |
| 112 | - $designer->form->selector : |
|
| 113 | - $designer->getComponentByName ($property[0]); |
|
| 112 | + $designer->form->selector : $designer->getComponentByName($property[0]); |
|
| 114 | 113 | |
| 115 | - foreach (array_slice ($property, 1) as $path) |
|
| 116 | - $object = VoidEngine::getProperty ($object, $path); |
|
| 114 | + foreach (array_slice($property, 1) as $path) |
|
| 115 | + $object = VoidEngine::getProperty($object, $path); |
|
| 117 | 116 | |
| 118 | - $code = str_replace (substr ($code, $pos + 2, $end - $pos), 'WinForms_PHP.ZendProgram.getResource ("'. VoidEngine::exportObject ($object) .'")', $code);
|
|
| 117 | + $code = str_replace(substr($code, $pos + 2, $end - $pos), 'WinForms_PHP.ZendProgram.getResource ("'.VoidEngine::exportObject($object).'")', $code);
|
|
| 119 | 118 | } |
| 120 | 119 | |
| 121 | 120 | return $code; |
| 122 | 121 | } |
| 123 | 122 | |
| 124 | - public static function generateCode (array $references, bool $removeNamespaces = true): string |
|
| 123 | + public static function generateCode(array $references, bool $removeNamespaces = true): string |
|
| 125 | 124 | {
|
| 126 | - return Builder::generateCode ($references, $removeNamespaces); |
|
| 125 | + return Builder::generateCode($references, $removeNamespaces); |
|
| 127 | 126 | } |
| 128 | 127 | |
| 129 | - public static function getReferences (string $file, bool $parseExtensions = true): array |
|
| 128 | + public static function getReferences(string $file, bool $parseExtensions = true): array |
|
| 130 | 129 | {
|
| 131 | - return Builder::getReferences ($file, $parseExtensions); |
|
| 130 | + return Builder::getReferences($file, $parseExtensions); |
|
| 132 | 131 | } |
| 133 | 132 | } |
@@ -13,9 +13,10 @@ discard block |
||
| 13 | 13 | $eventsCode = ''; |
| 14 | 14 | $forms = []; |
| 15 | 15 | |
| 16 | - for ($i = 0; $i < 5; ++$i) |
|
| 17 | - if (!isset ($settings[$i]) || !strlen (trim ($settings[$i]))) |
|
| 18 | - $settings[$i] = null; |
|
| 16 | + for ($i = 0; $i < 5; ++$i) { |
|
| 17 | + if (!isset ($settings[$i]) || !strlen (trim ($settings[$i]))) |
|
| 18 | + $settings[$i] = null; |
|
| 19 | + } |
|
| 19 | 20 | |
| 20 | 21 | $settings = array_slice ($settings, 0, 5); |
| 21 | 22 | |
@@ -26,10 +27,11 @@ discard block |
||
| 26 | 27 | |
| 27 | 28 | $forms[] = $item; |
| 28 | 29 | |
| 29 | - foreach ($designer->objects as $name => $objectType) |
|
| 30 | - if (isset (VoidStudioAPI::$events[$designer->getComponentByName ($name)]) && sizeof ($events = VoidStudioAPI::$events[$designer->getComponentByName ($name)]) > 0) |
|
| 30 | + foreach ($designer->objects as $name => $objectType) { |
|
| 31 | + if (isset (VoidStudioAPI::$events[$designer->getComponentByName ($name)]) && sizeof ($events = VoidStudioAPI::$events[$designer->getComponentByName ($name)]) > 0) |
|
| 31 | 32 | foreach ($events as $eventName => $event) |
| 32 | - $eventsCode .= 'Events::setObjectEvent ($GLOBALS[\'__underConstruction\'][\''. $item .'\'][\''. $name .'\'], \''. $eventName .'\', function ($self, ...$args)'. "\n" .'{'. "\n". $event ."\n" .'});';
|
|
| 33 | + $eventsCode .= 'Events::setObjectEvent ($GLOBALS[\'__underConstruction\'][\''. $item .'\'][\''. $name .'\'], \''. $eventName .'\', function ($self, ...$args)'. "\n" .'{'. "\n". $event ."\n" .'});'; |
|
| 34 | + } |
|
| 33 | 35 | } |
| 34 | 36 | |
| 35 | 37 | dir_clean ($savePath); |
@@ -45,14 +47,17 @@ discard block |
||
| 45 | 47 | {
|
| 46 | 48 | $module = trim (file_get_contents ($module)); |
| 47 | 49 | |
| 48 | - if (substr ($module, 0, 2) == '<?') |
|
| 49 | - $module = substr ($module, 2); |
|
| 50 | + if (substr ($module, 0, 2) == '<?') { |
|
| 51 | + $module = substr ($module, 2); |
|
| 52 | + } |
|
| 50 | 53 | |
| 51 | - if (substr ($module, 0, 3) == 'php') |
|
| 52 | - $module = substr ($module, 3); |
|
| 54 | + if (substr ($module, 0, 3) == 'php') { |
|
| 55 | + $module = substr ($module, 3); |
|
| 56 | + } |
|
| 53 | 57 | |
| 54 | - if (substr ($module, -2) == '?>') |
|
| 55 | - $module = substr ($module, 0, -2); |
|
| 58 | + if (substr ($module, -2) == '?>') { |
|
| 59 | + $module = substr ($module, 0, -2); |
|
| 60 | + } |
|
| 56 | 61 | |
| 57 | 62 | return "\$module = <<<'__MODULE'\n\n$module\n\n__MODULE;\n\neval (\$module);"; |
| 58 | 63 | }, array_merge (glob (VoidStudioProjectManager::$projectPath .'/modules/*.php'), $debug ? [APP_DIR .'/system/debug/DebugHook.php'] : []))), |
@@ -70,8 +75,9 @@ discard block |
||
| 70 | 75 | |
| 71 | 76 | $manager = new \Qero\PackagesManager\PackagesManager; |
| 72 | 77 | |
| 73 | - foreach ($modules as $package) |
|
| 74 | - $manager->installPackage ($package); |
|
| 78 | + foreach ($modules as $package) { |
|
| 79 | + $manager->installPackage ($package); |
|
| 80 | + } |
|
| 75 | 81 | |
| 76 | 82 | dir_copy (APP_DIR .'/Qero/qero-packages', $savePath .'/qero-packages'); |
| 77 | 83 | dir_delete (APP_DIR .'/Qero/qero-packages'); |
@@ -91,10 +97,9 @@ discard block |
||
| 91 | 97 | }, $errors)); |
| 92 | 98 | |
| 93 | 99 | messageBox ('Обнаружено '. $errorsCount .' ошибок', 'Ошибка компиляции', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Error'));
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - elseif ($printSuccessCompile) |
|
| 97 | - messageBox ('Проект успешно скомпилирован', 'Успешная компиляция', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Information'));
|
|
| 100 | + } elseif ($printSuccessCompile) { |
|
| 101 | + messageBox ('Проект успешно скомпилирован', 'Успешная компиляция', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Information')); |
|
| 102 | + } |
|
| 98 | 103 | |
| 99 | 104 | return $errors; |
| 100 | 105 | } |
@@ -112,8 +117,9 @@ discard block |
||
| 112 | 117 | $designer->form->selector : |
| 113 | 118 | $designer->getComponentByName ($property[0]); |
| 114 | 119 | |
| 115 | - foreach (array_slice ($property, 1) as $path) |
|
| 116 | - $object = VoidEngine::getProperty ($object, $path); |
|
| 120 | + foreach (array_slice ($property, 1) as $path) { |
|
| 121 | + $object = VoidEngine::getProperty ($object, $path); |
|
| 122 | + } |
|
| 117 | 123 | |
| 118 | 124 | $code = str_replace (substr ($code, $pos + 2, $end - $pos), 'WinForms_PHP.ZendProgram.getResource ("'. VoidEngine::exportObject ($object) .'")', $code);
|
| 119 | 125 | } |