mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
代码规范化
This commit is contained in:
@@ -172,7 +172,7 @@ class Command
|
|||||||
$statusCode = $this->execute($input, $output);
|
$statusCode = $this->execute($input, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_numeric($statusCode) ? (int)$statusCode : 0;
|
return is_numeric($statusCode) ? (int) $statusCode : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -362,7 +362,6 @@ class Command
|
|||||||
return $this->help;
|
return $this->help;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述信息
|
* 描述信息
|
||||||
* @return string
|
* @return string
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
namespace think\console;
|
namespace think\console;
|
||||||
|
|
||||||
use think\console\input\Definition;
|
|
||||||
use think\console\input\Argument;
|
use think\console\input\Argument;
|
||||||
|
use think\console\input\Definition;
|
||||||
use think\console\input\Option;
|
use think\console\input\Option;
|
||||||
|
|
||||||
class Input
|
class Input
|
||||||
@@ -38,7 +38,6 @@ class Input
|
|||||||
private $tokens;
|
private $tokens;
|
||||||
private $parsed;
|
private $parsed;
|
||||||
|
|
||||||
|
|
||||||
public function __construct($argv = null)
|
public function __construct($argv = null)
|
||||||
{
|
{
|
||||||
if (null === $argv) {
|
if (null === $argv) {
|
||||||
@@ -52,7 +51,6 @@ class Input
|
|||||||
$this->definition = new Definition();
|
$this->definition = new Definition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function setTokens(array $tokens)
|
protected function setTokens(array $tokens)
|
||||||
{
|
{
|
||||||
$this->tokens = $tokens;
|
$this->tokens = $tokens;
|
||||||
@@ -71,7 +69,6 @@ class Input
|
|||||||
$this->parse();
|
$this->parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析参数
|
* 解析参数
|
||||||
*/
|
*/
|
||||||
@@ -94,7 +91,6 @@ class Input
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析短选项
|
* 解析短选项
|
||||||
* @param string $token 当前的指令.
|
* @param string $token 当前的指令.
|
||||||
@@ -178,7 +174,6 @@ class Input
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加一个短选项的值
|
* 添加一个短选项的值
|
||||||
* @param string $shortcut 短名称
|
* @param string $shortcut 短名称
|
||||||
@@ -260,7 +255,6 @@ class Input
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查原始参数是否包含某个值
|
* 检查原始参数是否包含某个值
|
||||||
* @param string|array $values 需要检查的值
|
* @param string|array $values 需要检查的值
|
||||||
@@ -268,7 +262,7 @@ class Input
|
|||||||
*/
|
*/
|
||||||
public function hasParameterOption($values)
|
public function hasParameterOption($values)
|
||||||
{
|
{
|
||||||
$values = (array)$values;
|
$values = (array) $values;
|
||||||
|
|
||||||
foreach ($this->tokens as $token) {
|
foreach ($this->tokens as $token) {
|
||||||
foreach ($values as $value) {
|
foreach ($values as $value) {
|
||||||
@@ -289,7 +283,7 @@ class Input
|
|||||||
*/
|
*/
|
||||||
public function getParameterOption($values, $default = false)
|
public function getParameterOption($values, $default = false)
|
||||||
{
|
{
|
||||||
$values = (array)$values;
|
$values = (array) $values;
|
||||||
$tokens = $this->tokens;
|
$tokens = $this->tokens;
|
||||||
|
|
||||||
while (0 < count($tokens)) {
|
while (0 < count($tokens)) {
|
||||||
@@ -309,7 +303,6 @@ class Input
|
|||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证输入
|
* 验证输入
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
@@ -336,7 +329,7 @@ class Input
|
|||||||
*/
|
*/
|
||||||
public function setInteractive($interactive)
|
public function setInteractive($interactive)
|
||||||
{
|
{
|
||||||
$this->interactive = (bool)$interactive;
|
$this->interactive = (bool) $interactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -459,7 +452,7 @@ class Input
|
|||||||
return $match[1] . $this->escapeToken($match[2]);
|
return $match[1] . $this->escapeToken($match[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($token && $token[0] !== '-') {
|
if ($token && '-' !== $token[0]) {
|
||||||
return $this->escapeToken($token);
|
return $this->escapeToken($token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class Output
|
|||||||
*/
|
*/
|
||||||
public function setVerbosity($level)
|
public function setVerbosity($level)
|
||||||
{
|
{
|
||||||
$this->verbosity = (int)$level;
|
$this->verbosity = (int) $level;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,7 +99,7 @@ class Output
|
|||||||
{
|
{
|
||||||
$descriptor = new Descriptor();
|
$descriptor = new Descriptor();
|
||||||
$options = array_merge([
|
$options = array_merge([
|
||||||
'raw_text' => false
|
'raw_text' => false,
|
||||||
], $options);
|
], $options);
|
||||||
|
|
||||||
$descriptor->describe($this, $object, $options);
|
$descriptor->describe($this, $object, $options);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class Build extends Command
|
|||||||
$this->setName('build')
|
$this->setName('build')
|
||||||
->setDefinition([
|
->setDefinition([
|
||||||
new Option('config', null, Option::VALUE_OPTIONAL, "build.php path"),
|
new Option('config', null, Option::VALUE_OPTIONAL, "build.php path"),
|
||||||
new Option('module', null, Option::VALUE_OPTIONAL, "module name")
|
new Option('module', null, Option::VALUE_OPTIONAL, "module name"),
|
||||||
])
|
])
|
||||||
->setDescription('Build Application Dirs');
|
->setDescription('Build Application Dirs');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
|
|
||||||
namespace think\console\output;
|
namespace think\console\output;
|
||||||
|
|
||||||
use think\console\Output;
|
|
||||||
use think\console\input\Argument as InputArgument;
|
|
||||||
use think\console\input\Option as InputOption;
|
|
||||||
use think\console\input\Definition as InputDefinition;
|
|
||||||
use think\console\Command;
|
|
||||||
use think\Console;
|
use think\Console;
|
||||||
|
use think\console\Command;
|
||||||
|
use think\console\input\Argument as InputArgument;
|
||||||
|
use think\console\input\Definition as InputDefinition;
|
||||||
|
use think\console\input\Option as InputOption;
|
||||||
|
use think\console\Output;
|
||||||
use think\console\output\descriptor\Console as ConsoleDescription;
|
use think\console\output\descriptor\Console as ConsoleDescription;
|
||||||
|
|
||||||
class Descriptor
|
class Descriptor
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
namespace think\console\output;
|
namespace think\console\output;
|
||||||
|
|
||||||
use think\console\output\formatter\Style;
|
|
||||||
use think\console\output\formatter\Stack as StyleStack;
|
use think\console\output\formatter\Stack as StyleStack;
|
||||||
|
use think\console\output\formatter\Style;
|
||||||
|
|
||||||
class Formatter
|
class Formatter
|
||||||
{
|
{
|
||||||
@@ -51,7 +51,7 @@ class Formatter
|
|||||||
*/
|
*/
|
||||||
public function setDecorated($decorated)
|
public function setDecorated($decorated)
|
||||||
{
|
{
|
||||||
$this->decorated = (bool)$decorated;
|
$this->decorated = (bool) $decorated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,9 +11,8 @@
|
|||||||
|
|
||||||
namespace think\console\output\descriptor;
|
namespace think\console\output\descriptor;
|
||||||
|
|
||||||
|
|
||||||
use think\console\Command;
|
|
||||||
use think\Console as ThinkConsole;
|
use think\Console as ThinkConsole;
|
||||||
|
use think\console\Command;
|
||||||
|
|
||||||
class Console
|
class Console
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace think\console\output\driver;
|
namespace think\console\output\driver;
|
||||||
|
|
||||||
|
|
||||||
use think\console\Output;
|
use think\console\Output;
|
||||||
|
|
||||||
class Buffer
|
class Buffer
|
||||||
@@ -35,7 +34,7 @@ class Buffer
|
|||||||
|
|
||||||
public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL)
|
public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL)
|
||||||
{
|
{
|
||||||
$messages = (array)$messages;
|
$messages = (array) $messages;
|
||||||
|
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
$this->buffer .= $message;
|
$this->buffer .= $message;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ class Console
|
|||||||
/** @var Output */
|
/** @var Output */
|
||||||
private $output;
|
private $output;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(Output $output)
|
public function __construct(Output $output)
|
||||||
{
|
{
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
@@ -44,7 +43,7 @@ class Console
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$messages = (array)$messages;
|
$messages = (array) $messages;
|
||||||
|
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
@@ -132,7 +131,6 @@ class Console
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取终端宽度
|
* 获取终端宽度
|
||||||
* @return int|null
|
* @return int|null
|
||||||
@@ -167,19 +165,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->getMode(), $matches)) {
|
if (preg_match('/^(\d+)x(\d+)$/', $this->getMode(), $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]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +305,6 @@ class Console
|
|||||||
return false === $this->isRunningOS400();
|
return false === $this->isRunningOS400();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return resource
|
* @return resource
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace think\console\helper\question;
|
namespace think\console\helper\question;
|
||||||
|
|
||||||
|
|
||||||
class Choice extends Question
|
class Choice extends Question
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace think\console\helper\question;
|
namespace think\console\helper\question;
|
||||||
|
|
||||||
|
|
||||||
class Confirmation extends Question
|
class Confirmation extends Question
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ class Confirmation extends Question
|
|||||||
*/
|
*/
|
||||||
public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
|
public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
|
||||||
{
|
{
|
||||||
parent::__construct($question, (bool)$default);
|
parent::__construct($question, (bool) $default);
|
||||||
|
|
||||||
$this->trueAnswerRegex = $trueAnswerRegex;
|
$this->trueAnswerRegex = $trueAnswerRegex;
|
||||||
$this->setNormalizer($this->getDefaultNormalizer());
|
$this->setNormalizer($this->getDefaultNormalizer());
|
||||||
@@ -45,7 +44,7 @@ class Confirmation extends Question
|
|||||||
return $answer;
|
return $answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
$answerIsTrue = (bool)preg_match($regex, $answer);
|
$answerIsTrue = (bool) preg_match($regex, $answer);
|
||||||
if (false === $default) {
|
if (false === $default) {
|
||||||
return $answer && $answerIsTrue;
|
return $answer && $answerIsTrue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class Question
|
|||||||
throw new \LogicException('A hidden question cannot use the autocompleter.');
|
throw new \LogicException('A hidden question cannot use the autocompleter.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->hidden = (bool)$hidden;
|
$this->hidden = (bool) $hidden;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ class Question
|
|||||||
*/
|
*/
|
||||||
public function setHiddenFallback($fallback)
|
public function setHiddenFallback($fallback)
|
||||||
{
|
{
|
||||||
$this->hiddenFallback = (bool)$fallback;
|
$this->hiddenFallback = (bool) $fallback;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -206,6 +206,6 @@ class Question
|
|||||||
|
|
||||||
protected function isAssoc($array)
|
protected function isAssoc($array)
|
||||||
{
|
{
|
||||||
return (bool)count(array_filter(array_keys($array), 'is_string'));
|
return (bool) count(array_filter(array_keys($array), 'is_string'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user