Skip to content

Commit

Permalink
Merge branch '2.7' into 2.8
Browse files Browse the repository at this point in the history
* 2.7:
  fixed CS
  fixed CS
  fixed CS
  Fix WebProfilerBundle compatiblity with HttpKernel < 2.7
  [Validator] Deprecated PHP7-incompatible constraints and related validators
  [DebugBundle] Allow alternative destination for dumps
  [DebugBundle] Use output mechanism of dumpers instead of echoing
  [DebugBundle] Always collect dumps
  [FrameworkBundle] Applied new styles to the config:debug & config:dump-reference commands
  Fix tests in HHVM
  CS: Pre incrementation/decrementation should be used if possible

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/composer.json
  • Loading branch information
fabpot committed May 15, 2015
2 parents 2119bf3 + 0c613fb commit 4b71fe0
Show file tree
Hide file tree
Showing 79 changed files with 248 additions and 161 deletions.
6 changes: 6 additions & 0 deletions UPGRADE-2.7.md
Expand Up @@ -528,3 +528,9 @@ Config
* The `__toString()` method of the `\Symfony\Component\Config\ConfigCache` is marked as
deprecated in favor of the new `getPath()` method.

Validator
---------

* The PHP7-incompatible constraints (Null, True, False) and related validators
(NullValidator, TrueValidator, FalseValidator) are marked as deprecated
in favor of their `Is`-prefixed equivalent.
Expand Up @@ -121,7 +121,7 @@ public function testLogUTF8LongString()

$shortString = '';
$longString = '';
for ($i = 1; $i <= DbalLogger::MAX_STRING_LENGTH; $i++) {
for ($i = 1; $i <= DbalLogger::MAX_STRING_LENGTH; ++$i) {
$shortString .= $testStringArray[$i % $testStringCount];
$longString .= $testStringArray[$i % $testStringCount];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Extension/CodeExtension.php
Expand Up @@ -141,7 +141,7 @@ public function fileExcerpt($file, $line)
$content = preg_split('#<br />#', $code);

$lines = array();
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; $i++) {
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
}

Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Bundle/DebugBundle/DebugBundle.php
Expand Up @@ -14,7 +14,6 @@
use Symfony\Bundle\DebugBundle\DependencyInjection\Compiler\DumpDataCollectorPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\VarDumper;

/**
Expand All @@ -31,7 +30,7 @@ public function boot()
// configuration for CLI mode is overridden in HTTP mode on
// 'kernel.request' event
VarDumper::setHandler(function ($var) use ($container) {
$dumper = new CliDumper();
$dumper = $container->get('var_dumper.cli_dumper');
$cloner = $container->get('var_dumper.cloner');
$handler = function ($var) use ($dumper, $cloner) {
$dumper->dump($cloner->cloneVar($var));
Expand Down
Expand Up @@ -41,6 +41,11 @@ public function getConfigTreeBuilder()
->min(-1)
->defaultValue(-1)
->end()
->scalarNode('dump_destination')
->info('A stream URL where dumps should be written to')
->example('php://stderr')
->defaultNull()
->end()
->end()
;

Expand Down
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
Expand All @@ -35,8 +36,17 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('services.xml');

$container->getDefinition('var_dumper.cloner')
->addMethodCall('setMaxItems', array($config['max_items']))
->addMethodCall('setMaxItems', array($config['max_items']))
->addMethodCall('setMaxString', array($config['max_string_length']));

if (null !== $config['dump_destination']) {
$container->getDefinition('var_dumper.cli_dumper')
->replaceArgument(0, $config['dump_destination'])
;
$container->getDefinition('data_collector.dump')
->replaceArgument(4, new Reference('var_dumper.cli_dumper'))
;
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Bundle/DebugBundle/Resources/config/services.xml
Expand Up @@ -16,6 +16,7 @@
<argument>null</argument><!-- %templating.helper.code.file_link_format% -->
<argument>%kernel.charset%</argument>
<argument type="service" id="request_stack" />
<argument>null</argument><!-- var_dumper.cli_dumper when debug.dump_destination is set -->
</service>

<service id="debug.dump_listener" class="Symfony\Component\HttpKernel\EventListener\DumpListener">
Expand All @@ -25,6 +26,10 @@
</service>

<service id="var_dumper.cloner" class="Symfony\Component\VarDumper\Cloner\VarCloner" />
<service id="var_dumper.cli_dumper" class="Symfony\Component\VarDumper\Dumper\CliDumper">
<argument>null</argument><!-- debug.dump_destination -->
<argument>%kernel.charset%</argument>
</service>
</services>

</container>
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\StyleInterface;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;

/**
Expand All @@ -27,24 +28,21 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
{
protected function listBundles(OutputInterface $output)
{
$output->writeln('Available registered bundles with their extension alias if available:');

if (class_exists('Symfony\Component\Console\Helper\Table')) {
$table = new Table($output);
} else {
$table = $this->getHelperSet()->get('table');
}

$table->setHeaders(array('Bundle name', 'Extension alias'));
$headers = array('Bundle name', 'Extension alias');
$rows = array();
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
$extension = $bundle->getContainerExtension();
$table->addRow(array($bundle->getName(), $extension ? $extension->getAlias() : ''));
$rows[] = array($bundle->getName(), $extension ? $extension->getAlias() : '');
}

if (class_exists('Symfony\Component\Console\Helper\Table')) {
$table->render();
$message = 'Available registered bundles with their extension alias if available:';
if ($output instanceof StyleInterface) {
$output->writeln(' '.$message);
$output->table($headers, $rows);
} else {
$table->render($output);
$output->writeln($message);
$table = new Table($output);
$table->setHeaders($headers)->setRows($rows)->render($output);
}
}

Expand Down
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Yaml\Yaml;

/**
Expand Down Expand Up @@ -57,8 +58,9 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output);
if (false !== strpos($input->getFirstArgument(), ':d')) {
$output->writeln('<comment>The use of "config:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:config" instead.</comment>');
$output->caution('The use of "config:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:config" instead.');
}

$name = $input->getArgument('name');
Expand Down
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

/**
* A console command for dumping available configuration reference.
Expand Down Expand Up @@ -66,6 +67,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output);
$name = $input->getArgument('name');

if (empty($name)) {
Expand Down
Expand Up @@ -145,7 +145,7 @@ protected function validateInput(InputInterface $input)
$optionsCount = 0;
foreach ($options as $option) {
if ($input->getOption($option)) {
$optionsCount++;
++$optionsCount;
}
}

Expand Down
Expand Up @@ -55,7 +55,7 @@ protected function configure()
))
->setDefinition(array(
new InputArgument('name', InputArgument::OPTIONAL, 'A route name'),
new InputOption('show-controllers', null, InputOption::VALUE_NONE, 'Show assigned controllers in overview'),
new InputOption('show-controllers', null, InputOption::VALUE_NONE, 'Show assigned controllers in overview'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'To output route(s) in other formats', 'txt'),
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw route(s)'),
))
Expand Down
Expand Up @@ -30,10 +30,10 @@ class DescriptorHelper extends BaseDescriptorHelper
public function __construct()
{
$this
->register('txt', new TextDescriptor())
->register('xml', new XmlDescriptor())
->register('txt', new TextDescriptor())
->register('xml', new XmlDescriptor())
->register('json', new JsonDescriptor())
->register('md', new MarkdownDescriptor())
->register('md', new MarkdownDescriptor())
;
}
}
Expand Up @@ -135,7 +135,7 @@ public function fileExcerpt($file, $line)
$content = preg_split('#<br />#', $code);

$lines = array();
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; $i++) {
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
}

Expand Down
Expand Up @@ -147,7 +147,7 @@ protected function parseTokens($tokens, MessageCatalogue $catalog)
{
$tokenIterator = new \ArrayIterator($tokens);

for ($key = 0; $key < $tokenIterator->count(); $key++) {
for ($key = 0; $key < $tokenIterator->count(); ++$key) {
foreach ($this->sequences as $sequence) {
$message = '';
$tokenIterator->seek($key);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Expand Up @@ -35,7 +35,7 @@
"require-dev": {
"symfony/phpunit-bridge": "~2.7|~3.0.0",
"symfony/browser-kit": "~2.4|~3.0.0",
"symfony/console": "~2.6|~3.0.0",
"symfony/console": "~2.7|~3.0.0",
"symfony/css-selector": "~2.0,>=2.0.5|~3.0.0",
"symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0",
"symfony/finder": "~2.0,>=2.0.5|~3.0.0",
Expand Down
Expand Up @@ -8,7 +8,7 @@
<span>
{% if collector.applicationname %}
{{ collector.applicationname }} {{ collector.applicationversion }}
{% else %}
{% elseif collector.symfonyState is defined %}
{% if 'unknown' == collector.symfonyState -%}
<span class="sf-toolbar-status sf-toolbar-info-piece-additional" title="Unable to retrieve information about the Symfony version.">
{%- elseif 'eol' == collector.symfonyState -%}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/ClassLoader/ClassMapGenerator.php
Expand Up @@ -95,7 +95,7 @@ private static function findClasses($path)
$classes = array();

$namespace = '';
for ($i = 0, $max = count($tokens); $i < $max; $i++) {
for ($i = 0, $max = count($tokens); $i < $max; ++$i) {
$token = $tokens[$i];

if (is_string($token)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/Loader/FileLoader.php
Expand Up @@ -91,7 +91,7 @@ public function import($resource, $type = null, $ignoreErrors = false, $sourceRe
}

$resources = is_array($resource) ? $resource : array($resource);
for ($i = 0; $i < $resourcesCount = count($resources); $i++) {
for ($i = 0; $i < $resourcesCount = count($resources); ++$i) {
if (isset(self::$loading[$resources[$i]])) {
if ($i == $resourcesCount - 1) {
throw new FileLoaderImportCircularReferenceException(array_keys(self::$loading));
Expand Down
14 changes: 7 additions & 7 deletions src/Symfony/Component/Console/Application.php
Expand Up @@ -717,7 +717,7 @@ public function renderException($e, $output)
'args' => array(),
));

for ($i = 0, $count = count($trace); $i < $count; $i++) {
for ($i = 0, $count = count($trace); $i < $count; ++$i) {
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
$function = $trace[$i]['function'];
Expand Down Expand Up @@ -925,12 +925,12 @@ protected function getDefaultInputDefinition()
return new InputDefinition(array(
new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),

new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'),
new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'),
new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
));
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Helper/DialogHelper.php
Expand Up @@ -145,7 +145,7 @@ public function ask(OutputInterface $output, $question, $default = null, array $
// Backspace Character
if ("\177" === $c) {
if (0 === $numMatches && 0 !== $i) {
$i--;
--$i;
// Move cursor backwards
$output->write("\033[1D");
}
Expand Down Expand Up @@ -198,7 +198,7 @@ public function ask(OutputInterface $output, $question, $default = null, array $
} else {
$output->write($c);
$ret .= $c;
$i++;
++$i;

$numMatches = 0;
$ofs = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Input/ArgvInput.php
Expand Up @@ -123,7 +123,7 @@ private function parseShortOption($token)
private function parseShortOptionSet($name)
{
$len = strlen($name);
for ($i = 0; $i < $len; $i++) {
for ($i = 0; $i < $len; ++$i) {
if (!$this->definition->hasShortcut($name[$i])) {
throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i]));
}
Expand Down
Expand Up @@ -84,7 +84,7 @@ public function translateNthChild(XPathExpr $xpath, FunctionNode $function, $las

if ($last) {
$expr = 'last() - '.$expr;
$b--;
--$b;
}

if (0 !== $b) {
Expand Down
Expand Up @@ -189,9 +189,9 @@ public function testRecursionInArguments()
public function testTooBigArray()
{
$a = array();
for ($i = 0; $i < 20; $i++) {
for ($j = 0; $j < 50; $j++) {
for ($k = 0; $k < 10; $k++) {
for ($i = 0; $i < 20; ++$i) {
for ($j = 0; $j < 50; ++$j) {
for ($k = 0; $k < 10; ++$k) {
$a[$i][$j][$k] = 'value';
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -340,7 +340,7 @@ public function makePathRelative($endPath, $startPath)
// Find for which directory the common path stops
$index = 0;
while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
$index++;
++$index;
}

// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Finder/Glob.php
Expand Up @@ -52,7 +52,7 @@ public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardS
$inCurlies = 0;
$regex = '';
$sizeGlob = strlen($glob);
for ($i = 0; $i < $sizeGlob; $i++) {
for ($i = 0; $i < $sizeGlob; ++$i) {
$car = $glob[$i];
if ($firstByte) {
if ($strictLeadingDot && '.' !== $car) {
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Finder/Tests/FinderTest.php
Expand Up @@ -475,7 +475,7 @@ public function testCountDirectories()
$i = 0;

foreach ($directory as $dir) {
$i++;
++$i;
}

$this->assertCount($i, $directory);
Expand All @@ -487,7 +487,7 @@ public function testCountFiles()
$i = 0;

foreach ($files as $file) {
$i++;
++$i;
}

$this->assertCount($i, $files);
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Finder/Tests/GlobTest.php
Expand Up @@ -22,5 +22,4 @@ public function testGlobToRegexDelimiters()
$this->assertEquals(Glob::toRegex('.*', true, true, ''), '^\.[^/]*$');
$this->assertEquals(Glob::toRegex('.*', true, true, '/'), '/^\.[^/]*$/');
}

}

0 comments on commit 4b71fe0

Please sign in to comment.