From 305e2df322dbb69ecd3f57ff2732f0ba9596aac5 Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Tue, 26 Nov 2019 21:27:03 +0100 Subject: [PATCH 1/2] Replace abandoned container-interop/container-interop package with psr/container --- Slim/App.php | 2 +- Slim/Container.php | 6 +++--- Slim/DefaultServicesProvider.php | 2 +- Slim/Exception/ContainerException.php | 4 ++-- Slim/Exception/ContainerValueNotFoundException.php | 4 ++-- composer.json | 1 - tests/ContainerTest.php | 2 +- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Slim/App.php b/Slim/App.php index 38256d81c..75c3b4fa3 100644 --- a/Slim/App.php +++ b/Slim/App.php @@ -11,7 +11,7 @@ use Closure; use Exception; use FastRoute\Dispatcher; -use Interop\Container\Exception\ContainerException; +use Psr\Container\ContainerExceptionInterface as ContainerException; use InvalidArgumentException; use Psr\Container\ContainerInterface; use Psr\Http\Message\RequestInterface; diff --git a/Slim/Container.php b/Slim/Container.php index dcc5da70f..43d082555 100644 --- a/Slim/Container.php +++ b/Slim/Container.php @@ -8,8 +8,8 @@ namespace Slim; use ArrayAccess; -use Interop\Container\ContainerInterface; -use Interop\Container\Exception\ContainerException; +use Psr\Container\ContainerInterface; +use Psr\Container\ContainerExceptionInterface as ContainerException; use InvalidArgumentException; use Pimple\Container as PimpleContainer; use Slim\Exception\ContainerException as SlimContainerException; @@ -120,7 +120,7 @@ public function get($id) } /** - * Tests whether an exception needs to be recast for compliance with Container-Interop. This will be if the + * Tests whether an exception needs to be recast for compliance with psr/container. This will be if the * exception was thrown by Pimple. * * @param InvalidArgumentException $exception diff --git a/Slim/DefaultServicesProvider.php b/Slim/DefaultServicesProvider.php index 9f2612578..48a8d6e08 100644 --- a/Slim/DefaultServicesProvider.php +++ b/Slim/DefaultServicesProvider.php @@ -27,7 +27,7 @@ class DefaultServicesProvider /** * Register Slim's default services. * - * @param Container $container A DI container implementing ArrayAccess and container-interop. + * @param Container $container A DI container implementing ArrayAccess and psr/container. */ public function register($container) { diff --git a/Slim/Exception/ContainerException.php b/Slim/Exception/ContainerException.php index 92ff01093..fb0184986 100644 --- a/Slim/Exception/ContainerException.php +++ b/Slim/Exception/ContainerException.php @@ -7,9 +7,9 @@ namespace Slim\Exception; -use Interop\Container\Exception\ContainerException as InteropContainerException; +use Psr\Container\ContainerExceptionInterface; use InvalidArgumentException; -class ContainerException extends InvalidArgumentException implements InteropContainerException +class ContainerException extends InvalidArgumentException implements ContainerExceptionInterface { } diff --git a/Slim/Exception/ContainerValueNotFoundException.php b/Slim/Exception/ContainerValueNotFoundException.php index 456464d38..0c715935b 100644 --- a/Slim/Exception/ContainerValueNotFoundException.php +++ b/Slim/Exception/ContainerValueNotFoundException.php @@ -7,9 +7,9 @@ namespace Slim\Exception; -use Interop\Container\Exception\NotFoundException as InteropNotFoundException; +use Psr\Container\NotFoundExceptionInterface; use RuntimeException; -class ContainerValueNotFoundException extends RuntimeException implements InteropNotFoundException +class ContainerValueNotFoundException extends RuntimeException implements NotFoundExceptionInterface { } diff --git a/composer.json b/composer.json index 126e338be..7be1584bf 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,6 @@ "pimple/pimple": "^3.0", "psr/http-message": "^1.0", "nikic/fast-route": "^1.0", - "container-interop/container-interop": "^1.2", "psr/container": "^1.0" }, "require-dev": { diff --git a/tests/ContainerTest.php b/tests/ContainerTest.php index ef724121e..b989bb2ff 100644 --- a/tests/ContainerTest.php +++ b/tests/ContainerTest.php @@ -55,7 +55,7 @@ function (ContainerInterface $container) { } /** - * Test `get()` recasts InvalidArgumentException as ContainerInterop-compliant exceptions when an error is present + * Test `get()` recasts InvalidArgumentException as psr/container exceptions when an error is present * in the DI config * * @expectedException \Slim\Exception\ContainerException From 1a67c19a369c272198790d0379ac860c11d5eaf3 Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Wed, 27 Nov 2019 05:05:33 +0100 Subject: [PATCH 2/2] Improve Container `use` statements to use `psr/container` exception interface directly as opposed aliases --- Slim/Container.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Slim/Container.php b/Slim/Container.php index 43d082555..4641f6871 100644 --- a/Slim/Container.php +++ b/Slim/Container.php @@ -9,7 +9,7 @@ use ArrayAccess; use Psr\Container\ContainerInterface; -use Psr\Container\ContainerExceptionInterface as ContainerException; +use Psr\Container\ContainerExceptionInterface; use InvalidArgumentException; use Pimple\Container as PimpleContainer; use Slim\Exception\ContainerException as SlimContainerException; @@ -95,9 +95,10 @@ private function registerDefaultServices($userSettings) * @return mixed * * @throws InvalidArgumentException Thrown when an offset cannot be found in the Pimple container - * @throws SlimContainerException Thrown when an exception is not an instance of ContainerException + * @throws SlimContainerException Thrown when an exception is + * not an instance of ContainerExceptionInterface * @throws ContainerValueNotFoundException No entry was found for this identifier. - * @throws ContainerException Error while retrieving the entry. + * @throws ContainerExceptionInterface Error while retrieving the entry. */ public function get($id) { @@ -153,9 +154,10 @@ public function has($id) * @return mixed * * @throws InvalidArgumentException Thrown when an offset cannot be found in the Pimple container - * @throws SlimContainerException Thrown when an exception is not an instance of ContainerException + * @throws SlimContainerException Thrown when an exception is not + * an instance of ContainerExceptionInterface * @throws ContainerValueNotFoundException No entry was found for this identifier. - * @throws ContainerException Error while retrieving the entry. + * @throws ContainerExceptionInterface Error while retrieving the entry. */ public function __get($name) {