代码规范化

This commit is contained in:
thinkphp
2016-08-09 10:35:06 +08:00
parent 8b147f6895
commit 131aaf1357
18 changed files with 60 additions and 75 deletions

View File

@@ -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(" <info>%s</info>%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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -30,4 +30,4 @@ class Nothing
{
// do nothing
}
}
}

View File

@@ -113,4 +113,4 @@ class Stack
{
return $this->emptyStyle;
}
}
}

View File

@@ -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));
}
}
}

View File

@@ -11,7 +11,6 @@
namespace think\console\helper\question;
class Choice extends Question
{
@@ -154,4 +153,4 @@ class Choice extends Question
return current($multiselectChoices);
};
}
}
}

View File

@@ -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;
};
}
}
}

View File

@@ -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'));
}
}
}