Browse Source

[DependencyInjection] changed \LogicException to RuntimeException to be more consistent

Fabien Potencier 14 years ago
parent
commit
462f222319

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

@@ -13,6 +13,7 @@ namespace Symfony\Component\DependencyInjection\ParameterBag;
 
 use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
 use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
+use Symfony\Component\DependencyInjection\Exception\RuntimeException;
 
 /**
  *
@@ -132,7 +133,7 @@ class ParameterBag implements ParameterBagInterface
      *
      * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
      * @throws ParameterCircularReferenceException if a circular reference if detected
-     * @throws \LogicException when a given parameter has a type problem.
+     * @throws RuntimeException when a given parameter has a type problem.
      */
     public function resolveValue($value, array $resolving = array())
     {
@@ -162,7 +163,7 @@ class ParameterBag implements ParameterBagInterface
      *
      * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
      * @throws ParameterCircularReferenceException if a circular reference if detected
-     * @throws \LogicException when a given parameter has a type problem.
+     * @throws RuntimeException when a given parameter has a type problem.
      */
     public function resolveString($value, array $resolving = array())
     {
@@ -192,7 +193,7 @@ class ParameterBag implements ParameterBagInterface
             $resolved = $self->get($key);
 
             if (!is_string($resolved)) {
-                throw new \LogicException('A parameter cannot contain a non-string parameter.');
+                throw new RuntimeException('A parameter cannot contain a non-string parameter.');
             }
 
             $resolving[$key] = true;

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

@@ -14,6 +14,7 @@ namespace Symfony\Tests\Component\DependencyInjection\ParameterBag;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
 use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
+use Symfony\Component\DependencyInjection\Exception\RuntimeException;
 
 class ParameterBagTest extends \PHPUnit_Framework_TestCase
 {
@@ -117,9 +118,9 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase
         $bag = new ParameterBag(array('foo' => 'a %bar%', 'bar' => array()));
         try {
             $bag->resolveValue('%foo%');
-            $this->fail('->resolveValue() throws a LogicException when a parameter embeds another non-string parameter');
-        } catch (\LogicException $e) {
-            $this->assertEquals('A parameter cannot contain a non-string parameter.', $e->getMessage(), '->resolveValue() throws a LogicException when a parameter embeds another non-string parameter');
+            $this->fail('->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter');
+        } catch (RuntimeException $e) {
+            $this->assertEquals('A parameter cannot contain a non-string parameter.', $e->getMessage(), '->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter');
         }
 
         $bag = new ParameterBag(array('foo' => '%bar%', 'bar' => '%foobar%', 'foobar' => '%foo%'));