浏览代码

[DependencyInjection] renamed CircularReferenceException to ServiceCircularReferenceException

Fabien Potencier 14 年之前
父节点
当前提交
456eb53eb8

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

@@ -2,7 +2,7 @@
 
 
 namespace Symfony\Component\DependencyInjection\Compiler;
 namespace Symfony\Component\DependencyInjection\Compiler;
 
 
-use Symfony\Component\DependencyInjection\Exception\CircularReferenceException;
+use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 
 
 /**
 /**
@@ -50,7 +50,7 @@ class CheckCircularReferencesPass implements CompilerPassInterface
             $this->currentPath[] = $id = $node->getId();
             $this->currentPath[] = $id = $node->getId();
 
 
             if ($this->currentId === $id) {
             if ($this->currentId === $id) {
-                throw new CircularReferenceException($this->currentId, $this->currentPath);
+                throw new ServiceCircularReferenceException($this->currentId, $this->currentPath);
             }
             }
 
 
             $this->checkOutEdges($node->getOutEdges());
             $this->checkOutEdges($node->getOutEdges());

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

@@ -12,7 +12,7 @@
 namespace Symfony\Component\DependencyInjection;
 namespace Symfony\Component\DependencyInjection;
 
 
 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
-use Symfony\Component\DependencyInjection\Exception\CircularReferenceException;
+use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
 use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
@@ -219,7 +219,7 @@ class Container implements ContainerInterface
         }
         }
 
 
         if (isset($this->loading[$id])) {
         if (isset($this->loading[$id])) {
-            throw new CircularReferenceException($id, array_keys($this->loading));
+            throw new ServiceCircularReferenceException($id, array_keys($this->loading));
         }
         }
 
 
         if (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')) {
         if (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')) {

+ 2 - 2
src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

@@ -11,7 +11,7 @@
 
 
 namespace Symfony\Component\DependencyInjection\Dumper;
 namespace Symfony\Component\DependencyInjection\Dumper;
 
 
-use Symfony\Component\DependencyInjection\Exception\CircularReferenceException;
+use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
 use Symfony\Component\DependencyInjection\Variable;
 use Symfony\Component\DependencyInjection\Variable;
 use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -212,7 +212,7 @@ class PhpDumper extends Dumper
                 // $a = new ServiceA(ServiceB $b);
                 // $a = new ServiceA(ServiceB $b);
                 // $b->setServiceA(ServiceA $a);
                 // $b->setServiceA(ServiceA $a);
                 if ($this->hasReference($id, $sDefinition->getArguments())) {
                 if ($this->hasReference($id, $sDefinition->getArguments())) {
-                    throw new CircularReferenceException($id, array($id));
+                    throw new ServiceCircularReferenceException($id, array($id));
                 }
                 }
 
 
                 $arguments = array();
                 $arguments = array();

+ 10 - 1
src/Symfony/Component/DependencyInjection/Exception/CircularReferenceException.php

@@ -1,5 +1,14 @@
 <?php
 <?php
 
 
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
 namespace Symfony\Component\DependencyInjection\Exception;
 namespace Symfony\Component\DependencyInjection\Exception;
 
 
 /**
 /**
@@ -7,7 +16,7 @@ namespace Symfony\Component\DependencyInjection\Exception;
  *
  *
  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  */
  */
-class CircularReferenceException extends RuntimeException
+class ServiceCircularReferenceException extends RuntimeException
 {
 {
     private $serviceId;
     private $serviceId;
     private $path;
     private $path;

+ 2 - 2
tests/Symfony/Tests/Component/DependencyInjection/ContainerBuilderTest.php

@@ -107,8 +107,8 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
         $builder->register('baz', 'stdClass')->setArguments(array(new Reference('baz')));
         $builder->register('baz', 'stdClass')->setArguments(array(new Reference('baz')));
         try {
         try {
             @$builder->get('baz');
             @$builder->get('baz');
-            $this->fail('->get() throws a CircularReferenceException if the service has a circular reference to itself');
-        } catch (\Symfony\Component\DependencyInjection\Exception\CircularReferenceException $e) {
+            $this->fail('->get() throws a ServiceCircularReferenceException if the service has a circular reference to itself');
+        } catch (\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException $e) {
             $this->assertEquals('Circular reference detected for service "baz", path: "baz".', $e->getMessage(), '->get() throws a LogicException if the service has a circular reference to itself');
             $this->assertEquals('Circular reference detected for service "baz", path: "baz".', $e->getMessage(), '->get() throws a LogicException if the service has a circular reference to itself');
         }
         }
 
 

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

@@ -172,9 +172,9 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
         $sc = new ProjectServiceContainer();
         $sc = new ProjectServiceContainer();
         try {
         try {
             $sc->get('circular');
             $sc->get('circular');
-            $this->fail('->get() throws a CircularReferenceException if it contains circular reference');
+            $this->fail('->get() throws a ServiceCircularReferenceException if it contains circular reference');
         } catch (\Exception $e) {
         } catch (\Exception $e) {
-            $this->assertInstanceOf('\Symfony\Component\DependencyInjection\Exception\CircularReferenceException', $e, '->get() throws a CircularReferenceException if it contains circular reference');
+            $this->assertInstanceOf('\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException', $e, '->get() throws a ServiceCircularReferenceException if it contains circular reference');
             $this->assertStringStartsWith('Circular reference detected for service "circular"', $e->getMessage(), '->get() throws a \LogicException if it contains circular reference');
             $this->assertStringStartsWith('Circular reference detected for service "circular"', $e->getMessage(), '->get() throws a \LogicException if it contains circular reference');
         }
         }
     }
     }