fix:更新已知bug,优化代码

This commit is contained in:
Ying
2022-11-28 19:11:12 +08:00
parent f6aee95cfc
commit 9445b206a2
1378 changed files with 53759 additions and 20789 deletions

View File

@@ -40,8 +40,8 @@ use Symfony\Component\Console\Exception\RuntimeException;
*/
class ArgvInput extends Input
{
private $tokens;
private $parsed;
private array $tokens;
private array $parsed;
public function __construct(array $argv = null, InputDefinition $definition = null)
{
@@ -199,7 +199,7 @@ class ArgvInput extends Input
*
* @throws RuntimeException When option given doesn't exist
*/
private function addShortOption(string $shortcut, $value)
private function addShortOption(string $shortcut, mixed $value)
{
if (!$this->definition->hasShortcut($shortcut)) {
throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
@@ -213,7 +213,7 @@ class ArgvInput extends Input
*
* @throws RuntimeException When option given doesn't exist
*/
private function addLongOption(string $name, $value)
private function addLongOption(string $name, mixed $value)
{
if (!$this->definition->hasOption($name)) {
if (!$this->definition->hasNegation($name)) {
@@ -266,7 +266,7 @@ class ArgvInput extends Input
/**
* {@inheritdoc}
*/
public function getFirstArgument()
public function getFirstArgument(): ?string
{
$isOption = false;
foreach ($this->tokens as $i => $token) {
@@ -301,7 +301,7 @@ class ArgvInput extends Input
/**
* {@inheritdoc}
*/
public function hasParameterOption($values, bool $onlyParams = false)
public function hasParameterOption(string|array $values, bool $onlyParams = false): bool
{
$values = (array) $values;
@@ -326,7 +326,7 @@ class ArgvInput extends Input
/**
* {@inheritdoc}
*/
public function getParameterOption($values, $default = false, bool $onlyParams = false)
public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false): mixed
{
$values = (array) $values;
$tokens = $this->tokens;
@@ -356,10 +356,8 @@ class ArgvInput extends Input
/**
* Returns a stringified representation of the args passed to the command.
*
* @return string
*/
public function __toString()
public function __toString(): string
{
$tokens = array_map(function ($token) {
if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {