Skip to content

Commit

Permalink
修正命令行对8.1的兼容性
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Jan 7, 2022
1 parent c2a6053 commit 4611cbe
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/think/console/input/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class Option
{
// 无需传值
const VALUE_NONE = 1;
const VALUE_NONE = 1;
// 必须传值
const VALUE_REQUIRED = 2;
// 可选传值
Expand All @@ -30,13 +30,13 @@ class Option
* 选项名
* @var string
*/
private $name;
private $name = '';

/**
* 选项短名称
* @var string
*/
private $shortcut;
private $shortcut = '';

/**
* 选项类型
Expand All @@ -54,7 +54,7 @@ class Option
* 选项描述
* @var string
*/
private $description;
private $description = '';

/**
* 构造方法
Expand All @@ -76,10 +76,10 @@ public function __construct($name, $shortcut = null, $mode = null, $description
}

if (empty($shortcut)) {
$shortcut = null;
$shortcut = '';
}

if (null !== $shortcut) {
if ('' !== $shortcut) {
if (is_array($shortcut)) {
$shortcut = implode('|', $shortcut);
}
Expand Down Expand Up @@ -114,7 +114,7 @@ public function __construct($name, $shortcut = null, $mode = null, $description
* 获取短名称
* @return string
*/
public function getShortcut()
public function getShortcut(): string
{
return $this->shortcut;
}
Expand All @@ -123,7 +123,7 @@ public function getShortcut()
* 获取选项名
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}
Expand All @@ -132,7 +132,7 @@ public function getName()
* 是否可以设置值
* @return bool 类型不是 self::VALUE_NONE 的时候返回true,其他均返回false
*/
public function acceptValue()
public function acceptValue(): bool
{
return $this->isValueRequired() || $this->isValueOptional();
}
Expand All @@ -141,7 +141,7 @@ public function acceptValue()
* 是否必须
* @return bool 类型是 self::VALUE_REQUIRED 的时候返回true,其他均返回false
*/
public function isValueRequired()
public function isValueRequired(): bool
{
return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
}
Expand All @@ -150,7 +150,7 @@ public function isValueRequired()
* 是否可选
* @return bool 类型是 self::VALUE_OPTIONAL 的时候返回true,其他均返回false
*/
public function isValueOptional()
public function isValueOptional(): bool
{
return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
}
Expand All @@ -159,7 +159,7 @@ public function isValueOptional()
* 选项值是否接受数组
* @return bool 类型是 self::VALUE_IS_ARRAY 的时候返回true,其他均返回false
*/
public function isArray()
public function isArray(): bool
{
return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
}
Expand Down Expand Up @@ -199,7 +199,7 @@ public function getDefault()
* 获取描述文字
* @return string
*/
public function getDescription()
public function getDescription(): string
{
return $this->description;
}
Expand All @@ -209,7 +209,7 @@ public function getDescription()
* @param Option $option
* @return bool
*/
public function equals(Option $option)
public function equals(Option $option): bool
{
return $option->getName() === $this->getName()
&& $option->getShortcut() === $this->getShortcut()
Expand Down

0 comments on commit 4611cbe

Please sign in to comment.