Update to Drupal 8.2.6. For more information, see https://www.drupal.org/project/drupal/releases/8.2.6

This commit is contained in:
Pantheon Automation 2017-02-02 16:28:38 -08:00 committed by Greg Anderson
parent db56c09587
commit f1e72395cb
588 changed files with 26857 additions and 2777 deletions

View file

@ -78,7 +78,7 @@ class DescriptorHelper extends Helper
* @param string $format
* @param DescriptorInterface $descriptor
*
* @return DescriptorHelper
* @return $this
*/
public function register($format, DescriptorInterface $descriptor)
{

View file

@ -35,7 +35,7 @@ abstract class Helper implements HelperInterface
/**
* Gets the helper set associated with this helper.
*
* @return HelperSet A HelperSet instance
* @return HelperSet|null
*/
public function getHelperSet()
{
@ -62,26 +62,28 @@ abstract class Helper implements HelperInterface
{
static $timeFormats = array(
array(0, '< 1 sec'),
array(2, '1 sec'),
array(59, 'secs', 1),
array(1, '1 sec'),
array(2, 'secs', 1),
array(60, '1 min'),
array(3600, 'mins', 60),
array(5400, '1 hr'),
array(86400, 'hrs', 3600),
array(129600, '1 day'),
array(604800, 'days', 86400),
array(120, 'mins', 60),
array(3600, '1 hr'),
array(7200, 'hrs', 3600),
array(86400, '1 day'),
array(172800, 'days', 86400),
);
foreach ($timeFormats as $format) {
foreach ($timeFormats as $index => $format) {
if ($secs >= $format[0]) {
continue;
}
if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
|| $index == count($timeFormats) - 1
) {
if (2 == count($format)) {
return $format[1];
}
if (2 == count($format)) {
return $format[1];
return floor($secs / $format[2]).' '.$format[1];
}
}
return ceil($secs / $format[2]).' '.$format[1];
}
}

View file

@ -21,13 +21,16 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
*/
class HelperSet implements \IteratorAggregate
{
/**
* @var Helper[]
*/
private $helpers = array();
private $command;
/**
* Constructor.
*
* @param Helper[] $helpers An array of helper.
* @param Helper[] $helpers An array of helper
*/
public function __construct(array $helpers = array())
{
@ -110,6 +113,9 @@ class HelperSet implements \IteratorAggregate
return $this->command;
}
/**
* @return Helper[]
*/
public function getIterator()
{
return new \ArrayIterator($this->helpers);

View file

@ -41,10 +41,10 @@ class ProgressBar
private $startTime;
private $stepWidth;
private $percent = 0.0;
private $lastMessagesLength = 0;
private $formatLineCount;
private $messages;
private $messages = array();
private $overwrite = true;
private $firstRun = true;
private static $formatters;
private static $formats;
@ -141,6 +141,16 @@ class ProgressBar
return isset(self::$formats[$name]) ? self::$formats[$name] : null;
}
/**
* Associates a text with a named placeholder.
*
* The text is displayed when the progress bar is rendered but only
* when the corresponding placeholder is part of the custom format line
* (by wrapping the name with %).
*
* @param string $message The text to associate with the placeholder
* @param string $name The name of the placeholder
*/
public function setMessage($message, $name = 'message')
{
$this->messages[$name] = $message;
@ -473,7 +483,7 @@ class ProgressBar
$this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
}
$this->overwrite(str_repeat("\n", $this->formatLineCount));
$this->overwrite('');
}
/**
@ -513,37 +523,26 @@ class ProgressBar
*/
private function overwrite($message)
{
$lines = explode("\n", $message);
if ($this->overwrite) {
if (!$this->firstRun) {
// Move the cursor to the beginning of the line
$this->output->write("\x0D");
// append whitespace to match the line's length
if (null !== $this->lastMessagesLength) {
foreach ($lines as $i => $line) {
if ($this->lastMessagesLength > Helper::strlenWithoutDecoration($this->output->getFormatter(), $line)) {
$lines[$i] = str_pad($line, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
// Erase the line
$this->output->write("\x1B[2K");
// Erase previous lines
if ($this->formatLineCount > 0) {
$this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
}
}
}
if ($this->overwrite) {
// move back to the beginning of the progress bar before redrawing it
$this->output->write("\x0D");
} elseif ($this->step > 0) {
// move to new line
$this->output->writeln('');
}
if ($this->formatLineCount) {
$this->output->write(sprintf("\033[%dA", $this->formatLineCount));
}
$this->output->write(implode("\n", $lines));
$this->firstRun = false;
$this->lastMessagesLength = 0;
foreach ($lines as $line) {
$len = Helper::strlenWithoutDecoration($this->output->getFormatter(), $line);
if ($len > $this->lastMessagesLength) {
$this->lastMessagesLength = $len;
}
}
$this->output->write($message);
}
private function determineBestFormat()

View file

@ -372,8 +372,6 @@ class ProgressHelper extends Helper
}
if (isset($this->formatVars['bar'])) {
$completeBars = 0;
if ($this->max > 0) {
$completeBars = floor($percent * $this->barWidth);
} else {

View file

@ -11,6 +11,8 @@
namespace Symfony\Component\Console\Helper;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Exception\LogicException;
use Symfony\Component\Console\Output\OutputInterface;
/**
@ -26,7 +28,6 @@ class ProgressIndicator
private $indicatorCurrent;
private $indicatorChangeInterval;
private $indicatorUpdateTime;
private $lastMessagesLength;
private $started = false;
private static $formatters;
@ -53,7 +54,7 @@ class ProgressIndicator
$indicatorValues = array_values($indicatorValues);
if (2 > count($indicatorValues)) {
throw new \InvalidArgumentException('Must have at least 2 indicator value characters.');
throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
}
$this->format = self::getFormatDefinition($format);
@ -118,12 +119,11 @@ class ProgressIndicator
public function start($message)
{
if ($this->started) {
throw new \LogicException('Progress indicator already started.');
throw new LogicException('Progress indicator already started.');
}
$this->message = $message;
$this->started = true;
$this->lastMessagesLength = 0;
$this->startTime = time();
$this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
$this->indicatorCurrent = 0;
@ -137,7 +137,7 @@ class ProgressIndicator
public function advance()
{
if (!$this->started) {
throw new \LogicException('Progress indicator has not yet been started.');
throw new LogicException('Progress indicator has not yet been started.');
}
if (!$this->output->isDecorated()) {
@ -164,7 +164,7 @@ class ProgressIndicator
public function finish($message)
{
if (!$this->started) {
throw new \LogicException('Progress indicator has not yet been started.');
throw new LogicException('Progress indicator has not yet been started.');
}
$this->message = $message;
@ -260,27 +260,12 @@ class ProgressIndicator
*/
private function overwrite($message)
{
// append whitespace to match the line's length
if (null !== $this->lastMessagesLength) {
if ($this->lastMessagesLength > Helper::strlenWithoutDecoration($this->output->getFormatter(), $message)) {
$message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
}
}
if ($this->output->isDecorated()) {
$this->output->write("\x0D");
$this->output->write("\x0D\x1B[2K");
$this->output->write($message);
} else {
$this->output->writeln($message);
}
$this->lastMessagesLength = 0;
$len = Helper::strlenWithoutDecoration($this->output->getFormatter(), $message);
if ($len > $this->lastMessagesLength) {
$this->lastMessagesLength = $len;
}
}
private function getCurrentTimeInMilliseconds()

View file

@ -136,7 +136,7 @@ class QuestionHelper extends Helper
if (false === $ret) {
$ret = fgets($inputStream, 4096);
if (false === $ret) {
throw new \RuntimeException('Aborted');
throw new RuntimeException('Aborted');
}
$ret = trim($ret);
}
@ -202,6 +202,7 @@ class QuestionHelper extends Helper
*
* @param OutputInterface $output
* @param Question $question
* @param resource $inputStream
*
* @return string
*/
@ -318,7 +319,8 @@ class QuestionHelper extends Helper
/**
* Gets a hidden response from user.
*
* @param OutputInterface $output An Output instance
* @param OutputInterface $output An Output instance
* @param resource $inputStream The handler resource
*
* @return string The answer
*
@ -397,6 +399,8 @@ class QuestionHelper extends Helper
try {
return call_user_func($question->getValidator(), $interviewer());
} catch (RuntimeException $e) {
throw $e;
} catch (\Exception $error) {
}
}

View file

@ -18,6 +18,7 @@ use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Console\Formatter\OutputFormatter;
/**
* Symfony Style Guide compliant question helper.
@ -35,11 +36,11 @@ class SymfonyQuestionHelper extends QuestionHelper
$question->setValidator(function ($value) use ($validator) {
if (null !== $validator) {
$value = $validator($value);
}
// make required
if (!is_array($value) && !is_bool($value) && 0 === strlen($value)) {
throw new LogicException('A value is required.');
} else {
// make required
if (!is_array($value) && !is_bool($value) && 0 === strlen($value)) {
throw new LogicException('A value is required.');
}
}
return $value;
@ -53,7 +54,7 @@ class SymfonyQuestionHelper extends QuestionHelper
*/
protected function writePrompt(OutputInterface $output, Question $question)
{
$text = $question->getQuestion();
$text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
$default = $question->getDefault();
switch (true) {
@ -67,14 +68,26 @@ class SymfonyQuestionHelper extends QuestionHelper
break;
case $question instanceof ChoiceQuestion && $question->isMultiselect():
$choices = $question->getChoices();
$default = explode(',', $default);
foreach ($default as $key => $value) {
$default[$key] = $choices[trim($value)];
}
$text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
break;
case $question instanceof ChoiceQuestion:
$choices = $question->getChoices();
$text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, $choices[$default]);
$text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default]));
break;
default:
$text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, $default);
$text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
}
$output->writeln($text);

View file

@ -100,7 +100,7 @@ class Table
*
* @param string $name The style name
*
* @return TableStyle A TableStyle instance
* @return TableStyle
*/
public static function getStyleDefinition($name)
{
@ -108,11 +108,11 @@ class Table
self::$styles = self::initStyles();
}
if (!self::$styles[$name]) {
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
if (isset(self::$styles[$name])) {
return self::$styles[$name];
}
return self::$styles[$name];
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}
/**
@ -120,17 +120,11 @@ class Table
*
* @param TableStyle|string $name The style name or a TableStyle instance
*
* @return Table
* @return $this
*/
public function setStyle($name)
{
if ($name instanceof TableStyle) {
$this->style = $name;
} elseif (isset(self::$styles[$name])) {
$this->style = self::$styles[$name];
} else {
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}
$this->style = $this->resolveStyle($name);
return $this;
}
@ -151,19 +145,13 @@ class Table
* @param int $columnIndex Column index
* @param TableStyle|string $name The style name or a TableStyle instance
*
* @return Table
* @return $this
*/
public function setColumnStyle($columnIndex, $name)
{
$columnIndex = intval($columnIndex);
if ($name instanceof TableStyle) {
$this->columnStyles[$columnIndex] = $name;
} elseif (isset(self::$styles[$name])) {
$this->columnStyles[$columnIndex] = self::$styles[$name];
} else {
throw new \InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}
$this->columnStyles[$columnIndex] = $this->resolveStyle($name);
return $this;
}
@ -307,7 +295,7 @@ class Table
*/
private function renderColumnSeparator()
{
$this->output->write(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
return sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar());
}
/**
@ -324,12 +312,12 @@ class Table
return;
}
$this->renderColumnSeparator();
$rowContent = $this->renderColumnSeparator();
foreach ($this->getRowColumns($row) as $column) {
$this->renderCell($row, $column, $cellFormat);
$this->renderColumnSeparator();
$rowContent .= $this->renderCell($row, $column, $cellFormat);
$rowContent .= $this->renderColumnSeparator();
}
$this->output->writeln('');
$this->output->writeln($rowContent);
}
/**
@ -358,12 +346,13 @@ class Table
$style = $this->getColumnStyle($column);
if ($cell instanceof TableSeparator) {
$this->output->write(sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width)));
} else {
$width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
$content = sprintf($style->getCellRowContentFormat(), $cell);
$this->output->write(sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $style->getPadType())));
return sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width));
}
$width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
$content = sprintf($style->getCellRowContentFormat(), $cell);
return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $style->getPadType()));
}
/**
@ -447,7 +436,7 @@ class Table
}
// create a two dimensional array (rowspan x colspan)
$unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, ''), $unmergedRows);
$unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, array()), $unmergedRows);
foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
$value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
$unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
@ -569,6 +558,18 @@ class Table
continue;
}
foreach ($row as $i => $cell) {
if ($cell instanceof TableCell) {
$textLength = strlen($cell);
if ($textLength > 0) {
$contentColumns = str_split($cell, ceil($textLength / $cell->getColspan()));
foreach ($contentColumns as $position => $content) {
$row[$i + $position] = $content;
}
}
}
}
$lengths[] = $this->getCellWidth($row, $column);
}
@ -599,10 +600,6 @@ class Table
if (isset($row[$column])) {
$cell = $row[$column];
$cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
if ($cell instanceof TableCell && $cell->getColspan() > 1) {
// we assume that cell value will be across more than one column.
$cellWidth = $cellWidth / $cell->getColspan();
}
return $cellWidth;
}
@ -651,4 +648,17 @@ class Table
'symfony-style-guide' => $styleGuide,
);
}
private function resolveStyle($name)
{
if ($name instanceof TableStyle) {
return $name;
}
if (isset(self::$styles[$name])) {
return self::$styles[$name];
}
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}
}

View file

@ -49,7 +49,7 @@ class TableHelper extends Helper
*
* @param int $layout self::LAYOUT_*
*
* @return TableHelper
* @return $this
*
* @throws InvalidArgumentException when the table layout is not known
*/
@ -115,7 +115,7 @@ class TableHelper extends Helper
*
* @param string $paddingChar
*
* @return TableHelper
* @return $this
*/
public function setPaddingChar($paddingChar)
{
@ -129,7 +129,7 @@ class TableHelper extends Helper
*
* @param string $horizontalBorderChar
*
* @return TableHelper
* @return $this
*/
public function setHorizontalBorderChar($horizontalBorderChar)
{
@ -143,7 +143,7 @@ class TableHelper extends Helper
*
* @param string $verticalBorderChar
*
* @return TableHelper
* @return $this
*/
public function setVerticalBorderChar($verticalBorderChar)
{
@ -157,7 +157,7 @@ class TableHelper extends Helper
*
* @param string $crossingChar
*
* @return TableHelper
* @return $this
*/
public function setCrossingChar($crossingChar)
{
@ -171,7 +171,7 @@ class TableHelper extends Helper
*
* @param string $cellHeaderFormat
*
* @return TableHelper
* @return $this
*/
public function setCellHeaderFormat($cellHeaderFormat)
{
@ -185,7 +185,7 @@ class TableHelper extends Helper
*
* @param string $cellRowFormat
*
* @return TableHelper
* @return $this
*/
public function setCellRowFormat($cellRowFormat)
{
@ -199,7 +199,7 @@ class TableHelper extends Helper
*
* @param string $cellRowContentFormat
*
* @return TableHelper
* @return $this
*/
public function setCellRowContentFormat($cellRowContentFormat)
{
@ -213,7 +213,7 @@ class TableHelper extends Helper
*
* @param string $borderFormat
*
* @return TableHelper
* @return $this
*/
public function setBorderFormat($borderFormat)
{
@ -227,7 +227,7 @@ class TableHelper extends Helper
*
* @param int $padType STR_PAD_*
*
* @return TableHelper
* @return $this
*/
public function setPadType($padType)
{

View file

@ -19,8 +19,7 @@ namespace Symfony\Component\Console\Helper;
class TableSeparator extends TableCell
{
/**
* @param string $value
* @param array $options
* @param array $options
*/
public function __construct(array $options = array())
{

View file

@ -37,7 +37,7 @@ class TableStyle
*
* @param string $paddingChar
*
* @return TableStyle
* @return $this
*/
public function setPaddingChar($paddingChar)
{
@ -65,7 +65,7 @@ class TableStyle
*
* @param string $horizontalBorderChar
*
* @return TableStyle
* @return $this
*/
public function setHorizontalBorderChar($horizontalBorderChar)
{
@ -89,7 +89,7 @@ class TableStyle
*
* @param string $verticalBorderChar
*
* @return TableStyle
* @return $this
*/
public function setVerticalBorderChar($verticalBorderChar)
{
@ -113,7 +113,7 @@ class TableStyle
*
* @param string $crossingChar
*
* @return TableStyle
* @return $this
*/
public function setCrossingChar($crossingChar)
{
@ -137,7 +137,7 @@ class TableStyle
*
* @param string $cellHeaderFormat
*
* @return TableStyle
* @return $this
*/
public function setCellHeaderFormat($cellHeaderFormat)
{
@ -161,7 +161,7 @@ class TableStyle
*
* @param string $cellRowFormat
*
* @return TableStyle
* @return $this
*/
public function setCellRowFormat($cellRowFormat)
{
@ -185,7 +185,7 @@ class TableStyle
*
* @param string $cellRowContentFormat
*
* @return TableStyle
* @return $this
*/
public function setCellRowContentFormat($cellRowContentFormat)
{
@ -209,7 +209,7 @@ class TableStyle
*
* @param string $borderFormat
*
* @return TableStyle
* @return $this
*/
public function setBorderFormat($borderFormat)
{
@ -233,7 +233,7 @@ class TableStyle
*
* @param int $padType STR_PAD_*
*
* @return TableStyle
* @return $this
*/
public function setPadType($padType)
{