-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerAdapter.php
More file actions
146 lines (126 loc) · 3.27 KB
/
Copy pathContainerAdapter.php
File metadata and controls
146 lines (126 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php declare(strict_types=1);
namespace StellarWP\Foundation\Container;
use Closure;
use lucatume\DI52\Container as DI52Container;
use lucatume\DI52\ContainerException;
use StellarWP\Foundation\Container\Contracts\Container;
/**
* @method mixed make(string $id)
* @method mixed getVar(string $key, mixed|null $default = null)
*/
final class ContainerAdapter implements Container
{
public function __construct(
private readonly DI52Container $container
) {
}
/**
* @param string[]|null $afterBuildMethods
*
* @throws \lucatume\DI52\ContainerException
*/
public function bind(string $id, mixed $implementation = null, ?array $afterBuildMethods = null): void {
$this->container->bind($id, $implementation, $afterBuildMethods);
}
/**
* {@inheritDoc}
*/
public function get(string $id): mixed {
return $this->container->get($id);
}
/**
* @codeCoverageIgnore
*/
public function getContainer(): DI52Container {
return $this->container;
}
/**
* {@inheritDoc}
*
* @codeCoverageIgnore
*/
public function has(string $id): bool {
return $this->container->has($id);
}
/**
* @param string[]|null $afterBuildMethods
*
* @throws \lucatume\DI52\ContainerException
*/
public function singleton(string $id, mixed $implementation = null, ?array $afterBuildMethods = null): void {
$this->container->singleton($id, $implementation, $afterBuildMethods);
}
/**
* {@inheritDoc}
*/
public function register(string $serviceProviderClass, ...$alias): void {
$this->container->register($serviceProviderClass, ...$alias);
}
/**
* {@inheritDoc}
*/
public function when(string $class): Container {
$this->container->when($class);
return $this;
}
/**
* {@inheritDoc}
*/
public function needs(string $id): Container {
$this->container->needs($id);
return $this;
}
public function give(mixed $implementation): void {
$this->container->give($implementation);
}
public function instance(mixed $id, array $buildArgs = [], ?array $afterBuildMethods = null): Closure {
// @phpstan-ignore-next-line invalid DocBlock comments in DI52
return $this->container->instance($id, $buildArgs, $afterBuildMethods);
}
/**
* {@inheritDoc}
*
* @throws ContainerException
*/
public function mergeArrayVar(string $id, mixed $implementation): void {
$this->container->mergeArrayVar($id, $implementation);
}
/**
* @param class-string|string|object $id
*
* @throws ContainerException
*/
public function callback(object|string $id, string $method): callable {
return $this->container->callback($id, $method);
}
/**
* {@inheritDoc}
*/
public function singletonDecorators(
string $id,
array $decorators,
?array $afterBuildMethods = null,
bool $afterBuildAll = false
): void {
$this->container->singletonDecorators($id, $decorators, $afterBuildMethods, $afterBuildAll);
}
/**
* {@inheritDoc}
*/
public function bindDecorators(
string $id,
array $decorators,
?array $afterBuildMethods = null,
bool $afterBuildAll = false
): void {
$this->container->bindDecorators($id, $decorators, $afterBuildMethods, $afterBuildAll);
}
/**
* Defer all other calls to the container object.
*
* @param mixed[] $args
*/
public function __call(string $name, array $args): mixed {
return $this->container->{$name}(...$args);
}
}