mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
格式化代码
This commit is contained in:
@@ -38,7 +38,7 @@ class Console
|
|||||||
private $runningCommand;
|
private $runningCommand;
|
||||||
|
|
||||||
private $catchExceptions = true;
|
private $catchExceptions = true;
|
||||||
private $autoExit = true;
|
private $autoExit = true;
|
||||||
private $definition;
|
private $definition;
|
||||||
private $helperSet;
|
private $helperSet;
|
||||||
private $terminalDimensions;
|
private $terminalDimensions;
|
||||||
@@ -90,7 +90,7 @@ class Console
|
|||||||
|
|
||||||
$exitCode = $e->getCode();
|
$exitCode = $e->getCode();
|
||||||
if (is_numeric($exitCode)) {
|
if (is_numeric($exitCode)) {
|
||||||
$exitCode = (int) $exitCode;
|
$exitCode = (int)$exitCode;
|
||||||
if (0 === $exitCode) {
|
if (0 === $exitCode) {
|
||||||
$exitCode = 1;
|
$exitCode = 1;
|
||||||
}
|
}
|
||||||
@@ -112,8 +112,8 @@ class Console
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行指令
|
* 执行指令
|
||||||
* @param ConsoleInput $input
|
* @param ConsoleInput $input
|
||||||
* @param Output $output
|
* @param Output $output
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function doRun(ConsoleInput $input, Output $output)
|
public function doRun(ConsoleInput $input, Output $output)
|
||||||
@@ -201,7 +201,7 @@ class Console
|
|||||||
*/
|
*/
|
||||||
public function setCatchExceptions($boolean)
|
public function setCatchExceptions($boolean)
|
||||||
{
|
{
|
||||||
$this->catchExceptions = (bool) $boolean;
|
$this->catchExceptions = (bool)$boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,7 +211,7 @@ class Console
|
|||||||
*/
|
*/
|
||||||
public function setAutoExit($boolean)
|
public function setAutoExit($boolean)
|
||||||
{
|
{
|
||||||
$this->autoExit = (bool) $boolean;
|
$this->autoExit = (bool)$boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -379,7 +379,7 @@ class Console
|
|||||||
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) {
|
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) {
|
||||||
return preg_quote($matches[1]) . '[^:]*';
|
return preg_quote($matches[1]) . '[^:]*';
|
||||||
}, $namespace);
|
}, $namespace);
|
||||||
$namespaces = preg_grep('{^' . $expr . '}', $allNamespaces);
|
$namespaces = preg_grep('{^' . $expr . '}', $allNamespaces);
|
||||||
|
|
||||||
if (empty($namespaces)) {
|
if (empty($namespaces)) {
|
||||||
$message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
|
$message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
|
||||||
@@ -417,7 +417,7 @@ class Console
|
|||||||
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) {
|
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) {
|
||||||
return preg_quote($matches[1]) . '[^:]*';
|
return preg_quote($matches[1]) . '[^:]*';
|
||||||
}, $name);
|
}, $name);
|
||||||
$commands = preg_grep('{^' . $expr . '}', $allCommands);
|
$commands = preg_grep('{^' . $expr . '}', $allCommands);
|
||||||
|
|
||||||
if (empty($commands) || count(preg_grep('{^' . $expr . '$}', $commands)) < 1) {
|
if (empty($commands) || count(preg_grep('{^' . $expr . '$}', $commands)) < 1) {
|
||||||
if (false !== $pos = strrpos($name, ':')) {
|
if (false !== $pos = strrpos($name, ':')) {
|
||||||
@@ -606,19 +606,19 @@ class Console
|
|||||||
|
|
||||||
if ('\\' === DS) {
|
if ('\\' === DS) {
|
||||||
if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
|
if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
|
||||||
return [(int) $matches[1], (int) $matches[2]];
|
return [(int)$matches[1], (int)$matches[2]];
|
||||||
}
|
}
|
||||||
if (preg_match('/^(\d+)x(\d+)$/', $this->getConsoleMode(), $matches)) {
|
if (preg_match('/^(\d+)x(\d+)$/', $this->getConsoleMode(), $matches)) {
|
||||||
return [(int) $matches[1], (int) $matches[2]];
|
return [(int)$matches[1], (int)$matches[2]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sttyString = $this->getSttyColumns()) {
|
if ($sttyString = $this->getSttyColumns()) {
|
||||||
if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
|
if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
|
||||||
return [(int) $matches[2], (int) $matches[1]];
|
return [(int)$matches[2], (int)$matches[1]];
|
||||||
}
|
}
|
||||||
if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
|
if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
|
||||||
return [(int) $matches[2], (int) $matches[1]];
|
return [(int)$matches[2], (int)$matches[1]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,8 +640,8 @@ class Console
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置基于用户的参数和选项的输入和输出实例。
|
* 配置基于用户的参数和选项的输入和输出实例。
|
||||||
* @param ConsoleInput $input 输入实例
|
* @param ConsoleInput $input 输入实例
|
||||||
* @param Output $output 输出实例
|
* @param Output $output 输出实例
|
||||||
*/
|
*/
|
||||||
protected function configureIO(ConsoleInput $input, Output $output)
|
protected function configureIO(ConsoleInput $input, Output $output)
|
||||||
{
|
{
|
||||||
@@ -663,18 +663,11 @@ class Console
|
|||||||
if (true === $input->hasParameterOption(['--quiet', '-q'])) {
|
if (true === $input->hasParameterOption(['--quiet', '-q'])) {
|
||||||
$output->setVerbosity(Output::VERBOSITY_QUIET);
|
$output->setVerbosity(Output::VERBOSITY_QUIET);
|
||||||
} else {
|
} else {
|
||||||
if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3')
|
if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || $input->getParameterOption('--verbose') === 3) {
|
||||||
|| $input->getParameterOption('--verbose') === 3
|
|
||||||
) {
|
|
||||||
$output->setVerbosity(Output::VERBOSITY_DEBUG);
|
$output->setVerbosity(Output::VERBOSITY_DEBUG);
|
||||||
} elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2')
|
} elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || $input->getParameterOption('--verbose') === 2) {
|
||||||
|| $input->getParameterOption('--verbose') === 2
|
|
||||||
) {
|
|
||||||
$output->setVerbosity(Output::VERBOSITY_VERY_VERBOSE);
|
$output->setVerbosity(Output::VERBOSITY_VERY_VERBOSE);
|
||||||
} elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1')
|
} elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) {
|
||||||
|| $input->hasParameterOption('--verbose')
|
|
||||||
|| $input->getParameterOption('--verbose')
|
|
||||||
) {
|
|
||||||
$output->setVerbosity(Output::VERBOSITY_VERBOSE);
|
$output->setVerbosity(Output::VERBOSITY_VERBOSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -682,9 +675,9 @@ class Console
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行指令
|
* 执行指令
|
||||||
* @param Command $command 指令实例
|
* @param Command $command 指令实例
|
||||||
* @param ConsoleInput $input 输入实例
|
* @param ConsoleInput $input 输入实例
|
||||||
* @param Output $output 输出实例
|
* @param Output $output 输出实例
|
||||||
* @return int
|
* @return int
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ class Error
|
|||||||
if (!$e instanceof \Exception) {
|
if (!$e instanceof \Exception) {
|
||||||
$e = new ThrowableError($e);
|
$e = new ThrowableError($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::getExceptionHandler()->report($e);
|
self::getExceptionHandler()->report($e);
|
||||||
if(IS_CLI){
|
if (IS_CLI) {
|
||||||
self::getExceptionHandler()->renderForConsole(new ConsoleOutput, $e);
|
self::getExceptionHandler()->renderForConsole(new ConsoleOutput, $e);
|
||||||
}else{
|
} else {
|
||||||
self::getExceptionHandler()->render($e)->send();
|
self::getExceptionHandler()->render($e)->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,12 +77,7 @@ class Error
|
|||||||
{
|
{
|
||||||
if (!is_null($error = error_get_last()) && self::isFatal($error['type'])) {
|
if (!is_null($error = error_get_last()) && self::isFatal($error['type'])) {
|
||||||
// 将错误信息托管至think\ErrorException
|
// 将错误信息托管至think\ErrorException
|
||||||
$exception = new ErrorException(
|
$exception = new ErrorException($error['type'], $error['message'], $error['file'], $error['line']);
|
||||||
$error['type'],
|
|
||||||
$error['message'],
|
|
||||||
$error['file'],
|
|
||||||
$error['line']
|
|
||||||
);
|
|
||||||
|
|
||||||
self::appException($exception);
|
self::appException($exception);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user