Laravel version update
Laravel version update
This commit is contained in:
@@ -35,7 +35,7 @@ class DebugFormatterHelper extends Helper
|
||||
*/
|
||||
public function start($id, $message, $prefix = 'RUN')
|
||||
{
|
||||
$this->started[$id] = array('border' => ++$this->count % count($this->colors));
|
||||
$this->started[$id] = array('border' => ++$this->count % \count($this->colors));
|
||||
|
||||
return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@ use Symfony\Component\Console\Descriptor\JsonDescriptor;
|
||||
use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
|
||||
use Symfony\Component\Console\Descriptor\TextDescriptor;
|
||||
use Symfony\Component\Console\Descriptor\XmlDescriptor;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* This class adds helper method to describe objects in various formats.
|
||||
@@ -31,9 +31,6 @@ class DescriptorHelper extends Helper
|
||||
*/
|
||||
private $descriptors = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
@@ -78,7 +75,7 @@ class DescriptorHelper extends Helper
|
||||
* @param string $format
|
||||
* @param DescriptorInterface $descriptor
|
||||
*
|
||||
* @return DescriptorHelper
|
||||
* @return $this
|
||||
*/
|
||||
public function register($format, DescriptorInterface $descriptor)
|
||||
{
|
||||
|
@@ -45,7 +45,7 @@ class FormatterHelper extends Helper
|
||||
*/
|
||||
public function formatBlock($messages, $style, $large = false)
|
||||
{
|
||||
if (!is_array($messages)) {
|
||||
if (!\is_array($messages)) {
|
||||
$messages = array($messages);
|
||||
}
|
||||
|
||||
@@ -72,6 +72,30 @@ class FormatterHelper extends Helper
|
||||
return implode("\n", $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates a message to the given length.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $length
|
||||
* @param string $suffix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function truncate($message, $length, $suffix = '...')
|
||||
{
|
||||
$computedLength = $length - $this->strlen($suffix);
|
||||
|
||||
if ($computedLength > $this->strlen($message)) {
|
||||
return $message;
|
||||
}
|
||||
|
||||
if (false === $encoding = mb_detect_encoding($message, null, true)) {
|
||||
return substr($message, 0, $length).$suffix;
|
||||
}
|
||||
|
||||
return mb_substr($message, 0, $length, $encoding).$suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
39
vendor/symfony/console/Helper/Helper.php
vendored
39
vendor/symfony/console/Helper/Helper.php
vendored
@@ -23,9 +23,7 @@ abstract class Helper implements HelperInterface
|
||||
protected $helperSet = null;
|
||||
|
||||
/**
|
||||
* Sets the helper set associated with this helper.
|
||||
*
|
||||
* @param HelperSet $helperSet A HelperSet instance
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setHelperSet(HelperSet $helperSet = null)
|
||||
{
|
||||
@@ -33,9 +31,7 @@ abstract class Helper implements HelperInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the helper set associated with this helper.
|
||||
*
|
||||
* @return HelperSet A HelperSet instance
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getHelperSet()
|
||||
{
|
||||
@@ -52,12 +48,30 @@ abstract class Helper implements HelperInterface
|
||||
public static function strlen($string)
|
||||
{
|
||||
if (false === $encoding = mb_detect_encoding($string, null, true)) {
|
||||
return strlen($string);
|
||||
return \strlen($string);
|
||||
}
|
||||
|
||||
return mb_strwidth($string, $encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the subset of a string, using mb_substr if it is available.
|
||||
*
|
||||
* @param string $string String to subset
|
||||
* @param int $from Start offset
|
||||
* @param int|null $length Length to read
|
||||
*
|
||||
* @return string The string subset
|
||||
*/
|
||||
public static function substr($string, $from, $length = null)
|
||||
{
|
||||
if (false === $encoding = mb_detect_encoding($string, null, true)) {
|
||||
return substr($string, $from, $length);
|
||||
}
|
||||
|
||||
return mb_substr($string, $from, $length, $encoding);
|
||||
}
|
||||
|
||||
public static function formatTime($secs)
|
||||
{
|
||||
static $timeFormats = array(
|
||||
@@ -75,9 +89,9 @@ abstract class Helper implements HelperInterface
|
||||
foreach ($timeFormats as $index => $format) {
|
||||
if ($secs >= $format[0]) {
|
||||
if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
|
||||
|| $index == count($timeFormats) - 1
|
||||
|| $index == \count($timeFormats) - 1
|
||||
) {
|
||||
if (2 == count($format)) {
|
||||
if (2 == \count($format)) {
|
||||
return $format[1];
|
||||
}
|
||||
|
||||
@@ -105,6 +119,11 @@ abstract class Helper implements HelperInterface
|
||||
}
|
||||
|
||||
public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
|
||||
{
|
||||
return self::strlen(self::removeDecoration($formatter, $string));
|
||||
}
|
||||
|
||||
public static function removeDecoration(OutputFormatterInterface $formatter, $string)
|
||||
{
|
||||
$isDecorated = $formatter->isDecorated();
|
||||
$formatter->setDecorated(false);
|
||||
@@ -114,6 +133,6 @@ abstract class Helper implements HelperInterface
|
||||
$string = preg_replace("/\033\[[^m]*m/", '', $string);
|
||||
$formatter->setDecorated($isDecorated);
|
||||
|
||||
return self::strlen($string);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
@@ -20,8 +20,6 @@ interface HelperInterface
|
||||
{
|
||||
/**
|
||||
* Sets the helper set associated with this helper.
|
||||
*
|
||||
* @param HelperSet $helperSet A HelperSet instance
|
||||
*/
|
||||
public function setHelperSet(HelperSet $helperSet = null);
|
||||
|
||||
|
9
vendor/symfony/console/Helper/HelperSet.php
vendored
9
vendor/symfony/console/Helper/HelperSet.php
vendored
@@ -28,14 +28,12 @@ class HelperSet implements \IteratorAggregate
|
||||
private $command;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Helper[] $helpers An array of helper
|
||||
*/
|
||||
public function __construct(array $helpers = array())
|
||||
{
|
||||
foreach ($helpers as $alias => $helper) {
|
||||
$this->set($helper, is_int($alias) ? null : $alias);
|
||||
$this->set($helper, \is_int($alias) ? null : $alias);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,11 +83,6 @@ class HelperSet implements \IteratorAggregate
|
||||
return $this->helpers[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command associated with this helper set.
|
||||
*
|
||||
* @param Command $command A Command instance
|
||||
*/
|
||||
public function setCommand(Command $command = null)
|
||||
{
|
||||
$this->command = $command;
|
||||
|
@@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputAwareInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
/**
|
||||
* An implementation of InputAwareInterface for Helpers.
|
||||
|
@@ -15,7 +15,6 @@ use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Process\ProcessBuilder;
|
||||
|
||||
/**
|
||||
* The ProcessHelper class provides helpers to run external processes.
|
||||
@@ -44,9 +43,7 @@ class ProcessHelper extends Helper
|
||||
|
||||
$formatter = $this->getHelperSet()->get('debug_formatter');
|
||||
|
||||
if (is_array($cmd)) {
|
||||
$process = ProcessBuilder::create($cmd)->getProcess();
|
||||
} elseif ($cmd instanceof Process) {
|
||||
if ($cmd instanceof Process) {
|
||||
$process = $cmd;
|
||||
} else {
|
||||
$process = new Process($cmd);
|
||||
@@ -124,7 +121,7 @@ class ProcessHelper extends Helper
|
||||
$output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type));
|
||||
|
||||
if (null !== $callback) {
|
||||
call_user_func($callback, $type, $buffer);
|
||||
\call_user_func($callback, $type, $buffer);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
81
vendor/symfony/console/Helper/ProgressBar.php
vendored
81
vendor/symfony/console/Helper/ProgressBar.php
vendored
@@ -11,9 +11,10 @@
|
||||
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Console\Terminal;
|
||||
|
||||
/**
|
||||
* The ProgressBar provides helpers to display progress output.
|
||||
@@ -21,9 +22,8 @@ use Symfony\Component\Console\Exception\LogicException;
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Chris Jones <leeked@gmail.com>
|
||||
*/
|
||||
class ProgressBar
|
||||
final class ProgressBar
|
||||
{
|
||||
// options
|
||||
private $barWidth = 28;
|
||||
private $barChar;
|
||||
private $emptyBarChar = '-';
|
||||
@@ -31,10 +31,6 @@ class ProgressBar
|
||||
private $format;
|
||||
private $internalFormat;
|
||||
private $redrawFreq = 1;
|
||||
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
private $output;
|
||||
private $step = 0;
|
||||
private $max;
|
||||
@@ -44,14 +40,13 @@ class ProgressBar
|
||||
private $formatLineCount;
|
||||
private $messages = array();
|
||||
private $overwrite = true;
|
||||
private $terminal;
|
||||
private $firstRun = true;
|
||||
|
||||
private static $formatters;
|
||||
private static $formats;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param OutputInterface $output An OutputInterface instance
|
||||
* @param int $max Maximum steps (0 if unknown)
|
||||
*/
|
||||
@@ -63,6 +58,7 @@ class ProgressBar
|
||||
|
||||
$this->output = $output;
|
||||
$this->setMaxSteps($max);
|
||||
$this->terminal = new Terminal();
|
||||
|
||||
if (!$this->output->isDecorated()) {
|
||||
// disable overwrite when output does not support ANSI codes.
|
||||
@@ -218,7 +214,7 @@ class ProgressBar
|
||||
*/
|
||||
public function setBarWidth($size)
|
||||
{
|
||||
$this->barWidth = (int) $size;
|
||||
$this->barWidth = max(1, (int) $size);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -338,8 +334,6 @@ class ProgressBar
|
||||
* Advances the progress output X steps.
|
||||
*
|
||||
* @param int $step Number of steps to advance
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function advance($step = 1)
|
||||
{
|
||||
@@ -360,18 +354,15 @@ class ProgressBar
|
||||
* Sets the current progress.
|
||||
*
|
||||
* @param int $step The current progress
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function setProgress($step)
|
||||
{
|
||||
$step = (int) $step;
|
||||
if ($step < $this->step) {
|
||||
throw new LogicException('You can\'t regress the progress bar.');
|
||||
}
|
||||
|
||||
if ($this->max && $step > $this->max) {
|
||||
$this->max = $step;
|
||||
} elseif ($step < 0) {
|
||||
$step = 0;
|
||||
}
|
||||
|
||||
$prevPeriod = (int) ($this->step / $this->redrawFreq);
|
||||
@@ -413,21 +404,7 @@ class ProgressBar
|
||||
$this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
|
||||
}
|
||||
|
||||
$this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) {
|
||||
if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
|
||||
$text = call_user_func($formatter, $this, $this->output);
|
||||
} elseif (isset($this->messages[$matches[1]])) {
|
||||
$text = $this->messages[$matches[1]];
|
||||
} else {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
if (isset($matches[2])) {
|
||||
$text = sprintf('%'.$matches[2], $text);
|
||||
}
|
||||
|
||||
return $text;
|
||||
}, $this->format));
|
||||
$this->overwrite($this->buildLine());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -597,4 +574,44 @@ class ProgressBar
|
||||
'debug_nomax' => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function buildLine()
|
||||
{
|
||||
$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
|
||||
$callback = function ($matches) {
|
||||
if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
|
||||
$text = \call_user_func($formatter, $this, $this->output);
|
||||
} elseif (isset($this->messages[$matches[1]])) {
|
||||
$text = $this->messages[$matches[1]];
|
||||
} else {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
if (isset($matches[2])) {
|
||||
$text = sprintf('%'.$matches[2], $text);
|
||||
}
|
||||
|
||||
return $text;
|
||||
};
|
||||
$line = preg_replace_callback($regex, $callback, $this->format);
|
||||
|
||||
// gets string length for each sub line with multiline format
|
||||
$linesLength = array_map(function ($subLine) {
|
||||
return Helper::strlenWithoutDecoration($this->output->getFormatter(), rtrim($subLine, "\r"));
|
||||
}, explode("\n", $line));
|
||||
|
||||
$linesWidth = max($linesLength);
|
||||
|
||||
$terminalWidth = $this->terminal->getWidth();
|
||||
if ($linesWidth <= $terminalWidth) {
|
||||
return $line;
|
||||
}
|
||||
|
||||
$this->setBarWidth($this->barWidth - $linesWidth + $terminalWidth);
|
||||
|
||||
return preg_replace_callback($regex, $callback, $this->format);
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,6 @@ class ProgressIndicator
|
||||
private $indicatorCurrent;
|
||||
private $indicatorChangeInterval;
|
||||
private $indicatorUpdateTime;
|
||||
private $lastMessagesLength;
|
||||
private $started = false;
|
||||
|
||||
private static $formatters;
|
||||
@@ -54,7 +53,7 @@ class ProgressIndicator
|
||||
|
||||
$indicatorValues = array_values($indicatorValues);
|
||||
|
||||
if (2 > count($indicatorValues)) {
|
||||
if (2 > \count($indicatorValues)) {
|
||||
throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
|
||||
}
|
||||
|
||||
@@ -89,7 +88,6 @@ class ProgressIndicator
|
||||
|
||||
$this->message = $message;
|
||||
$this->started = true;
|
||||
$this->lastMessagesLength = 0;
|
||||
$this->startTime = time();
|
||||
$this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
|
||||
$this->indicatorCurrent = 0;
|
||||
@@ -198,7 +196,7 @@ class ProgressIndicator
|
||||
|
||||
$this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
|
||||
if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
|
||||
return call_user_func($formatter, $self);
|
||||
return \call_user_func($formatter, $self);
|
||||
}
|
||||
|
||||
return $matches[0];
|
||||
@@ -226,27 +224,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()
|
||||
@@ -258,7 +241,7 @@ class ProgressIndicator
|
||||
{
|
||||
return array(
|
||||
'indicator' => function (ProgressIndicator $indicator) {
|
||||
return $indicator->indicatorValues[$indicator->indicatorCurrent % count($indicator->indicatorValues)];
|
||||
return $indicator->indicatorValues[$indicator->indicatorCurrent % \count($indicator->indicatorValues)];
|
||||
},
|
||||
'message' => function (ProgressIndicator $indicator) {
|
||||
return $indicator->message;
|
||||
|
98
vendor/symfony/console/Helper/QuestionHelper.php
vendored
98
vendor/symfony/console/Helper/QuestionHelper.php
vendored
@@ -13,12 +13,14 @@ namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\StreamableInputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
|
||||
/**
|
||||
* The QuestionHelper class provides helpers to interact with the user.
|
||||
@@ -34,11 +36,7 @@ class QuestionHelper extends Helper
|
||||
/**
|
||||
* Asks a question to the user.
|
||||
*
|
||||
* @param InputInterface $input An InputInterface instance
|
||||
* @param OutputInterface $output An OutputInterface instance
|
||||
* @param Question $question The question to ask
|
||||
*
|
||||
* @return string The user answer
|
||||
* @return mixed The user answer
|
||||
*
|
||||
* @throws RuntimeException If there is no data to read in the input stream
|
||||
*/
|
||||
@@ -49,9 +47,19 @@ class QuestionHelper extends Helper
|
||||
}
|
||||
|
||||
if (!$input->isInteractive()) {
|
||||
if ($question instanceof ChoiceQuestion) {
|
||||
$choices = $question->getChoices();
|
||||
|
||||
return $choices[$question->getDefault()];
|
||||
}
|
||||
|
||||
return $question->getDefault();
|
||||
}
|
||||
|
||||
if ($input instanceof StreamableInputInterface && $stream = $input->getStream()) {
|
||||
$this->inputStream = $stream;
|
||||
}
|
||||
|
||||
if (!$question->getValidator()) {
|
||||
return $this->doAsk($output, $question);
|
||||
}
|
||||
@@ -68,13 +76,18 @@ class QuestionHelper extends Helper
|
||||
*
|
||||
* This is mainly useful for testing purpose.
|
||||
*
|
||||
* @deprecated since version 3.2, to be removed in 4.0. Use
|
||||
* StreamableInputInterface::setStream() instead.
|
||||
*
|
||||
* @param resource $stream The input stream
|
||||
*
|
||||
* @throws InvalidArgumentException In case the stream is not a resource
|
||||
*/
|
||||
public function setInputStream($stream)
|
||||
{
|
||||
if (!is_resource($stream)) {
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use %s::setStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED);
|
||||
|
||||
if (!\is_resource($stream)) {
|
||||
throw new InvalidArgumentException('Input stream must be a valid resource.');
|
||||
}
|
||||
|
||||
@@ -84,10 +97,17 @@ class QuestionHelper extends Helper
|
||||
/**
|
||||
* Returns the helper's input stream.
|
||||
*
|
||||
* @deprecated since version 3.2, to be removed in 4.0. Use
|
||||
* StreamableInputInterface::getStream() instead.
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function getInputStream()
|
||||
{
|
||||
if (0 === \func_num_args() || func_get_arg(0)) {
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use %s::getStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return $this->inputStream;
|
||||
}
|
||||
|
||||
@@ -99,16 +119,20 @@ class QuestionHelper extends Helper
|
||||
return 'question';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents usage of stty.
|
||||
*/
|
||||
public static function disableStty()
|
||||
{
|
||||
self::$stty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the question to the user.
|
||||
*
|
||||
* @param OutputInterface $output
|
||||
* @param Question $question
|
||||
*
|
||||
* @return bool|mixed|null|string
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \RuntimeException
|
||||
* @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden
|
||||
*/
|
||||
private function doAsk(OutputInterface $output, Question $question)
|
||||
{
|
||||
@@ -122,7 +146,7 @@ class QuestionHelper extends Helper
|
||||
if ($question->isHidden()) {
|
||||
try {
|
||||
$ret = trim($this->getHiddenResponse($output, $inputStream));
|
||||
} catch (\RuntimeException $e) {
|
||||
} catch (RuntimeException $e) {
|
||||
if (!$question->isHiddenFallback()) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -132,15 +156,15 @@ 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);
|
||||
}
|
||||
} else {
|
||||
$ret = trim($this->autocomplete($output, $question, $inputStream));
|
||||
$ret = trim($this->autocomplete($output, $question, $inputStream, \is_array($autocomplete) ? $autocomplete : iterator_to_array($autocomplete, false)));
|
||||
}
|
||||
|
||||
$ret = strlen($ret) > 0 ? $ret : $question->getDefault();
|
||||
$ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
|
||||
|
||||
if ($normalizer = $question->getNormalizer()) {
|
||||
return $normalizer($ret);
|
||||
@@ -151,9 +175,6 @@ class QuestionHelper extends Helper
|
||||
|
||||
/**
|
||||
* Outputs the question prompt.
|
||||
*
|
||||
* @param OutputInterface $output
|
||||
* @param Question $question
|
||||
*/
|
||||
protected function writePrompt(OutputInterface $output, Question $question)
|
||||
{
|
||||
@@ -178,9 +199,6 @@ class QuestionHelper extends Helper
|
||||
|
||||
/**
|
||||
* Outputs an error message.
|
||||
*
|
||||
* @param OutputInterface $output
|
||||
* @param \Exception $error
|
||||
*/
|
||||
protected function writeError(OutputInterface $output, \Exception $error)
|
||||
{
|
||||
@@ -198,18 +216,19 @@ class QuestionHelper extends Helper
|
||||
*
|
||||
* @param OutputInterface $output
|
||||
* @param Question $question
|
||||
* @param resource $inputStream
|
||||
* @param array $autocomplete
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function autocomplete(OutputInterface $output, Question $question, $inputStream)
|
||||
private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete)
|
||||
{
|
||||
$autocomplete = $question->getAutocompleterValues();
|
||||
$ret = '';
|
||||
|
||||
$i = 0;
|
||||
$ofs = -1;
|
||||
$matches = $autocomplete;
|
||||
$numMatches = count($matches);
|
||||
$numMatches = \count($matches);
|
||||
|
||||
$sttyMode = shell_exec('stty -g');
|
||||
|
||||
@@ -231,10 +250,10 @@ class QuestionHelper extends Helper
|
||||
$output->write("\033[1D");
|
||||
}
|
||||
|
||||
if ($i === 0) {
|
||||
if (0 === $i) {
|
||||
$ofs = -1;
|
||||
$matches = $autocomplete;
|
||||
$numMatches = count($matches);
|
||||
$numMatches = \count($matches);
|
||||
} else {
|
||||
$numMatches = 0;
|
||||
}
|
||||
@@ -258,13 +277,13 @@ class QuestionHelper extends Helper
|
||||
$ofs += ('A' === $c[2]) ? -1 : 1;
|
||||
$ofs = ($numMatches + $ofs) % $numMatches;
|
||||
}
|
||||
} elseif (ord($c) < 32) {
|
||||
} elseif (\ord($c) < 32) {
|
||||
if ("\t" === $c || "\n" === $c) {
|
||||
if ($numMatches > 0 && -1 !== $ofs) {
|
||||
$ret = $matches[$ofs];
|
||||
// Echo out remaining chars for current match
|
||||
$output->write(substr($ret, $i));
|
||||
$i = strlen($ret);
|
||||
$i = \strlen($ret);
|
||||
}
|
||||
|
||||
if ("\n" === $c) {
|
||||
@@ -286,7 +305,7 @@ class QuestionHelper extends Helper
|
||||
|
||||
foreach ($autocomplete as $value) {
|
||||
// If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle)
|
||||
if (0 === strpos($value, $ret) && $i !== strlen($value)) {
|
||||
if (0 === strpos($value, $ret)) {
|
||||
$matches[$numMatches++] = $value;
|
||||
}
|
||||
}
|
||||
@@ -299,7 +318,7 @@ class QuestionHelper extends Helper
|
||||
// Save cursor position
|
||||
$output->write("\0337");
|
||||
// Write highlighted text
|
||||
$output->write('<hl>'.substr($matches[$ofs], $i).'</hl>');
|
||||
$output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
|
||||
// Restore cursor position
|
||||
$output->write("\0338");
|
||||
}
|
||||
@@ -314,7 +333,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
|
||||
*
|
||||
@@ -322,7 +342,7 @@ class QuestionHelper extends Helper
|
||||
*/
|
||||
private function getHiddenResponse(OutputInterface $output, $inputStream)
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
|
||||
|
||||
// handle code running from a phar
|
||||
@@ -360,7 +380,7 @@ class QuestionHelper extends Helper
|
||||
}
|
||||
|
||||
if (false !== $shell = $this->getShell()) {
|
||||
$readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword';
|
||||
$readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
|
||||
$command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
|
||||
$value = rtrim(shell_exec($command));
|
||||
$output->writeln('');
|
||||
@@ -378,7 +398,7 @@ class QuestionHelper extends Helper
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param Question $question A Question instance
|
||||
*
|
||||
* @return string The validated response
|
||||
* @return mixed The validated response
|
||||
*
|
||||
* @throws \Exception In case the max number of attempts has been reached and no valid response has been given
|
||||
*/
|
||||
@@ -392,7 +412,9 @@ class QuestionHelper extends Helper
|
||||
}
|
||||
|
||||
try {
|
||||
return call_user_func($question->getValidator(), $interviewer());
|
||||
return \call_user_func($question->getValidator(), $interviewer());
|
||||
} catch (RuntimeException $e) {
|
||||
throw $e;
|
||||
} catch (\Exception $error) {
|
||||
}
|
||||
}
|
||||
@@ -440,6 +462,6 @@ class QuestionHelper extends Helper
|
||||
|
||||
exec('stty 2>&1', $output, $exitcode);
|
||||
|
||||
return self::$stty = $exitcode === 0;
|
||||
return self::$stty = 0 === $exitcode;
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
@@ -28,6 +29,8 @@ class SymfonyQuestionHelper extends QuestionHelper
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* To be removed in 4.0
|
||||
*/
|
||||
public function ask(InputInterface $input, OutputInterface $output, Question $question)
|
||||
{
|
||||
@@ -35,11 +38,13 @@ class SymfonyQuestionHelper extends QuestionHelper
|
||||
$question->setValidator(function ($value) use ($validator) {
|
||||
if (null !== $validator) {
|
||||
$value = $validator($value);
|
||||
}
|
||||
} else {
|
||||
// make required
|
||||
if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) {
|
||||
@trigger_error('The default question validator is deprecated since Symfony 3.3 and will not be used anymore in version 4.0. Set a custom question validator if needed.', E_USER_DEPRECATED);
|
||||
|
||||
// make required
|
||||
if (!is_array($value) && !is_bool($value) && 0 === strlen($value)) {
|
||||
throw new LogicException('A value is required.');
|
||||
throw new LogicException('A value is required.');
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
@@ -53,7 +58,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) {
|
||||
@@ -75,18 +80,18 @@ class SymfonyQuestionHelper extends QuestionHelper
|
||||
$default[$key] = $choices[trim($value)];
|
||||
}
|
||||
|
||||
$text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, implode(', ', $default));
|
||||
$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);
|
||||
|
132
vendor/symfony/console/Helper/Table.php
vendored
132
vendor/symfony/console/Helper/Table.php
vendored
@@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Provides helpers to display a table.
|
||||
@@ -26,29 +26,23 @@ class Table
|
||||
{
|
||||
/**
|
||||
* Table headers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $headers = array();
|
||||
|
||||
/**
|
||||
* Table rows.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $rows = array();
|
||||
|
||||
/**
|
||||
* Column widths cache.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $columnWidths = array();
|
||||
private $effectiveColumnWidths = array();
|
||||
|
||||
/**
|
||||
* Number of columns cache.
|
||||
*
|
||||
* @var array
|
||||
* @var int
|
||||
*/
|
||||
private $numberOfColumns;
|
||||
|
||||
@@ -67,6 +61,13 @@ class Table
|
||||
*/
|
||||
private $columnStyles = array();
|
||||
|
||||
/**
|
||||
* User set column widths.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $columnWidths = array();
|
||||
|
||||
private static $styles;
|
||||
|
||||
public function __construct(OutputInterface $output)
|
||||
@@ -100,7 +101,7 @@ class Table
|
||||
*
|
||||
* @param string $name The style name
|
||||
*
|
||||
* @return TableStyle A TableStyle instance
|
||||
* @return TableStyle
|
||||
*/
|
||||
public static function getStyleDefinition($name)
|
||||
{
|
||||
@@ -120,7 +121,7 @@ class Table
|
||||
*
|
||||
* @param TableStyle|string $name The style name or a TableStyle instance
|
||||
*
|
||||
* @return Table
|
||||
* @return $this
|
||||
*/
|
||||
public function setStyle($name)
|
||||
{
|
||||
@@ -145,11 +146,11 @@ 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);
|
||||
$columnIndex = (int) $columnIndex;
|
||||
|
||||
$this->columnStyles[$columnIndex] = $this->resolveStyle($name);
|
||||
|
||||
@@ -174,10 +175,42 @@ class Table
|
||||
return $this->getStyle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum width of a column.
|
||||
*
|
||||
* @param int $columnIndex Column index
|
||||
* @param int $width Minimum column width in characters
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnWidth($columnIndex, $width)
|
||||
{
|
||||
$this->columnWidths[(int) $columnIndex] = (int) $width;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum width of all columns.
|
||||
*
|
||||
* @param array $widths
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnWidths(array $widths)
|
||||
{
|
||||
$this->columnWidths = array();
|
||||
foreach ($widths as $index => $width) {
|
||||
$this->setColumnWidth($index, $width);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHeaders(array $headers)
|
||||
{
|
||||
$headers = array_values($headers);
|
||||
if (!empty($headers) && !is_array($headers[0])) {
|
||||
if (!empty($headers) && !\is_array($headers[0])) {
|
||||
$headers = array($headers);
|
||||
}
|
||||
|
||||
@@ -210,7 +243,7 @@ class Table
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!is_array($row)) {
|
||||
if (!\is_array($row)) {
|
||||
throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
|
||||
}
|
||||
|
||||
@@ -230,6 +263,7 @@ class Table
|
||||
* Renders table to output.
|
||||
*
|
||||
* Example:
|
||||
* <code>
|
||||
* +---------------+-----------------------+------------------+
|
||||
* | ISBN | Title | Author |
|
||||
* +---------------+-----------------------+------------------+
|
||||
@@ -237,6 +271,7 @@ class Table
|
||||
* | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
|
||||
* | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
|
||||
* +---------------+-----------------------+------------------+
|
||||
* </code>
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
@@ -270,7 +305,7 @@ class Table
|
||||
/**
|
||||
* Renders horizontal header separator.
|
||||
*
|
||||
* Example: +-----+-----------+-------+
|
||||
* Example: <code>+-----+-----------+-------+</code>
|
||||
*/
|
||||
private function renderRowSeparator()
|
||||
{
|
||||
@@ -284,7 +319,7 @@ class Table
|
||||
|
||||
$markup = $this->style->getCrossingChar();
|
||||
for ($column = 0; $column < $count; ++$column) {
|
||||
$markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->columnWidths[$column]).$this->style->getCrossingChar();
|
||||
$markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->effectiveColumnWidths[$column]).$this->style->getCrossingChar();
|
||||
}
|
||||
|
||||
$this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
|
||||
@@ -301,7 +336,7 @@ class Table
|
||||
/**
|
||||
* Renders table row.
|
||||
*
|
||||
* Example: | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
|
||||
* Example: <code>| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |</code>
|
||||
*
|
||||
* @param array $row
|
||||
* @param string $cellFormat
|
||||
@@ -330,17 +365,17 @@ class Table
|
||||
private function renderCell(array $row, $column, $cellFormat)
|
||||
{
|
||||
$cell = isset($row[$column]) ? $row[$column] : '';
|
||||
$width = $this->columnWidths[$column];
|
||||
$width = $this->effectiveColumnWidths[$column];
|
||||
if ($cell instanceof TableCell && $cell->getColspan() > 1) {
|
||||
// add the width of the following columns(numbers of colspan).
|
||||
foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
|
||||
$width += $this->getColumnSeparatorWidth() + $this->columnWidths[$nextColumn];
|
||||
$width += $this->getColumnSeparatorWidth() + $this->effectiveColumnWidths[$nextColumn];
|
||||
}
|
||||
}
|
||||
|
||||
// str_pad won't work properly with multi-byte strings, we need to fix the padding
|
||||
if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
|
||||
$width += strlen($cell) - mb_strwidth($cell, $encoding);
|
||||
$width += \strlen($cell) - mb_strwidth($cell, $encoding);
|
||||
}
|
||||
|
||||
$style = $this->getColumnStyle($column);
|
||||
@@ -379,7 +414,7 @@ class Table
|
||||
private function buildTableRows($rows)
|
||||
{
|
||||
$unmergedRows = array();
|
||||
for ($rowKey = 0; $rowKey < count($rows); ++$rowKey) {
|
||||
for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
|
||||
$rows = $this->fillNextRows($rows, $rowKey);
|
||||
|
||||
// Remove any new line breaks and replace it with a new line
|
||||
@@ -387,7 +422,7 @@ class Table
|
||||
if (!strstr($cell, "\n")) {
|
||||
continue;
|
||||
}
|
||||
$lines = explode("\n", $cell);
|
||||
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
|
||||
foreach ($lines as $lineKey => $line) {
|
||||
if ($cell instanceof TableCell) {
|
||||
$line = new TableCell($line, array('colspan' => $cell->getColspan()));
|
||||
@@ -419,17 +454,22 @@ class Table
|
||||
* @param int $line
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function fillNextRows($rows, $line)
|
||||
private function fillNextRows(array $rows, $line)
|
||||
{
|
||||
$unmergedRows = array();
|
||||
foreach ($rows[$line] as $column => $cell) {
|
||||
if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) {
|
||||
throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing __toString, %s given.', \gettype($cell)));
|
||||
}
|
||||
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
|
||||
$nbLines = $cell->getRowspan() - 1;
|
||||
$lines = array($cell);
|
||||
if (strstr($cell, "\n")) {
|
||||
$lines = explode("\n", $cell);
|
||||
$nbLines = count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
|
||||
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
|
||||
$nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
|
||||
|
||||
$rows[$line][$column] = new TableCell($lines[0], array('colspan' => $cell->getColspan()));
|
||||
unset($lines[0]);
|
||||
@@ -440,13 +480,16 @@ class Table
|
||||
foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
|
||||
$value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
|
||||
$unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
|
||||
if ($nbLines === $unmergedRowKey - $line) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
|
||||
// we need to know if $unmergedRow will be merged or inserted into $rows
|
||||
if (isset($rows[$unmergedRowKey]) && is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
|
||||
if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
|
||||
foreach ($unmergedRow as $cellKey => $cell) {
|
||||
// insert cell into row at cellKey position
|
||||
array_splice($rows[$unmergedRowKey], $cellKey, 0, array($cell));
|
||||
@@ -468,8 +511,6 @@ class Table
|
||||
/**
|
||||
* fill cells for a row that contains colspan > 1.
|
||||
*
|
||||
* @param array $row
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function fillCells($row)
|
||||
@@ -494,7 +535,7 @@ class Table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function copyRow($rows, $line)
|
||||
private function copyRow(array $rows, $line)
|
||||
{
|
||||
$row = $rows[$line];
|
||||
foreach ($row as $cellKey => $cellValue) {
|
||||
@@ -510,13 +551,11 @@ class Table
|
||||
/**
|
||||
* Gets number of columns by row.
|
||||
*
|
||||
* @param array $row
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getNumberOfColumns(array $row)
|
||||
{
|
||||
$columns = count($row);
|
||||
$columns = \count($row);
|
||||
foreach ($row as $column) {
|
||||
$columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
|
||||
}
|
||||
@@ -527,11 +566,9 @@ class Table
|
||||
/**
|
||||
* Gets list of columns for the given row.
|
||||
*
|
||||
* @param array $row
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getRowColumns($row)
|
||||
private function getRowColumns(array $row)
|
||||
{
|
||||
$columns = range(0, $this->numberOfColumns - 1);
|
||||
foreach ($row as $cellKey => $cell) {
|
||||
@@ -546,10 +583,8 @@ class Table
|
||||
|
||||
/**
|
||||
* Calculates columns widths.
|
||||
*
|
||||
* @param array $rows
|
||||
*/
|
||||
private function calculateColumnsWidth($rows)
|
||||
private function calculateColumnsWidth(array $rows)
|
||||
{
|
||||
for ($column = 0; $column < $this->numberOfColumns; ++$column) {
|
||||
$lengths = array();
|
||||
@@ -560,9 +595,10 @@ class Table
|
||||
|
||||
foreach ($row as $i => $cell) {
|
||||
if ($cell instanceof TableCell) {
|
||||
$textLength = strlen($cell);
|
||||
$textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
|
||||
$textLength = Helper::strlen($textContent);
|
||||
if ($textLength > 0) {
|
||||
$contentColumns = str_split($cell, ceil($textLength / $cell->getColspan()));
|
||||
$contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan()));
|
||||
foreach ($contentColumns as $position => $content) {
|
||||
$row[$i + $position] = $content;
|
||||
}
|
||||
@@ -573,7 +609,7 @@ class Table
|
||||
$lengths[] = $this->getCellWidth($row, $column);
|
||||
}
|
||||
|
||||
$this->columnWidths[$column] = max($lengths) + strlen($this->style->getCellRowContentFormat()) - 2;
|
||||
$this->effectiveColumnWidths[$column] = max($lengths) + \strlen($this->style->getCellRowContentFormat()) - 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,7 +620,7 @@ class Table
|
||||
*/
|
||||
private function getColumnSeparatorWidth()
|
||||
{
|
||||
return strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
|
||||
return \strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -597,14 +633,16 @@ class Table
|
||||
*/
|
||||
private function getCellWidth(array $row, $column)
|
||||
{
|
||||
$cellWidth = 0;
|
||||
|
||||
if (isset($row[$column])) {
|
||||
$cell = $row[$column];
|
||||
$cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
|
||||
|
||||
return $cellWidth;
|
||||
}
|
||||
|
||||
return 0;
|
||||
$columnWidth = isset($this->columnWidths[$column]) ? $this->columnWidths[$column] : 0;
|
||||
|
||||
return max($cellWidth, $columnWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -612,7 +650,7 @@ class Table
|
||||
*/
|
||||
private function cleanup()
|
||||
{
|
||||
$this->columnWidths = array();
|
||||
$this->effectiveColumnWidths = array();
|
||||
$this->numberOfColumns = null;
|
||||
}
|
||||
|
||||
|
11
vendor/symfony/console/Helper/TableCell.php
vendored
11
vendor/symfony/console/Helper/TableCell.php
vendored
@@ -18,14 +18,7 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class TableCell
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $options = array(
|
||||
'rowspan' => 1,
|
||||
'colspan' => 1,
|
||||
@@ -37,6 +30,10 @@ class TableCell
|
||||
*/
|
||||
public function __construct($value = '', array $options = array())
|
||||
{
|
||||
if (is_numeric($value) && !\is_string($value)) {
|
||||
$value = (string) $value;
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
|
||||
// check option names
|
||||
|
@@ -18,9 +18,6 @@ namespace Symfony\Component\Console\Helper;
|
||||
*/
|
||||
class TableSeparator extends TableCell
|
||||
{
|
||||
/**
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options = array())
|
||||
{
|
||||
parent::__construct('', $options);
|
||||
|
20
vendor/symfony/console/Helper/TableStyle.php
vendored
20
vendor/symfony/console/Helper/TableStyle.php
vendored
@@ -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,11 +233,11 @@ class TableStyle
|
||||
*
|
||||
* @param int $padType STR_PAD_*
|
||||
*
|
||||
* @return TableStyle
|
||||
* @return $this
|
||||
*/
|
||||
public function setPadType($padType)
|
||||
{
|
||||
if (!in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
|
||||
if (!\in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
|
||||
throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user