|
11 | 11 |
|
12 | 12 | namespace Aether\DI; |
13 | 13 |
|
| 14 | +use Aether\Contracts\DI\Container as ContainerContract; |
| 15 | +use Aether\Contracts\DI\Exception\EntryNotFoundException; |
| 16 | +use Aether\Contracts\DI\Factory as FactoryContract; |
| 17 | +use Aether\Contracts\DI\Invoker as InvokerContract; |
| 18 | +use Aether\DI\Definition\Binding\Alias; |
| 19 | +use Aether\DI\Definition\Binding\Factory; |
| 20 | +use Aether\DI\Definition\Binding\Scalar; |
| 21 | +use Aether\DI\Definition\Binding\Shared; |
| 22 | +use Aether\DI\Definition\Binding\WeakReference; |
| 23 | +use Aether\DI\Definition\Exception\CircularDependencyException; |
| 24 | +use Aether\DI\Definition\Resolver\DefinitionResolver; |
| 25 | +use Aether\DI\Definition\State; |
| 26 | + |
14 | 27 | use function array_key_exists; |
15 | 28 |
|
16 | 29 | use Closure; |
|
22 | 35 | use function is_string; |
23 | 36 | use function property_exists; |
24 | 37 |
|
25 | | -use Aether\DI\Definition\Binding\Alias; |
26 | | -use Aether\DI\Definition\Binding\Factory; |
27 | | -use Aether\DI\Definition\Binding\Scalar; |
28 | | -use Aether\DI\Definition\Binding\Shared; |
29 | | -use Aether\DI\Definition\Binding\WeakReference; |
30 | | - |
31 | | -use Aether\DI\Definition\Exception\CircularDependencyException; |
32 | | -use Aether\DI\Definition\Resolver\DefinitionResolver; |
33 | | -use Aether\DI\Definition\State; |
34 | | -use Aether\DI\Exception\EntryNotFoundException; |
35 | | -use Aether\DI\Invoker\Invoker; |
36 | | - |
37 | | -class Container implements ContainerInterface |
| 38 | +class Container implements ContainerContract |
38 | 39 | { |
39 | 40 | private State $state; |
40 | | - private FactoryInterface $factory; |
| 41 | + private FactoryContract $factory; |
41 | 42 |
|
42 | 43 | public function __construct() |
43 | 44 | { |
44 | | - |
45 | 45 | $this->state = new State(); |
46 | 46 | $this->factory = new DefinitionResolver($this->state, $this); |
47 | 47 |
|
48 | 48 | $shared = new Alias(self::class); |
49 | 49 |
|
50 | 50 | $this->state->bindings = [ |
51 | 51 | self::class => new WeakReference(\WeakReference::create($this)), |
52 | | - ContainerInterface::class => $shared, |
53 | | - FactoryInterface::class => $shared, |
54 | | - InvokerInterface::class => $shared |
| 52 | + ContainerContract::class => $shared, |
| 53 | + Factory::class => $shared, |
| 54 | + Invoker::class => $shared, |
55 | 55 | ]; |
56 | 56 | } |
57 | 57 |
|
@@ -85,6 +85,7 @@ public function get(string $id): int|float|string|callable|object |
85 | 85 | public function instance(string $id, int|float|string|callable|object $instance): int|float|string|callable|object |
86 | 86 | { |
87 | 87 | $this->state->instances[$id] = $instance; |
| 88 | + |
88 | 89 | return $instance; |
89 | 90 | } |
90 | 91 |
|
@@ -147,7 +148,7 @@ public function call(callable|array|string $callable, array $parameters = []): m |
147 | 148 | return $this->getInvoker()->call($callable, $parameters); |
148 | 149 | } |
149 | 150 |
|
150 | | - private function getInvoker(): InvokerInterface |
| 151 | + private function getInvoker(): InvokerContract |
151 | 152 | { |
152 | 153 | return new Invoker($this); |
153 | 154 | } |
|
0 commit comments