[DependencyInjection] fixed FrozenParameterBag and improved Parameter…
This commit is contained in:
parent
7c36f0b9a0
commit
3ad0794aa1
@ -69,4 +69,12 @@ class FrozenParameterBag extends ParameterBag
|
||||
{
|
||||
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.');
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\ParameterBag;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
||||
|
||||
/**
|
||||
@ -25,6 +26,8 @@ interface ParameterBagInterface
|
||||
/**
|
||||
* Clears all parameters.
|
||||
*
|
||||
* @throws LogicException if the ParameterBagInterface can not be cleared
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function clear();
|
||||
@ -34,6 +37,8 @@ interface ParameterBagInterface
|
||||
*
|
||||
* @param array $parameters An array of parameters
|
||||
*
|
||||
* @throws LogicException if the parameter can not be added
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function add(array $parameters);
|
||||
@ -66,6 +71,8 @@ interface ParameterBagInterface
|
||||
* @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);
|
||||
|
@ -57,4 +57,13 @@ class FrozenParameterBagTest extends \PHPUnit_Framework_TestCase
|
||||
$bag = new FrozenParameterBag(array());
|
||||
$bag->add(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
*/
|
||||
public function testRemove()
|
||||
{
|
||||
$bag = new FrozenParameterBag(array('foo' => 'bar'));
|
||||
$bag->remove('foo');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user