diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php
index db03abef..598bdd10 100644
--- a/src/SPC/ConsoleApplication.php
+++ b/src/SPC/ConsoleApplication.php
@@ -15,7 +15,7 @@ use Symfony\Component\Console\Command\ListCommand;
*/
class ConsoleApplication extends Application
{
- public const VERSION = '2.0-rc4';
+ public const VERSION = '2.0-rc5';
/**
* @throws \ReflectionException
diff --git a/src/SPC/command/BaseCommand.php b/src/SPC/command/BaseCommand.php
index 11ea6215..fe3775e1 100644
--- a/src/SPC/command/BaseCommand.php
+++ b/src/SPC/command/BaseCommand.php
@@ -91,7 +91,7 @@ abstract class BaseCommand extends Command
foreach ($msg as $v) {
logger()->error($v);
}
- return self::FAILURE;
+ return static::FAILURE;
} catch (\Throwable $e) {
// 不开 debug 模式就不要再显示复杂的调试栈信息了
if ($this->getOption('debug')) {
@@ -102,10 +102,10 @@ abstract class BaseCommand extends Command
logger()->error($v);
}
}
- return self::FAILURE;
+ return static::FAILURE;
}
}
- return self::SUCCESS;
+ return static::SUCCESS;
}
protected function getOption(string $name): mixed
diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php
index b6cf3461..f1427ed6 100644
--- a/src/SPC/command/BuildCliCommand.php
+++ b/src/SPC/command/BuildCliCommand.php
@@ -51,7 +51,7 @@ class BuildCliCommand extends BuildCommand
$this->output->writeln("\t--build-micro\tBuild phpmicro SAPI");
$this->output->writeln("\t--build-fpm\tBuild php-fpm SAPI");
$this->output->writeln("\t--build-all\tBuild all SAPI: cli, micro, fpm");
- return 1;
+ return static::FAILURE;
}
try {
// 构建对象
@@ -113,10 +113,10 @@ class BuildCliCommand extends BuildCommand
$dumper = new LicenseDumper();
$dumper->addExts($extensions)->addLibs($libraries)->addSources(['php-src'])->dump(BUILD_ROOT_PATH . '/license');
logger()->info('License path' . $fixed . ': ' . $build_root_path . '/license/');
- return 0;
+ return static::SUCCESS;
} catch (WrongUsageException $e) {
logger()->critical($e->getMessage());
- return 1;
+ return static::FAILURE;
} catch (\Throwable $e) {
if ($this->getOption('debug')) {
ExceptionHandler::getInstance()->handle($e);
@@ -124,7 +124,7 @@ class BuildCliCommand extends BuildCommand
logger()->critical('Build failed with ' . get_class($e) . ': ' . $e->getMessage());
logger()->critical('Please check with --debug option to see more details.');
}
- return 1;
+ return static::FAILURE;
}
}
}
diff --git a/src/SPC/command/BuildLibsCommand.php b/src/SPC/command/BuildLibsCommand.php
index d4a23a2a..cc1471eb 100644
--- a/src/SPC/command/BuildLibsCommand.php
+++ b/src/SPC/command/BuildLibsCommand.php
@@ -63,7 +63,7 @@ class BuildLibsCommand extends BuildCommand
$time = round(microtime(true) - START_TIME, 3);
logger()->info('Build libs complete, used ' . $time . ' s !');
- return 0;
+ return static::SUCCESS;
} catch (\Throwable $e) {
if ($this->getOption('debug')) {
ExceptionHandler::getInstance()->handle($e);
@@ -71,7 +71,7 @@ class BuildLibsCommand extends BuildCommand
logger()->critical('Build failed with ' . get_class($e) . ': ' . $e->getMessage());
logger()->critical('Please check with --debug option to see more details.');
}
- return 1;
+ return static::FAILURE;
}
}
}
diff --git a/src/SPC/command/DeployCommand.php b/src/SPC/command/DeployCommand.php
index dc97b035..0409f0b0 100644
--- a/src/SPC/command/DeployCommand.php
+++ b/src/SPC/command/DeployCommand.php
@@ -60,7 +60,7 @@ class DeployCommand extends BaseCommand
$ask = $this->getOption('overwrite') ? true : $prompt->requireBool('The file "' . $phar_path . '" already exists, do you want to overwrite it?' . PHP_EOL . 'If you want to, just Enter');
if (!$ask) {
$this->output->writeln('User canceled.');
- return 1;
+ return static::FAILURE;
}
@unlink($phar_path);
}
@@ -97,7 +97,7 @@ class DeployCommand extends BaseCommand
$phar->setStub($phar->createDefaultStub($stub));
} catch (\Throwable $e) {
$this->output->writeln($e);
- return 1;
+ return static::FAILURE;
}
$phar->addFromString('.prod', 'true');
$phar->stopBuffering();
@@ -114,7 +114,7 @@ class DeployCommand extends BaseCommand
}
chmod($phar_path, 0755);
$this->output->writeln('Phar Executable: ' . $phar_path . '');
- return 0;
+ return static::SUCCESS;
}
private function progress(int $max = 0): ProgressBar
diff --git a/src/SPC/command/DoctorCommand.php b/src/SPC/command/DoctorCommand.php
index 1db5e180..eacaf26b 100644
--- a/src/SPC/command/DoctorCommand.php
+++ b/src/SPC/command/DoctorCommand.php
@@ -24,8 +24,8 @@ class DoctorCommand extends BaseCommand
} catch (\Throwable $e) {
$this->output->writeln('' . $e->getMessage() . '');
pcntl_signal(SIGINT, SIG_IGN);
- return 1;
+ return static::FAILURE;
}
- return 0;
+ return static::SUCCESS;
}
}
diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php
index 23522fda..9d2e05a8 100644
--- a/src/SPC/command/DownloadCommand.php
+++ b/src/SPC/command/DownloadCommand.php
@@ -68,14 +68,14 @@ class DownloadCommand extends BaseCommand
f_passthru('rm -rf ' . DOWNLOAD_PATH . '/*');
f_passthru('rm -rf ' . BUILD_ROOT_PATH . '/*');
}
- return 0;
+ return static::FAILURE;
}
// --from-zip
if ($path = $this->getOption('from-zip')) {
if (!file_exists($path)) {
logger()->critical('File ' . $path . ' not exist or not a zip archive.');
- return 1;
+ return static::FAILURE;
}
// remove old download files first
if (is_dir(DOWNLOAD_PATH)) {
@@ -89,7 +89,7 @@ class DownloadCommand extends BaseCommand
if (PHP_OS_FAMILY !== 'Windows' && !$this->findCommand('unzip')) {
logger()->critical('Missing unzip command, you need to install it first !');
logger()->critical('You can use "bin/spc doctor" command to check and install required tools');
- return 1;
+ return static::FAILURE;
}
// create downloads
try {
@@ -103,10 +103,10 @@ class DownloadCommand extends BaseCommand
}
} catch (RuntimeException $e) {
logger()->critical('Extract failed: ' . $e->getMessage());
- return 1;
+ return static::FAILURE;
}
logger()->info('Extract success');
- return 0;
+ return static::SUCCESS;
}
// Define PHP major version
@@ -115,7 +115,7 @@ class DownloadCommand extends BaseCommand
preg_match('/^\d+\.\d+$/', $ver, $matches);
if (!$matches) {
logger()->error("bad version arg: {$ver}, x.y required!");
- return 1;
+ return static::FAILURE;
}
// Use shallow-clone can reduce git resource download
@@ -175,6 +175,6 @@ class DownloadCommand extends BaseCommand
// 打印拉取资源用时
$time = round(microtime(true) - START_TIME, 3);
logger()->info('Download complete, used ' . $time . ' s !');
- return 0;
+ return static::SUCCESS;
}
}
diff --git a/src/SPC/command/DumpLicenseCommand.php b/src/SPC/command/DumpLicenseCommand.php
index 00f6f3fd..ea4d377a 100644
--- a/src/SPC/command/DumpLicenseCommand.php
+++ b/src/SPC/command/DumpLicenseCommand.php
@@ -50,7 +50,7 @@ class DumpLicenseCommand extends BaseCommand
$this->output->writeln('Dump license with libraries: ' . implode(', ', $libraries));
$this->output->writeln('Dump license with' . ($this->getOption('without-php') ? 'out' : '') . ' php-src');
$this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir'));
- return 0;
+ return static::SUCCESS;
}
if ($this->getOption('by-libs') !== null) {
$libraries = array_map('trim', array_filter(explode(',', $this->getOption('by-libs'))));
@@ -58,16 +58,16 @@ class DumpLicenseCommand extends BaseCommand
$dumper->addLibs($libraries);
$dumper->dump($this->getOption('dump-dir'));
$this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir'));
- return 0;
+ return static::SUCCESS;
}
if ($this->getOption('by-sources') !== null) {
$sources = array_map('trim', array_filter(explode(',', $this->getOption('by-sources'))));
$dumper->addSources($sources);
$dumper->dump($this->getOption('dump-dir'));
$this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir'));
- return 0;
+ return static::SUCCESS;
}
$this->output->writeln('You must use one of "--by-extensions=", "--by-libs=", "--by-sources=" to dump');
- return 1;
+ return static::FAILURE;
}
}
diff --git a/src/SPC/command/ExtractCommand.php b/src/SPC/command/ExtractCommand.php
index f107bf5e..e9c69fdd 100644
--- a/src/SPC/command/ExtractCommand.php
+++ b/src/SPC/command/ExtractCommand.php
@@ -26,10 +26,10 @@ class ExtractCommand extends BaseCommand
$sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources'))));
if (empty($sources)) {
$this->output->writeln('sources cannot be empty, at least contain one !');
- return 1;
+ return static::FAILURE;
}
SourceExtractor::initSource(sources: $sources);
logger()->info('Extract done !');
- return 0;
+ return static::SUCCESS;
}
}
diff --git a/src/SPC/command/ListExtCommand.php b/src/SPC/command/ListExtCommand.php
index f12466db..d8547f07 100644
--- a/src/SPC/command/ListExtCommand.php
+++ b/src/SPC/command/ListExtCommand.php
@@ -21,6 +21,6 @@ class ListExtCommand extends BaseCommand
foreach (Config::getExts() as $ext => $meta) {
echo $ext . PHP_EOL;
}
- return 0;
+ return static::SUCCESS;
}
}
diff --git a/src/SPC/command/MicroCombineCommand.php b/src/SPC/command/MicroCombineCommand.php
index 2da6df49..2c209033 100644
--- a/src/SPC/command/MicroCombineCommand.php
+++ b/src/SPC/command/MicroCombineCommand.php
@@ -35,12 +35,12 @@ class MicroCombineCommand extends BaseCommand
// 1. Make sure specified micro.sfx file exists
if ($micro_file !== null && !file_exists($micro_file)) {
$this->output->writeln('The micro.sfx file you specified is incorrect or does not exist!');
- return 1;
+ return static::FAILURE;
}
// 2. Make sure buildroot/bin/micro.sfx exists
if ($micro_file === null && !file_exists($internal)) {
$this->output->writeln('You haven\'t compiled micro.sfx yet, please use "build" command and "--build-micro" to compile phpmicro first!');
- return 1;
+ return static::FAILURE;
}
// 3. Use buildroot/bin/micro.sfx
if ($micro_file === null) {
@@ -49,19 +49,19 @@ class MicroCombineCommand extends BaseCommand
// 4. Make sure php or phar file exists
if (!is_file(FileSystem::convertPath($file))) {
$this->output->writeln('The file to combine does not exist!');
- return 1;
+ return static::FAILURE;
}
// 5. Confirm ini files (ini-set has higher priority)
if ($ini_file !== null) {
// Check file exist first
if (!file_exists($ini_file)) {
$this->output->writeln('The ini file to combine does not exist! (' . $ini_file . ')');
- return 1;
+ return static::FAILURE;
}
$arr = parse_ini_file($ini_file);
if ($arr === false) {
$this->output->writeln('Cannot parse ini file');
- return 1;
+ return static::FAILURE;
}
$target_ini = array_merge($target_ini, $arr);
}
@@ -71,7 +71,7 @@ class MicroCombineCommand extends BaseCommand
$arr = parse_ini_string($item);
if ($arr === false) {
$this->output->writeln('--with-ini-set parse failed');
- return 1;
+ return static::FAILURE;
}
$target_ini = array_merge($target_ini, $arr);
}
@@ -90,12 +90,12 @@ class MicroCombineCommand extends BaseCommand
$result = file_put_contents($output, $file_target);
if ($result === false) {
$this->output->writeln('Combine failed.');
- return 1;
+ return static::FAILURE;
}
// 9. chmod +x
chmod($output, 0755);
$this->output->writeln('Combine success! Binary file: ' . $output . '');
- return 0;
+ return static::SUCCESS;
}
private function encodeINI(array $array): string
diff --git a/src/SPC/command/SortConfigCommand.php b/src/SPC/command/SortConfigCommand.php
index 3de55770..579b2a89 100644
--- a/src/SPC/command/SortConfigCommand.php
+++ b/src/SPC/command/SortConfigCommand.php
@@ -52,6 +52,6 @@ class SortConfigCommand extends BaseCommand
return 1;
}
$this->output->writeln('sort success');
- return 0;
+ return static::SUCCESS;
}
}
diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php
index 253e1d79..e04a984d 100644
--- a/src/SPC/command/dev/AllExtCommand.php
+++ b/src/SPC/command/dev/AllExtCommand.php
@@ -18,7 +18,6 @@ class AllExtCommand extends BaseCommand
public function handle(): int
{
$this->output->writeln(implode(',', array_keys(Config::getExts())));
-
- return 0;
+ return static::SUCCESS;
}
}
diff --git a/src/SPC/command/dev/ExtInfoCommand.php b/src/SPC/command/dev/ExtInfoCommand.php
index d45478c8..1175b2af 100644
--- a/src/SPC/command/dev/ExtInfoCommand.php
+++ b/src/SPC/command/dev/ExtInfoCommand.php
@@ -37,7 +37,6 @@ class ExtInfoCommand extends BaseCommand
}
$this->output->writeln('');
}
-
- return 0;
+ return static::SUCCESS;
}
}
diff --git a/src/SPC/command/dev/PhpVerCommand.php b/src/SPC/command/dev/PhpVerCommand.php
index 9b729da2..b307f1c5 100644
--- a/src/SPC/command/dev/PhpVerCommand.php
+++ b/src/SPC/command/dev/PhpVerCommand.php
@@ -25,9 +25,9 @@ class PhpVerCommand extends BaseCommand
$result = preg_match('/#define PHP_VERSION "([^"]+)"/', file_get_contents($file), $match);
if ($result === false) {
$this->output->writeln('PHP source not found, maybe you need to extract first ?');
- return 1;
+ return static::FAILURE;
}
$this->output->writeln('' . $match[1] . '');
- return 0;
+ return static::SUCCESS;
}
}