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,5 +1,6 @@
<?php
declare(strict_types=1);
namespace ZM\Command;
@@ -14,49 +15,53 @@ class CheckConfigCommand extends Command
private $need_update = false;
protected function configure() {
$this->setDescription("检查配置文件是否和框架当前版本有更新");
protected function configure()
{
$this->setDescription('检查配置文件是否和框架当前版本有更新');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
protected function execute(InputInterface $input, OutputInterface $output): int
{
if (LOAD_MODE !== 1) {
$output->writeln("<error>仅限在Composer依赖模式中使用此命令</error>");
$output->writeln('<error>仅限在Composer依赖模式中使用此命令</error>');
return 1;
}
$current_cfg = getcwd() . "/config/";
$remote_cfg = include_once FRAMEWORK_ROOT_DIR . "/config/global.php";
if (file_exists($current_cfg . "global.php")) {
$this->check($remote_cfg, "global.php", $output);
$current_cfg = getcwd() . '/config/';
$remote_cfg = include_once FRAMEWORK_ROOT_DIR . '/config/global.php';
if (file_exists($current_cfg . 'global.php')) {
$this->check($remote_cfg, 'global.php', $output);
}
if (file_exists($current_cfg . "global.development.php")) {
$this->check($remote_cfg, "global.development.php", $output);
if (file_exists($current_cfg . 'global.development.php')) {
$this->check($remote_cfg, 'global.development.php', $output);
}
if (file_exists($current_cfg . "global.staging.php")) {
$this->check($remote_cfg, "global.staging.php", $output);
if (file_exists($current_cfg . 'global.staging.php')) {
$this->check($remote_cfg, 'global.staging.php', $output);
}
if (file_exists($current_cfg . "global.production.php")) {
$this->check($remote_cfg, "global.production.php", $output);
if (file_exists($current_cfg . 'global.production.php')) {
$this->check($remote_cfg, 'global.production.php', $output);
}
if ($this->need_update === true) {
$output->writeln("<comment>有配置文件需要更新,详情见文档 `https://framework.zhamao.xin/update/config`</comment>");
$output->writeln('<comment>有配置文件需要更新,详情见文档 `https://framework.zhamao.xin/update/config`</comment>');
} else {
$output->writeln("<info>配置文件暂无更新!</info>");
$output->writeln('<info>配置文件暂无更新!</info>');
}
return 0;
}
/**
* @noinspection PhpIncludeInspection
* @param mixed $remote
* @param mixed $local
*/
private function check($remote, $local, OutputInterface $out) {
$local_file = include_once WORKING_DIR . "/config/".$local;
private function check($remote, $local, OutputInterface $out)
{
$local_file = include_once WORKING_DIR . '/config/' . $local;
if ($local_file === true) {
$local_file = ZMConfig::get("global");
$local_file = ZMConfig::get('global');
}
foreach($remote as $k => $v) {
foreach ($remote as $k => $v) {
if (!isset($local_file[$k])) {
$out->writeln("<comment>配置文件 ".$local . " 需要更新!(当前配置文件缺少 `$k` 字段配置)</comment>");
$out->writeln('<comment>配置文件 ' . $local . " 需要更新!(当前配置文件缺少 `{$k}` 字段配置)</comment>");
$this->need_update = true;
}
}