Skip to content

Commit

Permalink
#516 Remove DI\InvokerInterface in favor of Invoker\InvokerInterface
Browse files Browse the repository at this point in the history
`Invoker\InvokerInterface` exists since version 5 and is defined in the [PHP-DI/Invoker](https://github.com/PHP-DI/Invoker/blob/master/src/InvokerInterface.php) package.

The `DI\InvokerInterface` is useless, it's empty and extends `Invoker\InvokerInterface`.

Removing it is like removing `DI\ContainerInterface` in favor of PSR-11 or container-interop for example (until there's a PSR for invokers…).
  • Loading branch information
mnapoli committed Jul 29, 2017
1 parent ce140e7 commit 1074adb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 27 deletions.
1 change: 1 addition & 0 deletions change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ BC breaks:
- The deprecated `DI\link()` helper was removed, used `DI\get()` instead
- [#484](https://github.com/PHP-DI/PHP-DI/pull/484) The deprecated `\DI\Debug` class has been removed. Definitions can be cast to string directly
- The exception `DI\Definition\Exception\DefinitionException` was renamed to `DI\Definition\Exception\InvalidDefinition`
- [#516](https://github.com/PHP-DI/PHP-DI/issues/516) `DI\InvokerInterface` was removed in favor of `Invoker\InvokerInterface`.

Be also aware that internal classes or interfaces may have changed.

Expand Down
6 changes: 2 additions & 4 deletions doc/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,10 @@ $container->call($controller, $_GET); // $_GET contains ['name' => 'John']
This leaves the liberty to the developer writing controllers to get request parameters
*and* services using dependency injection.

As with `make()`, `call()` is defined in `DI\InvokerInterface` so that you can type-hint
against that interface without coupling yourself to the container.
`DI\InvokerInterface` is automatically bound to `DI\Container` so you can inject it without any configuration.
As with `make()`, `call()` is defined in `Invoker\InvokerInterface` (in the [PHP-DI/Invoker package](https://github.com/PHP-DI/Invoker)) so that you can type-hint against that interface without coupling yourself to the container. `Invoker\InvokerInterface` is automatically bound to `DI\Container` so you can inject it without any configuration.

```php
namespace DI;
namespace Invoker;

interface InvokerInterface
{
Expand Down
7 changes: 4 additions & 3 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Exception;
use InvalidArgumentException;
use Invoker\Invoker;
use Invoker\InvokerInterface;
use Invoker\ParameterResolver\AssociativeArrayResolver;
use Invoker\ParameterResolver\Container\TypeHintContainerResolver;
use Invoker\ParameterResolver\DefaultValueResolver;
Expand All @@ -34,7 +35,7 @@
*
* @author Matthieu Napoli <matthieu@mnapoli.fr>
*/
class Container implements ContainerInterface, FactoryInterface, \DI\InvokerInterface
class Container implements ContainerInterface, FactoryInterface, InvokerInterface
{
/**
* Map of entries that are already resolved.
Expand All @@ -59,7 +60,7 @@ class Container implements ContainerInterface, FactoryInterface, \DI\InvokerInte
protected $entriesBeingResolved = [];

/**
* @var \Invoker\InvokerInterface|null
* @var InvokerInterface|null
*/
private $invoker;

Expand Down Expand Up @@ -370,7 +371,7 @@ protected function setDefinition(string $name, Definition $definition)
$this->definitionSource->addDefinition($definition);
}

private function getInvoker() : \Invoker\InvokerInterface
private function getInvoker() : InvokerInterface
{
if (! $this->invoker) {
$parameterResolver = new ResolverChain([
Expand Down
16 changes: 0 additions & 16 deletions src/InvokerInterface.php

This file was deleted.

6 changes: 3 additions & 3 deletions tests/IntegrationTest/ContainerDebugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testKnownEntries()
$expectedEntries = [
'DI\Container',
'DI\FactoryInterface',
'DI\InvokerInterface',
'Invoker\InvokerInterface',
'Psr\Container\ContainerInterface',
'bar',
'foo',
Expand Down Expand Up @@ -80,8 +80,8 @@ public function testEntriesDefinitions()
$container->debugEntry('DI\FactoryInterface')
);
$this->assertRegExp(
'/^Object \(\n {4}class = #NOT INSTANTIABLE# DI\\\InvokerInterface\n/',
$container->debugEntry('DI\InvokerInterface')
'/^Object \(\n {4}class = #NOT INSTANTIABLE# Invoker\\\InvokerInterface\n/',
$container->debugEntry('Invoker\InvokerInterface')
);
$this->assertRegExp(
'/^Object \(\n {4}class = #NOT INSTANTIABLE# Psr\\\Container\\\ContainerInterface\n/',
Expand Down
2 changes: 1 addition & 1 deletion tests/IntegrationTest/DefaultEntriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use DI\Container;
use DI\ContainerBuilder;
use DI\FactoryInterface;
use DI\InvokerInterface;
use DI\Test\IntegrationTest\BaseContainerTest;
use Invoker\InvokerInterface;
use Psr\Container\ContainerInterface;

/**
Expand Down

0 comments on commit 1074adb

Please sign in to comment.