Skip to content

Commit

Permalink
[DependencyInjection] renamed NonExistentParameterException and NonEx…
Browse files Browse the repository at this point in the history
…istentServiceException to ParameterNotFoundException and ServiceNotFoundException
  • Loading branch information
fabpot committed May 17, 2011
1 parent 403156e commit 0168241
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
Expand Up @@ -4,7 +4,7 @@

use Symfony\Component\DependencyInjection\Definition;

use Symfony\Component\DependencyInjection\Exception\NonExistentServiceException;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -47,7 +47,7 @@ private function processReferences(array $arguments)
$destId = (string) $argument;

if (!$this->container->has($destId)) {
throw new NonExistentServiceException($destId, $this->sourceId);
throw new ServiceNotFoundException($destId, $this->sourceId);
}
}
}
Expand Down
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Component\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\NonExistentParameterException;
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;

/**
* Resolves all parameter placeholders "%somevalue%" to their real values.
Expand Down Expand Up @@ -45,7 +45,7 @@ public function process(ContainerBuilder $container)
$definition->setMethodCalls($calls);

$definition->setProperties($this->resolveValue($definition->getProperties()));
} catch (NonExistentParameterException $e) {
} catch (ParameterNotFoundException $e) {
$e->setSourceId($id);

throw $e;
Expand All @@ -62,7 +62,7 @@ public function process(ContainerBuilder $container)
foreach ($parameterBag->all() as $key => $value) {
try {
$parameterBag->set($key, $this->resolveValue($value));
} catch (NonExistentParameterException $e) {
} catch (ParameterNotFoundException $e) {
$e->setSourceKey($key);

throw $e;
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/DependencyInjection/Container.php
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\DependencyInjection;

use Symfony\Component\DependencyInjection\Exception\NonExistentServiceException;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\DependencyInjection\Exception\CircularReferenceException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
Expand Down Expand Up @@ -238,7 +238,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
}

if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
throw new NonExistentServiceException($id);
throw new ServiceNotFoundException($id);
}
}

Expand Down
Expand Up @@ -16,7 +16,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class NonExistentParameterException extends InvalidArgumentException
class ParameterNotFoundException extends InvalidArgumentException
{
private $key;
private $sourceId;
Expand Down
Expand Up @@ -7,7 +7,7 @@
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class NonExistentServiceException extends InvalidArgumentException
class ServiceNotFoundException extends InvalidArgumentException
{
private $id;
private $sourceId;
Expand Down
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\DependencyInjection\ParameterBag;

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

/**
*
Expand Down Expand Up @@ -69,14 +69,14 @@ public function all()
*
* @return mixed The parameter value
*
* @throws NonExistentParameterException if the parameter is not defined
* @throws ParameterNotFoundException if the parameter is not defined
*/
public function get($name)
{
$name = strtolower($name);

if (!array_key_exists($name, $this->parameters)) {
throw new NonExistentParameterException($name);
throw new ParameterNotFoundException($name);
}

return $this->parameters[$name];
Expand Down Expand Up @@ -113,7 +113,7 @@ public function resolve()
foreach ($this->parameters as $key => $value) {
try {
$this->parameters[$key] = $this->resolveValue($value);
} catch (NonExistentParameterException $e) {
} catch (ParameterNotFoundException $e) {
$e->setSourceKey($key);

throw $e;
Expand All @@ -126,7 +126,7 @@ public function resolve()
*
* @param mixed $value A value
*
* @throws NonExistentParameterException if a placeholder references a parameter that does not exist
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
*/
public function resolveValue($value)
{
Expand Down
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\DependencyInjection\ParameterBag;

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

/**
* ParameterBagInterface.
Expand Down Expand Up @@ -46,7 +46,7 @@ function all();
*
* @return mixed The parameter value
*
* @throws NonExistentParameterException if the parameter is not defined
* @throws ParameterNotFoundException if the parameter is not defined
*/
function get($name);

Expand Down Expand Up @@ -77,7 +77,7 @@ function resolve();
*
* @param mixed $value A value
*
* @throws NonExistentParameterException if a placeholder references a parameter that does not exist
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
*/
function resolveValue($value);
}
Expand Up @@ -22,7 +22,7 @@ public function testProcess()
}

/**
* @expectedException Symfony\Component\DependencyInjection\Exception\NonExistentServiceException
* @expectedException Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
*/
public function testProcessThrowsExceptionOnInvalidReference()
{
Expand All @@ -37,7 +37,7 @@ public function testProcessThrowsExceptionOnInvalidReference()
}

/**
* @expectedException Symfony\Component\DependencyInjection\Exception\NonExistentServiceException
* @expectedException Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
*/
public function testProcessThrowsExceptionOnInvalidReferenceFromInlinedDefinition()
{
Expand Down
Expand Up @@ -161,7 +161,7 @@ public function testGet()
$sc->get('');
$this->fail('->get() throws a \InvalidArgumentException exception if the service is empty');
} catch (\Exception $e) {
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\NonExistentServiceException', $e, '->get() throws a NonExistentServiceException exception if the service is empty');
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws a ServiceNotFoundException exception if the service is empty');
}
$this->assertNull($sc->get('', ContainerInterface::NULL_ON_INVALID_REFERENCE));
}
Expand Down
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Tests\Component\DependencyInjection\ParameterBag;

use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\DependencyInjection\Exception\NonExistentParameterException;
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;

class ParameterBagTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -100,15 +100,15 @@ public function testResolveValue()
try {
$bag->resolveValue('%foobar%', array());
$this->fail('->resolveValue() throws an InvalidArgumentException if a placeholder references a non-existent parameter');
} catch (NonExistentParameterException $e) {
$this->assertEquals('You have requested a non-existent parameter "foobar".', $e->getMessage(), '->resolveValue() throws a NonExistentParameterException if a placeholder references a non-existent parameter');
} catch (ParameterNotFoundException $e) {
$this->assertEquals('You have requested a non-existent parameter "foobar".', $e->getMessage(), '->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter');
}

try {
$bag->resolveValue('foo %foobar% bar', array());
$this->fail('->resolveValue() throws a NonExistentParameterException if a placeholder references a non-existent parameter');
} catch (NonExistentParameterException $e) {
$this->assertEquals('You have requested a non-existent parameter "foobar".', $e->getMessage(), '->resolveValue() throws a NonExistentParameterException if a placeholder references a non-existent parameter');
$this->fail('->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter');
} catch (ParameterNotFoundException $e) {
$this->assertEquals('You have requested a non-existent parameter "foobar".', $e->getMessage(), '->resolveValue() throws a ParameterNotFoundException if a placeholder references a non-existent parameter');
}
}

Expand All @@ -121,15 +121,15 @@ public function testResolveIndicatesWhyAParameterIsNeeded()

try {
$bag->resolve();
} catch (NonExistentParameterException $e) {
} catch (ParameterNotFoundException $e) {
$this->assertEquals('The parameter "foo" has a dependency on a non-existent parameter "bar".', $e->getMessage());
}

$bag = new ParameterBag(array('foo' => '%bar%'));

try {
$bag->resolve();
} catch (NonExistentParameterException $e) {
} catch (ParameterNotFoundException $e) {
$this->assertEquals('The parameter "foo" has a dependency on a non-existent parameter "bar".', $e->getMessage());
}
}
Expand Down

0 comments on commit 0168241

Please sign in to comment.