Skip to content

Commit a21ac4c

Browse files
committed
feature #40384 [DependencyInjection] Implement psr/container 1.1 (derrabus)
This PR was merged into the 5.3-dev branch. Discussion ---------- [DependencyInjection] Implement psr/container 1.1 | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A The `psr/container` interfaces have been updated with type declarations. The lack of those is what kept us from adding property type declarations to the `get()` and `has()` methods of our own `ContainerInterface`. A small BC break is that we have never prevented calling code from passing `null` as the service ID. Even without strict types, this will cause a `TypeError` after my changes. I already had to update `AutowirePass` because of that. On the other hand, it was neither documented that we allow `null` here nor did the container do anything useful (`has(null)` always resulted in `false` and `get(null)` always returned `null`). Commits ------- d9095aa892 [DependencyInjection] Implement psr/container 1.1
2 parents 832ef4f + 031db7a commit a21ac4c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Test/TestContainer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ public function set(string $id, $service)
9393
/**
9494
* {@inheritdoc}
9595
*/
96-
public function has($id): bool
96+
public function has(string $id): bool
9797
{
9898
return $this->getPublicContainer()->has($id) || $this->getPrivateContainer()->has($id);
9999
}
100100

101101
/**
102102
* {@inheritdoc}
103103
*/
104-
public function get($id, int $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1): ?object
104+
public function get(string $id, int $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1): ?object
105105
{
106106
return $this->getPrivateContainer()->has($id) ? $this->getPrivateContainer()->get($id) : $this->getPublicContainer()->get($id, $invalidBehavior);
107107
}

0 commit comments

Comments
 (0)