1 | <?php |
||
22 | final class Bind |
||
23 | { |
||
24 | /** @var Container */ |
||
25 | private $container; |
||
26 | |||
27 | /** |
||
28 | * @var string|class-string |
||
29 | * @phpstan-var class-string<MethodInterceptor>|string |
||
30 | */ |
||
31 | private $interface; |
||
32 | |||
33 | /** @var string */ |
||
34 | private $name = Name::ANY; |
||
35 | |||
36 | /** @var DependencyInterface */ |
||
37 | private $bound; |
||
38 | |||
39 | /** @var BindValidator */ |
||
40 | private $validate; |
||
41 | |||
42 | /** @var ?Untarget */ |
||
43 | private $untarget; |
||
44 | |||
45 | /** |
||
46 | * @param Container $container dependency container |
||
47 | * @param class-string<MethodInterceptor>|string $interface interface or concrete class name |
||
|
|||
48 | */ |
||
49 | public function __construct(Container $container, string $interface) |
||
64 | |||
65 | public function __destruct() |
||
72 | |||
73 | public function __toString(): string |
||
77 | |||
78 | /** |
||
79 | * Set dependency name |
||
80 | */ |
||
81 | public function annotatedWith(string $name): self |
||
87 | |||
88 | /** |
||
89 | * Bind to class |
||
90 | */ |
||
91 | public function to(string $class): self |
||
100 | |||
101 | /** |
||
102 | * Bind to constructor |
||
103 | * |
||
104 | * @param class-string $class class name |
||
105 | * @param array<string, string>|string $name "varName=bindName,..." or [$varName => $bindName, $varName => $bindName...] |
||
106 | * @param InjectionPoints $injectionPoints injection points |
||
107 | * @param string $postConstruct method name of initialization after all dependencies are injected* |
||
108 | */ |
||
109 | public function toConstructor(string $class, $name, ?InjectionPoints $injectionPoints = null, ?string $postConstruct = null): self |
||
122 | |||
123 | /** |
||
124 | * Bind to provider |
||
125 | * |
||
126 | * @phpstan-param class-string $provider |
||
127 | */ |
||
128 | public function toProvider(string $provider, string $context = ''): self |
||
137 | |||
138 | /** |
||
139 | * Bind to instance |
||
140 | * |
||
141 | * @param mixed $instance |
||
142 | */ |
||
143 | public function toInstance($instance): self |
||
151 | |||
152 | /** |
||
153 | * Bind to NullObject |
||
154 | */ |
||
155 | public function toNull(): self |
||
164 | |||
165 | /** |
||
166 | * Set scope |
||
167 | */ |
||
168 | public function in(string $scope): self |
||
180 | |||
181 | public function getBound(): DependencyInterface |
||
185 | |||
186 | public function setBound(DependencyInterface $bound): void |
||
190 | |||
191 | private function isRegistered(string $interface): bool |
||
195 | |||
196 | /** |
||
197 | * Return string |
||
198 | * |
||
199 | * input: ['varA' => 'nameA', 'varB' => 'nameB'] |
||
200 | * output: "varA=nameA,varB=nameB" |
||
201 | * |
||
202 | * @param array<string, string> $name |
||
203 | */ |
||
204 | private function getStringName(array $name): string |
||
228 | } |
||
229 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.