Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 9a6b68f

Browse files
authored
Merge pull request #187 from michaelmoussa/psr-11
Replace container-interop with PSR-11 container interface
2 parents 54f5a52 + c800b99 commit 9a6b68f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+147
-170
lines changed

benchmarks/BenchAsset/AbstractFactoryFoo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace ZendBench\ServiceManager\BenchAsset;
99

10-
use Interop\Container\ContainerInterface;
10+
use Psr\Container\ContainerInterface;
1111
use Zend\ServiceManager\Factory\AbstractFactoryInterface;
1212

1313
class AbstractFactoryFoo implements AbstractFactoryInterface

benchmarks/BenchAsset/FactoryFoo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace ZendBench\ServiceManager\BenchAsset;
99

10-
use Interop\Container\ContainerInterface;
10+
use Psr\Container\ContainerInterface;
1111
use Zend\ServiceManager\Factory\FactoryInterface;
1212

1313
class FactoryFoo implements FactoryInterface

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
},
2323
"require": {
2424
"php": "^7.1",
25-
"container-interop/container-interop": "^1.2",
2625
"psr/container": "^1.0",
2726
"zendframework/zend-stdlib": "^3.1"
2827
},
@@ -34,7 +33,6 @@
3433
"zendframework/zend-coding-standard": "~1.0.0"
3534
},
3635
"provide": {
37-
"container-interop/container-interop-implementation": "^1.2",
3836
"psr/container-implementation": "^1.0"
3937
},
4038
"suggest": {
@@ -55,6 +53,9 @@
5553
"config": {
5654
"sort-packages": true
5755
},
56+
"conflict": {
57+
"container-interop/container-interop": "<1.2.0"
58+
},
5859
"extra": {
5960
"branch-alias": {
6061
"dev-master": "3.3-dev",

composer.lock

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/book/configuring-the-service-manager.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ $serviceManager = new ServiceManager([
6060
As said before, a factory can also be a callable, to create more complex objects:
6161

6262
```php
63-
use Interop\Container\ContainerInterface;
63+
use Psr\Container\ContainerInterface;
6464
use Zend\ServiceManager\Factory\InvokableFactory;
6565
use Zend\ServiceManager\ServiceManager;
6666
use stdClass;
@@ -267,7 +267,7 @@ For instance, if we'd want to automatically inject the dependency
267267
`EventManagerAwareInterface`, we could create the following initializer:
268268

269269
```php
270-
use Interop\Container\ContainerInterface;
270+
use Psr\Container\ContainerInterface;
271271
use stdClass;
272272
use Zend\ServiceManager\ServiceManager;
273273

@@ -303,7 +303,7 @@ class MyInitializer implements InitializerInterface
303303

304304
// When creating the service manager:
305305

306-
use Interop\Container\ContainerInterface;
306+
use Psr\Container\ContainerInterface;
307307
use stdClass;
308308
use Zend\ServiceManager\ServiceManager;
309309

docs/book/delegators.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ intercept actions being performed on the delegate in an
1414
A delegator factory has the following signature:
1515

1616
```php
17-
use Interop\Container\ContainerInterface;
17+
use Psr\Container\ContainerInterface;
1818

1919
public function __invoke(
2020
ContainerInterface $container,
@@ -106,7 +106,7 @@ A simple delegator factory for the `buzzer` service can be implemented as
106106
following:
107107

108108
```php
109-
use Interop\Container\ContainerInterface;
109+
use Psr\Container\ContainerInterface;
110110
use Zend\ServiceManager\Factory\DelegatorFactoryInterface;
111111

112112
class BuzzerDelegatorFactory implements DelegatorFactoryInterface

docs/book/migration-v4.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Migration Guide
2+
3+
Migration guide for Zend Service version 4.0.0.
4+
5+
## PSR-11: Container Interface
6+
7+
[`container-interop/container-interop`](https://github.com/container-interop/container-interop)
8+
was officially deprecated in favor of [PSR-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md)
9+
on February 13, 2017. As such, all uses of the interop-container interfaces
10+
have been replaced with PSR-11 containers interfaces as follows:
11+
- `Interop\Container\ContainerInterface` to `Psr\Container\ContainerInterface`,
12+
- `Interop\Container\Exception\ContainerException` to `Psr\Container\ContainerExceptionInterface`,
13+
- `Interop\Container\Exception\NotFoundException` to `Psr\Container\NotFoundExceptionInterface`.
14+
15+
Further, installs of `container-interop/container-interop` below version `1.2.0`
16+
is prohibited via Composer's `conflicts` configuration. Version `1.2.0` _does_
17+
extend the PSR-11 interfaces, and is thus still usable.
18+
19+
If your project typehints any `Interop\ContainerInterop\*` interfaces where any
20+
`Zend\ServiceManager\*` classes are expected, you _**must**_ update your code to
21+
expect `Zend\ServiceManager\*` or `Psr\Container\*` classes or interfaces instead.
22+
The latter is preferred, unless your code utilizes any additional functionality
23+
provided by the `Zend\ServiceManager\*` classes that are not declared in the
24+
PSR-11 interfaces.
25+
26+
To do this, use your favorite find-and-replace tool to update the following:
27+
- `use Interop\Container\ContainerInterface;` -> `use Psr\Container\ContainerInterface;`
28+
- `use Interop\Container\Exception\ContainerException;` -> `use Psr\Container\ContainerExceptionInterface;`
29+
- `use Interop\Container\Exception\NotFoundException;` -> `use Psr\Container\NotFoundExceptionInterface;`
30+
- **Note:** You will also need to replace `ContainerException` with `ContainerExceptionInterface`
31+
and `NotFoundException` with `NotFoundExceptionInterface` where it is used
32+
throughout your code. If you _don't_ want to do that, you can include
33+
`as ContainerException`/`as NotFoundException` in the find-and-replace,
34+
and any existing use of `ContainerException`/`NotFoundException` will
35+
continue to work.
36+
37+
> ### Note
38+
>
39+
> If you use fully-qualified class names in your typehints, rather than taking
40+
> advantage of `use` statements, you will need to run additional find-and-replace
41+
> commands to update those class paths within your code. The exact finds and
42+
> replaces to run for those scenarios are not covered in this migration guide, as
43+
> they can vary greatly and are not a generally recommended practice.

docs/book/migration.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ $container->mapLazyService('MyClass');
251251
## ServiceLocatorInterface Changes
252252

253253
The `ServiceLocatorInterface` now extends the
254-
[container-interop](https://github.com/container-interop/container-interop)
254+
[Psr\Container\ContainerInterface](https://github.com/php-fig/container)
255255
interface `ContainerInterface`, which defines the same `get()` and `has()`
256256
methods as were previously defined.
257257

@@ -436,7 +436,7 @@ To update this for version 3 compatibility, you will add the methods
436436
them, and update the existing methods to proxy to the new methods:
437437

438438
```php
439-
use Interop\Container\ContainerInterface;
439+
use Psr\Container\ContainerInterface;
440440
use Zend\ServiceManager\AbstractFactoryInterface;
441441
use Zend\ServiceManager\ServiceLocatorInterface;
442442

@@ -474,7 +474,7 @@ the migration artifacts:
474474
From our example above, we would update the class to read as follows:
475475

476476
```php
477-
use Interop\Container\ContainerInterface;
477+
use Psr\Container\ContainerInterface;
478478
use Zend\ServiceManager\Factory\AbstractFactoryInterface; // <-- note the change!
479479

480480
class LenientAbstractFactory implements AbstractFactoryInterface
@@ -562,7 +562,7 @@ To prepare this for version 3, we'd implement the `__invoke()` signature from
562562
version 3, and modify `createDelegatorWithName()` to proxy to it:
563563

564564
```php
565-
use Interop\Container\ContainerInterface;
565+
use Psr\Container\ContainerInterface;
566566
use Zend\ServiceManager\DelegatorFactoryInterface;
567567
use Zend\ServiceManager\ServiceLocatorInterface;
568568

@@ -591,7 +591,7 @@ the migration artifacts:
591591
From our example above, we would update the class to read as follows:
592592

593593
```php
594-
use Interop\Container\ContainerInterface;
594+
use Psr\Container\ContainerInterface;
595595
use Zend\ServiceManager\Factory\DelegatorFactoryInterface; // <-- note the change!
596596

597597
class ObserverAttachmentDelegator implements DelegatorFactoryInterface
@@ -674,7 +674,7 @@ To prepare this for version 3, we'd implement the `__invoke()` signature from
674674
version 3, and modify `createService()` to proxy to it:
675675

676676
```php
677-
use Interop\Container\ContainerInterface;
677+
use Psr\Container\ContainerInterface;
678678
use Zend\ServiceManager\FactoryInterface;
679679
use Zend\ServiceManager\ServiceLocatorInterface;
680680

@@ -706,7 +706,7 @@ the migration artifacts:
706706
From our example above, we would update the class to read as follows:
707707

708708
```php
709-
use Interop\Container\ContainerInterface;
709+
use Psr\Container\ContainerInterface;
710710
use Zend\ServiceManager\Factory\FactoryInterface; // <-- note the change!
711711

712712
class FooFactory implements FactoryInterface
@@ -808,7 +808,7 @@ To prepare this for version 3, we'd implement the `__invoke()` signature from
808808
version 3, and modify `initialize()` to proxy to it:
809809

810810
```php
811-
use Interop\Container\ContainerInterface;
811+
use Psr\Container\ContainerInterface;
812812
use Zend\ServiceManager\InitializerInterface;
813813
use Zend\ServiceManager\ServiceLocatorInterface;
814814

@@ -839,7 +839,7 @@ the migration artifacts:
839839
From our example above, we would update the class to read as follows:
840840

841841
```php
842-
use Interop\Container\ContainerInterface;
842+
use Psr\Container\ContainerInterface;
843843
use Zend\ServiceManager\Initializer\InitializerInterface; // <-- note the change!
844844

845845
class FooInitializer implements InitializerInterface

docs/book/psr-11.md

Lines changed: 0 additions & 58 deletions
This file was deleted.

docs/book/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The Service Manager is a modern, fast, and easy-to-use implementation of the
44
[Service Locator design pattern](https://en.wikipedia.org/wiki/Service_locator_pattern).
55
The implementation implements the
6-
[Container Interop](https://github.com/container-interop/container-interop)
6+
[Psr\Container\ContainerInterface](https://github.com/psr/container)
77
interfaces, providing interoperability with other implementations.
88

99
The following is a "quick start" tutorial intended to get you up and running

0 commit comments

Comments
 (0)