fix:更新已知bug,优化代码
This commit is contained in:
@@ -21,8 +21,8 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
{
|
||||
private $decorated;
|
||||
private $styles = [];
|
||||
private bool $decorated;
|
||||
private array $styles = [];
|
||||
private $styleStack;
|
||||
|
||||
public function __clone()
|
||||
@@ -35,10 +35,8 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
|
||||
/**
|
||||
* Escapes "<" and ">" special chars in given text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function escape(string $text)
|
||||
public static function escape(string $text): string
|
||||
{
|
||||
$text = preg_replace('/([^\\\\]|^)([<>])/', '$1\\\\$2', $text);
|
||||
|
||||
@@ -94,7 +92,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isDecorated()
|
||||
public function isDecorated(): bool
|
||||
{
|
||||
return $this->decorated;
|
||||
}
|
||||
@@ -110,7 +108,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasStyle(string $name)
|
||||
public function hasStyle(string $name): bool
|
||||
{
|
||||
return isset($this->styles[strtolower($name)]);
|
||||
}
|
||||
@@ -118,7 +116,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStyle(string $name)
|
||||
public function getStyle(string $name): OutputFormatterStyleInterface
|
||||
{
|
||||
if (!$this->hasStyle($name)) {
|
||||
throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name));
|
||||
@@ -130,7 +128,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(?string $message)
|
||||
public function format(?string $message): ?string
|
||||
{
|
||||
return $this->formatAndWrap($message, 0);
|
||||
}
|
||||
@@ -186,10 +184,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
return strtr($output, ["\0" => '\\', '\\<' => '<', '\\>' => '>']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return OutputFormatterStyleStack
|
||||
*/
|
||||
public function getStyleStack()
|
||||
public function getStyleStack(): OutputFormatterStyleStack
|
||||
{
|
||||
return $this->styleStack;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user