Do some code quality check and fix #126

This commit is contained in:
crazywhalecc
2023-08-20 19:51:45 +08:00
committed by Jerry Ma
parent 9c57ed6439
commit c8fa767576
104 changed files with 1040 additions and 785 deletions

View File

@@ -39,11 +39,11 @@ const BUILD_STATUS_ALREADY = 1;
const BUILD_STATUS_FAILED = 2;
// build target type
const BUILD_TARGET_NONE = 0;
const BUILD_TARGET_CLI = 1;
const BUILD_TARGET_MICRO = 2;
const BUILD_TARGET_FPM = 4;
const BUILD_TARGET_ALL = 7;
const BUILD_TARGET_NONE = 0; // no target
const BUILD_TARGET_CLI = 1; // build cli
const BUILD_TARGET_MICRO = 2; // build micro
const BUILD_TARGET_FPM = 4; // build fpm
const BUILD_TARGET_ALL = 7; // build all
// doctor error fix policy
const FIX_POLICY_DIE = 1; // die directly
@@ -57,9 +57,4 @@ const PKGCONF_PATCH_LIBDIR = 4;
const PKGCONF_PATCH_INCLUDEDIR = 8;
const PKGCONF_PATCH_ALL = 15;
// Custom download type
const DOWNLOAD_TYPE_NONE = 0;
const DOWNLOAD_TYPE_ARCHIVE = 1;
const DOWNLOAD_TYPE_DIR = 2;
ConsoleLogger::$date_format = 'H:i:s';

View File

@@ -8,17 +8,15 @@ use SPC\util\UnixShell;
use ZM\Logger\ConsoleLogger;
/**
* 判断传入的数组是否为关联数组
*
* @param mixed $array
* Judge if an array is an associative array
*/
function is_assoc_array($array): bool
function is_assoc_array(mixed $array): bool
{
return is_array($array) && (!empty($array) && array_keys($array) !== range(0, count($array) - 1));
}
/**
* 助手方法,返回一个 Logger 实例
* Return a logger instance
*/
function logger(): LoggerInterface
{
@@ -30,7 +28,8 @@ function logger(): LoggerInterface
}
/**
* @param string $arch 架构名称转换为 GNU 标准形式
* Transfer architecture name to gnu triplet
*
* @throws WrongUsageException
*/
function arch2gnu(string $arch): string
@@ -50,7 +49,7 @@ function quote(string $str, string $quote = '"'): string
}
/**
* 将不同系统环境的编译使用工具集的文件夹名称进行一个返回
* Get Family name of current OS
*
* @throws WrongUsageException
*/
@@ -66,7 +65,7 @@ function osfamily2dir(): string
}
/**
* 执行shell直接输出在终端出现错误抛出异常
* Execute the shell command, and the output will be directly printed in the terminal. If there is an error, an exception will be thrown
*
* @throws \SPC\exception\RuntimeException
*/
@@ -92,12 +91,9 @@ function f_passthru(string $cmd): ?bool
}
/**
* 执行命令,不输出内容,返回执行结果和内容
*
* @param mixed $output
* @param mixed $result_code
* Execute a command, return the output and result code
*/
function f_exec(string $command, &$output, &$result_code): bool|string
function f_exec(string $command, mixed &$output, mixed &$result_code): bool|string
{
logger()->debug('Running command (no output) : ' . $command);
return exec($command, $output, $result_code);

View File

@@ -1,7 +1,5 @@
<?php
/** @noinspection PhpComposerExtensionStubsInspection */
declare(strict_types=1);
assert(function_exists('bcscale'));

View File

@@ -1,7 +1,5 @@
<?php
/** @noinspection PhpComposerExtensionStubsInspection */
declare(strict_types=1);
assert(class_exists('\\DOMDocument'));