Permalink
Browse files

feature #21265 [DI] Implement PSR-11 (greg0ire)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Implement PSR-11

TODO:

- [x] wait for a stable version of the psr/container package;
- [x] ~~deprecate instanciating ServiceNotFoundException directly, or using any of its methods directly;~~ not relevant anymore
- [x] act on the outcome of php-fig/container#8 (solved in php-fig/container#9) ;
- [x] ~~solve the mandatory NotFoundExceptionInterface on non-existing service
problem (with a flag ?);~~ non-issue, see comments below
- [x] provide meta-package psr/container-implementation if all problems can
be solved.

| Q             | A
| ------------- | ---
| Branch?       | master
| New feature?  | yes
| BC breaks?    | not at the moment
| Tests pass?   | didn't pass before pushing, or even starting to code, will see Travis
| License       | MIT
| Doc PR        | TODO

This PR is a first attempt at implementing PSR-11, or at least trying to get closer to it.
Delegate lookup is optional, and thus not implemented for now.

Commits
-------

bde0efd Implement PSR-11
  • Loading branch information...
2 parents 3193331 + bde0efd commit bcd897cfd4f92cdc085e2747175f9aff3a76c755 @fabpot fabpot committed Feb 8, 2017
View
@@ -20,6 +20,7 @@
"doctrine/common": "~2.4",
"twig/twig": "~1.28|~2.0",
"psr/cache": "~1.0",
+ "psr/container": "^1.0",
"psr/log": "~1.0",
"psr/simple-cache": "^1.0",
"symfony/polyfill-intl-icu": "~1.0",
@@ -102,6 +103,7 @@
},
"provide": {
"psr/cache-implementation": "1.0",
+ "psr/container-implementation": "1.0",
"psr/simple-cache-implementation": "1.0"
},
"autoload": {
@@ -40,6 +40,7 @@
<argument type="collection" />
</service>
+ <service id="Psr\Container\ContainerInterface" alias="service_container" public="false" />
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false" />
<service id="Symfony\Component\DependencyInjection\Container" alias="service_container" public="false" />
@@ -11,6 +11,7 @@
namespace Symfony\Component\DependencyInjection;
+use Psr\Container\ContainerInterface as PsrContainerInterface;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
@@ -21,7 +22,7 @@
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
-interface ContainerInterface
+interface ContainerInterface extends PsrContainerInterface
{
const EXCEPTION_ON_INVALID_REFERENCE = 1;
const NULL_ON_INVALID_REFERENCE = 2;
@@ -11,12 +11,14 @@
namespace Symfony\Component\DependencyInjection\Exception;
+use Psr\Container\ContainerExceptionInterface;
+
/**
* Base ExceptionInterface for Dependency Injection component.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Bulat Shakirzyanov <bulat@theopenskyproject.com>
*/
-interface ExceptionInterface
+interface ExceptionInterface extends ContainerExceptionInterface
{
}
@@ -11,12 +11,14 @@
namespace Symfony\Component\DependencyInjection\Exception;
+use Psr\Container\NotFoundExceptionInterface;
+
/**
* This exception is thrown when a non-existent service is requested.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
-class ServiceNotFoundException extends InvalidArgumentException
+class ServiceNotFoundException extends InvalidArgumentException implements NotFoundExceptionInterface
{
private $id;
private $sourceId;
@@ -16,7 +16,8 @@
}
],
"require": {
- "php": ">=5.5.9"
+ "php": ">=5.5.9",
+ "psr/container": "^1.0"
},
"require-dev": {
"symfony/yaml": "~3.2",
@@ -33,6 +34,9 @@
"symfony/config": "<3.3",
"symfony/yaml": "<3.2"
},
+ "provide": {
+ "psr/container-implementation": "1.0"
+ },
"autoload": {
"psr-4": { "Symfony\\Component\\DependencyInjection\\": "" },
"exclude-from-classmap": [

0 comments on commit bcd897c

Please sign in to comment.