Skip to content

Commit cc9c9b4

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Throw exception if incompatible version of psr/simple-cache is used [DependencyInjection] copy synthetic status when resolving child definitions [HttpClient] Fix Failed to open stream: Too many open files [Console] use STDOUT/ERR in ConsoleOutput to save opening too many file descriptors Fix for "Implicit conversion from float <float_number> to int loses precision" Fix typo in UPGRADE-6.0.md [Cache] Set mtime of cache files 1 year into future if they do not expire [DependencyInjection] remove arbitratry limitation to exclude inline services from bindings
2 parents fc5a358 + eb5f343 commit cc9c9b4

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

Compiler/ResolveChildDefinitionsPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ private function doResolveDefinition(ChildDefinition $definition): Definition
115115

116116
$def->setBindings($definition->getBindings() + $parentDef->getBindings());
117117

118+
$def->setSynthetic($definition->isSynthetic());
119+
118120
// overwrite with values specified in the decorator
119121
$changes = $definition->getChanges();
120122
if (isset($changes['class'])) {

Loader/Configurator/Traits/BindTrait.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator\Traits;
1313

1414
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
15-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1615
use Symfony\Component\DependencyInjection\Loader\Configurator\DefaultsConfigurator;
1716
use Symfony\Component\DependencyInjection\Loader\Configurator\InstanceofConfigurator;
18-
use Symfony\Component\DependencyInjection\Reference;
1917

2018
trait BindTrait
2119
{
@@ -34,9 +32,6 @@ trait BindTrait
3432
final public function bind(string $nameOrFqcn, mixed $valueOrRef): static
3533
{
3634
$valueOrRef = static::processValue($valueOrRef, true);
37-
if (!preg_match('/^(?:(?:array|bool|float|int|string|iterable)[ \t]*+)?\$/', $nameOrFqcn) && !$valueOrRef instanceof Reference) {
38-
throw new InvalidArgumentException(sprintf('Invalid binding for service "%s": named arguments must start with a "$", and FQCN must map to references. Neither applies to binding "%s".', $this->id, $nameOrFqcn));
39-
}
4035
$bindings = $this->definition->getBindings();
4136
$type = $this instanceof DefaultsConfigurator ? BoundArgument::DEFAULTS_BINDING : ($this instanceof InstanceofConfigurator ? BoundArgument::INSTANCEOF_BINDING : BoundArgument::SERVICE_BINDING);
4237
$bindings[$nameOrFqcn] = new BoundArgument($valueOrRef, true, $type, $this->path ?? null);

Tests/Compiler/ResolveChildDefinitionsPassTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,21 @@ public function testProcessDetectsChildDefinitionIndirectCircularReference()
396396

397397
$this->process($container);
398398
}
399+
400+
public function testProcessCopiesSyntheticStatus()
401+
{
402+
$container = new ContainerBuilder();
403+
404+
$container->register('parent');
405+
406+
$container
407+
->setDefinition('child', new ChildDefinition('parent'))
408+
->setSynthetic(true)
409+
;
410+
411+
$this->process($container);
412+
413+
$def = $container->getDefinition('child');
414+
$this->assertTrue($def->isSynthetic());
415+
}
399416
}

Tests/Fixtures/Prototype/Foo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#[When(env: 'dev')]
99
class Foo implements FooInterface, Sub\BarInterface
1010
{
11-
public function __construct($bar = null, iterable $foo = null)
11+
public function __construct($bar = null, iterable $foo = null, object $baz = null)
1212
{
1313
}
1414

Tests/Fixtures/config/defaults.expected.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ services:
1515
- t: { a: b }
1616
autowire: true
1717
autoconfigure: true
18-
arguments: ['@bar', !tagged_iterator foo]
18+
arguments: ['@bar', !tagged_iterator foo, !service { class: Baz }]
1919
bar:
2020
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
2121
public: true
2222
tags:
2323
- t: { a: b }
2424
autowire: true
25-
arguments: [null, !tagged_iterator foo]
25+
arguments: [null, !tagged_iterator foo, !service { class: Baz }]
2626
calls:
2727
- [setFoo, ['@bar']]
2828

Tests/Fixtures/config/defaults.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
->tag('t', ['a' => 'b'])
1616
->bind(Foo::class, service('bar'))
1717
->bind('iterable $foo', tagged_iterator('foo'))
18+
->bind('object $baz', inline('Baz'))
1819
->public();
1920

2021
$s->set(Foo::class)->args([service('bar')])->public();

0 commit comments

Comments
 (0)