add cs fixer and PHPStan and activate it (build 436)

This commit is contained in:
crazywhalecc
2022-03-15 18:05:33 +08:00
parent d01bd69aa5
commit 1706afbcd0
163 changed files with 4572 additions and 3588 deletions

View File

@@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
namespace ZM\Command\Module;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -19,42 +19,47 @@ class ModulePackCommand extends Command
// the name of the command (the part after "bin/console")
protected static $defaultName = 'module:pack';
protected function configure() {
$this->addArgument("module-name", InputArgument::REQUIRED);
$this->setDescription("将配置好的模块构建一个phar包");
$this->setHelp("此功能将会把炸毛框架的模块打包为\".phar\",供发布和执行。");
$this->addOption("target", "D", InputOption::VALUE_REQUIRED, "Output Directory | 指定输出目录");
protected function configure()
{
$this->addArgument('module-name', InputArgument::REQUIRED);
$this->setDescription('将配置好的模块构建一个phar包');
$this->setHelp('此功能将会把炸毛框架的模块打包为".phar",供发布和执行。');
$this->addOption('target', 'D', InputOption::VALUE_REQUIRED, 'Output Directory | 指定输出目录');
// ...
}
protected function execute(InputInterface $input, OutputInterface $output): int {
protected function execute(InputInterface $input, OutputInterface $output): int
{
ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config');
ZMConfig::setEnv($args["env"] ?? "");
if (ZMConfig::get("global") === false) {
die (zm_internal_errcode("E00007") . "Global config load failed: " . ZMConfig::$last_error . "\nPlease init first!\nSee: https://github.com/zhamao-robot/zhamao-framework/issues/37\n");
ZMConfig::setEnv($args['env'] ?? '');
if (ZMConfig::get('global') === false) {
exit(zm_internal_errcode('E00007') . 'Global config load failed: ' . ZMConfig::$last_error . "\nPlease init first!\nSee: https://github.com/zhamao-robot/zhamao-framework/issues/37\n");
}
//定义常量
include_once DataProvider::getFrameworkRootDir()."/src/ZM/global_defines.php";
include_once DataProvider::getFrameworkRootDir() . '/src/ZM/global_defines.php';
Console::init(
ZMConfig::get("global", "info_level") ?? 2,
ZMConfig::get('global', 'info_level') ?? 2,
null,
$args["log-theme"] ?? "default",
($o = ZMConfig::get("console_color")) === false ? [] : $o
$args['log-theme'] ?? 'default',
($o = ZMConfig::get('console_color')) === false ? [] : $o
);
$timezone = ZMConfig::get("global", "timezone") ?? "Asia/Shanghai";
$timezone = ZMConfig::get('global', 'timezone') ?? 'Asia/Shanghai';
date_default_timezone_set($timezone);
$list = ModuleManager::getConfiguredModules();
if (!isset($list[$input->getArgument("module-name")])) {
$output->writeln("<error>不存在模块 ".$input->getArgument("module-name")." !</error>");
if (!isset($list[$input->getArgument('module-name')])) {
$output->writeln('<error>不存在模块 ' . $input->getArgument('module-name') . ' !</error>');
return 1;
}
$result = ModuleManager::packModule($list[$input->getArgument("module-name")], $input->getOption("target"));
if ($result) Console::success("打包完成!");
else Console::error("打包失败!");
$result = ModuleManager::packModule($list[$input->getArgument('module-name')], $input->getOption('target'));
if ($result) {
Console::success('打包完成!');
} else {
Console::error('打包失败!');
}
return 0;
}
}
}