diff options
Diffstat (limited to 'vendor/symfony/console/Formatter')
8 files changed, 686 insertions, 0 deletions
diff --git a/vendor/symfony/console/Formatter/NullOutputFormatter.php b/vendor/symfony/console/Formatter/NullOutputFormatter.php new file mode 100644 index 0000000..5c11c76 --- /dev/null +++ b/vendor/symfony/console/Formatter/NullOutputFormatter.php | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | * This file is part of the Symfony package. | ||
| 5 | * | ||
| 6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
| 7 | * | ||
| 8 | * For the full copyright and license information, please view the LICENSE | ||
| 9 | * file that was distributed with this source code. | ||
| 10 | */ | ||
| 11 | |||
| 12 | namespace Symfony\Component\Console\Formatter; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * @author Tien Xuan Vo <tien.xuan.vo@gmail.com> | ||
| 16 | */ | ||
| 17 | final class NullOutputFormatter implements OutputFormatterInterface | ||
| 18 | { | ||
| 19 | private NullOutputFormatterStyle $style; | ||
| 20 | |||
| 21 | public function format(?string $message): ?string | ||
| 22 | { | ||
| 23 | return null; | ||
| 24 | } | ||
| 25 | |||
| 26 | public function getStyle(string $name): OutputFormatterStyleInterface | ||
| 27 | { | ||
| 28 | // to comply with the interface we must return a OutputFormatterStyleInterface | ||
| 29 | return $this->style ??= new NullOutputFormatterStyle(); | ||
| 30 | } | ||
| 31 | |||
| 32 | public function hasStyle(string $name): bool | ||
| 33 | { | ||
| 34 | return false; | ||
| 35 | } | ||
| 36 | |||
| 37 | public function isDecorated(): bool | ||
| 38 | { | ||
| 39 | return false; | ||
| 40 | } | ||
| 41 | |||
| 42 | public function setDecorated(bool $decorated): void | ||
| 43 | { | ||
| 44 | // do nothing | ||
| 45 | } | ||
| 46 | |||
| 47 | public function setStyle(string $name, OutputFormatterStyleInterface $style): void | ||
| 48 | { | ||
| 49 | // do nothing | ||
| 50 | } | ||
| 51 | } | ||
diff --git a/vendor/symfony/console/Formatter/NullOutputFormatterStyle.php b/vendor/symfony/console/Formatter/NullOutputFormatterStyle.php new file mode 100644 index 0000000..06fa6e4 --- /dev/null +++ b/vendor/symfony/console/Formatter/NullOutputFormatterStyle.php | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | * This file is part of the Symfony package. | ||
| 5 | * | ||
| 6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
| 7 | * | ||
| 8 | * For the full copyright and license information, please view the LICENSE | ||
| 9 | * file that was distributed with this source code. | ||
| 10 | */ | ||
| 11 | |||
| 12 | namespace Symfony\Component\Console\Formatter; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * @author Tien Xuan Vo <tien.xuan.vo@gmail.com> | ||
| 16 | */ | ||
| 17 | final class NullOutputFormatterStyle implements OutputFormatterStyleInterface | ||
| 18 | { | ||
| 19 | public function apply(string $text): string | ||
| 20 | { | ||
| 21 | return $text; | ||
| 22 | } | ||
| 23 | |||
| 24 | public function setBackground(?string $color): void | ||
| 25 | { | ||
| 26 | // do nothing | ||
| 27 | } | ||
| 28 | |||
| 29 | public function setForeground(?string $color): void | ||
| 30 | { | ||
| 31 | // do nothing | ||
| 32 | } | ||
| 33 | |||
| 34 | public function setOption(string $option): void | ||
| 35 | { | ||
| 36 | // do nothing | ||
| 37 | } | ||
| 38 | |||
| 39 | public function setOptions(array $options): void | ||
| 40 | { | ||
| 41 | // do nothing | ||
| 42 | } | ||
| 43 | |||
| 44 | public function unsetOption(string $option): void | ||
| 45 | { | ||
| 46 | // do nothing | ||
| 47 | } | ||
| 48 | } | ||
diff --git a/vendor/symfony/console/Formatter/OutputFormatter.php b/vendor/symfony/console/Formatter/OutputFormatter.php new file mode 100644 index 0000000..8e81e59 --- /dev/null +++ b/vendor/symfony/console/Formatter/OutputFormatter.php | |||
| @@ -0,0 +1,268 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | * This file is part of the Symfony package. | ||
| 5 | * | ||
| 6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
| 7 | * | ||
| 8 | * For the full copyright and license information, please view the LICENSE | ||
| 9 | * file that was distributed with this source code. | ||
| 10 | */ | ||
| 11 | |||
| 12 | namespace Symfony\Component\Console\Formatter; | ||
| 13 | |||
| 14 | use Symfony\Component\Console\Exception\InvalidArgumentException; | ||
| 15 | |||
| 16 | use function Symfony\Component\String\b; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * Formatter class for console output. | ||
| 20 | * | ||
| 21 | * @author Konstantin Kudryashov <ever.zet@gmail.com> | ||
| 22 | * @author Roland Franssen <franssen.roland@gmail.com> | ||
| 23 | */ | ||
| 24 | class OutputFormatter implements WrappableOutputFormatterInterface | ||
| 25 | { | ||
| 26 | private bool $decorated; | ||
| 27 | private array $styles = []; | ||
| 28 | private OutputFormatterStyleStack $styleStack; | ||
| 29 | |||
| 30 | public function __clone() | ||
| 31 | { | ||
| 32 | $this->styleStack = clone $this->styleStack; | ||
| 33 | foreach ($this->styles as $key => $value) { | ||
| 34 | $this->styles[$key] = clone $value; | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Escapes "<" and ">" special chars in given text. | ||
| 40 | */ | ||
| 41 | public static function escape(string $text): string | ||
| 42 | { | ||
| 43 | $text = preg_replace('/([^\\\\]|^)([<>])/', '$1\\\\$2', $text); | ||
| 44 | |||
| 45 | return self::escapeTrailingBackslash($text); | ||
| 46 | } | ||
| 47 | |||
| 48 | /** | ||
| 49 | * Escapes trailing "\" in given text. | ||
| 50 | * | ||
| 51 | * @internal | ||
| 52 | */ | ||
| 53 | public static function escapeTrailingBackslash(string $text): string | ||
| 54 | { | ||
| 55 | if (str_ends_with($text, '\\')) { | ||
| 56 | $len = \strlen($text); | ||
| 57 | $text = rtrim($text, '\\'); | ||
| 58 | $text = str_replace("\0", '', $text); | ||
| 59 | $text .= str_repeat("\0", $len - \strlen($text)); | ||
| 60 | } | ||
| 61 | |||
| 62 | return $text; | ||
| 63 | } | ||
| 64 | |||
| 65 | /** | ||
| 66 | * Initializes console output formatter. | ||
| 67 | * | ||
| 68 | * @param OutputFormatterStyleInterface[] $styles Array of "name => FormatterStyle" instances | ||
| 69 | */ | ||
| 70 | public function __construct(bool $decorated = false, array $styles = []) | ||
| 71 | { | ||
| 72 | $this->decorated = $decorated; | ||
| 73 | |||
| 74 | $this->setStyle('error', new OutputFormatterStyle('white', 'red')); | ||
| 75 | $this->setStyle('info', new OutputFormatterStyle('green')); | ||
| 76 | $this->setStyle('comment', new OutputFormatterStyle('yellow')); | ||
| 77 | $this->setStyle('question', new OutputFormatterStyle('black', 'cyan')); | ||
| 78 | |||
| 79 | foreach ($styles as $name => $style) { | ||
| 80 | $this->setStyle($name, $style); | ||
| 81 | } | ||
| 82 | |||
| 83 | $this->styleStack = new OutputFormatterStyleStack(); | ||
| 84 | } | ||
| 85 | |||
| 86 | public function setDecorated(bool $decorated): void | ||
| 87 | { | ||
| 88 | $this->decorated = $decorated; | ||
| 89 | } | ||
| 90 | |||
| 91 | public function isDecorated(): bool | ||
| 92 | { | ||
| 93 | return $this->decorated; | ||
| 94 | } | ||
| 95 | |||
| 96 | public function setStyle(string $name, OutputFormatterStyleInterface $style): void | ||
| 97 | { | ||
| 98 | $this->styles[strtolower($name)] = $style; | ||
| 99 | } | ||
| 100 | |||
| 101 | public function hasStyle(string $name): bool | ||
| 102 | { | ||
| 103 | return isset($this->styles[strtolower($name)]); | ||
| 104 | } | ||
| 105 | |||
| 106 | public function getStyle(string $name): OutputFormatterStyleInterface | ||
| 107 | { | ||
| 108 | if (!$this->hasStyle($name)) { | ||
| 109 | throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name)); | ||
| 110 | } | ||
| 111 | |||
| 112 | return $this->styles[strtolower($name)]; | ||
| 113 | } | ||
| 114 | |||
| 115 | public function format(?string $message): ?string | ||
| 116 | { | ||
| 117 | return $this->formatAndWrap($message, 0); | ||
| 118 | } | ||
| 119 | |||
| 120 | public function formatAndWrap(?string $message, int $width): string | ||
| 121 | { | ||
| 122 | if (null === $message) { | ||
| 123 | return ''; | ||
| 124 | } | ||
| 125 | |||
| 126 | $offset = 0; | ||
| 127 | $output = ''; | ||
| 128 | $openTagRegex = '[a-z](?:[^\\\\<>]*+ | \\\\.)*'; | ||
| 129 | $closeTagRegex = '[a-z][^<>]*+'; | ||
| 130 | $currentLineLength = 0; | ||
| 131 | preg_match_all("#<(($openTagRegex) | /($closeTagRegex)?)>#ix", $message, $matches, \PREG_OFFSET_CAPTURE); | ||
| 132 | foreach ($matches[0] as $i => $match) { | ||
| 133 | $pos = $match[1]; | ||
| 134 | $text = $match[0]; | ||
| 135 | |||
| 136 | if (0 != $pos && '\\' == $message[$pos - 1]) { | ||
| 137 | continue; | ||
| 138 | } | ||
| 139 | |||
| 140 | // add the text up to the next tag | ||
| 141 | $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset), $output, $width, $currentLineLength); | ||
| 142 | $offset = $pos + \strlen($text); | ||
| 143 | |||
| 144 | // opening tag? | ||
| 145 | if ($open = '/' !== $text[1]) { | ||
| 146 | $tag = $matches[1][$i][0]; | ||
| 147 | } else { | ||
| 148 | $tag = $matches[3][$i][0] ?? ''; | ||
| 149 | } | ||
| 150 | |||
| 151 | if (!$open && !$tag) { | ||
| 152 | // </> | ||
| 153 | $this->styleStack->pop(); | ||
| 154 | } elseif (null === $style = $this->createStyleFromString($tag)) { | ||
| 155 | $output .= $this->applyCurrentStyle($text, $output, $width, $currentLineLength); | ||
| 156 | } elseif ($open) { | ||
| 157 | $this->styleStack->push($style); | ||
| 158 | } else { | ||
| 159 | $this->styleStack->pop($style); | ||
| 160 | } | ||
| 161 | } | ||
| 162 | |||
| 163 | $output .= $this->applyCurrentStyle(substr($message, $offset), $output, $width, $currentLineLength); | ||
| 164 | |||
| 165 | return strtr($output, ["\0" => '\\', '\\<' => '<', '\\>' => '>']); | ||
| 166 | } | ||
| 167 | |||
| 168 | public function getStyleStack(): OutputFormatterStyleStack | ||
| 169 | { | ||
| 170 | return $this->styleStack; | ||
| 171 | } | ||
| 172 | |||
| 173 | /** | ||
| 174 | * Tries to create new style instance from string. | ||
| 175 | */ | ||
| 176 | private function createStyleFromString(string $string): ?OutputFormatterStyleInterface | ||
| 177 | { | ||
| 178 | if (isset($this->styles[$string])) { | ||
| 179 | return $this->styles[$string]; | ||
| 180 | } | ||
| 181 | |||
| 182 | if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, \PREG_SET_ORDER)) { | ||
| 183 | return null; | ||
| 184 | } | ||
| 185 | |||
| 186 | $style = new OutputFormatterStyle(); | ||
| 187 | foreach ($matches as $match) { | ||
| 188 | array_shift($match); | ||
| 189 | $match[0] = strtolower($match[0]); | ||
| 190 | |||
| 191 | if ('fg' == $match[0]) { | ||
| 192 | $style->setForeground(strtolower($match[1])); | ||
| 193 | } elseif ('bg' == $match[0]) { | ||
| 194 | $style->setBackground(strtolower($match[1])); | ||
| 195 | } elseif ('href' === $match[0]) { | ||
| 196 | $url = preg_replace('{\\\\([<>])}', '$1', $match[1]); | ||
| 197 | $style->setHref($url); | ||
| 198 | } elseif ('options' === $match[0]) { | ||
| 199 | preg_match_all('([^,;]+)', strtolower($match[1]), $options); | ||
| 200 | $options = array_shift($options); | ||
| 201 | foreach ($options as $option) { | ||
| 202 | $style->setOption($option); | ||
| 203 | } | ||
| 204 | } else { | ||
| 205 | return null; | ||
| 206 | } | ||
| 207 | } | ||
| 208 | |||
| 209 | return $style; | ||
| 210 | } | ||
| 211 | |||
| 212 | /** | ||
| 213 | * Applies current style from stack to text, if must be applied. | ||
| 214 | */ | ||
| 215 | private function applyCurrentStyle(string $text, string $current, int $width, int &$currentLineLength): string | ||
| 216 | { | ||
| 217 | if ('' === $text) { | ||
| 218 | return ''; | ||
| 219 | } | ||
| 220 | |||
| 221 | if (!$width) { | ||
| 222 | return $this->isDecorated() ? $this->styleStack->getCurrent()->apply($text) : $text; | ||
| 223 | } | ||
| 224 | |||
| 225 | if (!$currentLineLength && '' !== $current) { | ||
| 226 | $text = ltrim($text); | ||
| 227 | } | ||
| 228 | |||
| 229 | if ($currentLineLength) { | ||
| 230 | $prefix = substr($text, 0, $i = $width - $currentLineLength)."\n"; | ||
| 231 | $text = substr($text, $i); | ||
| 232 | } else { | ||
| 233 | $prefix = ''; | ||
| 234 | } | ||
| 235 | |||
| 236 | preg_match('~(\\n)$~', $text, $matches); | ||
| 237 | $text = $prefix.$this->addLineBreaks($text, $width); | ||
| 238 | $text = rtrim($text, "\n").($matches[1] ?? ''); | ||
| 239 | |||
| 240 | if (!$currentLineLength && '' !== $current && !str_ends_with($current, "\n")) { | ||
| 241 | $text = "\n".$text; | ||
| 242 | } | ||
| 243 | |||
| 244 | $lines = explode("\n", $text); | ||
| 245 | |||
| 246 | foreach ($lines as $line) { | ||
| 247 | $currentLineLength += \strlen($line); | ||
| 248 | if ($width <= $currentLineLength) { | ||
| 249 | $currentLineLength = 0; | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | if ($this->isDecorated()) { | ||
| 254 | foreach ($lines as $i => $line) { | ||
| 255 | $lines[$i] = $this->styleStack->getCurrent()->apply($line); | ||
| 256 | } | ||
| 257 | } | ||
| 258 | |||
| 259 | return implode("\n", $lines); | ||
| 260 | } | ||
| 261 | |||
| 262 | private function addLineBreaks(string $text, int $width): string | ||
| 263 | { | ||
| 264 | $encoding = mb_detect_encoding($text, null, true) ?: 'UTF-8'; | ||
| 265 | |||
| 266 | return b($text)->toCodePointString($encoding)->wordwrap($width, "\n", true)->toByteString($encoding); | ||
| 267 | } | ||
| 268 | } | ||
diff --git a/vendor/symfony/console/Formatter/OutputFormatterInterface.php b/vendor/symfony/console/Formatter/OutputFormatterInterface.php new file mode 100644 index 0000000..947347f --- /dev/null +++ b/vendor/symfony/console/Formatter/OutputFormatterInterface.php | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | * This file is part of the Symfony package. | ||
| 5 | * | ||
| 6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
| 7 | * | ||
| 8 | * For the full copyright and license information, please view the LICENSE | ||
| 9 | * file that was distributed with this source code. | ||
| 10 | */ | ||
| 11 | |||
| 12 | namespace Symfony\Component\Console\Formatter; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * Formatter interface for console output. | ||
| 16 | * | ||
| 17 | * @author Konstantin Kudryashov <ever.zet@gmail.com> | ||
| 18 | */ | ||
| 19 | interface OutputFormatterInterface | ||
| 20 | { | ||
| 21 | /** | ||
| 22 | * Sets the decorated flag. | ||
| 23 | */ | ||
| 24 | public function setDecorated(bool $decorated): void; | ||
| 25 | |||
| 26 | /** | ||
| 27 | * Whether the output will decorate messages. | ||
| 28 | */ | ||
| 29 | public function isDecorated(): bool; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Sets a new style. | ||
| 33 | */ | ||
| 34 | public function setStyle(string $name, OutputFormatterStyleInterface $style): void; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Checks if output formatter has style with specified name. | ||
| 38 | */ | ||
| 39 | public function hasStyle(string $name): bool; | ||
| 40 | |||
| 41 | /** | ||
| 42 | * Gets style options from style with specified name. | ||
| 43 | * | ||
| 44 | * @throws \InvalidArgumentException When style isn't defined | ||
| 45 | */ | ||
| 46 | public function getStyle(string $name): OutputFormatterStyleInterface; | ||
| 47 | |||
| 48 | /** | ||
| 49 | * Formats a message according to the given styles. | ||
| 50 | */ | ||
| 51 | public function format(?string $message): ?string; | ||
| 52 | } | ||
diff --git a/vendor/symfony/console/Formatter/OutputFormatterStyle.php b/vendor/symfony/console/Formatter/OutputFormatterStyle.php new file mode 100644 index 0000000..20a65b5 --- /dev/null +++ b/vendor/symfony/console/Formatter/OutputFormatterStyle.php | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | * This file is part of the Symfony package. | ||
| 5 | * | ||
| 6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
| 7 | * | ||
| 8 | * For the full copyright and license information, please view the LICENSE | ||
| 9 | * file that was distributed with this source code. | ||
| 10 | */ | ||
| 11 | |||
| 12 | namespace Symfony\Component\Console\Formatter; | ||
| 13 | |||
| 14 | use Symfony\Component\Console\Color; | ||
| 15 | |||
| 16 | /** | ||
| 17 | * Formatter style class for defining styles. | ||
| 18 | * | ||
| 19 | * @author Konstantin Kudryashov <ever.zet@gmail.com> | ||
| 20 | */ | ||
| 21 | class OutputFormatterStyle implements OutputFormatterStyleInterface | ||
| 22 | { | ||
| 23 | private Color $color; | ||
| 24 | private string $foreground; | ||
| 25 | private string $background; | ||
| 26 | private array $options; | ||
| 27 | private ?string $href = null; | ||
| 28 | private bool $handlesHrefGracefully; | ||
| 29 | |||
| 30 | /** | ||
| 31 | * Initializes output formatter style. | ||
| 32 | * | ||
| 33 | * @param string|null $foreground The style foreground color name | ||
| 34 | * @param string|null $background The style background color name | ||
| 35 | */ | ||
| 36 | public function __construct(?string $foreground = null, ?string $background = null, array $options = []) | ||
| 37 | { | ||
| 38 | $this->color = new Color($this->foreground = $foreground ?: '', $this->background = $background ?: '', $this->options = $options); | ||
| 39 | } | ||
| 40 | |||
| 41 | public function setForeground(?string $color): void | ||
| 42 | { | ||
| 43 | $this->color = new Color($this->foreground = $color ?: '', $this->background, $this->options); | ||
| 44 | } | ||
| 45 | |||
| 46 | public function setBackground(?string $color): void | ||
| 47 | { | ||
| 48 | $this->color = new Color($this->foreground, $this->background = $color ?: '', $this->options); | ||
| 49 | } | ||
| 50 | |||
| 51 | public function setHref(string $url): void | ||
| 52 | { | ||
| 53 | $this->href = $url; | ||
| 54 | } | ||
| 55 | |||
| 56 | public function setOption(string $option): void | ||
| 57 | { | ||
| 58 | $this->options[] = $option; | ||
| 59 | $this->color = new Color($this->foreground, $this->background, $this->options); | ||
| 60 | } | ||
| 61 | |||
| 62 | public function unsetOption(string $option): void | ||
| 63 | { | ||
| 64 | $pos = array_search($option, $this->options); | ||
| 65 | if (false !== $pos) { | ||
| 66 | unset($this->options[$pos]); | ||
| 67 | } | ||
| 68 | |||
| 69 | $this->color = new Color($this->foreground, $this->background, $this->options); | ||
| 70 | } | ||
| 71 | |||
| 72 | public function setOptions(array $options): void | ||
| 73 | { | ||
| 74 | $this->color = new Color($this->foreground, $this->background, $this->options = $options); | ||
| 75 | } | ||
| 76 | |||
| 77 | public function apply(string $text): string | ||
| 78 | { | ||
| 79 | $this->handlesHrefGracefully ??= 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR') | ||
| 80 | && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100) | ||
| 81 | && !isset($_SERVER['IDEA_INITIAL_DIRECTORY']); | ||
| 82 | |||
| 83 | if (null !== $this->href && $this->handlesHrefGracefully) { | ||
| 84 | $text = "\033]8;;$this->href\033\\$text\033]8;;\033\\"; | ||
| 85 | } | ||
| 86 | |||
| 87 | return $this->color->apply($text); | ||
| 88 | } | ||
| 89 | } | ||
diff --git a/vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php b/vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php new file mode 100644 index 0000000..0374192 --- /dev/null +++ b/vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | * This file is part of the Symfony package. | ||
| 5 | * | ||
| 6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
| 7 | * | ||
| 8 | * For the full copyright and license information, please view the LICENSE | ||
| 9 | * file that was distributed with this source code. | ||
| 10 | */ | ||
| 11 | |||
| 12 | namespace Symfony\Component\Console\Formatter; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * Formatter style interface for defining styles. | ||
| 16 | * | ||
| 17 | * @author Konstantin Kudryashov <ever.zet@gmail.com> | ||
| 18 | */ | ||
| 19 | interface OutputFormatterStyleInterface | ||
| 20 | { | ||
| 21 | /** | ||
| 22 | * Sets style foreground color. | ||
| 23 | */ | ||
| 24 | public function setForeground(?string $color): void; | ||
| 25 | |||
| 26 | /** | ||
| 27 | * Sets style background color. | ||
| 28 | */ | ||
| 29 | public function setBackground(?string $color): void; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Sets some specific style option. | ||
| 33 | */ | ||
| 34 | public function setOption(string $option): void; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Unsets some specific style option. | ||
| 38 | */ | ||
| 39 | public function unsetOption(string $option): void; | ||
| 40 | |||
| 41 | /** | ||
| 42 | * Sets multiple style options at once. | ||
| 43 | */ | ||
| 44 | public function setOptions(array $options): void; | ||
| 45 | |||
| 46 | /** | ||
| 47 | * Applies the style to a given text. | ||
| 48 | */ | ||
| 49 | public function apply(string $text): string; | ||
| 50 | } | ||
diff --git a/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php b/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php new file mode 100644 index 0000000..4985213 --- /dev/null +++ b/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | * This file is part of the Symfony package. | ||
| 5 | * | ||
| 6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
| 7 | * | ||
| 8 | * For the full copyright and license information, please view the LICENSE | ||
| 9 | * file that was distributed with this source code. | ||
| 10 | */ | ||
| 11 | |||
| 12 | namespace Symfony\Component\Console\Formatter; | ||
| 13 | |||
| 14 | use Symfony\Component\Console\Exception\InvalidArgumentException; | ||
| 15 | use Symfony\Contracts\Service\ResetInterface; | ||
| 16 | |||
| 17 | /** | ||
| 18 | * @author Jean-François Simon <contact@jfsimon.fr> | ||
| 19 | */ | ||
| 20 | class OutputFormatterStyleStack implements ResetInterface | ||
| 21 | { | ||
| 22 | /** | ||
| 23 | * @var OutputFormatterStyleInterface[] | ||
| 24 | */ | ||
| 25 | private array $styles = []; | ||
| 26 | |||
| 27 | private OutputFormatterStyleInterface $emptyStyle; | ||
| 28 | |||
| 29 | public function __construct(?OutputFormatterStyleInterface $emptyStyle = null) | ||
| 30 | { | ||
| 31 | $this->emptyStyle = $emptyStyle ?? new OutputFormatterStyle(); | ||
| 32 | $this->reset(); | ||
| 33 | } | ||
| 34 | |||
| 35 | /** | ||
| 36 | * Resets stack (ie. empty internal arrays). | ||
| 37 | */ | ||
| 38 | public function reset(): void | ||
| 39 | { | ||
| 40 | $this->styles = []; | ||
| 41 | } | ||
| 42 | |||
| 43 | /** | ||
| 44 | * Pushes a style in the stack. | ||
| 45 | */ | ||
| 46 | public function push(OutputFormatterStyleInterface $style): void | ||
| 47 | { | ||
| 48 | $this->styles[] = $style; | ||
| 49 | } | ||
| 50 | |||
| 51 | /** | ||
| 52 | * Pops a style from the stack. | ||
| 53 | * | ||
| 54 | * @throws InvalidArgumentException When style tags incorrectly nested | ||
| 55 | */ | ||
| 56 | public function pop(?OutputFormatterStyleInterface $style = null): OutputFormatterStyleInterface | ||
| 57 | { | ||
| 58 | if (!$this->styles) { | ||
| 59 | return $this->emptyStyle; | ||
| 60 | } | ||
| 61 | |||
| 62 | if (null === $style) { | ||
| 63 | return array_pop($this->styles); | ||
| 64 | } | ||
| 65 | |||
| 66 | foreach (array_reverse($this->styles, true) as $index => $stackedStyle) { | ||
| 67 | if ($style->apply('') === $stackedStyle->apply('')) { | ||
| 68 | $this->styles = \array_slice($this->styles, 0, $index); | ||
| 69 | |||
| 70 | return $stackedStyle; | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | throw new InvalidArgumentException('Incorrectly nested style tag found.'); | ||
| 75 | } | ||
| 76 | |||
| 77 | /** | ||
| 78 | * Computes current style with stacks top codes. | ||
| 79 | */ | ||
| 80 | public function getCurrent(): OutputFormatterStyleInterface | ||
| 81 | { | ||
| 82 | if (!$this->styles) { | ||
| 83 | return $this->emptyStyle; | ||
| 84 | } | ||
| 85 | |||
| 86 | return $this->styles[\count($this->styles) - 1]; | ||
| 87 | } | ||
| 88 | |||
| 89 | /** | ||
| 90 | * @return $this | ||
| 91 | */ | ||
| 92 | public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle): static | ||
| 93 | { | ||
| 94 | $this->emptyStyle = $emptyStyle; | ||
| 95 | |||
| 96 | return $this; | ||
| 97 | } | ||
| 98 | |||
| 99 | public function getEmptyStyle(): OutputFormatterStyleInterface | ||
| 100 | { | ||
| 101 | return $this->emptyStyle; | ||
| 102 | } | ||
| 103 | } | ||
diff --git a/vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php b/vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php new file mode 100644 index 0000000..412d997 --- /dev/null +++ b/vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | * This file is part of the Symfony package. | ||
| 5 | * | ||
| 6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
| 7 | * | ||
| 8 | * For the full copyright and license information, please view the LICENSE | ||
| 9 | * file that was distributed with this source code. | ||
| 10 | */ | ||
| 11 | |||
| 12 | namespace Symfony\Component\Console\Formatter; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * Formatter interface for console output that supports word wrapping. | ||
| 16 | * | ||
| 17 | * @author Roland Franssen <franssen.roland@gmail.com> | ||
| 18 | */ | ||
| 19 | interface WrappableOutputFormatterInterface extends OutputFormatterInterface | ||
| 20 | { | ||
| 21 | /** | ||
| 22 | * Formats a message according to the given styles, wrapping at `$width` (0 means no wrapping). | ||
| 23 | */ | ||
| 24 | public function formatAndWrap(?string $message, int $width): string; | ||
| 25 | } | ||
