Procházet zdrojové kódy

[DependencyInjection] renamed NonExistentParameterException and NonExistentServiceException to ParameterNotFoundException and ServiceNotFoundException

Fabien Potencier před 14 roky
rodič
revize
0168241014

+ 2 - 2
src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php

@@ -4,7 +4,7 @@ namespace Symfony\Component\DependencyInjection\Compiler;
 
 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;
@@ -47,7 +47,7 @@ class CheckExceptionOnInvalidReferenceBehaviorPass implements CompilerPassInterf
                 $destId = (string) $argument;
 
                 if (!$this->container->has($destId)) {
-                    throw new NonExistentServiceException($destId, $this->sourceId);
+                    throw new ServiceNotFoundException($destId, $this->sourceId);
                 }
             }
         }

+ 3 - 3
src/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php

@@ -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.
@@ -45,7 +45,7 @@ class ResolveParameterPlaceHoldersPass implements CompilerPassInterface
                 $definition->setMethodCalls($calls);
 
                 $definition->setProperties($this->resolveValue($definition->getProperties()));
-            } catch (NonExistentParameterException $e) {
+            } catch (ParameterNotFoundException $e) {
                 $e->setSourceId($id);
 
                 throw $e;
@@ -62,7 +62,7 @@ class ResolveParameterPlaceHoldersPass implements CompilerPassInterface
         foreach ($parameterBag->all() as $key => $value) {
             try {
                 $parameterBag->set($key, $this->resolveValue($value));
-            } catch (NonExistentParameterException $e) {
+            } catch (ParameterNotFoundException $e) {
                 $e->setSourceKey($key);
 
                 throw $e;

+ 2 - 2
src/Symfony/Component/DependencyInjection/Container.php

@@ -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;
@@ -238,7 +238,7 @@ class Container implements ContainerInterface
         }
 
         if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
-            throw new NonExistentServiceException($id);
+            throw new ServiceNotFoundException($id);
         }
     }
 

+ 1 - 1
src/Symfony/Component/DependencyInjection/Exception/NonExistentParameterException.php

@@ -16,7 +16,7 @@ namespace Symfony\Component\DependencyInjection\Exception;
  *
  * @author Fabien Potencier <fabien@symfony.com>
  */
-class NonExistentParameterException extends InvalidArgumentException
+class ParameterNotFoundException extends InvalidArgumentException
 {
     private $key;
     private $sourceId;

+ 1 - 1
src/Symfony/Component/DependencyInjection/Exception/NonExistentServiceException.php

@@ -7,7 +7,7 @@ namespace Symfony\Component\DependencyInjection\Exception;
  *
  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  */
-class NonExistentServiceException extends InvalidArgumentException
+class ServiceNotFoundException extends InvalidArgumentException
 {
     private $id;
     private $sourceId;

+ 5 - 5
src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php

@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\DependencyInjection\ParameterBag;
 
-use Symfony\Component\DependencyInjection\Exception\NonExistentParameterException;
+use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
 
 /**
  *
@@ -69,14 +69,14 @@ class ParameterBag implements ParameterBagInterface
      *
      * @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];
@@ -113,7 +113,7 @@ class ParameterBag implements ParameterBagInterface
         foreach ($this->parameters as $key => $value) {
             try {
                 $this->parameters[$key] = $this->resolveValue($value);
-            } catch (NonExistentParameterException $e) {
+            } catch (ParameterNotFoundException $e) {
                 $e->setSourceKey($key);
 
                 throw $e;
@@ -126,7 +126,7 @@ class ParameterBag implements ParameterBagInterface
      *
      * @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)
     {

+ 3 - 3
src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php

@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\DependencyInjection\ParameterBag;
 
-use Symfony\Component\DependencyInjection\Exception\NonExistentParameterException;
+use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
 
 /**
  * ParameterBagInterface.
@@ -46,7 +46,7 @@ interface ParameterBagInterface
      *
      * @return mixed  The parameter value
      *
-     * @throws NonExistentParameterException if the parameter is not defined
+     * @throws ParameterNotFoundException if the parameter is not defined
      */
     function get($name);
 
@@ -77,7 +77,7 @@ interface ParameterBagInterface
      *
      * @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);
 }

+ 2 - 2
tests/Symfony/Tests/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php

@@ -22,7 +22,7 @@ class CheckExceptionOnInvalidReferenceBehaviorPassTest extends \PHPUnit_Framewor
     }
 
     /**
-     * @expectedException Symfony\Component\DependencyInjection\Exception\NonExistentServiceException
+     * @expectedException Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
      */
     public function testProcessThrowsExceptionOnInvalidReference()
     {
@@ -37,7 +37,7 @@ class CheckExceptionOnInvalidReferenceBehaviorPassTest extends \PHPUnit_Framewor
     }
 
     /**
-     * @expectedException Symfony\Component\DependencyInjection\Exception\NonExistentServiceException
+     * @expectedException Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
      */
     public function testProcessThrowsExceptionOnInvalidReferenceFromInlinedDefinition()
     {

+ 1 - 1
tests/Symfony/Tests/Component/DependencyInjection/ContainerTest.php

@@ -161,7 +161,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
             $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));
     }

+ 8 - 8
tests/Symfony/Tests/Component/DependencyInjection/ParameterBag/ParameterBagTest.php

@@ -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
 {
@@ -100,15 +100,15 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase
         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');
         }
     }
 
@@ -121,7 +121,7 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase
 
         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());
         }
 
@@ -129,7 +129,7 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase
 
         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());
         }
     }