Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -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);
$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];
@@ -151,7 +145,7 @@ class OutputFormatter implements OutputFormatterInterface
// add the text up to the next tag
$output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
$offset = $pos + strlen($text);
$offset = $pos + \strlen($text);
// opening tag?
if ($open = '/' != $text[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 Symfony 3.2 and will be removed in 4.0. Exception "%s".', $e->getMessage()), E_USER_DEPRECATED);
return false;
}
}
} else {
return false;
}
}
@@ -235,6 +237,6 @@ class OutputFormatter implements OutputFormatterInterface
*/
private function applyCurrentStyle($text)
{
return $this->isDecorated() && strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
}
}

View File

@@ -55,6 +55,8 @@ interface OutputFormatterInterface
* @param string $name
*
* @return OutputFormatterStyleInterface
*
* @throws \InvalidArgumentException When style isn't defined
*/
public function getStyle($name);

View File

@@ -69,7 +69,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
if (null !== $background) {
$this->setBackground($background);
}
if (count($options)) {
if (\count($options)) {
$this->setOptions($options);
}
}
@@ -143,7 +143,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
));
}
if (!in_array(static::$availableOptions[$option], $this->options)) {
if (!\in_array(static::$availableOptions[$option], $this->options)) {
$this->options[] = static::$availableOptions[$option];
}
}
@@ -172,9 +172,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
}
/**
* Sets multiple style options at once.
*
* @param array $options
* {@inheritdoc}
*/
public function setOptions(array $options)
{
@@ -205,14 +203,14 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
$setCodes[] = $this->background['set'];
$unsetCodes[] = $this->background['unset'];
}
if (count($this->options)) {
if (\count($this->options)) {
foreach ($this->options as $option) {
$setCodes[] = $option['set'];
$unsetCodes[] = $option['unset'];
}
}
if (0 === count($setCodes)) {
if (0 === \count($setCodes)) {
return $text;
}

View File

@@ -48,8 +48,6 @@ interface OutputFormatterStyleInterface
/**
* Sets multiple style options at once.
*
* @param array $options
*/
public function setOptions(array $options);

View File

@@ -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
@@ -78,7 +66,7 @@ class OutputFormatterStyleStack
foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
if ($style->apply('') === $stackedStyle->apply('')) {
$this->styles = array_slice($this->styles, 0, $index);
$this->styles = \array_slice($this->styles, 0, $index);
return $stackedStyle;
}
@@ -98,13 +86,11 @@ class OutputFormatterStyleStack
return $this->emptyStyle;
}
return $this->styles[count($this->styles) - 1];
return $this->styles[\count($this->styles) - 1];
}
/**
* @param OutputFormatterStyleInterface $emptyStyle
*
* @return OutputFormatterStyleStack
* @return $this
*/
public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
{