Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Added automatic type resolving for ContainerInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
tux-rampage committed Sep 9, 2016
1 parent 2824972 commit 4de59c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/DependencyInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@ private function resolveMethodParameters($type, $method, array $params = [])
continue;
}

if ($arg == ContainerInterface::class) {
$params[] = $container;
continue;
}

if ($arg instanceof Resolver\TypeInjection) {
$arg = $arg->getType();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resolver/DependencyResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function resolveMethodParameters($requestedType, $method, array $callTime
continue;
}

if (!$this->container || $this->container->has($type)) {
if (($type === ContainerInterface::class) || !$this->container || $this->container->has($type)) {
$result[$name] = $type;
continue;
}
Expand Down

0 comments on commit 4de59c3

Please sign in to comment.