Mercurial > hg > isophonics-drupal-site
diff vendor/symfony/console/Application.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | 1fec387a4317 |
line wrap: on
line diff
--- a/vendor/symfony/console/Application.php Fri Feb 23 15:51:18 2018 +0000 +++ b/vendor/symfony/console/Application.php Fri Feb 23 15:52:07 2018 +0000 @@ -14,6 +14,7 @@ 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; @@ -129,7 +130,7 @@ } if (null !== $e) { - if (!$this->catchExceptions) { + if (!$this->catchExceptions || !$x instanceof \Exception) { throw $x; } @@ -189,7 +190,12 @@ if (!$name) { $name = $this->defaultCommand; - $input = new ArrayInput(array('command' => $this->defaultCommand)); + $this->definition->setArguments(array_merge( + $this->definition->getArguments(), + array( + 'command' => new InputArgument('command', InputArgument::OPTIONAL, $this->definition->getArgument('command')->getDescription(), $name), + ) + )); } $this->runningCommand = null; @@ -638,7 +644,7 @@ $output->isVerbose() && 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '' ); - $len = $this->stringWidth($title); + $len = Helper::strlen($title); $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 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 @@ -649,7 +655,7 @@ 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); @@ -658,7 +664,7 @@ $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])); } @@ -1038,15 +1044,6 @@ return $this; } - 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.