Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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