Merge branch '2.8' into 3.2

* 2.8:
  [Console] Do not duplicate Helper::strlen() code
  [FrameworkBundle] Adding the extension XML
  [Form] Minor: Fix comment in ChoiceType
  [FrameworkBundle] AbstractConfigCommand: do not try registering bundles twice
This commit is contained in:
Fabien Potencier 2017-05-11 09:41:44 -07:00
commit 329e96c583
4 changed files with 7 additions and 14 deletions

View File

@ -117,7 +117,7 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
// Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method
// as this method is not called when the container is loaded from the cache.
$container = $this->getContainerBuilder();
$bundles = $this->getContainer()->get('kernel')->registerBundles();
$bundles = $this->getContainer()->get('kernel')->getBundles();
foreach ($bundles as $bundle) {
if ($extension = $bundle->getContainerExtension()) {
$container->registerExtension($extension);

View File

@ -17,6 +17,7 @@
],
"require": {
"php": ">=5.5.9",
"ext-xml": "*",
"symfony/cache": "~3.2.2|~3.3",
"symfony/class-loader": "~3.2",
"symfony/dependency-injection": "~3.2.1|~3.3",

View File

@ -14,6 +14,7 @@ namespace Symfony\Component\Console;
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;
@ -638,7 +639,7 @@ class Application
$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 +650,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);
@ -658,7 +659,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]));
}
@ -1038,15 +1039,6 @@ class Application
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.

View File

@ -158,7 +158,7 @@ class ChoiceType extends AbstractType
}
// To avoid issues when the submitted choices are arrays (i.e. array to string conversions),
// we have to ensure that all elements of the submitted choice data are strings or null.
// we have to ensure that all elements of the submitted choice data are NULL, strings or ints.
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
$data = $event->getData();