8000 Merge branch '2.6' into 2.7 · symfony/symfony@26ff514 · GitHub
[go: up one dir, main page]

Skip to content

Commit 26ff514

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: CS: fix some license headers CS: Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline use visited lookup with reference to gain performance Replace GET parameters when changed [FrameworkBundle][debug:config] added support for dynamic configurations. [WebProfiler] Fix partial search on url in list Conflicts: src/Symfony/Bridge/Propel1/Form/EventListener/TranslationCollectionFormListener.php src/Symfony/Bridge/Propel1/Form/EventListener/TranslationFormListener.php
2 parents cb70899 + 2559628 commit 26ff514

File tree

18 files changed

+140
-56
lines changed

18 files changed

+140
-56
lines changed

.php_cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
return Symfony\CS\Config\Config::create()
4+
->setUsingLinter(false)
5+
->setUsingCache(true)
6+
;

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

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
use Symfony\Component\Config\Definition\ConfigurationInterface;
1515
use Symfony\Component\Console\Output\OutputInterface;
1616
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
17-
use Symfony\Component\DependencyInjection\ContainerBuilder;
18-
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
1917

2018
/**
2119
* A console command for dumping available configuration reference.
@@ -43,37 +41,24 @@ protected function listBundles(OutputInterface $output)
4341
protected function findExtension($name)
4442
{
4543
$extension = null;
44+
$bundles = $this->initializeBundles();
45+
foreach ($bundles as $bundle) {
46+
$extension = $bundle->getContainerExtension();
4647

47-
$bundles = $this->getContainer()->get('kernel')->getBundles();
48-
49-
if (preg_match('/Bundle$/', $name)) {
50-
// input is bundle name
51-
52-
if (isset($bundles[$name])) {
53-
$extension = $bundles[$name]->getContainerExtension();
54-
}
55-
56-
if (!$extension) {
57-
throw new \LogicException(sprintf('No extensions with configuration available for "%s"', $name));
48+
if ($extension && ($name === $extension->getAlias() || $name === $bundle->getName())) {
49+
break;
5850
}
59-
} else {
60-
foreach ($bundles as $bundle) {
61-
$extension = $bundle->getContainerExtension();
62-
63-
if ($extension && $name === $extension->getAlias()) {
64-
break;
65-
}
51+
}
6652

67-
$extension = null;
53+
if (!$extension) {
54+
$message = sprintf('No extension with alias "%s" is enabled', $name);
55+
if (preg_match('/Bundle$/', $name)) {
56+
$message = sprintf('No extensions with configuration available for "%s"', $name);
6857
}
6958

70-
if (!$extension) {
71-
throw new \LogicException(sprintf('No extension with alias "%s" is enabled', $name));
72-
}
59+
throw new \LogicException($message);
7360
}
7461

75-
$this->initializeExtensions($bundles);
76-
7762
return $extension;
7863
}
7964

@@ -88,21 +73,22 @@ public function validateConfiguration(ExtensionInterface $extension, $configurat
8873
}
8974
}
9075

91-
private function initializeExtensions($bundles)
76+
private function initializeBundles()
9277
{
9378
// Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method
9479
// as this method is not called when the container is loaded from the cache.
95-
$parameters = $this->getContainer()->getParameterBag()->all();
96-
$container = new ContainerBuilder(new ParameterBag($parameters));
80+
$container = $this->getContainerBuilder();
81+
$bundles = $this->getContainer()->get('kernel')->registerBundles();
9782
foreach ($bundles as $bundle) {
9883
if ($extension = $bundle->getContainerExtension()) {
9984
$container->registerExtension($extension);
10085
}
10186
}
10287

10388
foreach ($bundles as $bundle) {
104-
$bundle = clone $bundle;
10589
$bundle->build($container);
10690
}
91+
92+
return $bundles;
10793
}
10894
}

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7070
}
7171

7272
$extension = $this->findExtension($name);
73-
74-
$kernel = $this->getContainer()->get('kernel');
75-
$method = new \ReflectionMethod($kernel, 'buildContainer');
76-
$method->setAccessible(true);
77-
$container = $method->invoke($kernel);
73+
$container = $this->compileContainer();
7874

7975
$configs = $container->getExtensionConfig($extension->getAlias());
8076
$configuration = $extension->getConfiguration($configs, $container);
@@ -94,4 +90,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
9490

9591
$output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
9692
}
93+
94+
private function compileContainer()
95+
{
96+
$kernel = clone $this->getContainer()->get('kernel');
97+
$kernel->boot();
98+
99+
$method = new \ReflectionMethod($kernel, 'buildContainer');
100+
$method->setAccessible(true);
101+
$container = $method->invoke($kernel);
102+
$container->getCompiler()->compile($container);
103+
104+
return $container;
105+
}
97106
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ protected function validateInput(InputInterface $input)
166166
*/
167167
protected function getContainerBuilder()
168168
{
169+
if ($this->containerBuilder) {
170+
return $this->containerBuilder;
171+
}
172+
169173
if (!$this->getApplication()->getKernel()->isDebug()) {
170174
throw new \LogicException(sprintf('Debug information about the container is only available in debug mode.'));
171175
}
@@ -179,7 +183,7 @@ protected function getContainerBuilder()
179183
$loader = new XmlFileLoader($container, new FileLocator());
180184
$loader->load($cachedFile);
181185

182-
return $container;
186+
return $this->containerBuilder = $container;
183187
}
184188

185189
private function findProperServiceName(InputInterface $input, OutputInterface $output, ContainerBuilder $builder, $name)

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313

1414
use Symfony\Component\DependencyInjection\ContainerBuilder;
1515
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
16+
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
1617

17-
class TestExtension extends Extension
18+
class TestExtension extends Extension implements PrependExtensionInterface
1819
{
1920
private $customConfig;
2021

@@ -27,6 +28,14 @@ public function load(array $configs, ContainerBuilder $container)
2728
$config = $this->processConfiguration($configuration, $configs);
2829
}
2930

31+
/**
32+
* {@inheritdoc}
33+
*/
34+
public function prepend(ContainerBuilder $container)
35+
{
36+
$container->prependExtensionConfig('test', array('custom' => 'foo'));
37+
}
38+
3039
/**
3140
* {@inheritdoc}
3241
*/
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
13+
14+
use Symfony\Bundle\FrameworkBundle\Console\Application;
15+
use Symfony\Component\Console\Input\ArrayInput;
16+
use Symfony\Component\Console\Output\NullOutput;
17+
use Symfony\Component\Console\Tester\CommandTester;
18+
19+
/**
20+
* @group functional
21+
*/
22+
class ConfigDebugCommandTest extends WebTestCase
23+
{
24+
private $application;
25+
26+
protected function setUp()
27+
{
28+
$kernel = static::createKernel(array('test_case' => 'ConfigDump', 'root_config' => 'config.yml'));
29+
$this->application = new Application($kernel);
30+
$this->application->doRun(new ArrayInput(array()), new NullOutput());
31+
}
32+
33+
public function testDumpBundleName()
34+
{
35+
$tester = $this->createCommandTester();
36+
$ret = $tester->execute(array('name' => 'TestBundle'));
37+
38+
$this->assertSame(0, $ret, 'Returns 0 in case of success');
39+
$this->assertContains('custom: foo', $tester->getDisplay());
40+
}
41+
42+
/**
43+
* @return CommandTester
44+
*/
45+
private function createCommandTester()
46+
{
47+
$command = $this->application->find('debug:config');
48+
49+
return new CommandTester($command);
50+
}
51+
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testDumpBundleName()
3535
$tester = $this->createCommandTester();
3636
$ret = $tester->execute(array('name' => 'TestBundle'));
3737

38-
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
38+
$this->assertSame(0, $ret, 'Returns 0 in case of success');
3939
$this->assertContains('test:', $tester->getDisplay());
4040
$this->assertContains(' custom:', $tester->getDisplay());
4141
}

src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static function parse($str)
7777
if ('\'' === $str[$bLength]) {
7878
return str_replace(
7979
array('\\\\', '\\\''),
80-
array( '\\', '\''),
80+
array('\\', '\''),
8181
substr($str, $bLength + 1, -1)
8282
);
8383
} else {

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/search.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</select>
1616
<div class="clear-fix"></div>
1717
<label for="url">URL</label>
18-
<input type="url" name="url" id="url" value="{{ url }}" placeholder="e.g. {{ request.baseUrl }}">
18+
<input type="text" name="url" id="url" value="{{ url }}" placeholder="e.g. {{ request.baseUrl }}">
1919
<div class="clear-fix"></div>
2020
<label for="token">Token</label>
2121
<input type="text" name="token" id="token" value="{{ token }}" placeholder="e.g. 1f321b">

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ private function getDefinitionsFromArguments(array $arguments)
12411241
*
12421242
* @return bool
12431243
*/
1244-
private function hasReference($id, array $arguments, $deep = false, array $visited = array())
1244+
private function hasReference($id, array $arguments, $deep = false, array &$visited = array())
12451245
{
12461246
foreach ($arguments as $argument) {
12471247
if (is_array($argument)) {

src/Symfony/Component/DomCrawler/Form.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,18 @@ public function getUri()
197197
{
198198
$uri = parent::getUri();
199199

200-
if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH')) && $queryString = http_build_query($this->getValues(), null, '&')) {
201-
$sep = false === strpos($uri, '?') ? '?' : '&';
202-
$uri .= $sep.$queryString;
200+
if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
201+
$query = parse_url($uri, PHP_URL_QUERY);
202+
$currentParameters = array();
203+
if ($query) {
204+
parse_str($query, $currentParameters);
205+
}
206+
207+
$queryString = http_build_query(array_merge($currentParameters, $this->getValues()), null, '&');
208+
209+
$pos = strpos($uri, '?');
210+
$base = false === $pos ? $uri : substr($uri, 0, $pos);
211+
$uri = rtrim($base.'?'.$queryString, '?');
203212
}
204213

205214
return $uri;

src/Symfony/Component/DomCrawler/Tests/FormTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,12 @@ public function provideGetUriValues()
593593
array(),
594594
'/foo?bar=bar&foo=foo',
595595
),
596+
10000 array(
597+
'replaces query values with the form values',
598+
'<form action="/foo?bar=bar"><input type="text" name="bar" value="foo" /><input type="submit" /></form>',
599+
array(),
600+
'/foo?bar=foo',
601+
),
596602
array(
597603
'returns an empty URI if the action is empty',
598604
'<form><input type="submit" /></form>',

src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
/*
44
* This file is part of the Symfony package.
5-
*
6-
* (c) Fabien Potencier <fabien@symfony.com>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
1111

1212
namespace Symfony\Component\Form\Extension\Core\ChoiceList;
1313

src/Symfony/Component/Form/FormEvents.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/*
34
* This file is part of the Symfony package.
45
*

src/Symfony/Component/Form/Test/TypeTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the Symfony package.
55
*
6-
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6+
* (c) Fabien Potencier <fabien@symfony.com>
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/*
34
* This file is part of the Symfony package.
45
*

src/Symfony/Component/Security/Acl/Domain/Acl.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/*
34
* This file is part of the Symfony package.
45
*

src/Symfony/Component/Security/Http/RememberMe/RememberMeServicesInterface.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<?php
2-
namespace Symfony\Component\Security\Http\RememberMe;
3-
4-
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
5-
use Symfony\Component\HttpFoundation\Response;
6-
use Symfony\Component\HttpFoundation\Request;
72

83
/*
94
* This file is part of the Symfony package.
@@ -14,6 +9,12 @@
149
* file that was distributed with this source code.
1510
*/
1611

12+
namespace Symfony\Component\Security\Http\RememberMe;
13+
14+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
15+
use Symfony\Component\HttpFoundation\Response;
16+
use Symfony\Component\HttpFoundation\Request;
17+
1718
/**
1819
* Interface that needs to be implemented by classes which provide remember-me
1920
* capabilities.

0 commit comments

Comments
 (0)
0