Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 45e26ca

Browse files
Merge branch '3.0'
* 3.0: [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 Fix DeprecationErrorHandler on PHP 5.3 [FrameworkBundle] prevent cache:clear creating too long paths [FrameworkBundle] [Translation] Fixed translations not written when no translations directory in update command
2 parents c3b60a9 + c1bfa46 commit 45e26ca

35 files changed

+552
-935
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ addons:
1010
cache:
1111
directories:
1212
- .phpunit
13+
- php-5.5.9
1314

1415
matrix:
1516
include:
@@ -31,6 +32,7 @@ env:
3132

3233
before_install:
3334
- if [[ "$deps" = "no" ]] && [[ "$TRAVIS_PHP_VERSION" = 5.6 ]] && [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then export deps=skip; fi;
35+
- 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;
3436
- 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;
3537
- echo "memory_limit = -1" >> $INI_FILE
3638
- echo "session.gc_probability = 0" >> $INI_FILE
@@ -57,6 +59,7 @@ install:
5759
script:
5860
- if [ "$deps" = "no" ]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi;
5961
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi;
62+
- 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;
6063
- if [ "$deps" = "high" ]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
6164
- 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;
6265
- if [ "$deps" = "2.8" ]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data,legacy'; fi;

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ protected function configure()
8383

8484
protected function execute(InputInterface $input, OutputInterface $output)
8585
{
86-
$output = new SymfonyStyle($input, $output);
86+
$io = new SymfonyStyle($input, $output);
8787
$twig = $this->getTwigEnvironment();
8888

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

9292
return 1;
9393
}
@@ -102,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
102102
}
103103
}
104104
$data['tests'] = array_keys($data['tests']);
105-
$output->writeln(json_encode($data));
105+
$io->writeln(json_encode($data));
106106

107107
return 0;
108108
}
@@ -121,10 +121,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
121121
continue;
122122
}
123123

124-
$output->section(ucfirst($type));
124+
$io->section(ucfirst($type));
125125

126126
ksort($items);
127-
$output->listing($items);
127+
$io->listing($items);
128128
}
129129

130130
return 0;

src/Symfony/Bridge/Twig/Command/LintCommand.php

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,10 @@ protected function configure()
8484

8585
protected function execute(InputInterface $input, OutputInterface $output)
8686
{
87-
$stdout = $output;
88-
$output = new SymfonyStyle($input, $output);
87+
$io = new SymfonyStyle($input, $output);
8988

90-
$twig = $this->getTwigEnvironment();
91-
92-
if (null === $twig) {
93-
$output->error('The Twig environment needs to be set.');
89+
if (null === $twig = $this->getTwigEnvironment()) {
90+
$io->error('The Twig environment needs to be set.');
9491

9592
return 1;
9693
}
@@ -107,12 +104,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
107104
$template .= fread(STDIN, 1024);
108105
}
109106

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

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

115-
return $this->display($input, $stdout, $output, $filesInfo);
112+
return $this->display($input, $output, $io, $filesInfo);
116113
}
117114

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

159-
private function display(InputInterface $input, OutputInterface $stdout, $output, $files)
156+
private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, $files)
160157
{
161158
switch ($input->getOption('format')) {
162159
case 'txt':
163-
return $this->displayTxt($stdout, $output, $files);
160+
return $this->displayTxt($output, $io, $files);
164161
case 'json':
165-
return $this->displayJson($stdout, $files);
162+
return $this->displayJson($output, $files);
166163
default:
167164
throw new \InvalidArgumentException(sprintf('The format "%s" is not supported.', $input->getOption('format')));
168165
}
169166
}
170167

171-
private function displayTxt(OutputInterface $stdout, $output, $filesInfo)
168+
private function displayTxt(OutputInterface $output, SymfonyStyle $io, $filesInfo)
172169
{
173170
$errors = 0;
174171

175172
foreach ($filesInfo as $info) {
176-
if ($info['valid'] && $stdout->isVerbose()) {
177-
$output->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
173+
if ($info['valid'] && $output->isVerbose()) {
174+
$io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
178175
} elseif (!$info['valid']) {
179176
++$errors;
180-
$this->renderException($output, $info['template'], $info['exception'], $info['file']);
177+
$this->renderException($io, $info['template'], $info['exception'], $info['file']);
181178
}
182179
}
183180

184181
if ($errors === 0) {
185-
$output->success(sprintf('All %d Twig files contain valid syntax.', count($filesInfo)));
182+
$io->success(sprintf('All %d Twig files contain valid syntax.', count($filesInfo)));
186183
} else {
187-
$output->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', count($filesInfo) - $errors, $errors));
184+
$io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', count($filesInfo) - $errors, $errors));
188185
}
189186

190187
return min($errors, 1);

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ protected function configure()
5555
protected function execute(InputInterface $input, OutputInterface $output)
5656
{
5757
$outputIsVerbose = $output->isVerbose();
58-
$output = new SymfonyStyle($input, $output);
58+
$io = new SymfonyStyle($input, $output);
5959

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

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

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

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

8486
if ($filesystem->exists($warmupDir)) {
8587
if ($outputIsVerbose) {
86-
$output->comment('Clearing outdated warmup directory...');
88+
$io->comment('Clearing outdated warmup directory...');
8789
}
8890
$filesystem->remove($warmupDir);
8991
}
9092

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

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

103105
if ($outputIsVerbose) {
104-
$output->comment('Removing old cache directory...');
106+
$io->comment('Removing old cache directory...');
105107
}
106108

107109
$filesystem->remove($oldCacheDir);
108110

109111
if ($outputIsVerbose) {
110-
$output->comment('Finished');
112+
$io->comment('Finished');
111113
}
112114

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

116118
/**
@@ -120,8 +122,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
120122
*/
121123
protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = true)
122124
{
123-
$this->getContainer()->get('filesystem')->remove($warmupDir);
124-
125125
// create a temporary kernel
126126
$realKernel = $this->getContainer()->get('kernel');
127127
$realKernelClass = get_class($realKernel);

src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ protected function configure()
5454
*/
5555
protected function execute(InputInterface $input, OutputInterface $output)
5656
{
57-
$output = new SymfonyStyle($input, $output);
57+
$io = new SymfonyStyle($input, $output);
5858

5959
$kernel = $this->getContainer()->get('kernel');
60-
$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)));
60+
$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)));
6161

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

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

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

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

src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ protected function configure()
5555
*/
5656
protected function execute(InputInterface $input, OutputInterface $output)
5757
{
58-
$output = new SymfonyStyle($input, $output);
58+
$io = new SymfonyStyle($input, $output);
5959
$name = $input->getArgument('name');
6060

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

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

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

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

9191
private function compileContainer()

src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ protected function configure()
6767
*/
6868
protected function execute(InputInterface $input, OutputInterface $output)
6969
{
70-
$output = new SymfonyStyle($input, $output);
70+
$io = new SymfonyStyle($input, $output);
7171
$name = $input->getArgument('name');
7272

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

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

9393
switch ($input->getOption('format')) {
9494
case 'yaml':
95-
$output->writeln(sprintf('# %s', $message));
95+
$io->writeln(sprintf('# %s', $message));
9696
$dumper = new YamlReferenceDumper();
9797
break;
9898
case 'xml':
99-
$output->writeln(sprintf('<!-- %s -->', $message));
99+
$io->writeln(sprintf('<!-- %s -->', $message));
100100
$dumper = new XmlReferenceDumper();
101101
break;
102102
default:
103-
$output->writeln($message);
103+
$io->writeln($message);
104104
throw new \InvalidArgumentException('Only the yaml and xml formats are supported.');
105105
}
106106

107-
$output->writeln($dumper->dump($configuration, $extension->getNamespace()));
107+
$io->writeln($dumper->dump($configuration, $extension->getNamespace()));
108108
}
109109
}

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function configure()
9191
*/
9292
protected function execute(InputInterface $input, OutputInterface $output)
9393
{
94-
$output = new SymfonyStyle($input, $output);
94+
$io = new SymfonyStyle($input, $output);
9595
$this->validateInput($input);
9696

9797
if ($input->getOption('parameters')) {
@@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
108108
$options = array('tag' => $tag, 'show_private' => $input->getOption('show-private'));
109109
} elseif ($name = $input->getArgument('name')) {
110110
$object = $this->getContainerBuilder();
111-
$name = $this->findProperServiceName($input, $output, $object, $name);
111+
$name = $this->findProperServiceName($input, $io, $object, $name);
112112
$options = array('id' => $name);
113113
} else {
114114
$object = $this->getContainerBuilder();
@@ -122,7 +122,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
122122
$helper->describe($output, $object, $options);
123123

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

@@ -181,7 +181,7 @@ protected function getContainerBuilder()
181181
return $this->containerBuilder = $container;
182182
}
183183

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

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

198198
private function findServiceIdsContaining(ContainerBuilder $builder, $name)

src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ protected function configure()
5959
*/
6060
protected function execute(InputInterface $input, OutputInterface $output)
6161
{
62-
$output = new SymfonyStyle($input, $output);
62+
$io = new SymfonyStyle($input, $output);
6363
$dispatcher = $this->getEventDispatcher();
6464

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

7070
return;
7171
}
@@ -76,8 +76,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
7676
$helper = new DescriptorHelper();
7777
$options['format'] = $input->getOption('format');
7878
$options['raw_text'] = $input->getOption('raw');
79-
$options['output'] = $output;
80-
$helper->describe($output, $dispatcher, $options);
79+
$options['output'] = $io;
80+
$helper->describe($io, $dispatcher, $options);
8181
}
8282

8383
/**

0 commit comments

Comments
 (0)