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

Skip to content

Commit e103e1d

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: Permit empty suffix on Windows [Console][Table] fixed render when using multiple rowspans. add docblocks for Twig url and path function to improve ide completion check for circular refs caused by method calls [Serializer] fix upper camel case conversion (see #21399) [DI] Auto register extension configuration classes as a resource [Console] Updated phpdoc on return types
2 parents 0319430 + 3441b15 commit e103e1d

File tree

17 files changed

+118
-52
lines changed

17 files changed

+118
-52
lines changed

src/Symfony/Bridge/Twig/Extension/RoutingExtension.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,25 @@ public function getFunctions()
4040
);
4141
}
4242

43+
/**
44+
* @param string $name
45+
* @param array $parameters
46+
* @param bool $relative
47+
*
48+
* @return string
49+
*/
4350
public function getPath($name, $parameters = array(), $relative = false)
4451
{
4552
return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH);
4653
}
4754

55+
/**
56+
* @param string $name
57+
* @param array $parameters
58+
* @param bool $schemeRelative
59+
*
60+
* @return string
61+
*/
4862
public function getUrl($name, $parameters = array(), $schemeRelative = false)
4963
{
5064
return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class QuestionHelper extends Helper
3838
* @param OutputInterface $output An OutputInterface instance
3939
* @param Question $question The question to ask
4040
*
41-
* @return string The user answer
41+
* @return mixed The user answer
4242
*
4343
* @throws RuntimeException If there is no data to read in the input stream
4444
*/
@@ -384,7 +384,7 @@ private function getHiddenResponse(OutputInterface $output, $inputStream)
384384
* @param OutputInterface $output An Output instance
385385
* @param Question $question A Question instance
386386
*
387-
* @return string The validated response
387+
* @return mixed The validated response
388388
*
389389
* @throws \Exception In case the max number of attempts has been reached and no valid response has been given
390390
*/

src/Symfony/Component/Console/Helper/Table.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,9 @@ private function fillNextRows($rows, $line)
440440
foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
441441
$value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
442442
$unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
443+
if ($nbLines === $unmergedRowKey - $line) {
444+
break;
445+
}
443446
}
444447
}
445448
}

src/Symfony/Component/Console/Tests/Helper/TableTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -298,29 +298,29 @@ public function testRenderProvider()
298298
array(
299299
array(
300300
new TableCell('9971-5-0210-0', array('rowspan' => 3)),
301-
'Divine Comedy',
301+
new TableCell('Divine Comedy', array('rowspan' => 2)),
302302
'Dante Alighieri',
303303
),
304-
array('A Tale of Two Cities', 'Charles Dickens'),
304+
array(),
305305
array("The Lord of \nthe Rings", "J. R. \nR. Tolkien"),
306306
new TableSeparator(),
307307
array('80-902734-1-6', new TableCell("And Then \nThere \nWere None", array('rowspan' => 3)), 'Agatha Christie'),
308308
array('80-902734-1-7', 'Test'),
309309
),
310310
'default',
311311
<<<'TABLE'
312-
+---------------+----------------------+-----------------+
313-
| ISBN | Title | Author |
314-
+---------------+----------------------+-----------------+
315-
| 9971-5-0210-0 | Divine Comedy | Dante Alighieri |
316-
| | A Tale of Two Cities | Charles Dickens |
317-
| | The Lord of | J. R. |
318-
| | the Rings | R. Tolkien |
319-
+---------------+----------------------+-----------------+
320-
| 80-902734-1-6 | And Then | Agatha Christie |
321-
| 80-902734-1-7 | There | Test |
322-
| | Were None | |
323-
+---------------+----------------------+-----------------+
312+
+---------------+---------------+-----------------+
313+
| ISBN | Title | Author |
314+
+---------------+---------------+-----------------+
315+
| 9971-5-0210-0 | Divine Comedy | Dante Alighieri |
316+
| | | |
317+
| | The Lord of | J. R. |
318+
| | the Rings | R. Tolkien |
319+
+---------------+---------------+-----------------+
320+
| 80-902734-1-6 | And Then | Agatha Christie |
321+
| 80-902734-1-7 | There | Test |
322+
| | Were None | |
323+
+---------------+---------------+-----------------+
324324

325325
TABLE
326326
),

src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\ContainerBuilder;
15+
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
1516
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
1617

1718
/**
@@ -47,6 +48,9 @@ public function process(ContainerBuilder $container)
4748
$tmpContainer = new ContainerBuilder($container->getParameterBag());
4849
$tmpContainer->setResourceTracking($container->isTrackingResources());
4950
$tmpContainer->addObjectResource($extension);
51+
if ($extension instanceof ConfigurationExtensionInterface && null !== $configuration = $extension->getConfiguration($config, $tmpContainer)) {
52+
$tmpContainer->addObjectResource($configuration);
53+
}
5054

5155
foreach ($exprLangProviders as $provider) {
5256
$tmpContainer->addExpressionLanguageProvider($provider);

src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function __construct()
6464
new RemoveUnusedDefinitionsPass(),
6565
)),
6666
new CheckExceptionOnInvalidReferenceBehaviorPass(),
67+
new CheckCircularReferencesPass(),
6768
);
6869
}
6970

src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,30 @@ public function testProcessInlinesWhenThereAreMultipleReferencesButFromTheSameDe
113113
$this->assertFalse($container->hasDefinition('b'));
114 F438 114
$this->assertFalse($container->hasDefinition('c'), 'Service C was not inlined.');
115115
}
116+
117+
/**
118+
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
119+
*/
120+
public function testCircularReferencesCausedByMethodCallsAreDetectedDuringCompilation()
121+
{
122+
$container = new ContainerBuilder();
123+
$container->setResourceTracking(false);
124+
125+
$container
126+
->register('foobar', '\stdClass')
127+
->addArgument(new Reference('foo'))
128+
;
129+
130+
$container
131+
->register('foo', '\stdClass')
132+
->addArgument(new Reference('bar'))
133+
;
134+
135+
$container
136+
->register('foo', '\stdClass')
137+
->addMethodCall('addFoobar', array(new Reference('foobar')))
138+
;
139+
140+
$container->compile();
141+
}
116142
}

src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
1313

14+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15+
use Symfony\Component\Config\Definition\ConfigurationInterface;
16+
use Symfony\Component\Config\Resource\FileResource;
1417
use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass;
1518
use Symfony\Component\DependencyInjection\ContainerBuilder;
1619
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@@ -48,4 +51,32 @@ public function testExpressionLanguageProviderForwarding()
4851

4952
$this->assertEquals(array($provider), $tmpProviders);
5053
}
54+
55+
public function testExtensionConfigurationIsTrackedByDefault()
56+
{
57+
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\Extension')->getMock();
58+
$extension->expects($this->once())
59+
->method('getConfiguration')
60+
->will($this->returnValue(new FooConfiguration()));
61+
$extension->expects($this->any())
62+
->method('getAlias')
63+
->will($this->returnValue('foo'));
64+
65+
$container = new ContainerBuilder(new ParameterBag());
66+
$container->registerExtension($extension);
67+
$container->prependExtensionConfig('foo', array('bar' => true));
68+
69+
$pass = new MergeExtensionConfigurationPass();
70+
$pass->process($container);
71+
72+
$this->assertContains(new FileResource(__FILE__), $container->getResources(), '', false, false);
73+
}
74+
}
75+
76+
class FooConfiguration implements ConfigurationInterface
77+
{
78+
public function getConfigTreeBuilder()
79+
{
80+
return new TreeBuilder();
81+
}
5182
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
;
6464
$container
6565
->register('baz', 'Baz')
66-
->addMethodCall('setFoo', array(new Reference('foo_with_inline')))
6766
;
6867
$container
6968
->register('request', 'Request')

src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,5 @@ digraph sc {
3737
node_method_call1 -> node_foobaz [label="setBar()" style="dashed"];
3838
node_foo_with_inline -> node_inlined [label="setBar()" style="dashed"];
3939
node_inlined -> node_baz [label="setBaz()" style="dashed"];
40-
node_baz -> node_foo_with_inline [label="setFoo()" style="dashed"];
4140
node_configurator_service -> node_baz [label="setFoo()" style="dashed"];
4241
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,7 @@ protected function getBarService()
8181
*/
8282
protected function getBazService()
8383
{
84-
$this->services['baz'] = $instance = new \Baz();
85-
86-
$instance->setFoo($this->get('foo_with_inline'));
87-
88-
return $instance;
84+
return $this->services['baz'] = new \Baz();
8985
}
9086

9187
/**

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,7 @@ protected function getBarService()
100100
*/
101101
protected function getBazService()
102102
{
103-
$this->services['baz'] = $instance = new \Baz();
104-
105-
$instance->setFoo($this->get('foo_with_inline'));
106-
107-
return $instance;
103+
return $this->services['baz'] = new \Baz();
108104
}
109105

110106
/**
@@ -245,12 +241,11 @@ protected function getFooBarService()
245241
protected function getFooWithInlineService()
246242
{
247243
$a = new \Bar();
248-
249-
$this->services['foo_with_inline'] = $instance = new \Foo();
250-
251244
$a->pub = 'pub';
252245
$a->setBaz($this->get('baz'));
253246

247+
$this->services['foo_with_inline'] = $instance = new \Foo();
248+
254249
$instance->setBar($a);
255250

256251
return $instance;

src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@
7070
<argument type="service" id="baz"/>
7171
</call>
7272
</service>
73-
<service id="baz" class="Baz">
74-
<call method="setFoo">
75-
<argument type="service" id="foo_with_inline"/>
76-
</call>
77-
</service>
73+
<service id="baz" class="Baz"/>
7874
<service id="request" class="Request" synthetic="true"/>
7975
<service id="configurator_service" class="ConfClass" public="false">
8076
<call method="setFoo">

src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ services:
5252

5353
baz:
5454
class: Baz
55-
calls:
56-
- [setFoo, ['@foo_with_inline']]
5755

5856
request:
5957
class: Request

src/Symfony/Component/Process/ExecutableFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function find($name, $default = null, array $extraDirs = array())
7575
$suffixes = array('');
7676
if ('\\' === DIRECTORY_SEPARATOR) {
7777
$pathExt = getenv('PATHEXT');
78-
$suffixes = $pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes;
78+
$suffixes = array_merge($suffixes, $pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes);
7979
}
8080
foreach ($suffixes as $suffix) {
8181
foreach ($dirs as $dir) {

src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ public function __construct(array $attributes = null, $lowerCamelCase = true)
4444
public function normalize($propertyName)
4545
{
4646
if (null === $this->attributes || in_array($propertyName, $this->attributes)) {
47+
$lcPropertyName = lcfirst($propertyName);
4748
$snakeCasedName = '';
4849

49-
$len = strlen($propertyName);
50+
$len = strlen($lcPropertyName);
5051
for ($i = 0; $i < $len; ++$i) {
51-
if (ctype_upper($propertyName[$i])) {
52-
$snakeCasedName .= '_'.strtolower($propertyName[$i]);
52+
if (ctype_upper($lcPropertyName[$i])) {
53+
$snakeCasedName .= '_'.strtolower($lcPropertyName[$i]);
5354
} else {
54-
$snakeCasedName .= strtolower($propertyName[$i]);
55+
$snakeCasedName .= strtolower($lcPropertyName[$i]);
5556
}
5657
}
5758

src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,30 @@ public function testInterface()
2727
/**
2828
* @dataProvider attributeProvider
2929
*/
30-
public function testNormalize($underscored, $lowerCamelCased)
30+
public function testNormalize($underscored, $camelCased, $useLowerCamelCase)
3131
{
32-
$nameConverter = new CamelCaseToSnakeCaseNameConverter();
33-
$this->assertEquals($nameConverter->normalize($lowerCamelCased), $underscored);
32+
$nameConverter = new CamelCaseToSnakeCaseNameConverter(null, $useLowerCamelCase);
33+
$this->assertEquals($nameConverter->normalize($camelCased), $underscored);
3434
}
3535

3636
/**
3737
* @dataProvider attributeProvider
3838
*/
39-
public function testDenormalize($underscored, $lowerCamelCased)
39+
public function testDenormalize($underscored, $camelCased, $useLowerCamelCase)
4040
{
41-
$nameConverter = new CamelCaseToSnakeCaseNameConverter();
42-
$this->assertEquals($nameConverter->denormalize($underscored), $lowerCamelCased);
41+
$nameConverter = new CamelCaseToSnakeCaseNameConverter(null, $useLowerCamelCase);
42+
$this->assertEquals($nameConverter->denormalize($underscored), $camelCased);
4343
}
4444

4545
public function attributeProvider()
4646
{
4747
return array(
48-
array('coop_tilleuls', 'coopTilleuls'),
49-
array('_kevin_dunglas', '_kevinDunglas'),
50-
array('this_is_a_test', 'thisIsATest'),
48+
array('coop_tilleuls', 'coopTilleuls', true),
49+
array('_kevin_dunglas', '_kevinDunglas', true),
50+
array('this_is_a_test', 'thisIsATest', true),
51+
array('coop_tilleuls', 'CoopTilleuls', false),
52+
array('_kevin_dunglas', '_kevinDunglas', false),
53+
array('this_is_a_test', 'ThisIsATest', false),
5154
);
5255
}
5356
}

0 commit comments

Comments
 (0)
0