From eb554755d9cfaf7eee1425ee8a077ba1483335d6 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Sat, 28 Aug 2021 16:13:55 -0500 Subject: [PATCH] Remove checks for Symfony's DI Container --- composer.json | 1 - src/Driver/LazyLoadingDriver.php | 11 +++++------ tests/Driver/LazyLoadingDriverTest.php | 17 ----------------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index ff86b64..77edc7b 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,6 @@ "phpunit/phpunit": "^8.5|^9.0", "psr/container": "^1.0", "symfony/cache" : "^3.1|^4.0|^5.0", - "symfony/dependency-injection" : "^3.1|^4.0|^5.0", "mikey179/vfsstream": "^1.6.7" }, "autoload": { diff --git a/src/Driver/LazyLoadingDriver.php b/src/Driver/LazyLoadingDriver.php index d271a7b..234292b 100644 --- a/src/Driver/LazyLoadingDriver.php +++ b/src/Driver/LazyLoadingDriver.php @@ -5,13 +5,12 @@ namespace Metadata\Driver; use Metadata\ClassMetadata; -use Psr\Container\ContainerInterface as PsrContainerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Psr\Container\ContainerInterface; class LazyLoadingDriver implements DriverInterface { /** - * @var ContainerInterface|PsrContainerInterface + * @var ContainerInterface */ private $container; @@ -21,12 +20,12 @@ class LazyLoadingDriver implements DriverInterface private $realDriverId; /** - * @param ContainerInterface|PsrContainerInterface $container + * @param ContainerInterface $container */ public function __construct($container, string $realDriverId) { - if (!$container instanceof PsrContainerInterface && !$container instanceof ContainerInterface) { - throw new \InvalidArgumentException(sprintf('The container must be an instance of %s or %s (%s given).', PsrContainerInterface::class, ContainerInterface::class, \is_object($container) ? \get_class($container) : \gettype($container))); + if (!$container instanceof ContainerInterface) { + throw new \InvalidArgumentException(sprintf('The container must be an instance of %s (%s given).', ContainerInterface::class, \is_object($container) ? \get_class($container) : \gettype($container))); } $this->container = $container; diff --git a/tests/Driver/LazyLoadingDriverTest.php b/tests/Driver/LazyLoadingDriverTest.php index 41a9e86..13fa2a1 100644 --- a/tests/Driver/LazyLoadingDriverTest.php +++ b/tests/Driver/LazyLoadingDriverTest.php @@ -10,7 +10,6 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; -use Symfony\Component\DependencyInjection\Container; class LazyLoadingDriverTest extends TestCase { @@ -37,22 +36,6 @@ protected function setUp(): void $this->realDriver = $this->createMock(DriverInterface::class); } - public function testSymfonyContainer() - { - $this->realDriver - ->expects($this->once()) - ->method('loadMetadataForClass') - ->with($this->ref) - ->willReturn($this->metadata); - - $container = new Container(); - $container->set('foo', $this->realDriver); - - $driver = new LazyLoadingDriver($container, 'foo'); - - self::assertSame($this->metadata, $driver->loadMetadataForClass($this->ref)); - } - public function testPsrContainer() { $this->realDriver