Skip to content

Commit 004f953

Browse files
committed
Prevent rolling out new instances when container has getter for type
1 parent f5c2fd7 commit 004f953

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: src/Activator.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public function call(callable $callable)
3434
public function instantiate(string $type): object
3535
{
3636
return $this->track($type, function () use ($type) {
37+
if ($this->container->has($type)) {
38+
return $this->container->get($type);
39+
}
40+
3741
$reflection = new ReflectionClass($type);
3842

3943
if ($reflection->isInterface() or $reflection->isAbstract()) {
40-
if ($this->container->has($type)) {
41-
return $this->container->get($type);
42-
}
43-
4444
throw new ContainerException('Type [' . $type . '] is not instantiable.');
4545
}
4646

0 commit comments

Comments
 (0)