Johannes Schmitt 14 yıl önce
ebeveyn
işleme
763bba9b89

+ 2 - 3
src/Symfony/Component/DependencyInjection/InterfaceInjector.php

@@ -80,9 +80,8 @@ class InterfaceInjector
     {
     {
         if (is_string($object)) {
         if (is_string($object)) {
             $reflection = new \ReflectionClass($object);
             $reflection = new \ReflectionClass($object);
-
-            return $reflection->implementsInterface($this->class)
-                   || $reflection->isSubClassOf($this->class)
+            
+            return $reflection->isSubClassOf($this->class)
                    || $object === $this->class;
                    || $object === $this->class;
         }
         }
 
 

+ 6 - 1
tests/Symfony/Tests/Component/DependencyInjection/InterfaceInjectorTest.php

@@ -146,6 +146,9 @@ class InterfaceInjectorTest extends \PHPUnit_Framework_TestCase
             array(new InterfaceInjector('Symfony\Tests\Component\DependencyInjection\SubService'), 'Symfony\Tests\Component\DependencyInjection\Service', false),
             array(new InterfaceInjector('Symfony\Tests\Component\DependencyInjection\SubService'), 'Symfony\Tests\Component\DependencyInjection\Service', false),
             array(new InterfaceInjector('Symfony\Tests\Component\DependencyInjection\Service'), 'Symfony\Tests\Component\DependencyInjection\SubService', true),
             array(new InterfaceInjector('Symfony\Tests\Component\DependencyInjection\Service'), 'Symfony\Tests\Component\DependencyInjection\SubService', true),
             array(new InterfaceInjector('Symfony\Tests\Component\DependencyInjection\SubService'), 'Symfony\Tests\Component\DependencyInjection\SubService', true),
             array(new InterfaceInjector('Symfony\Tests\Component\DependencyInjection\SubService'), 'Symfony\Tests\Component\DependencyInjection\SubService', true),
+            array(new InterfaceInjector('Symfony\Tests\Component\DependencyInjection\FooInterface'), 'Symfony\Tests\Component\DependencyInjection\SubService', true),
+            array(new InterfaceInjector('Symfony\Tests\Component\DependencyInjection\FooInterface'), 'Symfony\Tests\Component\DependencyInjection\Service', false),
+            array(new InterfaceInjector('Symfony\Tests\Component\DependencyInjection\FooInterface'), 'Symfony\Tests\Component\DependencyInjection\ServiceWithConstructor', false),
         );
         );
     }
     }
 
 
@@ -168,5 +171,7 @@ class InterfaceInjectorTest extends \PHPUnit_Framework_TestCase
     }
     }
 }
 }
 
 
+class ServiceWithConstructor { public function __construct(\DateTime $required) {} }
 class Service {}
 class Service {}
-class SubService extends Service {}
+class SubService extends Service implements FooInterface {}
+interface FooInterface {}