Aggiornato Composer
This commit is contained in:
@@ -27,7 +27,7 @@ final class NullOutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setBackground(string $color = null): void
|
||||
public function setBackground(?string $color = null): void
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
@@ -35,7 +35,7 @@ final class NullOutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setForeground(string $color = null): void
|
||||
public function setForeground(?string $color = null): void
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace Symfony\Component\Console\Formatter;
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
|
||||
use function Symfony\Component\String\b;
|
||||
|
||||
/**
|
||||
* Formatter class for console output.
|
||||
*
|
||||
@@ -258,7 +260,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
}
|
||||
|
||||
preg_match('~(\\n)$~', $text, $matches);
|
||||
$text = $prefix.preg_replace('~([^\\n]{'.$width.'})\\ *~', "\$1\n", $text);
|
||||
$text = $prefix.$this->addLineBreaks($text, $width);
|
||||
$text = rtrim($text, "\n").($matches[1] ?? '');
|
||||
|
||||
if (!$currentLineLength && '' !== $current && "\n" !== substr($current, -1)) {
|
||||
@@ -282,4 +284,11 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
private function addLineBreaks(string $text, int $width): string
|
||||
{
|
||||
$encoding = mb_detect_encoding($text, null, true) ?: 'UTF-8';
|
||||
|
||||
return b($text)->toCodePointString($encoding)->wordwrap($width, "\n", true)->toByteString($encoding);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
* @param string|null $foreground The style foreground color name
|
||||
* @param string|null $background The style background color name
|
||||
*/
|
||||
public function __construct(string $foreground = null, string $background = null, array $options = [])
|
||||
public function __construct(?string $foreground = null, ?string $background = null, array $options = [])
|
||||
{
|
||||
$this->color = new Color($this->foreground = $foreground ?: '', $this->background = $background ?: '', $this->options = $options);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setForeground(string $color = null)
|
||||
public function setForeground(?string $color = null)
|
||||
{
|
||||
$this->color = new Color($this->foreground = $color ?: '', $this->background, $this->options);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setBackground(string $color = null)
|
||||
public function setBackground(?string $color = null)
|
||||
{
|
||||
$this->color = new Color($this->foreground, $this->background = $color ?: '', $this->options);
|
||||
}
|
||||
@@ -96,7 +96,8 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
{
|
||||
if (null === $this->handlesHrefGracefully) {
|
||||
$this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
|
||||
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100);
|
||||
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100)
|
||||
&& !isset($_SERVER['IDEA_INITIAL_DIRECTORY']);
|
||||
}
|
||||
|
||||
if (null !== $this->href && $this->handlesHrefGracefully) {
|
||||
|
||||
@@ -21,12 +21,12 @@ interface OutputFormatterStyleInterface
|
||||
/**
|
||||
* Sets style foreground color.
|
||||
*/
|
||||
public function setForeground(string $color = null);
|
||||
public function setForeground(?string $color = null);
|
||||
|
||||
/**
|
||||
* Sets style background color.
|
||||
*/
|
||||
public function setBackground(string $color = null);
|
||||
public function setBackground(?string $color = null);
|
||||
|
||||
/**
|
||||
* Sets some specific style option.
|
||||
|
||||
@@ -26,7 +26,7 @@ class OutputFormatterStyleStack implements ResetInterface
|
||||
|
||||
private $emptyStyle;
|
||||
|
||||
public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
|
||||
public function __construct(?OutputFormatterStyleInterface $emptyStyle = null)
|
||||
{
|
||||
$this->emptyStyle = $emptyStyle ?? new OutputFormatterStyle();
|
||||
$this->reset();
|
||||
@@ -55,7 +55,7 @@ class OutputFormatterStyleStack implements ResetInterface
|
||||
*
|
||||
* @throws InvalidArgumentException When style tags incorrectly nested
|
||||
*/
|
||||
public function pop(OutputFormatterStyleInterface $style = null)
|
||||
public function pop(?OutputFormatterStyleInterface $style = null)
|
||||
{
|
||||
if (empty($this->styles)) {
|
||||
return $this->emptyStyle;
|
||||
|
||||
Reference in New Issue
Block a user