Skip to content

Commit bcd897c

Browse files
committed
feature symfony#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
2 parents 3193331 + bde0efd commit bcd897c

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

composer.json

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"doctrine/common": "~2.4",
2121
"twig/twig": "~1.28|~2.0",
2222
"psr/cache": "~1.0",
23+
"psr/container": "^1.0",
2324
"psr/log": "~1.0",
2425
"psr/simple-cache": "^1.0",
2526
"symfony/polyfill-intl-icu": "~1.0",
@@ -102,6 +103,7 @@
102103
},
103104
"provide": {
104105
"psr/cache-implementation": "1.0",
106+
"psr/container-implementation": "1.0",
105107
"psr/simple-cache-implementation": "1.0"
106108
},
107109
"autoload": {

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<argument type="collection" />
4141
</service>
4242

43+
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false" />
4344
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false" />
4445
<service id="Symfony\Component\DependencyInjection\Container" alias="service_container" public="false" />
4546

src/Symfony/Component/DependencyInjection/ContainerInterface.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\DependencyInjection;
1313

14+
use Psr\Container\ContainerInterface as PsrContainerInterface;
1415
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1516
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
1617
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
@@ -21,7 +22,7 @@
2122
* @author Fabien Potencier <[email protected]>
2223
* @author Johannes M. Schmitt <[email protected]>
2324
*/
24-
interface ContainerInterface
25+
interface ContainerInterface extends PsrContainerInterface
2526
{
2627
const EXCEPTION_ON_INVALID_REFERENCE = 1;
2728
const NULL_ON_INVALID_REFERENCE = 2;

src/Symfony/Component/DependencyInjection/Exception/ExceptionInterface.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Exception;
1313

14+
use Psr\Container\ContainerExceptionInterface;
15+
1416
/**
1517
* Base ExceptionInterface for Dependency Injection component.
1618
*
1719
* @author Fabien Potencier <[email protected]>
1820
* @author Bulat Shakirzyanov <[email protected]>
1921
*/
20-
interface ExceptionInterface
22+
interface ExceptionInterface extends ContainerExceptionInterface
2123
{
2224
}

src/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Exception;
1313

14+
use Psr\Container\NotFoundExceptionInterface;
15+
1416
/**
1517
* This exception is thrown when a non-existent service is requested.
1618
*
1719
* @author Johannes M. Schmitt <[email protected]>
1820
*/
19-
class ServiceNotFoundException extends InvalidArgumentException
21+
class ServiceNotFoundException extends InvalidArgumentException implements NotFoundExceptionInterface
2022
{
2123
private $id;
2224
private $sourceId;

src/Symfony/Component/DependencyInjection/composer.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.5.9"
19+
"php": ">=5.5.9",
20+
"psr/container": "^1.0"
2021
},
2122
"require-dev": {
2223
"symfony/yaml": "~3.2",
@@ -33,6 +34,9 @@
3334
"symfony/config": "<3.3",
3435
"symfony/yaml": "<3.2"
3536
},
37+
"provide": {
38+
"psr/container-implementation": "1.0"
39+
},
3640
"autoload": {
3741
"psr-4": { "Symfony\\Component\\DependencyInjection\\": "" },
3842
"exclude-from-classmap": [

0 commit comments

Comments
 (0)