From 60e951cd867e723cc05ba5495f78059eea4af547 Mon Sep 17 00:00:00 2001 From: Sam Burns Date: Fri, 10 Feb 2017 11:47:29 +0000 Subject: [PATCH] Accepting PSR-11 delegate containers --- README.md | 5 +++-- composer.json | 3 ++- src/Picotainer.php | 11 ++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8c02f4e..5be90aa 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ Picotainer This package contains a really minimalist dependency injection container (24 lines of code!) compatible with [container-interop](https://github.com/container-interop/container-interop) (supports ContainerInterface and -delegate lookup feature). +delegate lookup feature). It is also, therefore, compatible with +[PSR-11](https://github.com/php-fig/fig-standards/blob/master/proposed/container.md), the FIG container standard. Picotainer is heavily influenced by the [Pimple DI container](http://pimple.sensiolabs.org/). Think about it as a Pimple container with even less features, and ContainerInterop compatibility. @@ -36,7 +37,7 @@ The `Picotainer` class takes 2 parameters: ```php use Mouf\Picotainer\Picotainer; -use Interop\Container\ContainerInterface; +use Psr\Container\ContainerInterface; $container = new Picotainer([ "myInstance"=>function(ContainerInterface $container) { diff --git a/composer.json b/composer.json index 520189b..a3761cd 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ "homepage" : "http://mouf-php.com", "license" : "MIT", "require" : { - "container-interop/container-interop" : "~1.0" + "container-interop/container-interop" : "~1.2", + "psr/container": "^1.0" }, "require-dev" : { "phpunit/phpunit" : "~4.8", diff --git a/src/Picotainer.php b/src/Picotainer.php index f7ab588..f709839 100644 --- a/src/Picotainer.php +++ b/src/Picotainer.php @@ -1,7 +1,8 @@ */ -class Picotainer implements ContainerInterface +class Picotainer implements InteropContainer { /** * The delegate lookup. * - * @var ContainerInterface + * @var Psr11Container */ protected $delegateLookupContainer; @@ -37,9 +38,9 @@ class Picotainer implements ContainerInterface * Instantiate the container. * * @param array $entries Entries must be passed as an array of anonymous functions. - * @param ContainerInterface $delegateLookupContainer Optional delegate lookup container. + * @param Psr11Container $delegateLookupContainer Optional delegate lookup container. */ - public function __construct(array $entries, ContainerInterface $delegateLookupContainer = null) + public function __construct(array $entries, Psr11Container $delegateLookupContainer = null) { $this->callbacks = $entries; $this->delegateLookupContainer = $delegateLookupContainer ?: $this;