Skip to content

Commit

Permalink
Merge branch '2.8' into 3.0
Browse files Browse the repository at this point in the history
* 2.8:
  [Process] Enhance compatiblity with --enable-sigchild
  [Validator] removes unused variable in LengthValidator class.
  [FrameworkBundle] [Bug] Fixes new InputStyle bug #16920
  fix short array syntax for php 5.3
  [Serializer] Fixed  on array of objects in .
  [Process] Always call proc_close
  [Form] Add missing tests for StringUtil::fqcnToBlockPrefix()
  [Security] Fix a Polyfill import statement in StringUtils
  [Validator] Updated Luxembourgish translations for 2.8
  Improved the code of the commands that use the new SymfonyStyle class
  disable server commands without Process component
  list all server command names in suggestion
  Suggested Process dependency
  disable server:run cmd without Process component
  Suggested Process dependency
  [FrameworkBundle] prevent cache:clear creating too long paths
  [FrameworkBundle] [Translation] Fixed translations not written when no translations directory in update command

Conflicts:
	.travis.yml
	src/Symfony/Bridge/Twig/Command/LintCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php
	src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php
	src/Symfony/Component/Security/Core/Util/StringUtils.php
  • Loading branch information
nicolas-grekas committed Dec 10, 2015
2 parents 99884c7 + 829c011 commit c1bfa46
Show file tree
Hide file tree
Showing 35 changed files with 552 additions and 935 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -10,6 +10,7 @@ addons:
cache:
directories:
- .phpunit
- php-5.5.9

matrix:
include:
Expand All @@ -31,6 +32,7 @@ env:

before_install:
- if [[ "$deps" = "no" ]] && [[ "$TRAVIS_PHP_VERSION" = 5.6 ]] && [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then export deps=skip; fi;
- if [[ $deps = no && $TRAVIS_PHP_VERSION = 5.5 && ! -d php-5.5.9/sapi ]]; then wget http://museum.php.net/php5/php-5.5.9.tar.bz2; tar -xjf php-5.5.9.tar.bz2; (cd php-5.5.9; ./configure --enable-sigchild --enable-pcntl; make -j2); fi;
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi;
- echo "memory_limit = -1" >> $INI_FILE
- echo "session.gc_probability = 0" >> $INI_FILE
Expand All @@ -57,6 +59,7 @@ install:
script:
- if [ "$deps" = "no" ]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi;
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi;
- if [[ $deps = no && $TRAVIS_PHP_VERSION = 5.5 ]]; then echo -e "1\\n0" | parallel --gnu 'echo -e "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-5.5.9/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi;
- if [ "$deps" = "high" ]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
- if [ "$deps" = "low" ]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
- if [ "$deps" = "2.8" ]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data,legacy'; fi;
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Bridge/Twig/Command/DebugCommand.php
Expand Up @@ -83,11 +83,11 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output);
$io = new SymfonyStyle($input, $output);
$twig = $this->getTwigEnvironment();

if (null === $twig) {
$output->error('The Twig environment needs to be set.');
$io->error('The Twig environment needs to be set.');

return 1;
}
Expand All @@ -102,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
$data['tests'] = array_keys($data['tests']);
$output->writeln(json_encode($data));
$io->writeln(json_encode($data));

return 0;
}
Expand All @@ -121,10 +121,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
continue;
}

$output->section(ucfirst($type));
$io->section(ucfirst($type));

ksort($items);
$output->listing($items);
$io->listing($items);
}

return 0;
Expand Down
31 changes: 14 additions & 17 deletions src/Symfony/Bridge/Twig/Command/LintCommand.php
Expand Up @@ -84,13 +84,10 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$stdout = $output;
$output = new SymfonyStyle($input, $output);
$io = new SymfonyStyle($input, $output);

$twig = $this->getTwigEnvironment();

if (null === $twig) {
$output->error('The Twig environment needs to be set.');
if (null === $twig = $this->getTwigEnvironment()) {
$io->error('The Twig environment needs to be set.');

return 1;
}
Expand All @@ -107,12 +104,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
$template .= fread(STDIN, 1024);
}

return $this->display($input, $stdout, $output, array($this->validate($twig, $template, uniqid('sf_'))));
return $this->display($input, $output, $io, array($this->validate($twig, $template, uniqid('sf_'))));
}

$filesInfo = $this->getFilesInfo($twig, $filenames);

return $this->display($input, $stdout, $output, $filesInfo);
return $this->display($input, $output, $io, $filesInfo);
}

private function getFilesInfo(\Twig_Environment $twig, array $filenames)
Expand Down Expand Up @@ -156,35 +153,35 @@ private function validate(\Twig_Environment $twig, $template, $file)
return array('template' => $template, 'file' => $file, 'valid' => true);
}

private function display(InputInterface $input, OutputInterface $stdout, $output, $files)
private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, $files)
{
switch ($input->getOption('format')) {
case 'txt':
return $this->displayTxt($stdout, $output, $files);
return $this->displayTxt($output, $io, $files);
case 'json':
return $this->displayJson($stdout, $files);
return $this->displayJson($output, $files);
default:
throw new \InvalidArgumentException(sprintf('The format "%s" is not supported.', $input->getOption('format')));
}
}

private function displayTxt(OutputInterface $stdout, $output, $filesInfo)
private function displayTxt(OutputInterface $output, SymfonyStyle $io, $filesInfo)
{
$errors = 0;

foreach ($filesInfo as $info) {
if ($info['valid'] && $stdout->isVerbose()) {
$output->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
if ($info['valid'] && $output->isVerbose()) {
$io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
} elseif (!$info['valid']) {
++$errors;
$this->renderException($output, $info['template'], $info['exception'], $info['file']);
$this->renderException($io, $info['template'], $info['exception'], $info['file']);
}
}

if ($errors === 0) {
$output->success(sprintf('All %d Twig files contain valid syntax.', count($filesInfo)));
$io->success(sprintf('All %d Twig files contain valid syntax.', count($filesInfo)));
} else {
$output->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', count($filesInfo) - $errors, $errors));
$io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', count($filesInfo) - $errors, $errors));
}

return min($errors, 1);
Expand Down
22 changes: 11 additions & 11 deletions src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
Expand Up @@ -55,10 +55,12 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$outputIsVerbose = $output->isVerbose();
$output = new SymfonyStyle($input, $output);
$io = new SymfonyStyle($input, $output);

$realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
$oldCacheDir = $realCacheDir.'_old';
// the old cache dir name must not be longer than the real one to avoid exceeding
// the maximum length of a directory or file path within it (esp. Windows MAX_PATH)
$oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~');
$filesystem = $this->getContainer()->get('filesystem');

if (!is_writable($realCacheDir)) {
Expand All @@ -70,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$kernel = $this->getContainer()->get('kernel');
$output->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$this->getContainer()->get('cache_clearer')->clear($realCacheDir);

if ($input->getOption('no-warmup')) {
Expand All @@ -79,17 +81,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
// the warmup cache dir name must have the same length than the real one
// to avoid the many problems in serialized resources files
$realCacheDir = realpath($realCacheDir);
$warmupDir = substr($realCacheDir, 0, -1).'_';
$warmupDir = substr($realCacheDir, 0, -1).('_' === substr($realCacheDir, -1) ? '-' : '_');

if ($filesystem->exists($warmupDir)) {
if ($outputIsVerbose) {
$output->comment('Clearing outdated warmup directory...');
$io->comment('Clearing outdated warmup directory...');
}
$filesystem->remove($warmupDir);
}

if ($outputIsVerbose) {
$output->comment('Warming up cache...');
$io->comment('Warming up cache...');
}
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));

Expand All @@ -101,16 +103,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

if ($outputIsVerbose) {
$output->comment('Removing old cache directory...');
$io->comment('Removing old cache directory...');
}

$filesystem->remove($oldCacheDir);

if ($outputIsVerbose) {
$output->comment('Finished');
$io->comment('Finished');
}

$output->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
}

/**
Expand All @@ -120,8 +122,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = true)
{
$this->getContainer()->get('filesystem')->remove($warmupDir);

// create a temporary kernel
$realKernel = $this->getContainer()->get('kernel');
$realKernelClass = get_class($realKernel);
Expand Down
Expand Up @@ -54,10 +54,10 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output);
$io = new SymfonyStyle($input, $output);

$kernel = $this->getContainer()->get('kernel');
$output->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$io->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));

$warmer = $this->getContainer()->get('cache_warmer');

Expand All @@ -67,6 +67,6 @@ protected function execute(InputInterface $input, OutputInterface $output)

$warmer->warmUp($this->getContainer()->getParameter('kernel.cache_dir'));

$output->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
}
}
Expand Up @@ -55,12 +55,12 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output);
$io = new SymfonyStyle($input, $output);
$name = $input->getArgument('name');

if (empty($name)) {
$output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
$output->newLine();
$io->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
$io->newLine();
$this->listBundles($output);

return;
Expand All @@ -80,12 +80,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
$config = $processor->processConfiguration($configuration, $configs);

if ($name === $extension->getAlias()) {
$output->title(sprintf('Current configuration for extension with alias "%s"', $name));
$io->title(sprintf('Current configuration for extension with alias "%s"', $name));
} else {
$output->title(sprintf('Current configuration for "%s"', $name));
$io->title(sprintf('Current configuration for "%s"', $name));
}

$output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
$io->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
}

private function compileContainer()
Expand Down
Expand Up @@ -67,12 +67,12 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output);
$io = new SymfonyStyle($input, $output);
$name = $input->getArgument('name');

if (empty($name)) {
$output->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration.');
$output->newLine();
$io->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration.');
$io->newLine();
$this->listBundles($output);

return;
Expand All @@ -92,18 +92,18 @@ protected function execute(InputInterface $input, OutputInterface $output)

switch ($input->getOption('format')) {
case 'yaml':
$output->writeln(sprintf('# %s', $message));
$io->writeln(sprintf('# %s', $message));
$dumper = new YamlReferenceDumper();
break;
case 'xml':
$output->writeln(sprintf('<!-- %s -->', $message));
$io->writeln(sprintf('<!-- %s -->', $message));
$dumper = new XmlReferenceDumper();
break;
default:
$output->writeln($message);
$io->writeln($message);
throw new \InvalidArgumentException('Only the yaml and xml formats are supported.');
}

$output->writeln($dumper->dump($configuration, $extension->getNamespace()));
$io->writeln($dumper->dump($configuration, $extension->getNamespace()));
}
}
Expand Up @@ -91,7 +91,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output);
$io = new SymfonyStyle($input, $output);
$this->validateInput($input);

if ($input->getOption('parameters')) {
Expand All @@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$options = array('tag' => $tag, 'show_private' => $input->getOption('show-private'));
} elseif ($name = $input->getArgument('name')) {
$object = $this->getContainerBuilder();
$name = $this->findProperServiceName($input, $output, $object, $name);
$name = $this->findProperServiceName($input, $io, $object, $name);
$options = array('id' => $name);
} else {
$object = $this->getContainerBuilder();
Expand All @@ -122,7 +122,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$helper->describe($output, $object, $options);

if (!$input->getArgument('name') && $input->isInteractive()) {
$output->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)');
$io->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)');
}
}

Expand Down Expand Up @@ -181,7 +181,7 @@ protected function getContainerBuilder()
return $this->containerBuilder = $container;
}

private function findProperServiceName(InputInterface $input, SymfonyStyle $output, ContainerBuilder $builder, $name)
private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, $name)
{
if ($builder->has($name) || !$input->isInteractive()) {
return $name;
Expand All @@ -192,7 +192,7 @@ private function findProperServiceName(InputInterface $input, SymfonyStyle $outp
throw new \InvalidArgumentException(sprintf('No services found that match "%s".', $name));
}

return $output->choice('Select one of the following services to display its information', $matchingServices);
return $io->choice('Select one of the following services to display its information', $matchingServices);
}

private function findServiceIdsContaining(ContainerBuilder $builder, $name)
Expand Down
Expand Up @@ -59,13 +59,13 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output);
$io = new SymfonyStyle($input, $output);
$dispatcher = $this->getEventDispatcher();

$options = array();
if ($event = $input->getArgument('event')) {
if (!$dispatcher->hasListeners($event)) {
$output->warning(sprintf('The event "%s" does not have any registered listeners.', $event));
$io->warning(sprintf('The event "%s" does not have any registered listeners.', $event));

return;
}
Expand All @@ -76,8 +76,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$helper = new DescriptorHelper();
$options['format'] = $input->getOption('format');
$options['raw_text'] = $input->getOption('raw');
$options['output'] = $output;
$helper->describe($output, $dispatcher, $options);
$options['output'] = $io;
$helper->describe($io, $dispatcher, $options);
}

/**
Expand Down

0 comments on commit c1bfa46

Please sign in to comment.