Core and composer updates

This commit is contained in:
Rob Davies 2017-07-03 16:47:07 +01:00
parent a82634bb98
commit 62cac30480
1118 changed files with 21770 additions and 6306 deletions

View file

@ -16,6 +16,7 @@ use Symfony\Component\Console\Descriptor\XmlDescriptor;
use Symfony\Component\Console\Exception\ExceptionInterface;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Helper\DebugFormatterHelper;
use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Console\Helper\ProcessHelper;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
@ -106,6 +107,8 @@ class Application
* @param OutputInterface $output An Output instance
*
* @return int 0 if everything went fine, or an error code
*
* @throws \Exception When running fails. Bypass this when {@link setCatchExceptions()}.
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
{
@ -120,10 +123,17 @@ class Application
$this->configureIO($input, $output);
try {
$e = null;
$exitCode = $this->doRun($input, $output);
} catch (\Exception $e) {
if (!$this->catchExceptions) {
throw $e;
} catch (\Exception $x) {
$e = $x;
} catch (\Throwable $x) {
$e = new FatalThrowableError($x);
}
if (null !== $e) {
if (!$this->catchExceptions || !$x instanceof \Exception) {
throw $x;
}
if ($output instanceof ConsoleOutputInterface) {
@ -185,6 +195,7 @@ class Application
$input = new ArrayInput(array('command' => $this->defaultCommand));
}
$this->runningCommand = null;
// the command name MUST be the first element of the input
$command = $this->find($name);
@ -646,7 +657,7 @@ class Application
do {
$title = sprintf(' [%s] ', get_class($e));
$len = $this->stringWidth($title);
$len = Helper::strlen($title);
$width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
// HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327
@ -657,7 +668,7 @@ class Application
foreach (preg_split('/\r?\n/', $e->getMessage()) as $line) {
foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
// pre-format lines to get the right string length
$lineLength = $this->stringWidth($line) + 4;
$lineLength = Helper::strlen($line) + 4;
$lines[] = array($line, $lineLength);
$len = max($lineLength, $len);
@ -666,7 +677,7 @@ class Application
$messages = array();
$messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
$messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title))));
$messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::strlen($title))));
foreach ($lines as $line) {
$messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
}
@ -842,13 +853,7 @@ class Application
}
if (null === $this->dispatcher) {
try {
return $command->run($input, $output);
} catch (\Exception $e) {
throw $e;
} catch (\Throwable $e) {
throw new FatalThrowableError($e);
}
return $command->run($input, $output);
}
// bind before the console.command event, so the listeners have access to input options/arguments
@ -860,37 +865,37 @@ class Application
}
$event = new ConsoleCommandEvent($command, $input, $output);
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
$e = null;
if ($event->commandShouldRun()) {
try {
$e = null;
try {
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
if ($event->commandShouldRun()) {
$exitCode = $command->run($input, $output);
} catch (\Exception $x) {
$e = $x;
} catch (\Throwable $x) {
$e = new FatalThrowableError($x);
} else {
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
}
if (null !== $e) {
$event = new ConsoleExceptionEvent($command, $input, $output, $e, $e->getCode());
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
if (null !== $e) {
$x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
$event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
if ($e !== $event->getException()) {
$x = $e = $event->getException();
}
$event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
throw $x;
if ($x !== $event->getException()) {
$e = $event->getException();
}
} else {
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
$exitCode = $e->getCode();
}
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
if (null !== $e) {
throw $e;
}
return $event->getExitCode();
}
@ -1093,15 +1098,6 @@ class Application
$this->defaultCommand = $commandName;
}
private function stringWidth($string)
{
if (false === $encoding = mb_detect_encoding($string, null, true)) {
return strlen($string);
}
return mb_strwidth($string, $encoding);
}
private function splitStringByWidth($string, $width)
{
// str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly.

View file

@ -205,6 +205,8 @@ class Command
*
* @return int The command exit code
*
* @throws \Exception When binding input fails. Bypass this by calling {@link ignoreValidationErrors()}.
*
* @see setCode()
* @see execute()
*/

View file

@ -247,7 +247,7 @@ class TextDescriptor extends Descriptor
}
}
if (PHP_VERSION_ID < 50400) {
if (\PHP_VERSION_ID < 50400) {
return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
}

View file

@ -81,9 +81,7 @@ class OutputFormatter implements OutputFormatterInterface
}
/**
* Sets the decorated flag.
*
* @param bool $decorated Whether to decorate the messages or not
* {@inheritdoc}
*/
public function setDecorated($decorated)
{
@ -91,9 +89,7 @@ class OutputFormatter implements OutputFormatterInterface
}
/**
* Gets the decorated flag.
*
* @return bool true if the output will decorate messages, false otherwise
* {@inheritdoc}
*/
public function isDecorated()
{
@ -101,10 +97,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)
{
@ -112,11 +105,7 @@ class OutputFormatter implements OutputFormatterInterface
}
/**
* Checks if output formatter has style with specified name.
*
* @param string $name
*
* @return bool
* {@inheritdoc}
*/
public function hasStyle($name)
{
@ -124,13 +113,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)
{
@ -142,11 +125,7 @@ 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)
{

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

@ -149,7 +149,7 @@ class Table
*/
public function setColumnStyle($columnIndex, $name)
{
$columnIndex = intval($columnIndex);
$columnIndex = (int) $columnIndex;
$this->columnStyles[$columnIndex] = $this->resolveStyle($name);

View file

@ -34,6 +34,10 @@ class ChoiceQuestion extends Question
*/
public function __construct($question, array $choices, $default = null)
{
if (!$choices) {
throw new \LogicException('Choice question must have at least 1 choice available.');
}
parent::__construct($question, $default);
$this->choices = $choices;
@ -137,7 +141,7 @@ class ChoiceQuestion extends Question
if ($multiselect) {
// Check for a separated comma values
if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
throw new InvalidArgumentException(sprintf($errorMessage, $selected));
}
$selectedChoices = explode(',', $selectedChoices);

View file

@ -5,6 +5,8 @@
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="error_reporting" value="-1" />