diff options
author | Frédéric Guillot <fred@kanboard.net> | 2017-12-15 11:24:35 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2017-12-15 11:55:42 -0800 |
commit | a93b8e10f5954be0853eec693c13e84c4bd9e6f2 (patch) | |
tree | eda5de9494b819235616e8623bb3393e9cc373af /vendor/symfony/console/Formatter | |
parent | 2c72a283f2d51034f85f4e2ca8b194d304a3c433 (diff) |
Kanboard requires at least PHP 5.6 now
Diffstat (limited to 'vendor/symfony/console/Formatter')
5 files changed, 44 insertions, 58 deletions
diff --git a/vendor/symfony/console/Formatter/OutputFormatter.php b/vendor/symfony/console/Formatter/OutputFormatter.php index 56cd5e56..3f3ebfbc 100644 --- a/vendor/symfony/console/Formatter/OutputFormatter.php +++ b/vendor/symfony/console/Formatter/OutputFormatter.php @@ -35,10 +35,25 @@ class OutputFormatter implements OutputFormatterInterface { $text = preg_replace('/([^\\\\]?)</', '$1\\<', $text); + return self::escapeTrailingBackslash($text); + } + + /** + * Escapes trailing "\" in given text. + * + * @param string $text Text to escape + * + * @return string Escaped text + * + * @internal + */ + public static function escapeTrailingBackslash($text) + { if ('\\' === substr($text, -1)) { $len = strlen($text); $text = rtrim($text, '\\'); - $text .= str_repeat('<<', $len - strlen($text)); + $text = str_replace("\0", '', $text); + $text .= str_repeat("\0", $len - strlen($text)); } return $text; @@ -67,9 +82,7 @@ class OutputFormatter implements OutputFormatterInterface } /** - * Sets the decorated flag. - * - * @param bool $decorated Whether to decorate the messages or not + * {@inheritdoc} */ public function setDecorated($decorated) { @@ -77,9 +90,7 @@ class OutputFormatter implements OutputFormatterInterface } /** - * Gets the decorated flag. - * - * @return bool true if the output will decorate messages, false otherwise + * {@inheritdoc} */ public function isDecorated() { @@ -87,10 +98,7 @@ class OutputFormatter implements OutputFormatterInterface } /** - * Sets a new style. - * - * @param string $name The style name - * @param OutputFormatterStyleInterface $style The style instance + * {@inheritdoc} */ public function setStyle($name, OutputFormatterStyleInterface $style) { @@ -98,11 +106,7 @@ class OutputFormatter implements OutputFormatterInterface } /** - * Checks if output formatter has style with specified name. - * - * @param string $name - * - * @return bool + * {@inheritdoc} */ public function hasStyle($name) { @@ -110,13 +114,7 @@ class OutputFormatter implements OutputFormatterInterface } /** - * Gets style options from style with specified name. - * - * @param string $name - * - * @return OutputFormatterStyleInterface - * - * @throws InvalidArgumentException When style isn't defined + * {@inheritdoc} */ public function getStyle($name) { @@ -128,18 +126,14 @@ class OutputFormatter implements OutputFormatterInterface } /** - * Formats a message according to the given styles. - * - * @param string $message The message to style - * - * @return string The styled message + * {@inheritdoc} */ public function format($message) { $message = (string) $message; $offset = 0; $output = ''; - $tagRegex = '[a-z][a-z0-9_=;-]*+'; + $tagRegex = '[a-z][a-z0-9,_=;-]*+'; preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE); foreach ($matches[0] as $i => $match) { $pos = $match[1]; @@ -174,8 +168,8 @@ class OutputFormatter implements OutputFormatterInterface $output .= $this->applyCurrentStyle(substr($message, $offset)); - if (false !== strpos($output, '<<')) { - return strtr($output, array('\\<' => '<', '<<' => '\\')); + if (false !== strpos($output, "\0")) { + return strtr($output, array("\0" => '\\', '\\<' => '<')); } return str_replace('\\<', '<', $output); @@ -194,7 +188,7 @@ class OutputFormatter implements OutputFormatterInterface * * @param string $string * - * @return OutputFormatterStyle|bool false if string is not format string + * @return OutputFormatterStyle|false false if string is not format string */ private function createStyleFromString($string) { @@ -202,7 +196,7 @@ class OutputFormatter implements OutputFormatterInterface return $this->styles[$string]; } - if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) { + if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) { return false; } @@ -214,12 +208,20 @@ class OutputFormatter implements OutputFormatterInterface $style->setForeground($match[1]); } elseif ('bg' == $match[0]) { $style->setBackground($match[1]); - } else { - try { - $style->setOption($match[1]); - } catch (\InvalidArgumentException $e) { - return false; + } elseif ('options' === $match[0]) { + preg_match_all('([^,;]+)', $match[1], $options); + $options = array_shift($options); + foreach ($options as $option) { + try { + $style->setOption($option); + } catch (\InvalidArgumentException $e) { + @trigger_error(sprintf('Unknown style options are deprecated since version 3.2 and will be removed in 4.0. Exception "%s".', $e->getMessage()), E_USER_DEPRECATED); + + return false; + } } + } else { + return false; } } diff --git a/vendor/symfony/console/Formatter/OutputFormatterInterface.php b/vendor/symfony/console/Formatter/OutputFormatterInterface.php index 5a52ba09..281e240c 100644 --- a/vendor/symfony/console/Formatter/OutputFormatterInterface.php +++ b/vendor/symfony/console/Formatter/OutputFormatterInterface.php @@ -55,6 +55,8 @@ interface OutputFormatterInterface * @param string $name * * @return OutputFormatterStyleInterface + * + * @throws \InvalidArgumentException When style isn't defined */ public function getStyle($name); diff --git a/vendor/symfony/console/Formatter/OutputFormatterStyle.php b/vendor/symfony/console/Formatter/OutputFormatterStyle.php index c7c6b4a0..7ada54f4 100644 --- a/vendor/symfony/console/Formatter/OutputFormatterStyle.php +++ b/vendor/symfony/console/Formatter/OutputFormatterStyle.php @@ -172,9 +172,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface } /** - * Sets multiple style options at once. - * - * @param array $options + * {@inheritdoc} */ public function setOptions(array $options) { diff --git a/vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php b/vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php index c36fda80..4c7dc413 100644 --- a/vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php +++ b/vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php @@ -48,8 +48,6 @@ interface OutputFormatterStyleInterface /** * Sets multiple style options at once. - * - * @param array $options */ public function setOptions(array $options); diff --git a/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php b/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php index e5d14ea3..bf0beb70 100644 --- a/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php +++ b/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php @@ -23,16 +23,8 @@ class OutputFormatterStyleStack */ private $styles; - /** - * @var OutputFormatterStyleInterface - */ private $emptyStyle; - /** - * Constructor. - * - * @param OutputFormatterStyleInterface|null $emptyStyle - */ public function __construct(OutputFormatterStyleInterface $emptyStyle = null) { $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle(); @@ -49,8 +41,6 @@ class OutputFormatterStyleStack /** * Pushes a style in the stack. - * - * @param OutputFormatterStyleInterface $style */ public function push(OutputFormatterStyleInterface $style) { @@ -60,8 +50,6 @@ class OutputFormatterStyleStack /** * Pops a style from the stack. * - * @param OutputFormatterStyleInterface|null $style - * * @return OutputFormatterStyleInterface * * @throws InvalidArgumentException When style tags incorrectly nested @@ -102,9 +90,7 @@ class OutputFormatterStyleStack } /** - * @param OutputFormatterStyleInterface $emptyStyle - * - * @return OutputFormatterStyleStack + * @return $this */ public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle) { |