Skip to content

Commit b1dd1ca

Browse files
Tomaz Ahlinfabpot
authored andcommitted
[DependencyInjection] fixed FrozenParameterBag and improved Parameter…
1 parent 82cea2c commit b1dd1ca

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

ParameterBag/FrozenParameterBag.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,12 @@ public function set($name, $value)
6969
{
7070
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
7171
}
72+
73+
/**
74+
* {@inheritdoc}
75+
*/
76+
public function remove($name)
77+
{
78+
throw new LogicException('Impossible to call remove() on a frozen ParameterBag.');
79+
}
7280
}

ParameterBag/ParameterBagInterface.php

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

1212
namespace Symfony\Component\DependencyInjection\ParameterBag;
1313

14+
use Symfony\Component\DependencyInjection\Exception\LogicException;
1415
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
1516

1617
/**
@@ -25,6 +26,8 @@ interface ParameterBagInterface
2526
/**
2627
* Clears all parameters.
2728
*
29+
* @throws LogicException if the ParameterBagInterface can not be cleared
30+
*
2831
* @api
2932
*/
3033
public function clear();
@@ -34,6 +37,8 @@ public function clear();
3437
*
3538
* @param array $parameters An array of parameters
3639
*
40+
* @throws LogicException if the parameter can not be added
41+
*
3742
* @api
3843
*/
3944
public function add(array $parameters);
@@ -66,6 +71,8 @@ public function get($name);
6671
* @param string $name The parameter name
6772
* @param mixed $value The parameter value
6873
*
74+
* @throws LogicException if the parameter can not be set
75+
*
6976
* @api
7077
*/
7178
public function set($name, $value);

Tests/ParameterBag/FrozenParameterBagTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,13 @@ public function testAdd()
5757
$bag = new FrozenParameterBag(array());
5858
$bag->add(array());
5959
}
60+
61+
/**
62+
* @expectedException \LogicException
63+
*/
64+
public function testRemove()
65+
{
66+
$bag = new FrozenParameterBag(array('foo' => 'bar'));
67+
$bag->remove('foo');
68+
}
6069
}

0 commit comments

Comments
 (0)