Skip to content

Commit efc0f78

Browse files
Register itself
1 parent 07fd8d7 commit efc0f78

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Container.php

+19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use Closure;
66
use Exception;
77
use Reliese\Component\Dependency\Container as ContainerComponent;
8+
use Reliese\Component\Dependency\DependencyCaller;
9+
use Reliese\Component\Dependency\DependencyLocator;
10+
use Reliese\Component\Dependency\DependencyRegistrar;
811
use Reliese\Component\Dependency\Exceptions\UnresolvableDependencyException;
912
use ReflectionClass;
1013
use ReflectionException;
@@ -22,6 +25,22 @@ class Container implements ContainerComponent
2225
*/
2326
private $singletons = [];
2427

28+
/**
29+
* Container constructor.
30+
*/
31+
public function __construct()
32+
{
33+
$self = function () {
34+
return $this;
35+
};
36+
37+
$this->singleton(static::class, $self);
38+
$this->singleton(ContainerComponent::class, $self);
39+
$this->singleton(DependencyRegistrar::class, $self);
40+
$this->singleton(DependencyLocator::class, $self);
41+
$this->singleton(DependencyCaller::class, $self);
42+
}
43+
2544
/**
2645
* @param $dependency
2746
* @param Closure $abstraction

0 commit comments

Comments
 (0)