Skip to content

Commit

Permalink
Merge pull request #6 from Sam-Burns/psr-11
Browse files Browse the repository at this point in the history
PSR-11 changes
  • Loading branch information
moufmouf committed Mar 9, 2017
2 parents 9a15a5c + 60e951c commit 83737d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 6 additions & 5 deletions src/Picotainer.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<?php
namespace Mouf\Picotainer;

use Interop\Container\ContainerInterface;
use Interop\Container\ContainerInterface as InteropContainer;
use Psr\Container\ContainerInterface as Psr11Container;

/**
* This class is a minimalist dependency injection container.
* It has compatibility with container-interop's ContainerInterface and delegate-lookup feature.
*
* @author David Négrier <david@mouf-php.com>
*/
class Picotainer implements ContainerInterface
class Picotainer implements InteropContainer
{

/**
* The delegate lookup.
*
* @var ContainerInterface
* @var Psr11Container
*/
protected $delegateLookupContainer;

Expand All @@ -37,9 +38,9 @@ class Picotainer implements ContainerInterface
* Instantiate the container.
*
* @param array<string, Closure> $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;
Expand Down

0 comments on commit 83737d6

Please sign in to comment.