Skip to content

Commit e72bccd

Browse files
Merge branch '3.3' into 3.4
* 3.3: [TwigBridge] Fix namespaced classes bumped Symfony version to 3.3.2 updated VERSION for 3.3.1 updated CHANGELOG for 3.3.1 [DependencyInjection] Fix named args support in ChildDefinition [Cache] Fallback to positional when keyed results are broken [HttpFoundation][FrameworkBundle] Revert "trusted proxies" BC break [Cache] MemcachedAdapter not working with TagAwareAdapter Remove closure-proxy leftovers [DependencyInjection] Use more clear message when unused environment variables detected [Form][Profiler] Fixes form collector triggering deprecations mitigate BC break with empty trusted_proxies [Profiler] Never wrap in code excerpts [Form][FrameworkBundle] Remove non-existing arg for data_collector.form explain that a role can be an instance of Role [Cache] fix Redis scheme detection mix attr options between type-guess options and user options
2 parents c88ab65 + 4cec19e commit e72bccd

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

ChildDefinition.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function setParent($parent)
6262
* If replaceArgument() has been used to replace an argument, this method
6363
* will return the replacement value.
6464
*
65-
* @param int $index
65+
* @param int|string $index
6666
*
6767
* @return mixed The argument value
6868
*
@@ -74,13 +74,7 @@ public function getArgument($index)
7474
return $this->arguments['index_'.$index];
7575
}
7676

77-
$lastIndex = count(array_filter(array_keys($this->arguments), 'is_int')) - 1;
78-
79-
if ($index < 0 || $index > $lastIndex) {
80-
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, $lastIndex));
81-
}
82-
83-
return $this->arguments[$index];
77+
return parent::getArgument($index);
8478
}
8579

8680
/**
@@ -91,8 +85,8 @@ public function getArgument($index)
9185
* certain conventions when you want to overwrite the arguments of the
9286
* parent definition, otherwise your arguments will only be appended.
9387
*
94-
* @param int $index
95-
* @param mixed $value
88+
* @param int|string $index
89+
* @param mixed $value
9690
*
9791
* @return self the current instance
9892
*
@@ -105,7 +99,7 @@ public function replaceArgument($index, $value)
10599
} elseif (0 === strpos($index, '$')) {
106100
$this->arguments[$index] = $value;
107101
} else {
108-
throw new InvalidArgumentException('$index must be an integer.');
102+
throw new InvalidArgumentException('The argument must be an existing index or the name of a constructor\'s parameter.');
109103
}
110104

111105
return $this;

Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function dump(array $options = array())
175175
}
176176
}
177177
if ($unusedEnvs) {
178-
throw new EnvParameterException($unusedEnvs);
178+
throw new EnvParameterException($unusedEnvs, null, 'Environment variables "%s" are never used. Please, check your container\'s configuration.');
179179
}
180180

181181
return $code;

Exception/EnvParameterException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
class EnvParameterException extends InvalidArgumentException
2020
{
21-
public function __construct(array $usedEnvs, \Exception $previous = null)
21+
public function __construct(array $envs, \Exception $previous = null, $message = 'Incompatible use of dynamic environment variables "%s" found in parameters.')
2222
{
23-
parent::__construct(sprintf('Incompatible use of dynamic environment variables "%s" found in parameters.', implode('", "', $usedEnvs)), 0, $previous);
23+
parent::__construct(sprintf($message, implode('", "', $envs)), 0, $previous);
2424
}
2525
}

Tests/ChildDefinitionTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ public function testReplaceArgument()
113113
$this->assertSame('baz', $def->getArgument(1));
114114

115115
$this->assertSame(array(0 => 'foo', 1 => 'bar', 'index_1' => 'baz'), $def->getArguments());
116+
117+
$this->assertSame($def, $def->replaceArgument('$bar', 'val'));
118+
$this->assertSame('val', $def->getArgument('$bar'));
119+
$this->assertSame(array(0 => 'foo', 1 => 'bar', 'index_1' => 'baz', '$bar' => 'val'), $def->getArguments());
116120
}
117121

118122
/**

Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public function testEnvParameter()
336336

337337
/**
338338
* @expectedException \Symfony\Component\DependencyInjection\Exception\EnvParameterException
339-
* @expectedExceptionMessage Incompatible use of dynamic environment variables "FOO" found in parameters.
339+
* @expectedExceptionMessage Environment variables "FOO" are never used. Please, check your container's configuration.
340340
*/
341341
public function testUnusedEnvParameter()
342342
{

0 commit comments

Comments
 (0)