Skip to content

Commit 97016c0

Browse files
committed
Merge branch '4.3' into 4.4
* 4.3: [DotEnv] Remove `usePutEnv` property default value Set up typo fix [Validator] Allow underscore character "_" in URL username and password [SecurityBundle] Passwords are not encoded when algorithm set to \"true\" do not validate passwords when the hash is null [DI] fix resolving bindings for named TypedReference [DI] Fix making the container path-independent when the app is in /app Allow copy instead of symlink for ./link script [FrameworkBundle] resolve service locators in `debug:*` commands bumped Symfony version to 4.3.10 updated VERSION for 4.3.9 updated CHANGELOG for 4.3.9 bumped Symfony version to 3.4.37 updated VERSION for 3.4.36 update CONTRIBUTORS for 3.4.36 updated CHANGELOG for 3.4.36 Add test on ServerLogHandler
2 parents 0b0679f + 4169e62 commit 97016c0

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

Compiler/ResolveBindingsPass.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ protected function processValue($value, $isRoot = false)
9696
if ($value instanceof TypedReference && $value->getType() === (string) $value) {
9797
// Already checked
9898
$bindings = $this->container->getDefinition($this->currentId)->getBindings();
99+
$name = $value->getName();
100+
101+
if (isset($name, $bindings[$name = $value.' $'.$name])) {
102+
return $this->getBindingValue($bindings[$name]);
103+
}
99104

100105
if (isset($bindings[$value->getType()])) {
101106
return $this->getBindingValue($bindings[$value->getType()]);

Dumper/PhpDumper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ public function dump(array $options = [])
202202
if (!empty($options['file']) && is_dir($dir = \dirname($options['file']))) {
203203
// Build a regexp where the first root dirs are mandatory,
204204
// but every other sub-dir is optional up to the full path in $dir
205-
// Mandate at least 2 root dirs and not more that 5 optional dirs.
205+
// Mandate at least 1 root dir and not more than 5 optional dirs.
206206

207207
$dir = explode(\DIRECTORY_SEPARATOR, realpath($dir));
208208
$i = \count($dir);
209209

210-
if (3 <= $i) {
210+
if (2 + (int) ('\\' === \DIRECTORY_SEPARATOR) <= $i) {
211211
$regex = '';
212-
$lastOptionalDir = $i > 8 ? $i - 5 : 3;
212+
$lastOptionalDir = $i > 8 ? $i - 5 : (2 + (int) ('\\' === \DIRECTORY_SEPARATOR));
213213
$this->targetDirMaxMatches = $i - $lastOptionalDir;
214214

215215
while (--$i >= $lastOptionalDir) {

Tests/Compiler/ResolveBindingsPassTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ public function testTypedReferenceSupport()
8484
{
8585
$container = new ContainerBuilder();
8686

87-
$bindings = [CaseSensitiveClass::class => new BoundArgument(new Reference('foo'))];
87+
$bindings = [
88+
CaseSensitiveClass::class => new BoundArgument(new Reference('foo')),
89+
CaseSensitiveClass::class.' $c' => new BoundArgument(new Reference('bar')),
90+
];
8891

8992
// Explicit service id
9093
$definition1 = $container->register('def1', NamedArgumentsDummy::class);
@@ -95,11 +98,16 @@ public function testTypedReferenceSupport()
9598
$definition2->addArgument(new TypedReference(CaseSensitiveClass::class, CaseSensitiveClass::class));
9699
$definition2->setBindings($bindings);
97100

101+
$definition3 = $container->register('def3', NamedArgumentsDummy::class);
102+
$definition3->addArgument(new TypedReference(CaseSensitiveClass::class, CaseSensitiveClass::class, ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, 'c'));
103+
$definition3->setBindings($bindings);
104+
98105
$pass = new ResolveBindingsPass();
99106
$pass->process($container);
100107

101108
$this->assertEquals([$typedRef], $container->getDefinition('def1')->getArguments());
102109
$this->assertEquals([new Reference('foo')], $container->getDefinition('def2')->getArguments());
110+
$this->assertEquals([new Reference('bar')], $container->getDefinition('def3')->getArguments());
103111
}
104112

105113
public function testScalarSetter()

0 commit comments

Comments
 (0)