Skip to content

Commit

Permalink
[DependencyInjection] fixed FrozenParameterBag and improved Parameter…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomaz Ahlin authored and fabpot committed Jul 26, 2015
1 parent 7c36f0b commit 3ad0794
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Expand Up @@ -69,4 +69,12 @@ public function set($name, $value)
{
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
}

/**
* {@inheritdoc}
*/
public function remove($name)
{
throw new LogicException('Impossible to call remove() on a frozen ParameterBag.');
}
}
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\DependencyInjection\ParameterBag;

use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;

/**
Expand All @@ -25,6 +26,8 @@ interface ParameterBagInterface
/**
* Clears all parameters.
*
* @throws LogicException if the ParameterBagInterface can not be cleared
*
* @api
*/
public function clear();
Expand All @@ -34,6 +37,8 @@ public function clear();
*
* @param array $parameters An array of parameters
*
* @throws LogicException if the parameter can not be added
*
* @api
*/
public function add(array $parameters);
Expand Down Expand Up @@ -66,6 +71,8 @@ public function get($name);
* @param string $name The parameter name
* @param mixed $value The parameter value
*
* @throws LogicException if the parameter can not be set
*
* @api
*/
public function set($name, $value);
Expand Down
Expand Up @@ -57,4 +57,13 @@ public function testAdd()
$bag = new FrozenParameterBag(array());
$bag->add(array());
}

/**
* @expectedException \LogicException
*/
public function testRemove()
{
$bag = new FrozenParameterBag(array('foo' => 'bar'));
$bag->remove('foo');
}
}

0 comments on commit 3ad0794

Please sign in to comment.