@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -$name = basenameNoExt (__FILE__); |
|
5 | +$name = basenameNoExt(__FILE__); |
|
6 | 6 | |
7 | -$parser = new VLFParser (__DIR__. '/'. $name .'.vlf', [ |
|
7 | +$parser = new VLFParser(__DIR__.'/'.$name.'.vlf', [ |
|
8 | 8 | 'strong_line_parser' => false, |
9 | 9 | 'ignore_postobject_info' => true, |
10 | 10 | 'ignore_unexpected_method_args' => true, |
@@ -15,4 +15,4 @@ discard block |
||
15 | 15 | |
16 | 16 | // file_put_contents ('SyntaxTree__'. $name .'.json', json_encode ($parser->tree, JSON_PRETTY_PRINT)); |
17 | 17 | |
18 | -VoidStudioAPI::addObjects ($name, VLFInterpreter::run ($parser)); |
|
18 | +VoidStudioAPI::addObjects($name, VLFInterpreter::run($parser)); |
@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -$name = basenameNoExt (__FILE__); |
|
5 | +$name = basenameNoExt(__FILE__); |
|
6 | 6 | |
7 | -$parser = new VLFParser (__DIR__. '/'. $name .'.vlf', [ |
|
7 | +$parser = new VLFParser(__DIR__.'/'.$name.'.vlf', [ |
|
8 | 8 | 'strong_line_parser' => false, |
9 | 9 | 'ignore_postobject_info' => true, |
10 | 10 | 'ignore_unexpected_method_args' => true, |
@@ -15,4 +15,4 @@ discard block |
||
15 | 15 | |
16 | 16 | // file_put_contents ('SyntaxTree__'. $name .'.json', json_encode ($parser->tree, JSON_PRETTY_PRINT)); |
17 | 17 | |
18 | -VoidStudioAPI::addObjects ($name, VLFInterpreter::run ($parser)); |
|
18 | +VoidStudioAPI::addObjects($name, VLFInterpreter::run($parser)); |
@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace VoidEngine; |
4 | 4 | |
5 | -$name = basenameNoExt (__FILE__); |
|
5 | +$name = basenameNoExt(__FILE__); |
|
6 | 6 | |
7 | -$parser = new VLFParser (__DIR__. '/'. $name .'.vlf', [ |
|
7 | +$parser = new VLFParser(__DIR__.'/'.$name.'.vlf', [ |
|
8 | 8 | 'strong_line_parser' => false, |
9 | 9 | 'ignore_postobject_info' => true, |
10 | 10 | 'ignore_unexpected_method_args' => true, |
@@ -15,4 +15,4 @@ discard block |
||
15 | 15 | |
16 | 16 | // file_put_contents ('SyntaxTree__'. $name .'.json', json_encode ($parser->tree, JSON_PRETTY_PRINT)); |
17 | 17 | |
18 | -VoidStudioAPI::addObjects ($name, VLFInterpreter::run ($parser)); |
|
18 | +VoidStudioAPI::addObjects($name, VLFInterpreter::run($parser)); |
@@ -23,7 +23,7 @@ |
||
23 | 23 | |
24 | 24 | $required_packages = array |
25 | 25 | ( |
26 | - array ('github:winforms-php/VoidFramework', '3.5.2'), |
|
27 | - array ('github:KRypt0nn/ConsoleArgs', '1.5'), |
|
28 | - array ('github:winforms-php/VoidBuilder', '1.2') |
|
26 | + array ('github:winforms-php/VoidFramework', '3.5.2'), |
|
27 | + array ('github:KRypt0nn/ConsoleArgs', '1.5'), |
|
28 | + array ('github:winforms-php/VoidBuilder', '1.2') |
|
29 | 29 | ); |
@@ -10,20 +10,18 @@ |
||
10 | 10 | require 'winforms-php/VoidBuilder/VoidBuilder.php'; |
11 | 11 | |
12 | 12 | |
13 | -$classes = array |
|
14 | -( |
|
13 | +$classes = array( |
|
15 | 14 | |
16 | 15 | ); |
17 | 16 | |
18 | -spl_autoload_register (function ($class) use ($classes) |
|
17 | +spl_autoload_register(function($class) use ($classes) |
|
19 | 18 | { |
20 | 19 | if (isset ($classes[$class])) |
21 | - include __DIR__ .'/'. $classes[$class]; |
|
20 | + include __DIR__.'/'.$classes[$class]; |
|
22 | 21 | }); |
23 | 22 | |
24 | -$required_packages = array |
|
25 | -( |
|
26 | - array ('github:winforms-php/VoidFramework', '3.5.2'), |
|
27 | - array ('github:KRypt0nn/ConsoleArgs', '1.5'), |
|
28 | - array ('github:winforms-php/VoidBuilder', '1.2') |
|
23 | +$required_packages = array( |
|
24 | + array('github:winforms-php/VoidFramework', '3.5.2'), |
|
25 | + array('github:KRypt0nn/ConsoleArgs', '1.5'), |
|
26 | + array('github:winforms-php/VoidBuilder', '1.2') |
|
29 | 27 | ); |
@@ -17,9 +17,10 @@ |
||
17 | 17 | |
18 | 18 | spl_autoload_register (function ($class) use ($classes) |
19 | 19 | { |
20 | - if (isset ($classes[$class])) |
|
21 | - include __DIR__ .'/'. $classes[$class]; |
|
22 | -}); |
|
20 | + if (isset ($classes[$class])) { |
|
21 | + include __DIR__ .'/'. $classes[$class]; |
|
22 | + } |
|
23 | + }); |
|
23 | 24 | |
24 | 25 | $required_packages = array |
25 | 26 | ( |
@@ -22,7 +22,7 @@ |
||
22 | 22 | |
23 | 23 | namespace VoidBuilder; |
24 | 24 | |
25 | -if (is_dir ('qero-packages')) |
|
25 | +if (is_dir('qero-packages')) |
|
26 | 26 | require_once 'qero-packages/autoload.php'; |
27 | 27 | |
28 | 28 | require 'php/Builder.php'; |
@@ -22,8 +22,9 @@ |
||
22 | 22 | |
23 | 23 | namespace VoidBuilder; |
24 | 24 | |
25 | -if (is_dir ('qero-packages')) |
|
25 | +if (is_dir ('qero-packages')) { |
|
26 | 26 | require_once 'qero-packages/autoload.php'; |
27 | +} |
|
27 | 28 | |
28 | 29 | require 'php/Builder.php'; |
29 | 30 | require 'php/Joiner.php'; |
@@ -14,85 +14,85 @@ |
||
14 | 14 | if (!isset ($argv)) |
15 | 15 | { |
16 | 16 | $argv = [__FILE__]; |
17 | - $params = json_decode (file_get_contents ('params.json'), true); |
|
17 | + $params = json_decode(file_get_contents('params.json'), true); |
|
18 | 18 | |
19 | 19 | foreach ($params as $name => $param) |
20 | 20 | { |
21 | - if (!is_array ($param)) |
|
21 | + if (!is_array($param)) |
|
22 | 22 | $param = [$param]; |
23 | 23 | |
24 | 24 | foreach ($param as $arg) |
25 | - if (strlen ($arg) > 0) |
|
25 | + if (strlen($arg) > 0) |
|
26 | 26 | { |
27 | 27 | $argv[] = $name; |
28 | 28 | $argv[] = $arg; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | - unlink ('params.json'); |
|
32 | + unlink('params.json'); |
|
33 | 33 | |
34 | - define ('VoidEngine\ENGINE_DIR', $params['--engine-dir']); |
|
35 | - define ('VoidEngine\CORE_DIR', dirname (ENGINE_DIR) .'/core'); |
|
34 | + define('VoidEngine\ENGINE_DIR', $params['--engine-dir']); |
|
35 | + define('VoidEngine\CORE_DIR', dirname(ENGINE_DIR).'/core'); |
|
36 | 36 | |
37 | - require $params['--engine-dir'] .'/VoidEngine.php'; |
|
37 | + require $params['--engine-dir'].'/VoidEngine.php'; |
|
38 | 38 | } |
39 | 39 | |
40 | -(new Manager ([], (new DefaultCommand (function ($args, $params) |
|
40 | +(new Manager([], (new DefaultCommand(function($args, $params) |
|
41 | 41 | { |
42 | 42 | foreach (['--app-dir', '--output-dir', '--icon-path'] as $param) |
43 | - if (is_array ($params[$param])) |
|
44 | - $params[$param] = end ($params[$param]); |
|
43 | + if (is_array($params[$param])) |
|
44 | + $params[$param] = end($params[$param]); |
|
45 | 45 | |
46 | - if (class_exists ('VoidEngine\VoidEngine')) |
|
46 | + if (class_exists('VoidEngine\VoidEngine')) |
|
47 | 47 | { |
48 | - $errors = (new Builder ($params['--app-dir']))->build ($params['--output-dir'], $params['--icon-path'], !$params['--no-compress']); |
|
48 | + $errors = (new Builder($params['--app-dir']))->build($params['--output-dir'], $params['--icon-path'], !$params['--no-compress']); |
|
49 | 49 | |
50 | - if (sizeof ($errors) > 0) |
|
51 | - print_r ($errors); |
|
50 | + if (sizeof($errors) > 0) |
|
51 | + print_r($errors); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | else |
55 | 55 | { |
56 | 56 | echo PHP_EOL; |
57 | - echo ' Building ['. dirname (str_replace (dirname ($params['--app-dir'], 2) .'\\', '', $params['--app-dir'])) .']...'. PHP_EOL . PHP_EOL; |
|
57 | + echo ' Building ['.dirname(str_replace(dirname($params['--app-dir'], 2).'\\', '', $params['--app-dir'])).']...'.PHP_EOL.PHP_EOL; |
|
58 | 58 | |
59 | - $begin = microtime (true); |
|
59 | + $begin = microtime(true); |
|
60 | 60 | |
61 | - $package = json_decode (file_get_contents (dirname ($params['--app-dir']) .'/qero-packages/packages.json'), true)['github:KRypt0nn/VoidFramework']['basefolder']; |
|
61 | + $package = json_decode(file_get_contents(dirname($params['--app-dir']).'/qero-packages/packages.json'), true)['github:KRypt0nn/VoidFramework']['basefolder']; |
|
62 | 62 | |
63 | - $params['--engine-dir'] = dirname ($params['--app-dir']) .'/qero-packages/KRypt0nn/VoidFramework/'. $package .'/engine'; |
|
64 | - file_put_contents ('params.json', json_encode ($params, JSON_PRETTY_PRINT)); |
|
63 | + $params['--engine-dir'] = dirname($params['--app-dir']).'/qero-packages/KRypt0nn/VoidFramework/'.$package.'/engine'; |
|
64 | + file_put_contents('params.json', json_encode($params, JSON_PRETTY_PRINT)); |
|
65 | 65 | |
66 | - shell_exec ('"'. dirname ($params['--app-dir']) .'/qero-packages/KRypt0nn/VoidFramework/'. $package .'/core/VoidCore.exe" "'. __FILE__ .'"'); |
|
66 | + shell_exec('"'.dirname($params['--app-dir']).'/qero-packages/KRypt0nn/VoidFramework/'.$package.'/core/VoidCore.exe" "'.__FILE__.'"'); |
|
67 | 67 | |
68 | - echo ' Building completed after '. round (microtime (true) - $begin, 6) .' seconds'. PHP_EOL; |
|
69 | - echo ' Saved at '. $params['--output-dir'] .'/build'. PHP_EOL . PHP_EOL; |
|
68 | + echo ' Building completed after '.round(microtime(true) - $begin, 6).' seconds'.PHP_EOL; |
|
69 | + echo ' Saved at '.$params['--output-dir'].'/build'.PHP_EOL.PHP_EOL; |
|
70 | 70 | |
71 | 71 | if (isset ($params['--join'])) |
72 | 72 | { |
73 | - if (!is_array ($params['--join'])) |
|
73 | + if (!is_array($params['--join'])) |
|
74 | 74 | $params['--join'] = [$params['--join']]; |
75 | 75 | |
76 | - if (($size = sizeof ($params['--join'])) > 0) |
|
76 | + if (($size = sizeof($params['--join'])) > 0) |
|
77 | 77 | { |
78 | - echo ' Union '. $size .' files...'. PHP_EOL; |
|
78 | + echo ' Union '.$size.' files...'.PHP_EOL; |
|
79 | 79 | |
80 | - $begin = microtime (true); |
|
81 | - $joiner = new Joiner ($params['--output-dir'] .'/build/app.exe', $params['--output-dir'] .'/app.exe'); |
|
80 | + $begin = microtime(true); |
|
81 | + $joiner = new Joiner($params['--output-dir'].'/build/app.exe', $params['--output-dir'].'/app.exe'); |
|
82 | 82 | |
83 | 83 | foreach ($params['--join'] as $file) |
84 | - $joiner->add (file_exists ($file) ? $file : $params['--output-dir'] .'/build/'. $file); |
|
84 | + $joiner->add(file_exists($file) ? $file : $params['--output-dir'].'/build/'.$file); |
|
85 | 85 | |
86 | - echo str_replace ("\n", "\n ", $joiner->join ()) . PHP_EOL; |
|
87 | - echo ' Union completed after '. round (microtime (true) - $begin, 6) .' seconds'. PHP_EOL; |
|
88 | - echo ' Saved at '. $params['--output-dir'] . PHP_EOL; |
|
86 | + echo str_replace("\n", "\n ", $joiner->join()).PHP_EOL; |
|
87 | + echo ' Union completed after '.round(microtime(true) - $begin, 6).' seconds'.PHP_EOL; |
|
88 | + echo ' Saved at '.$params['--output-dir'].PHP_EOL; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
92 | -}))->addParams ([ |
|
93 | - (new Param ('--app-dir', null, true))->addAliase ('-d'), |
|
94 | - (new Param ('--output-dir', __DIR__ .'/build'))->addAliase ('-o'), |
|
95 | - (new Param ('--icon-path', __DIR__ .'/system/Icon.ico'))->addAliase ('-i'), |
|
96 | - (new Param ('--join'))->addAliase ('-j'), |
|
97 | - (new Flag ('--no-compress'))->addAliase ('-nc') |
|
98 | -])))->execute ($argv); |
|
92 | +}))->addParams([ |
|
93 | + (new Param('--app-dir', null, true))->addAliase('-d'), |
|
94 | + (new Param('--output-dir', __DIR__.'/build'))->addAliase('-o'), |
|
95 | + (new Param('--icon-path', __DIR__.'/system/Icon.ico'))->addAliase('-i'), |
|
96 | + (new Param('--join'))->addAliase('-j'), |
|
97 | + (new Flag('--no-compress'))->addAliase('-nc') |
|
98 | +])))->execute($argv); |
@@ -18,13 +18,15 @@ discard block |
||
18 | 18 | |
19 | 19 | foreach ($params as $name => $param) |
20 | 20 | { |
21 | - if (!is_array ($param)) |
|
22 | - $param = [$param]; |
|
21 | + if (!is_array ($param)) { |
|
22 | + $param = [$param]; |
|
23 | + } |
|
23 | 24 | |
24 | - foreach ($param as $arg) |
|
25 | - if (strlen ($arg) > 0) |
|
25 | + foreach ($param as $arg) { |
|
26 | + if (strlen ($arg) > 0) |
|
26 | 27 | { |
27 | 28 | $argv[] = $name; |
29 | + } |
|
28 | 30 | $argv[] = $arg; |
29 | 31 | } |
30 | 32 | } |
@@ -39,19 +41,19 @@ discard block |
||
39 | 41 | |
40 | 42 | (new Manager ([], (new DefaultCommand (function ($args, $params) |
41 | 43 | { |
42 | - foreach (['--app-dir', '--output-dir', '--icon-path'] as $param) |
|
43 | - if (is_array ($params[$param])) |
|
44 | + foreach (['--app-dir', '--output-dir', '--icon-path'] as $param) { |
|
45 | + if (is_array ($params[$param])) |
|
44 | 46 | $params[$param] = end ($params[$param]); |
47 | + } |
|
45 | 48 | |
46 | 49 | if (class_exists ('VoidEngine\VoidEngine')) |
47 | 50 | { |
48 | 51 | $errors = (new Builder ($params['--app-dir']))->build ($params['--output-dir'], $params['--icon-path'], !$params['--no-compress']); |
49 | 52 | |
50 | - if (sizeof ($errors) > 0) |
|
51 | - print_r ($errors); |
|
52 | - } |
|
53 | - |
|
54 | - else |
|
53 | + if (sizeof ($errors) > 0) { |
|
54 | + print_r ($errors); |
|
55 | + } |
|
56 | + } else |
|
55 | 57 | { |
56 | 58 | echo PHP_EOL; |
57 | 59 | echo ' Building ['. dirname (str_replace (dirname ($params['--app-dir'], 2) .'\\', '', $params['--app-dir'])) .']...'. PHP_EOL . PHP_EOL; |
@@ -70,8 +72,9 @@ discard block |
||
70 | 72 | |
71 | 73 | if (isset ($params['--join'])) |
72 | 74 | { |
73 | - if (!is_array ($params['--join'])) |
|
74 | - $params['--join'] = [$params['--join']]; |
|
75 | + if (!is_array ($params['--join'])) { |
|
76 | + $params['--join'] = [$params['--join']]; |
|
77 | + } |
|
75 | 78 | |
76 | 79 | if (($size = sizeof ($params['--join'])) > 0) |
77 | 80 | { |
@@ -80,8 +83,9 @@ discard block |
||
80 | 83 | $begin = microtime (true); |
81 | 84 | $joiner = new Joiner ($params['--output-dir'] .'/build/app.exe', $params['--output-dir'] .'/app.exe'); |
82 | 85 | |
83 | - foreach ($params['--join'] as $file) |
|
84 | - $joiner->add (file_exists ($file) ? $file : $params['--output-dir'] .'/build/'. $file); |
|
86 | + foreach ($params['--join'] as $file) { |
|
87 | + $joiner->add (file_exists ($file) ? $file : $params['--output-dir'] .'/build/'. $file); |
|
88 | + } |
|
85 | 89 | |
86 | 90 | echo str_replace ("\n", "\n ", $joiner->join ()) . PHP_EOL; |
87 | 91 | echo ' Union completed after '. round (microtime (true) - $begin, 6) .' seconds'. PHP_EOL; |
@@ -8,57 +8,57 @@ discard block |
||
8 | 8 | { |
9 | 9 | public $appDir; |
10 | 10 | |
11 | - public function __construct (string $appDir) |
|
11 | + public function __construct(string $appDir) |
|
12 | 12 | { |
13 | - if (!is_dir ($appDir)) |
|
14 | - throw new \Exception ('Wrong $appDir param'); |
|
13 | + if (!is_dir($appDir)) |
|
14 | + throw new \Exception('Wrong $appDir param'); |
|
15 | 15 | |
16 | 16 | $this->appDir = $appDir; |
17 | 17 | } |
18 | 18 | |
19 | - public function build (string $outputDir, string $iconPath = null, bool $union = true): array |
|
19 | + public function build(string $outputDir, string $iconPath = null, bool $union = true): array |
|
20 | 20 | { |
21 | - \VoidEngine\dir_clean ($outputDir .'/build'); |
|
22 | - \VoidEngine\dir_copy (\VoidEngine\CORE_DIR, $outputDir .'/build'); |
|
21 | + \VoidEngine\dir_clean($outputDir.'/build'); |
|
22 | + \VoidEngine\dir_copy(\VoidEngine\CORE_DIR, $outputDir.'/build'); |
|
23 | 23 | |
24 | - unlink ($outputDir .'/build/script.php'); |
|
25 | - unlink ($outputDir .'/build/VoidCore.exe'); |
|
24 | + unlink($outputDir.'/build/script.php'); |
|
25 | + unlink($outputDir.'/build/VoidCore.exe'); |
|
26 | 26 | |
27 | - return VoidEngine::compile ($outputDir .'/build/app.exe', \VoidEngine\text ($iconPath ?? dirname (__DIR__) .'/system/Icon.ico'), \VoidEngine\str_replace_assoc (file_get_contents (dirname (__DIR__) .'/system/preset.php'), [ |
|
28 | - '%VoidEngine%' => self::generateCode (self::getReferences (\VoidEngine\ENGINE_DIR .'/VoidEngine.php')), |
|
29 | - '%APP%' => base64_encode (gzdeflate (serialize ($union ? array_merge ( |
|
30 | - self::getFiles ($this->appDir), |
|
31 | - self::getFiles (dirname ($this->appDir) .'/qero-packages', 'qero-packages/KRypt0nn/VoidFramework') |
|
27 | + return VoidEngine::compile($outputDir.'/build/app.exe', \VoidEngine\text($iconPath ?? dirname(__DIR__).'/system/Icon.ico'), \VoidEngine\str_replace_assoc(file_get_contents(dirname(__DIR__).'/system/preset.php'), [ |
|
28 | + '%VoidEngine%' => self::generateCode(self::getReferences(\VoidEngine\ENGINE_DIR.'/VoidEngine.php')), |
|
29 | + '%APP%' => base64_encode(gzdeflate(serialize($union ? array_merge ( |
|
30 | + self::getFiles($this->appDir), |
|
31 | + self::getFiles(dirname($this->appDir).'/qero-packages', 'qero-packages/KRypt0nn/VoidFramework') |
|
32 | 32 | ) : []), 9)) |
33 | 33 | ]), null, null, null, null, null, '', ''); |
34 | 34 | } |
35 | 35 | |
36 | - public static function generateCode (array $references, bool $removeNamespaces = true): string |
|
36 | + public static function generateCode(array $references, bool $removeNamespaces = true): string |
|
37 | 37 | { |
38 | - $code = "/*\n\n\t". join ("\n\t", explode ("\n", file_get_contents (dirname (\VoidEngine\ENGINE_DIR) .'/license.txt'))) ."\n\n*/\n\n"; |
|
38 | + $code = "/*\n\n\t".join("\n\t", explode("\n", file_get_contents(dirname(\VoidEngine\ENGINE_DIR).'/license.txt')))."\n\n*/\n\n"; |
|
39 | 39 | |
40 | 40 | foreach ($references as $path) |
41 | - $code .= join (array_slice (array_map (function ($line) |
|
41 | + $code .= join(array_slice(array_map(function($line) |
|
42 | 42 | { |
43 | - return substr ($line, 0, 7) != 'require' ? $line : ''; |
|
44 | - }, file ($path)), 1)); |
|
43 | + return substr($line, 0, 7) != 'require' ? $line : ''; |
|
44 | + }, file($path)), 1)); |
|
45 | 45 | |
46 | 46 | return $removeNamespaces ? |
47 | - preg_replace ('/'. "\n" .'namespace [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*;'. "\n" .'/', "\n\n", $code) : $code; |
|
47 | + preg_replace ('/'."\n".'namespace [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*;'."\n".'/', "\n\n", $code) : $code; |
|
48 | 48 | } |
49 | 49 | |
50 | - public static function getReferences (string $file, bool $parseExtensions = true): array |
|
50 | + public static function getReferences(string $file, bool $parseExtensions = true): array |
|
51 | 51 | { |
52 | 52 | $references = []; |
53 | 53 | |
54 | - foreach (file ($file) as $id => $line) |
|
55 | - if (substr ($line, 0, 7) == 'require') |
|
54 | + foreach (file($file) as $id => $line) |
|
55 | + if (substr($line, 0, 7) == 'require') |
|
56 | 56 | try |
57 | 57 | { |
58 | - $begin = strpos ($line, "'"); |
|
59 | - $end = strrpos ($line, "'") - $begin + 1; |
|
58 | + $begin = strpos($line, "'"); |
|
59 | + $end = strrpos($line, "'") - $begin + 1; |
|
60 | 60 | |
61 | - $references = array_merge ($references, self::getReferences (dirname ($file) .'/'. eval ('namespace VoidEngine; return '. substr ($line, $begin, $end) .';'), false)); |
|
61 | + $references = array_merge($references, self::getReferences(dirname($file).'/'.eval ('namespace VoidEngine; return '.substr($line, $begin, $end).';'), false)); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | catch (\Throwable $e) |
@@ -67,30 +67,30 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | if ($parseExtensions) |
70 | - if (is_dir (\VoidEngine\ENGINE_DIR .'/extensions') && is_array ($exts = scandir (\VoidEngine\ENGINE_DIR .'/extensions'))) |
|
70 | + if (is_dir(\VoidEngine\ENGINE_DIR.'/extensions') && is_array($exts = scandir(\VoidEngine\ENGINE_DIR.'/extensions'))) |
|
71 | 71 | foreach ($exts as $id => $ext) |
72 | - if (is_dir (\VoidEngine\ENGINE_DIR .'/extensions/'. $ext) && file_exists ($ext = \VoidEngine\ENGINE_DIR .'/extensions/'. $ext .'/main.php')) |
|
73 | - $references = array_merge ($references, self::getReferences ($ext, false)); |
|
72 | + if (is_dir(\VoidEngine\ENGINE_DIR.'/extensions/'.$ext) && file_exists($ext = \VoidEngine\ENGINE_DIR.'/extensions/'.$ext.'/main.php')) |
|
73 | + $references = array_merge($references, self::getReferences($ext, false)); |
|
74 | 74 | |
75 | 75 | $references[] = $file; |
76 | 76 | |
77 | 77 | return $references; |
78 | 78 | } |
79 | 79 | |
80 | - public static function getFiles (string $path, string $prefixBlacklist = null, array $files = [], int $originalPathLength = -1): array |
|
80 | + public static function getFiles(string $path, string $prefixBlacklist = null, array $files = [], int $originalPathLength = -1): array |
|
81 | 81 | { |
82 | 82 | if ($originalPathLength == -1) |
83 | - $originalPathLength = strlen (dirname ($path)) + 1; |
|
83 | + $originalPathLength = strlen(dirname($path)) + 1; |
|
84 | 84 | |
85 | - $len = strlen ($prefixBlacklist); |
|
85 | + $len = strlen($prefixBlacklist); |
|
86 | 86 | |
87 | - foreach (array_slice (scandir ($path), 2) as $name) |
|
88 | - if ($prefixBlacklist === null || substr ($path .'/'. $name, $originalPathLength, $len) != $prefixBlacklist) |
|
87 | + foreach (array_slice(scandir($path), 2) as $name) |
|
88 | + if ($prefixBlacklist === null || substr($path.'/'.$name, $originalPathLength, $len) != $prefixBlacklist) |
|
89 | 89 | { |
90 | - if (is_dir ($file = $path .'/'. $name)) |
|
91 | - $files = self::getFiles ($file, $prefixBlacklist, $files, $originalPathLength); |
|
90 | + if (is_dir($file = $path.'/'.$name)) |
|
91 | + $files = self::getFiles($file, $prefixBlacklist, $files, $originalPathLength); |
|
92 | 92 | |
93 | - else $files[substr ($file, $originalPathLength)] = file_get_contents ($file); |
|
93 | + else $files[substr($file, $originalPathLength)] = file_get_contents($file); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | return $files; |
@@ -10,8 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | public function __construct (string $appDir) |
12 | 12 | { |
13 | - if (!is_dir ($appDir)) |
|
14 | - throw new \Exception ('Wrong $appDir param'); |
|
13 | + if (!is_dir ($appDir)) { |
|
14 | + throw new \Exception ('Wrong $appDir param'); |
|
15 | + } |
|
15 | 16 | |
16 | 17 | $this->appDir = $appDir; |
17 | 18 | } |
@@ -37,10 +38,11 @@ discard block |
||
37 | 38 | { |
38 | 39 | $code = "/*\n\n\t". join ("\n\t", explode ("\n", file_get_contents (dirname (\VoidEngine\ENGINE_DIR) .'/license.txt'))) ."\n\n*/\n\n"; |
39 | 40 | |
40 | - foreach ($references as $path) |
|
41 | - $code .= join (array_slice (array_map (function ($line) |
|
41 | + foreach ($references as $path) { |
|
42 | + $code .= join (array_slice (array_map (function ($line) |
|
42 | 43 | { |
43 | 44 | return substr ($line, 0, 7) != 'require' ? $line : ''; |
45 | + } |
|
44 | 46 | }, file ($path)), 1)); |
45 | 47 | |
46 | 48 | return $removeNamespaces ? |
@@ -51,26 +53,26 @@ discard block |
||
51 | 53 | { |
52 | 54 | $references = []; |
53 | 55 | |
54 | - foreach (file ($file) as $id => $line) |
|
55 | - if (substr ($line, 0, 7) == 'require') |
|
56 | + foreach (file ($file) as $id => $line) { |
|
57 | + if (substr ($line, 0, 7) == 'require') |
|
56 | 58 | try |
57 | 59 | { |
58 | 60 | $begin = strpos ($line, "'"); |
61 | + } |
|
59 | 62 | $end = strrpos ($line, "'") - $begin + 1; |
60 | 63 | |
61 | 64 | $references = array_merge ($references, self::getReferences (dirname ($file) .'/'. eval ('namespace VoidEngine; return '. substr ($line, $begin, $end) .';'), false)); |
62 | - } |
|
63 | - |
|
64 | - catch (\Throwable $e) |
|
65 | + } catch (\Throwable $e) |
|
65 | 66 | { |
66 | 67 | continue; |
67 | 68 | } |
68 | 69 | |
69 | - if ($parseExtensions) |
|
70 | - if (is_dir (\VoidEngine\ENGINE_DIR .'/extensions') && is_array ($exts = scandir (\VoidEngine\ENGINE_DIR .'/extensions'))) |
|
70 | + if ($parseExtensions) { |
|
71 | + if (is_dir (\VoidEngine\ENGINE_DIR .'/extensions') && is_array ($exts = scandir (\VoidEngine\ENGINE_DIR .'/extensions'))) |
|
71 | 72 | foreach ($exts as $id => $ext) |
72 | 73 | if (is_dir (\VoidEngine\ENGINE_DIR .'/extensions/'. $ext) && file_exists ($ext = \VoidEngine\ENGINE_DIR .'/extensions/'. $ext .'/main.php')) |
73 | 74 | $references = array_merge ($references, self::getReferences ($ext, false)); |
75 | + } |
|
74 | 76 | |
75 | 77 | $references[] = $file; |
76 | 78 | |
@@ -79,18 +81,22 @@ discard block |
||
79 | 81 | |
80 | 82 | public static function getFiles (string $path, string $prefixBlacklist = null, array $files = [], int $originalPathLength = -1): array |
81 | 83 | { |
82 | - if ($originalPathLength == -1) |
|
83 | - $originalPathLength = strlen (dirname ($path)) + 1; |
|
84 | + if ($originalPathLength == -1) { |
|
85 | + $originalPathLength = strlen (dirname ($path)) + 1; |
|
86 | + } |
|
84 | 87 | |
85 | 88 | $len = strlen ($prefixBlacklist); |
86 | 89 | |
87 | - foreach (array_slice (scandir ($path), 2) as $name) |
|
88 | - if ($prefixBlacklist === null || substr ($path .'/'. $name, $originalPathLength, $len) != $prefixBlacklist) |
|
90 | + foreach (array_slice (scandir ($path), 2) as $name) { |
|
91 | + if ($prefixBlacklist === null || substr ($path .'/'. $name, $originalPathLength, $len) != $prefixBlacklist) |
|
89 | 92 | { |
90 | 93 | if (is_dir ($file = $path .'/'. $name)) |
91 | 94 | $files = self::getFiles ($file, $prefixBlacklist, $files, $originalPathLength); |
95 | + } |
|
92 | 96 | |
93 | - else $files[substr ($file, $originalPathLength)] = file_get_contents ($file); |
|
97 | + else { |
|
98 | + $files[substr ($file, $originalPathLength)] = file_get_contents ($file); |
|
99 | + } |
|
94 | 100 | } |
95 | 101 | |
96 | 102 | return $files; |
@@ -6,17 +6,17 @@ discard block |
||
6 | 6 | { |
7 | 7 | public $path; |
8 | 8 | |
9 | - public function __construct (string $path) |
|
9 | + public function __construct(string $path) |
|
10 | 10 | { |
11 | - if (!is_file ($path)) |
|
12 | - throw new \Exception ('Wrong $path paeam'); |
|
11 | + if (!is_file($path)) |
|
12 | + throw new \Exception('Wrong $path paeam'); |
|
13 | 13 | |
14 | 14 | $this->path = $path; |
15 | 15 | } |
16 | 16 | |
17 | - public function toXML (): string |
|
17 | + public function toXML(): string |
|
18 | 18 | { |
19 | - return '<File><Type>2</Type><Name>'. basename ($this->path) .'</Name><File>'. $this->path .'</File><ActiveX>False</ActiveX><ActiveXInstall>False</ActiveXInstall><Action>0</Action><OverwriteDateTime>False</OverwriteDateTime><OverwriteAttributes>False</OverwriteAttributes><PassCommandLine>False</PassCommandLine><HideFromDialogs>0</HideFromDialogs></File>'; |
|
19 | + return '<File><Type>2</Type><Name>'.basename($this->path).'</Name><File>'.$this->path.'</File><ActiveX>False</ActiveX><ActiveXInstall>False</ActiveXInstall><Action>0</Action><OverwriteDateTime>False</OverwriteDateTime><OverwriteAttributes>False</OverwriteAttributes><PassCommandLine>False</PassCommandLine><HideFromDialogs>0</HideFromDialogs></File>'; |
|
20 | 20 | } |
21 | 21 | } |
22 | 22 | |
@@ -25,24 +25,24 @@ discard block |
||
25 | 25 | public $path; |
26 | 26 | public $files = []; |
27 | 27 | |
28 | - public function __construct (string $path) |
|
28 | + public function __construct(string $path) |
|
29 | 29 | { |
30 | - if (!is_dir ($path)) |
|
31 | - throw new \Exception ('Wrong $path param'); |
|
30 | + if (!is_dir($path)) |
|
31 | + throw new \Exception('Wrong $path param'); |
|
32 | 32 | |
33 | 33 | $this->path = $path; |
34 | 34 | |
35 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
36 | - $this->files[] = is_dir ($file = $path .'/'. $file) ? |
|
37 | - new Folder ($file) : new File ($file); |
|
35 | + foreach (array_slice(scandir($path), 2) as $file) |
|
36 | + $this->files[] = is_dir($file = $path.'/'.$file) ? |
|
37 | + new Folder($file) : new File($file); |
|
38 | 38 | } |
39 | 39 | |
40 | - public function toXML (): string |
|
40 | + public function toXML(): string |
|
41 | 41 | { |
42 | - return '<File><Type>3</Type><Name>'. basename ($this->path) .'</Name><Action>0</Action><OverwriteDateTime>False</OverwriteDateTime><OverwriteAttributes>False</OverwriteAttributes><HideFromDialogs>0</HideFromDialogs><Files>'. implode ('', array_map (function ($item) |
|
42 | + return '<File><Type>3</Type><Name>'.basename($this->path).'</Name><Action>0</Action><OverwriteDateTime>False</OverwriteDateTime><OverwriteAttributes>False</OverwriteAttributes><HideFromDialogs>0</HideFromDialogs><Files>'.implode('', array_map(function($item) |
|
43 | 43 | { |
44 | - return $item->toXML (); |
|
45 | - }, $this->files)) .'</Files></File>'; |
|
44 | + return $item->toXML(); |
|
45 | + }, $this->files)).'</Files></File>'; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
@@ -52,44 +52,44 @@ discard block |
||
52 | 52 | public $output; |
53 | 53 | public $files = []; |
54 | 54 | |
55 | - public function __construct (string $input, string $output) |
|
55 | + public function __construct(string $input, string $output) |
|
56 | 56 | { |
57 | - if (!is_file ($input)) |
|
58 | - throw new \Exception ('Wrong $input param'); |
|
57 | + if (!is_file($input)) |
|
58 | + throw new \Exception('Wrong $input param'); |
|
59 | 59 | |
60 | 60 | $this->input = $input; |
61 | 61 | $this->output = $output; |
62 | 62 | } |
63 | 63 | |
64 | - public function add (string $path): Joiner |
|
64 | + public function add(string $path): Joiner |
|
65 | 65 | { |
66 | - $this->files[] = is_dir ($path) ? |
|
67 | - new Folder ($path) : new File ($path); |
|
66 | + $this->files[] = is_dir($path) ? |
|
67 | + new Folder($path) : new File($path); |
|
68 | 68 | |
69 | 69 | return $this; |
70 | 70 | } |
71 | 71 | |
72 | - public function getEVB (): string |
|
72 | + public function getEVB(): string |
|
73 | 73 | { |
74 | - return str_replace ([ |
|
74 | + return str_replace([ |
|
75 | 75 | '%INPUT_FILE%', |
76 | 76 | '%OUTPUT_FILE%', |
77 | 77 | '%FILES%' |
78 | 78 | ], [ |
79 | 79 | $this->input, |
80 | 80 | $this->output, |
81 | - implode ('', array_map (function ($item) |
|
81 | + implode('', array_map(function($item) |
|
82 | 82 | { |
83 | - return $item->toXML (); |
|
83 | + return $item->toXML(); |
|
84 | 84 | }, $this->files)) |
85 | - ], file_get_contents (dirname (__DIR__) .'/system/stub.evb')); |
|
85 | + ], file_get_contents(dirname(__DIR__).'/system/stub.evb')); |
|
86 | 86 | } |
87 | 87 | |
88 | - public function join (): string |
|
88 | + public function join(): string |
|
89 | 89 | { |
90 | - file_put_contents (dirname (__DIR__) .'/system/temp.evb', $this->getEVB ()); |
|
91 | - $return = shell_exec ('"'. dirname (__DIR__) .'/system/enigmavbconsole.exe" "system/temp.evb"'); |
|
92 | - unlink (dirname (__DIR__) .'/system/temp.evb'); |
|
90 | + file_put_contents(dirname(__DIR__).'/system/temp.evb', $this->getEVB()); |
|
91 | + $return = shell_exec('"'.dirname(__DIR__).'/system/enigmavbconsole.exe" "system/temp.evb"'); |
|
92 | + unlink(dirname(__DIR__).'/system/temp.evb'); |
|
93 | 93 | |
94 | 94 | return $return; |
95 | 95 | } |
@@ -8,8 +8,9 @@ discard block |
||
8 | 8 | |
9 | 9 | public function __construct (string $path) |
10 | 10 | { |
11 | - if (!is_file ($path)) |
|
12 | - throw new \Exception ('Wrong $path paeam'); |
|
11 | + if (!is_file ($path)) { |
|
12 | + throw new \Exception ('Wrong $path paeam'); |
|
13 | + } |
|
13 | 14 | |
14 | 15 | $this->path = $path; |
15 | 16 | } |
@@ -27,14 +28,16 @@ discard block |
||
27 | 28 | |
28 | 29 | public function __construct (string $path) |
29 | 30 | { |
30 | - if (!is_dir ($path)) |
|
31 | - throw new \Exception ('Wrong $path param'); |
|
31 | + if (!is_dir ($path)) { |
|
32 | + throw new \Exception ('Wrong $path param'); |
|
33 | + } |
|
32 | 34 | |
33 | 35 | $this->path = $path; |
34 | 36 | |
35 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
36 | - $this->files[] = is_dir ($file = $path .'/'. $file) ? |
|
37 | + foreach (array_slice (scandir ($path), 2) as $file) { |
|
38 | + $this->files[] = is_dir ($file = $path .'/'. $file) ? |
|
37 | 39 | new Folder ($file) : new File ($file); |
40 | + } |
|
38 | 41 | } |
39 | 42 | |
40 | 43 | public function toXML (): string |
@@ -54,8 +57,9 @@ discard block |
||
54 | 57 | |
55 | 58 | public function __construct (string $input, string $output) |
56 | 59 | { |
57 | - if (!is_file ($input)) |
|
58 | - throw new \Exception ('Wrong $input param'); |
|
60 | + if (!is_file ($input)) { |
|
61 | + throw new \Exception ('Wrong $input param'); |
|
62 | + } |
|
59 | 63 | |
60 | 64 | $this->input = $input; |
61 | 65 | $this->output = $output; |
@@ -31,14 +31,14 @@ |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | public function applyToObject (int $selector): void |
34 | - { |
|
35 | - VoidEngine::setProperty ($selector, 'Icon', $this->selector); |
|
36 | - } |
|
34 | + { |
|
35 | + VoidEngine::setProperty ($selector, 'Icon', $this->selector); |
|
36 | + } |
|
37 | 37 | |
38 | - public function saveToFile (string $file): void |
|
39 | - { |
|
40 | - VoidEngine::callMethod ($this->selector, 'Save', $file); |
|
41 | - } |
|
38 | + public function saveToFile (string $file): void |
|
39 | + { |
|
40 | + VoidEngine::callMethod ($this->selector, 'Save', $file); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | class Bitmap extends WFObject |
@@ -7,14 +7,14 @@ discard block |
||
7 | 7 | public $class = 'System.Drawing.Image'; |
8 | 8 | public $namespace = 'System.Drawing'; |
9 | 9 | |
10 | - public function __construct () |
|
10 | + public function __construct() |
|
11 | 11 | { |
12 | - parent::__construct ($this->class); |
|
12 | + parent::__construct($this->class); |
|
13 | 13 | } |
14 | 14 | |
15 | - public function loadFromFile (string $path) |
|
15 | + public function loadFromFile(string $path) |
|
16 | 16 | { |
17 | - return $this->fromFile ($path); |
|
17 | + return $this->fromFile($path); |
|
18 | 18 | } |
19 | 19 | } |
20 | 20 | |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | public $class = 'System.Drawing.Icon'; |
24 | 24 | public $namespace = 'System.Drawing'; |
25 | 25 | |
26 | - public function __construct (string $file) |
|
26 | + public function __construct(string $file) |
|
27 | 27 | { |
28 | - parent::__construct ($this->class); |
|
28 | + parent::__construct($this->class); |
|
29 | 29 | |
30 | - $this->fromFile ($file); |
|
30 | + $this->fromFile($file); |
|
31 | 31 | } |
32 | 32 | |
33 | - public function applyToObject (int $selector): void |
|
33 | + public function applyToObject(int $selector): void |
|
34 | 34 | { |
35 | - VoidEngine::setProperty ($selector, 'Icon', $this->selector); |
|
35 | + VoidEngine::setProperty($selector, 'Icon', $this->selector); |
|
36 | 36 | } |
37 | 37 | |
38 | - public function saveToFile (string $file): void |
|
38 | + public function saveToFile(string $file): void |
|
39 | 39 | { |
40 | - VoidEngine::callMethod ($this->selector, 'Save', $file); |
|
40 | + VoidEngine::callMethod($this->selector, 'Save', $file); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | public $class = 'System.Drawing.Bitmap'; |
47 | 47 | public $namespace = 'System.Drawing'; |
48 | 48 | |
49 | - public function __construct (string $filename) |
|
49 | + public function __construct(string $filename) |
|
50 | 50 | { |
51 | - parent::__construct ($this->class, $this->namespace, [$filename, 'string']); |
|
51 | + parent::__construct($this->class, $this->namespace, [$filename, 'string']); |
|
52 | 52 | } |
53 | 53 | } |