From 131aaf135752ca7bd4db47b746b0afbec8955323 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 9 Aug 2016 10:35:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/console/Command.php | 11 ++++----- library/think/console/Input.php | 19 +++++---------- library/think/console/Output.php | 6 ++--- library/think/console/command/Build.php | 2 +- library/think/console/input/Argument.php | 2 +- library/think/console/input/Definition.php | 2 +- library/think/console/input/Option.php | 12 +++++----- library/think/console/output/Descriptor.php | 16 ++++++------- library/think/console/output/Formatter.php | 6 ++--- .../console/output/descriptor/Console.php | 5 ++-- .../think/console/output/driver/Buffer.php | 5 ++-- .../think/console/output/driver/Console.php | 23 ++++++++----------- .../think/console/output/driver/Nothing.php | 2 +- .../think/console/output/formatter/Stack.php | 2 +- .../think/console/output/formatter/Style.php | 4 ++-- .../think/console/output/question/Choice.php | 3 +-- .../console/output/question/Confirmation.php | 7 +++--- .../console/output/question/Question.php | 8 +++---- 18 files changed, 60 insertions(+), 75 deletions(-) diff --git a/library/think/console/Command.php b/library/think/console/Command.php index fd3a16d5..57b0d8fe 100644 --- a/library/think/console/Command.php +++ b/library/think/console/Command.php @@ -22,7 +22,7 @@ class Command /** @var Console */ private $console; private $name; - private $aliases = []; + private $aliases = []; private $definition; private $help; private $description; @@ -30,8 +30,8 @@ class Command private $consoleDefinitionMerged = false; private $consoleDefinitionMergedWithArgs = false; private $code; - private $synopsis = []; - private $usages = []; + private $synopsis = []; + private $usages = []; /** @var Input */ protected $input; @@ -172,7 +172,7 @@ class Command $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 string @@ -465,4 +464,4 @@ class Command throw new \InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); } } -} \ No newline at end of file +} diff --git a/library/think/console/Input.php b/library/think/console/Input.php index 889ee39e..269196eb 100644 --- a/library/think/console/Input.php +++ b/library/think/console/Input.php @@ -11,8 +11,8 @@ namespace think\console; -use think\console\input\Definition; use think\console\input\Argument; +use think\console\input\Definition; use think\console\input\Option; class Input @@ -38,7 +38,6 @@ class Input private $tokens; private $parsed; - public function __construct($argv = null) { if (null === $argv) { @@ -52,7 +51,6 @@ class Input $this->definition = new Definition(); } - protected function setTokens(array $tokens) { $this->tokens = $tokens; @@ -71,7 +69,6 @@ class Input $this->parse(); } - /** * 解析参数 */ @@ -94,7 +91,6 @@ class Input } } - /** * 解析短选项 * @param string $token 当前的指令. @@ -178,7 +174,6 @@ class Input } } - /** * 添加一个短选项的值 * @param string $shortcut 短名称 @@ -260,7 +255,6 @@ class Input return null; } - /** * 检查原始参数是否包含某个值 * @param string|array $values 需要检查的值 @@ -268,7 +262,7 @@ class Input */ public function hasParameterOption($values) { - $values = (array)$values; + $values = (array) $values; foreach ($this->tokens as $token) { foreach ($values as $value) { @@ -289,7 +283,7 @@ class Input */ public function getParameterOption($values, $default = false) { - $values = (array)$values; + $values = (array) $values; $tokens = $this->tokens; while (0 < count($tokens)) { @@ -309,7 +303,6 @@ class Input return $default; } - /** * 验证输入 * @throws \RuntimeException @@ -336,7 +329,7 @@ class Input */ 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]); } - if ($token && $token[0] !== '-') { + if ($token && '-' !== $token[0]) { return $this->escapeToken($token); } @@ -468,4 +461,4 @@ class Input return implode(' ', $tokens); } -} \ No newline at end of file +} diff --git a/library/think/console/Output.php b/library/think/console/Output.php index 38fe9051..c4983c79 100644 --- a/library/think/console/Output.php +++ b/library/think/console/Output.php @@ -64,7 +64,7 @@ class Output */ public function setVerbosity($level) { - $this->verbosity = (int)$level; + $this->verbosity = (int) $level; } /** @@ -99,7 +99,7 @@ class Output { $descriptor = new Descriptor(); $options = array_merge([ - 'raw_text' => false + 'raw_text' => false, ], $options); $descriptor->describe($this, $object, $options); @@ -114,4 +114,4 @@ class Output } } -} \ No newline at end of file +} diff --git a/library/think/console/command/Build.php b/library/think/console/command/Build.php index 0523ac93..39806c3f 100644 --- a/library/think/console/command/Build.php +++ b/library/think/console/command/Build.php @@ -27,7 +27,7 @@ class Build extends Command $this->setName('build') ->setDefinition([ 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'); } diff --git a/library/think/console/input/Argument.php b/library/think/console/input/Argument.php index 843f928c..16223bbe 100644 --- a/library/think/console/input/Argument.php +++ b/library/think/console/input/Argument.php @@ -112,4 +112,4 @@ class Argument { return $this->description; } -} \ No newline at end of file +} diff --git a/library/think/console/input/Definition.php b/library/think/console/input/Definition.php index 4df9389a..c71977ec 100644 --- a/library/think/console/input/Definition.php +++ b/library/think/console/input/Definition.php @@ -372,4 +372,4 @@ class Definition return implode(' ', $elements); } -} \ No newline at end of file +} diff --git a/library/think/console/input/Option.php b/library/think/console/input/Option.php index 4406b278..e5707c9a 100644 --- a/library/think/console/input/Option.php +++ b/library/think/console/input/Option.php @@ -181,10 +181,10 @@ class Option public function equals(Option $option) { return $option->getName() === $this->getName() - && $option->getShortcut() === $this->getShortcut() - && $option->getDefault() === $this->getDefault() - && $option->isArray() === $this->isArray() - && $option->isValueRequired() === $this->isValueRequired() - && $option->isValueOptional() === $this->isValueOptional(); + && $option->getShortcut() === $this->getShortcut() + && $option->getDefault() === $this->getDefault() + && $option->isArray() === $this->isArray() + && $option->isValueRequired() === $this->isValueRequired() + && $option->isValueOptional() === $this->isValueOptional(); } -} \ No newline at end of file +} diff --git a/library/think/console/output/Descriptor.php b/library/think/console/output/Descriptor.php index fff31e6b..6d98d53c 100644 --- a/library/think/console/output/Descriptor.php +++ b/library/think/console/output/Descriptor.php @@ -11,12 +11,12 @@ 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\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; class Descriptor @@ -254,7 +254,7 @@ class Descriptor $this->writeText("\n"); $spacingWidth = $width - strlen($name); $this->writeText(sprintf(" %s%s%s", $name, str_repeat(' ', $spacingWidth), $description->getCommand($name) - ->getDescription()), $options); + ->getDescription()), $options); } } @@ -268,7 +268,7 @@ class Descriptor private function writeText($content, array $options = []) { $this->write(isset($options['raw_text']) - && $options['raw_text'] ? strip_tags($content) : $content, isset($options['raw_output']) ? !$options['raw_output'] : true); + && $options['raw_text'] ? strip_tags($content) : $content, isset($options['raw_output']) ? !$options['raw_output'] : true); } /** @@ -316,4 +316,4 @@ class Descriptor return $totalWidth; } -} \ No newline at end of file +} diff --git a/library/think/console/output/Formatter.php b/library/think/console/output/Formatter.php index d3ffc659..2266457c 100644 --- a/library/think/console/output/Formatter.php +++ b/library/think/console/output/Formatter.php @@ -10,8 +10,8 @@ // +---------------------------------------------------------------------- namespace think\console\output; -use think\console\output\formatter\Style; use think\console\output\formatter\Stack as StyleStack; +use think\console\output\formatter\Style; class Formatter { @@ -51,7 +51,7 @@ class Formatter */ public function setDecorated($decorated) { - $this->decorated = (bool)$decorated; + $this->decorated = (bool) $decorated; } /** @@ -195,4 +195,4 @@ class Formatter { return $this->isDecorated() && strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text; } -} \ No newline at end of file +} diff --git a/library/think/console/output/descriptor/Console.php b/library/think/console/output/descriptor/Console.php index 60867ec7..4648b68e 100644 --- a/library/think/console/output/descriptor/Console.php +++ b/library/think/console/output/descriptor/Console.php @@ -11,9 +11,8 @@ namespace think\console\output\descriptor; - -use think\console\Command; use think\Console as ThinkConsole; +use think\console\Command; class Console { @@ -147,4 +146,4 @@ class Console return $namespacedCommands; } -} \ No newline at end of file +} diff --git a/library/think/console/output/driver/Buffer.php b/library/think/console/output/driver/Buffer.php index a720732a..96c94217 100644 --- a/library/think/console/output/driver/Buffer.php +++ b/library/think/console/output/driver/Buffer.php @@ -11,7 +11,6 @@ namespace think\console\output\driver; - use think\console\Output; class Buffer @@ -35,7 +34,7 @@ class Buffer public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL) { - $messages = (array)$messages; + $messages = (array) $messages; foreach ($messages as $message) { $this->buffer .= $message; @@ -50,4 +49,4 @@ class Buffer // do nothing } -} \ No newline at end of file +} diff --git a/library/think/console/output/driver/Console.php b/library/think/console/output/driver/Console.php index 7134b3f1..84226ac9 100644 --- a/library/think/console/output/driver/Console.php +++ b/library/think/console/output/driver/Console.php @@ -28,7 +28,6 @@ class Console /** @var Output */ private $output; - public function __construct(Output $output) { $this->output = $output; @@ -44,7 +43,7 @@ class Console return; } - $messages = (array)$messages; + $messages = (array) $messages; foreach ($messages as $message) { switch ($type) { @@ -132,7 +131,6 @@ class Console } - /** * 获取终端宽度 * @return int|null @@ -167,19 +165,19 @@ class Console if ('\\' === DS) { 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)) { - return [(int)$matches[1], (int)$matches[2]]; + return [(int) $matches[1], (int) $matches[2]]; } } if ($sttyString = $this->getSttyColumns()) { 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)) { - 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 resource */ @@ -354,13 +351,13 @@ class Console { if (DIRECTORY_SEPARATOR === '\\') { return - 0 >= version_compare('10.0.10586', PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD) - || false !== getenv('ANSICON') - || 'ON' === getenv('ConEmuANSI') - || 'xterm' === getenv('TERM'); + 0 >= version_compare('10.0.10586', PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD) + || false !== getenv('ANSICON') + || 'ON' === getenv('ConEmuANSI') + || 'xterm' === getenv('TERM'); } return function_exists('posix_isatty') && @posix_isatty($stream); } -} \ No newline at end of file +} diff --git a/library/think/console/output/driver/Nothing.php b/library/think/console/output/driver/Nothing.php index 673521d7..9a55f777 100644 --- a/library/think/console/output/driver/Nothing.php +++ b/library/think/console/output/driver/Nothing.php @@ -30,4 +30,4 @@ class Nothing { // do nothing } -} \ No newline at end of file +} diff --git a/library/think/console/output/formatter/Stack.php b/library/think/console/output/formatter/Stack.php index 0335d6c0..4864a3f2 100644 --- a/library/think/console/output/formatter/Stack.php +++ b/library/think/console/output/formatter/Stack.php @@ -113,4 +113,4 @@ class Stack { return $this->emptyStyle; } -} \ No newline at end of file +} diff --git a/library/think/console/output/formatter/Style.php b/library/think/console/output/formatter/Style.php index 1ffbd811..d9b09998 100644 --- a/library/think/console/output/formatter/Style.php +++ b/library/think/console/output/formatter/Style.php @@ -34,7 +34,7 @@ class Style 'cyan' => ['set' => 46, 'unset' => 49], 'white' => ['set' => 47, 'unset' => 49], ]; - private static $availableOptions = [ + private static $availableOptions = [ 'bold' => ['set' => 1, 'unset' => 22], 'underscore' => ['set' => 4, 'unset' => 24], 'blink' => ['set' => 5, 'unset' => 25], @@ -186,4 +186,4 @@ class Style return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes)); } -} \ No newline at end of file +} diff --git a/library/think/console/output/question/Choice.php b/library/think/console/output/question/Choice.php index 8badcd7b..89217139 100644 --- a/library/think/console/output/question/Choice.php +++ b/library/think/console/output/question/Choice.php @@ -11,7 +11,6 @@ namespace think\console\helper\question; - class Choice extends Question { @@ -154,4 +153,4 @@ class Choice extends Question return current($multiselectChoices); }; } -} \ No newline at end of file +} diff --git a/library/think/console/output/question/Confirmation.php b/library/think/console/output/question/Confirmation.php index e67fd439..0cfd2eec 100644 --- a/library/think/console/output/question/Confirmation.php +++ b/library/think/console/output/question/Confirmation.php @@ -11,7 +11,6 @@ namespace think\console\helper\question; - class Confirmation extends Question { @@ -25,7 +24,7 @@ class Confirmation extends Question */ public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i') { - parent::__construct($question, (bool)$default); + parent::__construct($question, (bool) $default); $this->trueAnswerRegex = $trueAnswerRegex; $this->setNormalizer($this->getDefaultNormalizer()); @@ -45,7 +44,7 @@ class Confirmation extends Question return $answer; } - $answerIsTrue = (bool)preg_match($regex, $answer); + $answerIsTrue = (bool) preg_match($regex, $answer); if (false === $default) { return $answer && $answerIsTrue; } @@ -53,4 +52,4 @@ class Confirmation extends Question return !$answer || $answerIsTrue; }; } -} \ No newline at end of file +} diff --git a/library/think/console/output/question/Question.php b/library/think/console/output/question/Question.php index 2bacf7b2..80fddad9 100644 --- a/library/think/console/output/question/Question.php +++ b/library/think/console/output/question/Question.php @@ -72,7 +72,7 @@ class Question throw new \LogicException('A hidden question cannot use the autocompleter.'); } - $this->hidden = (bool)$hidden; + $this->hidden = (bool) $hidden; return $this; } @@ -93,7 +93,7 @@ class Question */ public function setHiddenFallback($fallback) { - $this->hiddenFallback = (bool)$fallback; + $this->hiddenFallback = (bool) $fallback; return $this; } @@ -206,6 +206,6 @@ class Question protected function isAssoc($array) { - return (bool)count(array_filter(array_keys($array), 'is_string')); + return (bool) count(array_filter(array_keys($array), 'is_string')); } -} \ No newline at end of file +}