Skip to content

Commit 0a732a9

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [FrameworkBundle] Fix Incorrect line break in exception message (500 debug page) Minor cleanups and improvements [form] lazy trans `post_max_size_message`. [DI] Fix setting synthetic services on ContainerBuilder [ClassLoader] Fix ClassCollectionLoader inlining with declare(strict_types=1)
2 parents 0552fbf + ad44c46 commit 0a732a9

File tree

9 files changed

+30
-41
lines changed

9 files changed

+30
-41
lines changed

Compiler/RepeatedPass.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ public function __construct(array $passes)
5656
*/
5757
public function process(ContainerBuilder $container)
5858
{
59-
$this->repeat = false;
60-
foreach ($this->passes as $pass) {
61-
$pass->process($container);
62-
}
63-
64-
if ($this->repeat) {
65-
$this->process($container);
66-
}
59+
do {
60+
$this->repeat = false;
61+
foreach ($this->passes as $pass) {
62+
$pass->process($container);
63+
}
64+
} while ($this->repeat);
6765
}
6866

6967
/**

ContainerBuilder.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -381,21 +381,14 @@ public function getScopeChildren($triggerDeprecationError = true)
381381
public function set($id, $service, $scope = self::SCOPE_CONTAINER)
382382
{
383383
$id = strtolower($id);
384+
$set = isset($this->definitions[$id]);
384385

385-
if ($this->isFrozen()) {
386+
if ($this->isFrozen() && ($set || isset($this->obsoleteDefinitions[$id])) && !$this->{$set ? 'definitions' : 'obsoleteDefinitions'}[$id]->isSynthetic()) {
386387
// setting a synthetic service on a frozen container is alright
387-
if (
388-
(!isset($this->definitions[$id]) && !isset($this->obsoleteDefinitions[$id]))
389-
||
390-
(isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic())
391-
||
392-
(isset($this->obsoleteDefinitions[$id]) && !$this->obsoleteDefinitions[$id]->isSynthetic())
393-
) {
394-
throw new BadMethodCallException(sprintf('Setting service "%s" on a frozen container is not allowed.', $id));
395-
}
388+
throw new BadMethodCallException(sprintf('Setting service "%s" on a frozen container is not allowed.', $id));
396389
}
397390

398-
if (isset($this->definitions[$id])) {
391+
if ($set) {
399392
$this->obsoleteDefinitions[$id] = $this->definitions[$id];
400393
}
401394

Dumper/GraphvizDumper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private function addEdges()
130130
*
131131
* @return array An array of edges
132132
*/
133-
private function findEdges($id, $arguments, $required, $name)
133+
private function findEdges($id, array $arguments, $required, $name)
134134
{
135135
$edges = array();
136136
foreach ($arguments as $argument) {
@@ -246,7 +246,7 @@ private function endDot()
246246
*
247247
* @return string A comma separated list of attributes
248248
*/
249-
private function addAttributes($attributes)
249+
private function addAttributes(array $attributes)
250250
{
251251
$code = array();
252252
foreach ($attributes as $k => $v) {
@@ -263,7 +263,7 @@ private function addAttributes($attributes)
263263
*
264264
* @return string A space separated list of options
265265
*/
266-
private function addOptions($options)
266+
private function addOptions(array $options)
267267
{
268268
$code = array();
269269
foreach ($options as $k => $v) {

Dumper/PhpDumper.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ private function addServiceReturn($id, $definition)
375375
* @throws InvalidArgumentException
376376
* @throws RuntimeException
377377
*/
378-
private function addServiceInstance($id, $definition)
378+
private function addServiceInstance($id, Definition $definition)
379379
{
380380
$class = $definition->getClass();
381381

@@ -425,7 +425,7 @@ private function addServiceInstance($id, $definition)
425425
*
426426
* @return bool
427427
*/
428-
private function isSimpleInstance($id, $definition)
428+
private function isSimpleInstance($id, Definition $definition)
429429
{
430430
foreach (array_merge(array($definition), $this->getInlinedDefinitions($definition)) as $sDefinition) {
431431
if ($definition !== $sDefinition && !$this->hasReference($id, $sDefinition->getMethodCalls())) {
@@ -449,7 +449,7 @@ private function isSimpleInstance($id, $definition)
449449
*
450450
* @return string
451451
*/
452-
private function addServiceMethodCalls($id, $definition, $variableName = 'instance')
452+
private function addServiceMethodCalls($id, Definition $definition, $variableName = 'instance')
453453
{
454454
$calls = '';
455455
foreach ($definition->getMethodCalls() as $call) {
@@ -464,7 +464,7 @@ private function addServiceMethodCalls($id, $definition, $variableName = 'instan
464464
return $calls;
465465
}
466466

467-
private function addServiceProperties($id, $definition, $variableName = 'instance')
467+
private function addServiceProperties($id, Definition $definition, $variableName = 'instance')
468468
{
469469
$code = '';
470470
foreach ($definition->getProperties() as $name => $value) {
@@ -484,7 +484,7 @@ private function addServiceProperties($id, $definition, $variableName = 'instanc
484484
*
485485
* @throws ServiceCircularReferenceException when the container contains a circular reference
486486
*/
487-
private function addServiceInlinedDefinitionsSetup($id, $definition)
487+
private function addServiceInlinedDefinitionsSetup($id, Definition $definition)
488488
{
489489
$this->referenceVariables[$id] = new Variable('instance');
490490

@@ -528,7 +528,7 @@ private function addServiceInlinedDefinitionsSetup($id, $definition)
528528
*
529529
* @return string
530530
*/
531-
private function addServiceConfigurator($id, $definition, $variableName = 'instance')
531+
private function addServiceConfigurator($id, Definition $definition, $variableName = 'instance')
532532
{
533533
if (!$callable = $definition->getConfigurator()) {
534534
return '';
@@ -560,7 +560,7 @@ private function addServiceConfigurator($id, $definition, $variableName = 'insta
560560
*
561561
* @return string
562562
*/
563-
private function addService($id, $definition)
563+
private function addService($id, Definition $definition)
564564
{
565565
$this->definitionVariables = new \SplObjectStorage();
566566
$this->referenceVariables = array();
@@ -1144,7 +1144,7 @@ protected function getDefaultParameters()
11441144
*
11451145
* @throws InvalidArgumentException
11461146
*/
1147-
private function exportParameters($parameters, $path = '', $indent = 12)
1147+
private function exportParameters(array $parameters, $path = '', $indent = 12)
11481148
{
11491149
$php = array();
11501150
foreach ($parameters as $key => $value) {

Dumper/XmlDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ private function addServices(\DOMElement $parent)
286286
* @param \DOMElement $parent
287287
* @param string $keyAttribute
288288
*/
289-
private function convertParameters($parameters, $type, \DOMElement $parent, $keyAttribute = 'key')
289+
private function convertParameters(array $parameters, $type, \DOMElement $parent, $keyAttribute = 'key')
290290
{
291291
$withKeys = array_keys($parameters) !== range(0, count($parameters) - 1);
292292
foreach ($parameters as $key => $value) {
@@ -335,7 +335,7 @@ private function convertParameters($parameters, $type, \DOMElement $parent, $key
335335
*
336336
* @return array
337337
*/
338-
private function escape($arguments)
338+
private function escape(array $arguments)
339339
{
340340
$args = array();
341341
foreach ($arguments as $k => $v) {

Dumper/YamlDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private function getExpressionCall($expression)
327327
*
328328
* @return array
329329
*/
330-
private function prepareParameters($parameters, $escape = true)
330+
private function prepareParameters(array $parameters, $escape = true)
331331
{
332332
$filtered = array();
333333
foreach ($parameters as $key => $value) {
@@ -350,7 +350,7 @@ private function prepareParameters($parameters, $escape = true)
350350
*
351351
* @return array
352352
*/
353-
private function escape($arguments)
353+
private function escape(array $arguments)
354354
{
355355
$args = array();
356356
foreach ($arguments as $k => $v) {

Loader/YamlFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,9 @@ private function resolveServices($value)
420420
{
421421
if (is_array($value)) {
422422
$value = array_map(array($this, 'resolveServices'), $value);
423-
} elseif (is_string($value) && 0 === strpos($value, '@=')) {
423+
} elseif (is_string($value) && 0 === strpos($value, '@=')) {
424424
return new Expression(substr($value, 2));
425-
} elseif (is_string($value) && 0 === strpos($value, '@')) {
425+
} elseif (is_string($value) && 0 === strpos($value, '@')) {
426426
if (0 === strpos($value, '@@')) {
427427
$value = substr($value, 1);
428428
$invalidBehavior = null;

Tests/ContainerBuilderTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,14 +677,12 @@ public function testThrowsExceptionWhenSetServiceOnAFrozenContainer()
677677
$container->set('a', new \stdClass());
678678
}
679679

680-
/**
681-
* @expectedException \BadMethodCallException
682-
*/
683680
public function testThrowsExceptionWhenAddServiceOnAFrozenContainer()
684681
{
685682
$container = new ContainerBuilder();
686683
$container->compile();
687-
$container->set('a', new \stdClass());
684+
$container->set('a', $foo = new \stdClass());
685+
$this->assertSame($foo, $container->get('a'));
688686
}
689687

690688
public function testNoExceptionWhenSetSyntheticServiceOnAFrozenContainer()

Tests/ContainerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function testGetReturnsNullOnInactiveScope()
269269

270270
/**
271271
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
272-
* @expectedExcepionMessage You have requested a synthetic service ("request"). The DIC does not know how to construct this service.
272+
* @expectedExceptionMessage You have requested a synthetic service ("request"). The DIC does not know how to construct this service.
273273
*/
274274
public function testGetSyntheticServiceAlwaysThrows()
275275
{

0 commit comments

Comments
 (0)