@@ -53,7 +53,7 @@ |
||
53 | 53 | public function resolve(object $attribute, object $service, \ReflectionMethod $method): void |
54 | 54 | { |
55 | 55 | $attributeClass = $attribute::class; |
56 | - if (!isset($this->resolvers[$attributeClass])) { |
|
56 | + if (!isset($this->resolvers[$attributeClass])){ |
|
57 | 57 | throw new \RuntimeException("No resolver for attribute {$attributeClass}"); |
58 | 58 | } |
59 | 59 |
@@ -53,7 +53,8 @@ |
||
53 | 53 | public function resolve(object $attribute, object $service, \ReflectionMethod $method): void |
54 | 54 | { |
55 | 55 | $attributeClass = $attribute::class; |
56 | - if (!isset($this->resolvers[$attributeClass])) { |
|
56 | + if (!isset($this->resolvers[$attributeClass])) |
|
57 | + { |
|
57 | 58 | throw new \RuntimeException("No resolver for attribute {$attributeClass}"); |
58 | 59 | } |
59 | 60 |
@@ -38,7 +38,8 @@ discard block |
||
38 | 38 | protected readonly BinderInterface $binder, |
39 | 39 | protected readonly ClassesRegistry $bootloaders = new ClassesRegistry(), |
40 | 40 | ?BootloaderCheckerInterface $checker = null, |
41 | - ) {} |
|
41 | + ) { |
|
42 | +} |
|
42 | 43 | |
43 | 44 | /** |
44 | 45 | * Instantiate bootloader objects and resolve dependencies |
@@ -52,21 +53,25 @@ discard block |
||
52 | 53 | { |
53 | 54 | $this->checker ??= $this->initDefaultChecker(); |
54 | 55 | |
55 | - foreach ($classes as $bootloader => $options) { |
|
56 | + foreach ($classes as $bootloader => $options) |
|
57 | + { |
|
56 | 58 | // default bootload syntax as simple array |
57 | - if (\is_string($options) || $options instanceof BootloaderInterface) { |
|
59 | + if (\is_string($options) || $options instanceof BootloaderInterface) |
|
60 | + { |
|
58 | 61 | $bootloader = $options; |
59 | 62 | $options = []; |
60 | 63 | } |
61 | 64 | $options = $useConfig ? $this->getBootloadConfig($bootloader, $options) : []; |
62 | 65 | |
63 | - if (!$this->checker->canInitialize($bootloader, $useConfig ? $options : null)) { |
|
66 | + if (!$this->checker->canInitialize($bootloader, $useConfig ? $options : null)) |
|
67 | + { |
|
64 | 68 | continue; |
65 | 69 | } |
66 | 70 | |
67 | 71 | $this->bootloaders->register($bootloader instanceof BootloaderInterface ? $bootloader::class : $bootloader); |
68 | 72 | |
69 | - if (!$bootloader instanceof BootloaderInterface) { |
|
73 | + if (!$bootloader instanceof BootloaderInterface) |
|
74 | + { |
|
70 | 75 | $bootloader = $this->container->get($bootloader); |
71 | 76 | } |
72 | 77 | |
@@ -104,11 +109,13 @@ discard block |
||
104 | 109 | */ |
105 | 110 | private function initBootloader(BootloaderInterface $bootloader): void |
106 | 111 | { |
107 | - foreach ($bootloader->defineBindings() as $alias => $resolver) { |
|
112 | + foreach ($bootloader->defineBindings() as $alias => $resolver) |
|
113 | + { |
|
108 | 114 | $this->binder->bind($alias, $resolver); |
109 | 115 | } |
110 | 116 | |
111 | - foreach ($bootloader->defineSingletons() as $alias => $resolver) { |
|
117 | + foreach ($bootloader->defineSingletons() as $alias => $resolver) |
|
118 | + { |
|
112 | 119 | $this->binder->bindSingleton($alias, $resolver); |
113 | 120 | } |
114 | 121 | |
@@ -153,7 +160,8 @@ discard block |
||
153 | 160 | string|BootloaderInterface $bootloader, |
154 | 161 | array|callable|BootloadConfig $config, |
155 | 162 | ): BootloadConfig { |
156 | - if ($config instanceof \Closure) { |
|
163 | + if ($config instanceof \Closure) |
|
164 | + { |
|
157 | 165 | $config = $this->container instanceof ResolverInterface |
158 | 166 | ? $config(...$this->container->resolveArguments(new \ReflectionFunction($config))) |
159 | 167 | : $config(); |
@@ -189,12 +197,14 @@ discard block |
||
189 | 197 | private function getBootloadConfigAttribute(string|BootloaderInterface $bootloader): ?BootloadConfig |
190 | 198 | { |
191 | 199 | $attribute = null; |
192 | - if ($bootloader instanceof BootloaderInterface || \class_exists($bootloader)) { |
|
200 | + if ($bootloader instanceof BootloaderInterface || \class_exists($bootloader)) |
|
201 | + { |
|
193 | 202 | $ref = new \ReflectionClass($bootloader); |
194 | 203 | $attribute = $ref->getAttributes(BootloadConfig::class)[0] ?? null; |
195 | 204 | } |
196 | 205 | |
197 | - if ($attribute === null) { |
|
206 | + if ($attribute === null) |
|
207 | + { |
|
198 | 208 | return null; |
199 | 209 | } |
200 | 210 | |
@@ -216,13 +226,16 @@ discard block |
||
216 | 226 | $methods = $initialMethods; |
217 | 227 | |
218 | 228 | $refl = new \ReflectionClass($bootloader); |
219 | - foreach ($refl->getMethods() as $method) { |
|
220 | - if ($method->isStatic()) { |
|
229 | + foreach ($refl->getMethods() as $method) |
|
230 | + { |
|
231 | + if ($method->isStatic()) |
|
232 | + { |
|
221 | 233 | continue; |
222 | 234 | } |
223 | 235 | |
224 | 236 | $attrs = $method->getAttributes($attribute); |
225 | - if (\count($attrs) === 0) { |
|
237 | + if (\count($attrs) === 0) |
|
238 | + { |
|
226 | 239 | continue; |
227 | 240 | } |
228 | 241 | /** @var InitMethod|BootMethod $attr */ |
@@ -242,7 +255,8 @@ discard block |
||
242 | 255 | */ |
243 | 256 | private function resolveAttributeBindings(BootloaderInterface $bootloader): void |
244 | 257 | { |
245 | - if (!$this->container->has(AttributeResolver::class)) { |
|
258 | + if (!$this->container->has(AttributeResolver::class)) |
|
259 | + { |
|
246 | 260 | return; |
247 | 261 | } |
248 | 262 | |
@@ -252,14 +266,18 @@ discard block |
||
252 | 266 | $availableAttributes = $attributeResolver->getResolvers(); |
253 | 267 | |
254 | 268 | $refl = new \ReflectionClass($bootloader); |
255 | - foreach ($refl->getMethods() as $method) { |
|
256 | - if ($method->isStatic()) { |
|
269 | + foreach ($refl->getMethods() as $method) |
|
270 | + { |
|
271 | + if ($method->isStatic()) |
|
272 | + { |
|
257 | 273 | continue; |
258 | 274 | } |
259 | 275 | |
260 | - foreach ($availableAttributes as $attributeClass) { |
|
276 | + foreach ($availableAttributes as $attributeClass) |
|
277 | + { |
|
261 | 278 | $attrs = $method->getAttributes($attributeClass); |
262 | - foreach ($attrs as $attr) { |
|
279 | + foreach ($attrs as $attr) |
|
280 | + { |
|
263 | 281 | $instance = $attr->newInstance(); |
264 | 282 | $attributeResolver->resolve($instance, $bootloader, $method); |
265 | 283 | } |
@@ -276,7 +294,8 @@ discard block |
||
276 | 294 | private function resolveDependencies(BootloaderInterface $bootloader, array $bootloaderMethods): iterable |
277 | 295 | { |
278 | 296 | $deps = $this->findDependenciesInMethods($bootloader, $bootloaderMethods); |
279 | - if ($bootloader instanceof DependedInterface) { |
|
297 | + if ($bootloader instanceof DependedInterface) |
|
298 | + { |
|
280 | 299 | $deps = [...$deps, ...$bootloader->defineDependencies()]; |
281 | 300 | } |
282 | 301 | |
@@ -293,8 +312,10 @@ discard block |
||
293 | 312 | |
294 | 313 | $methodsDeps = []; |
295 | 314 | |
296 | - foreach ($methods as $method) { |
|
297 | - if ($reflectionClass->hasMethod($method)) { |
|
315 | + foreach ($methods as $method) |
|
316 | + { |
|
317 | + if ($reflectionClass->hasMethod($method)) |
|
318 | + { |
|
298 | 319 | $methodsDeps[] = $this->findBootloaderClassesInMethod( |
299 | 320 | $reflectionClass->getMethod($method), |
300 | 321 | ); |
@@ -310,9 +331,11 @@ discard block |
||
310 | 331 | private function findBootloaderClassesInMethod(\ReflectionMethod $method): array |
311 | 332 | { |
312 | 333 | $args = []; |
313 | - foreach ($method->getParameters() as $parameter) { |
|
334 | + foreach ($method->getParameters() as $parameter) |
|
335 | + { |
|
314 | 336 | $type = $parameter->getType(); |
315 | - if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)) { |
|
337 | + if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)) |
|
338 | + { |
|
316 | 339 | $args[] = $type->getName(); |
317 | 340 | } |
318 | 341 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | protected readonly BinderInterface $binder, |
39 | 39 | protected readonly ClassesRegistry $bootloaders = new ClassesRegistry(), |
40 | 40 | ?BootloaderCheckerInterface $checker = null, |
41 | - ) {} |
|
41 | + ){} |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Instantiate bootloader objects and resolve dependencies |
@@ -52,21 +52,21 @@ discard block |
||
52 | 52 | { |
53 | 53 | $this->checker ??= $this->initDefaultChecker(); |
54 | 54 | |
55 | - foreach ($classes as $bootloader => $options) { |
|
55 | + foreach ($classes as $bootloader => $options){ |
|
56 | 56 | // default bootload syntax as simple array |
57 | - if (\is_string($options) || $options instanceof BootloaderInterface) { |
|
57 | + if (\is_string($options) || $options instanceof BootloaderInterface){ |
|
58 | 58 | $bootloader = $options; |
59 | 59 | $options = []; |
60 | 60 | } |
61 | 61 | $options = $useConfig ? $this->getBootloadConfig($bootloader, $options) : []; |
62 | 62 | |
63 | - if (!$this->checker->canInitialize($bootloader, $useConfig ? $options : null)) { |
|
63 | + if (!$this->checker->canInitialize($bootloader, $useConfig ? $options : null)){ |
|
64 | 64 | continue; |
65 | 65 | } |
66 | 66 | |
67 | 67 | $this->bootloaders->register($bootloader instanceof BootloaderInterface ? $bootloader::class : $bootloader); |
68 | 68 | |
69 | - if (!$bootloader instanceof BootloaderInterface) { |
|
69 | + if (!$bootloader instanceof BootloaderInterface){ |
|
70 | 70 | $bootloader = $this->container->get($bootloader); |
71 | 71 | } |
72 | 72 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @psalm-pure |
113 | 113 | * @psalm-assert-if-true TClass $class |
114 | 114 | */ |
115 | - protected function isBootloader(string|object $class): bool |
|
115 | + protected function isBootloader(string | object $class): bool |
|
116 | 116 | { |
117 | 117 | return \is_subclass_of($class, BootloaderInterface::class); |
118 | 118 | } |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | */ |
133 | 133 | private function initBootloader(BootloaderInterface $bootloader): void |
134 | 134 | { |
135 | - foreach ($bootloader->defineBindings() as $alias => $resolver) { |
|
135 | + foreach ($bootloader->defineBindings() as $alias => $resolver){ |
|
136 | 136 | $this->binder->bind($alias, $resolver); |
137 | 137 | } |
138 | 138 | |
139 | - foreach ($bootloader->defineSingletons() as $alias => $resolver) { |
|
139 | + foreach ($bootloader->defineSingletons() as $alias => $resolver){ |
|
140 | 140 | $this->binder->bindSingleton($alias, $resolver); |
141 | 141 | } |
142 | 142 | |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | * @throws \ReflectionException |
151 | 151 | */ |
152 | 152 | private function getBootloadConfig( |
153 | - string|BootloaderInterface $bootloader, |
|
154 | - array|callable|BootloadConfig $config, |
|
153 | + string | BootloaderInterface $bootloader, |
|
154 | + array | callable | BootloadConfig $config, |
|
155 | 155 | ): BootloadConfig { |
156 | - if ($config instanceof \Closure) { |
|
156 | + if ($config instanceof \Closure){ |
|
157 | 157 | $config = $this->container instanceof ResolverInterface |
158 | 158 | ? $config(...$this->container->resolveArguments(new \ReflectionFunction($config))) |
159 | 159 | : $config(); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $getArgument = static fn(string $key, bool $override, mixed $default = []): mixed => match (true) { |
165 | 165 | $config instanceof BootloadConfig && $override => $config->{$key}, |
166 | 166 | $config instanceof BootloadConfig && !$override && \is_array($default) => |
167 | - $config->{$key} + ($attr->{$key} ?? []), |
|
167 | + $config->{$key} +($attr->{$key} ?? []), |
|
168 | 168 | $config instanceof BootloadConfig && !$override && \is_bool($default) => $config->{$key}, |
169 | 169 | \is_array($config) && $config !== [] && $key === 'args' => $config, |
170 | 170 | default => $attr->{$key} ?? $default, |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | * @param class-string<BootloaderInterface>|BootloaderInterface $bootloader |
187 | 187 | * @throws \ReflectionException |
188 | 188 | */ |
189 | - private function getBootloadConfigAttribute(string|BootloaderInterface $bootloader): ?BootloadConfig |
|
189 | + private function getBootloadConfigAttribute(string | BootloaderInterface $bootloader): ?BootloadConfig |
|
190 | 190 | { |
191 | 191 | $attribute = null; |
192 | - if ($bootloader instanceof BootloaderInterface || \class_exists($bootloader)) { |
|
192 | + if ($bootloader instanceof BootloaderInterface || \class_exists($bootloader)){ |
|
193 | 193 | $ref = new \ReflectionClass($bootloader); |
194 | 194 | $attribute = $ref->getAttributes(BootloadConfig::class)[0] ?? null; |
195 | 195 | } |
196 | 196 | |
197 | - if ($attribute === null) { |
|
197 | + if ($attribute === null){ |
|
198 | 198 | return null; |
199 | 199 | } |
200 | 200 | |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | $methods = $initialMethods; |
217 | 217 | |
218 | 218 | $refl = new \ReflectionClass($bootloader); |
219 | - foreach ($refl->getMethods() as $method) { |
|
220 | - if ($method->isStatic()) { |
|
219 | + foreach ($refl->getMethods() as $method){ |
|
220 | + if ($method->isStatic()){ |
|
221 | 221 | continue; |
222 | 222 | } |
223 | 223 | |
224 | 224 | $attrs = $method->getAttributes($attribute); |
225 | - if (\count($attrs) === 0) { |
|
225 | + if (\count($attrs) === 0){ |
|
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | /** @var InitMethod|BootMethod $attr */ |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | private function resolveAttributeBindings(BootloaderInterface $bootloader): void |
244 | 244 | { |
245 | - if (!$this->container->has(AttributeResolver::class)) { |
|
245 | + if (!$this->container->has(AttributeResolver::class)){ |
|
246 | 246 | return; |
247 | 247 | } |
248 | 248 | |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | $availableAttributes = $attributeResolver->getResolvers(); |
253 | 253 | |
254 | 254 | $refl = new \ReflectionClass($bootloader); |
255 | - foreach ($refl->getMethods() as $method) { |
|
256 | - if ($method->isStatic()) { |
|
255 | + foreach ($refl->getMethods() as $method){ |
|
256 | + if ($method->isStatic()){ |
|
257 | 257 | continue; |
258 | 258 | } |
259 | 259 | |
260 | - foreach ($availableAttributes as $attributeClass) { |
|
260 | + foreach ($availableAttributes as $attributeClass){ |
|
261 | 261 | $attrs = $method->getAttributes($attributeClass); |
262 | - foreach ($attrs as $attr) { |
|
262 | + foreach ($attrs as $attr){ |
|
263 | 263 | $instance = $attr->newInstance(); |
264 | 264 | $attributeResolver->resolve($instance, $bootloader, $method); |
265 | 265 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | private function resolveDependencies(BootloaderInterface $bootloader, array $bootloaderMethods): iterable |
277 | 277 | { |
278 | 278 | $deps = $this->findDependenciesInMethods($bootloader, $bootloaderMethods); |
279 | - if ($bootloader instanceof DependedInterface) { |
|
279 | + if ($bootloader instanceof DependedInterface){ |
|
280 | 280 | $deps = [...$deps, ...$bootloader->defineDependencies()]; |
281 | 281 | } |
282 | 282 | |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | |
294 | 294 | $methodsDeps = []; |
295 | 295 | |
296 | - foreach ($methods as $method) { |
|
297 | - if ($reflectionClass->hasMethod($method)) { |
|
296 | + foreach ($methods as $method){ |
|
297 | + if ($reflectionClass->hasMethod($method)){ |
|
298 | 298 | $methodsDeps[] = $this->findBootloaderClassesInMethod( |
299 | 299 | $reflectionClass->getMethod($method), |
300 | 300 | ); |
@@ -310,9 +310,9 @@ discard block |
||
310 | 310 | private function findBootloaderClassesInMethod(\ReflectionMethod $method): array |
311 | 311 | { |
312 | 312 | $args = []; |
313 | - foreach ($method->getParameters() as $parameter) { |
|
313 | + foreach ($method->getParameters() as $parameter){ |
|
314 | 314 | $type = $parameter->getType(); |
315 | - if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)) { |
|
315 | + if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)){ |
|
316 | 316 | $args[] = $type->getName(); |
317 | 317 | } |
318 | 318 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | { |
22 | 22 | public function __construct( |
23 | 23 | protected readonly BinderInterface $binder, |
24 | - ) {} |
|
24 | + ){} |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @psalm-param T $attribute |
@@ -32,35 +32,35 @@ discard block |
||
32 | 32 | $alias = $attribute->alias ?? null; |
33 | 33 | |
34 | 34 | $aliases = []; |
35 | - if ($alias !== null) { |
|
35 | + if ($alias !== null){ |
|
36 | 36 | $aliases[] = $alias; |
37 | 37 | } |
38 | 38 | |
39 | 39 | $attrs = $method->getAttributes(name: BindAlias::class); |
40 | - foreach ($attrs as $attr) { |
|
40 | + foreach ($attrs as $attr){ |
|
41 | 41 | $aliases = [...$aliases, ...$attr->newInstance()->aliases]; |
42 | 42 | } |
43 | 43 | |
44 | 44 | // If no aliases are provided, we will use the return type as the alias. |
45 | - if (\count($aliases) > 0 && !$attribute->aliasesFromReturnType) { |
|
45 | + if (\count($aliases) > 0 && !$attribute->aliasesFromReturnType){ |
|
46 | 46 | return \array_unique(\array_filter($aliases)); |
47 | 47 | } |
48 | 48 | |
49 | 49 | $type = $method->getReturnType(); |
50 | 50 | |
51 | - if ($type instanceof \ReflectionUnionType || $type instanceof \ReflectionIntersectionType) { |
|
52 | - foreach ($type->getTypes() as $type) { |
|
53 | - if ($type->isBuiltin()) { |
|
51 | + if ($type instanceof \ReflectionUnionType || $type instanceof \ReflectionIntersectionType){ |
|
52 | + foreach ($type->getTypes() as $type){ |
|
53 | + if ($type->isBuiltin()){ |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $aliases[] = $type->getName(); |
58 | 58 | } |
59 | - } elseif ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) { |
|
59 | + } elseif ($type instanceof \ReflectionNamedType && !$type->isBuiltin()){ |
|
60 | 60 | $aliases[] = $type->getName(); |
61 | 61 | } |
62 | 62 | |
63 | - if ($aliases === []) { |
|
63 | + if ($aliases === []){ |
|
64 | 64 | throw new \LogicException( |
65 | 65 | "No alias provided for binding {$method->getDeclaringClass()->getName()}::{$method->getName()}", |
66 | 66 | ); |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | |
72 | 72 | protected function getScope(\ReflectionMethod $method): ?string |
73 | 73 | { |
74 | - $attrs = $method->getAttributes(name: BindScope::class); |
|
74 | + $attrs = $method->getAttributes(name : BindScope::class); |
|
75 | 75 | |
76 | - if ($attrs === []) { |
|
76 | + if ($attrs === []){ |
|
77 | 77 | return null; |
78 | 78 | } |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $binder = $this->binder->getBinder($scope); |
86 | 86 | |
87 | 87 | $alias = \array_shift($aliases); |
88 | - foreach ($aliases as $a) { |
|
88 | + foreach ($aliases as $a){ |
|
89 | 89 | $binder->bind($alias, $a); |
90 | 90 | $alias = \array_shift($aliases); |
91 | 91 | } |
@@ -21,7 +21,8 @@ discard block |
||
21 | 21 | { |
22 | 22 | public function __construct( |
23 | 23 | protected readonly BinderInterface $binder, |
24 | - ) {} |
|
24 | + ) { |
|
25 | +} |
|
25 | 26 | |
26 | 27 | /** |
27 | 28 | * @psalm-param T $attribute |
@@ -32,35 +33,44 @@ discard block |
||
32 | 33 | $alias = $attribute->alias ?? null; |
33 | 34 | |
34 | 35 | $aliases = []; |
35 | - if ($alias !== null) { |
|
36 | + if ($alias !== null) |
|
37 | + { |
|
36 | 38 | $aliases[] = $alias; |
37 | 39 | } |
38 | 40 | |
39 | 41 | $attrs = $method->getAttributes(name: BindAlias::class); |
40 | - foreach ($attrs as $attr) { |
|
42 | + foreach ($attrs as $attr) |
|
43 | + { |
|
41 | 44 | $aliases = [...$aliases, ...$attr->newInstance()->aliases]; |
42 | 45 | } |
43 | 46 | |
44 | 47 | // If no aliases are provided, we will use the return type as the alias. |
45 | - if (\count($aliases) > 0 && !$attribute->aliasesFromReturnType) { |
|
48 | + if (\count($aliases) > 0 && !$attribute->aliasesFromReturnType) |
|
49 | + { |
|
46 | 50 | return \array_unique(\array_filter($aliases)); |
47 | 51 | } |
48 | 52 | |
49 | 53 | $type = $method->getReturnType(); |
50 | 54 | |
51 | - if ($type instanceof \ReflectionUnionType || $type instanceof \ReflectionIntersectionType) { |
|
52 | - foreach ($type->getTypes() as $type) { |
|
53 | - if ($type->isBuiltin()) { |
|
55 | + if ($type instanceof \ReflectionUnionType || $type instanceof \ReflectionIntersectionType) |
|
56 | + { |
|
57 | + foreach ($type->getTypes() as $type) |
|
58 | + { |
|
59 | + if ($type->isBuiltin()) |
|
60 | + { |
|
54 | 61 | continue; |
55 | 62 | } |
56 | 63 | |
57 | 64 | $aliases[] = $type->getName(); |
58 | 65 | } |
59 | - } elseif ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) { |
|
66 | + } |
|
67 | + elseif ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) |
|
68 | + { |
|
60 | 69 | $aliases[] = $type->getName(); |
61 | 70 | } |
62 | 71 | |
63 | - if ($aliases === []) { |
|
72 | + if ($aliases === []) |
|
73 | + { |
|
64 | 74 | throw new \LogicException( |
65 | 75 | "No alias provided for binding {$method->getDeclaringClass()->getName()}::{$method->getName()}", |
66 | 76 | ); |
@@ -73,7 +83,8 @@ discard block |
||
73 | 83 | { |
74 | 84 | $attrs = $method->getAttributes(name: BindScope::class); |
75 | 85 | |
76 | - if ($attrs === []) { |
|
86 | + if ($attrs === []) |
|
87 | + { |
|
77 | 88 | return null; |
78 | 89 | } |
79 | 90 | |
@@ -85,7 +96,8 @@ discard block |
||
85 | 96 | $binder = $this->binder->getBinder($scope); |
86 | 97 | |
87 | 98 | $alias = \array_shift($aliases); |
88 | - foreach ($aliases as $a) { |
|
99 | + foreach ($aliases as $a) |
|
100 | + { |
|
89 | 101 | $binder->bind($alias, $a); |
90 | 102 | $alias = \array_shift($aliases); |
91 | 103 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | public function __construct( |
21 | 21 | private readonly BinderInterface $binder, |
22 | 22 | private readonly InvokerInterface $invoker, |
23 | - ) {} |
|
23 | + ){} |
|
24 | 24 | |
25 | 25 | public function resolve(object $attribute, object $service, \ReflectionMethod $method): void |
26 | 26 | { |
@@ -20,7 +20,8 @@ |
||
20 | 20 | public function __construct( |
21 | 21 | private readonly BinderInterface $binder, |
22 | 22 | private readonly InvokerInterface $invoker, |
23 | - ) {} |
|
23 | + ) { |
|
24 | +} |
|
24 | 25 | |
25 | 26 | public function resolve(object $attribute, object $service, \ReflectionMethod $method): void |
26 | 27 | { |
@@ -19,5 +19,5 @@ |
||
19 | 19 | * Add aliases from the return type of the method even if the method has an alias. |
20 | 20 | */ |
21 | 21 | public readonly bool $aliasesFromReturnType = false, |
22 | - ) {} |
|
22 | + ){} |
|
23 | 23 | } |
@@ -19,5 +19,6 @@ |
||
19 | 19 | * Add aliases from the return type of the method even if the method has an alias. |
20 | 20 | */ |
21 | 21 | public readonly bool $aliasesFromReturnType = false, |
22 | - ) {} |
|
22 | + ) { |
|
23 | +} |
|
23 | 24 | } |
@@ -9,8 +9,8 @@ |
||
9 | 9 | { |
10 | 10 | public readonly string $scope; |
11 | 11 | |
12 | - public function __construct(string|\BackedEnum $scope) |
|
12 | + public function __construct(string | \BackedEnum $scope) |
|
13 | 13 | { |
14 | - $this->scope = \is_object($scope) ? (string) $scope->value : $scope; |
|
14 | + $this->scope = \is_object($scope) ? (string)$scope->value : $scope; |
|
15 | 15 | } |
16 | 16 | } |
@@ -9,5 +9,5 @@ |
||
9 | 9 | { |
10 | 10 | public function __construct( |
11 | 11 | public readonly int $priority = 0, |
12 | - ) {} |
|
12 | + ){} |
|
13 | 13 | } |
@@ -9,5 +9,6 @@ |
||
9 | 9 | { |
10 | 10 | public function __construct( |
11 | 11 | public readonly int $priority = 0, |
12 | - ) {} |
|
12 | + ) { |
|
13 | +} |
|
13 | 14 | } |
@@ -5,4 +5,4 @@ |
||
5 | 5 | namespace Spiral\Boot\Attribute; |
6 | 6 | |
7 | 7 | #[\Attribute(\Attribute::TARGET_METHOD)] |
8 | -final class SingletonMethod extends AbstractMethod {} |
|
8 | +final class SingletonMethod extends AbstractMethod{} |
@@ -5,4 +5,6 @@ |
||
5 | 5 | namespace Spiral\Boot\Attribute; |
6 | 6 | |
7 | 7 | #[\Attribute(\Attribute::TARGET_METHOD)] |
8 | -final class SingletonMethod extends AbstractMethod {} |
|
8 | +final class SingletonMethod extends AbstractMethod |
|
9 | +{ |
|
10 | +} |
@@ -5,4 +5,4 @@ |
||
5 | 5 | namespace Spiral\Boot\Attribute; |
6 | 6 | |
7 | 7 | #[\Attribute(\Attribute::TARGET_METHOD)] |
8 | -final class BindMethod extends AbstractMethod {} |
|
8 | +final class BindMethod extends AbstractMethod{} |
@@ -5,4 +5,6 @@ |
||
5 | 5 | namespace Spiral\Boot\Attribute; |
6 | 6 | |
7 | 7 | #[\Attribute(\Attribute::TARGET_METHOD)] |
8 | -final class BindMethod extends AbstractMethod {} |
|
8 | +final class BindMethod extends AbstractMethod |
|
9 | +{ |
|
10 | +} |