Passed
Pull Request — master (#1190)
by butschster
11:23
created
src/Boot/tests/Fixtures/BootloaderQ.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 class BootloaderQ extends Bootloader
11 11
 {
12 12
     #[SingletonMethod]
13
-    private function bind(): SampleClass|SampleClassInterface
13
+    private function bind(): SampleClass | SampleClassInterface
14 14
     {
15 15
         return new SampleClass();
16 16
     }
Please login to merge, or discard this patch.
src/Boot/src/BootloadManager/AttributeResolver.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Boot/src/BootloadManager/Initializer.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
      */
105 105
     private function initBootloader(BootloaderInterface $bootloader): void
106 106
     {
107
-        foreach ($bootloader->defineBindings() as $alias => $resolver) {
107
+        foreach ($bootloader->defineBindings() as $alias => $resolver){
108 108
             $this->binder->bind($alias, $resolver);
109 109
         }
110 110
 
111
-        foreach ($bootloader->defineSingletons() as $alias => $resolver) {
111
+        foreach ($bootloader->defineSingletons() as $alias => $resolver){
112 112
             $this->binder->bindSingleton($alias, $resolver);
113 113
         }
114 114
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      * @psalm-pure
129 129
      * @psalm-assert-if-true TClass $class
130 130
      */
131
-    protected function isBootloader(string|object $class): bool
131
+    protected function isBootloader(string | object $class): bool
132 132
     {
133 133
         return \is_subclass_of($class, BootloaderInterface::class);
134 134
     }
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +46 added lines, -23 removed lines patch added patch discarded remove patch
@@ -38,7 +38,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Boot/src/BootloadManager/AttributeResolver/AbstractResolver.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +23 added lines, -11 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Boot/src/BootloadManager/AttributeResolver/InjectorMethodResolver.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
src/Boot/src/BootloadManager/DefaultInvokerStrategy.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
         private readonly InitializerInterface $initializer,
15 15
         private readonly InvokerInterface $invoker,
16 16
         private readonly ResolverInterface $resolver
17
-    ) {
17
+    ){
18 18
     }
19 19
 
20 20
     public function invokeBootloaders(
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
         /** @psalm-suppress TooManyArguments */
27 27
         $bootloaders = \iterator_to_array($this->initializer->init($classes, $useConfig));
28 28
 
29
-        foreach ($bootloaders as $data) {
30
-            foreach ($data['init_methods'] as $methodName) {
29
+        foreach ($bootloaders as $data){
30
+            foreach ($data['init_methods'] as $methodName){
31 31
                 $this->invokeBootloader($data['bootloader'], $methodName, $data['options']);
32 32
             }
33 33
         }
34 34
 
35 35
         $this->fireCallbacks($bootingCallbacks);
36 36
 
37
-        foreach ($bootloaders as $data) {
38
-            foreach ($data['boot_methods'] as $methodName) {
37
+        foreach ($bootloaders as $data){
38
+            foreach ($data['boot_methods'] as $methodName){
39 39
                 $this->invokeBootloader($data['bootloader'], $methodName, $data['options']);
40 40
             }
41 41
         }
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
     private function invokeBootloader(BootloaderInterface $bootloader, string $method, array $options): void
47 47
     {
48 48
         $refl = new \ReflectionClass($bootloader);
49
-        if (!$refl->hasMethod($method)) {
49
+        if (!$refl->hasMethod($method)){
50 50
             return;
51 51
         }
52 52
 
53 53
         $method = $refl->getMethod($method);
54 54
 
55 55
         $args = $this->resolver->resolveArguments($method);
56
-        if (!isset($args['boot'])) {
56
+        if (!isset($args['boot'])){
57 57
             $args['boot'] = $options;
58 58
         }
59 59
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     private function fireCallbacks(array $callbacks): void
67 67
     {
68
-        foreach ($callbacks as $callback) {
68
+        foreach ($callbacks as $callback){
69 69
             $this->invoker->invoke($callback);
70 70
         }
71 71
     }
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,16 +26,20 @@  discard block
 block discarded – undo
26 26
         /** @psalm-suppress TooManyArguments */
27 27
         $bootloaders = \iterator_to_array($this->initializer->init($classes, $useConfig));
28 28
 
29
-        foreach ($bootloaders as $data) {
30
-            foreach ($data['init_methods'] as $methodName) {
29
+        foreach ($bootloaders as $data)
30
+        {
31
+            foreach ($data['init_methods'] as $methodName)
32
+            {
31 33
                 $this->invokeBootloader($data['bootloader'], $methodName, $data['options']);
32 34
             }
33 35
         }
34 36
 
35 37
         $this->fireCallbacks($bootingCallbacks);
36 38
 
37
-        foreach ($bootloaders as $data) {
38
-            foreach ($data['boot_methods'] as $methodName) {
39
+        foreach ($bootloaders as $data)
40
+        {
41
+            foreach ($data['boot_methods'] as $methodName)
42
+            {
39 43
                 $this->invokeBootloader($data['bootloader'], $methodName, $data['options']);
40 44
             }
41 45
         }
@@ -46,14 +50,16 @@  discard block
 block discarded – undo
46 50
     private function invokeBootloader(BootloaderInterface $bootloader, string $method, array $options): void
47 51
     {
48 52
         $refl = new \ReflectionClass($bootloader);
49
-        if (!$refl->hasMethod($method)) {
53
+        if (!$refl->hasMethod($method))
54
+        {
50 55
             return;
51 56
         }
52 57
 
53 58
         $method = $refl->getMethod($method);
54 59
 
55 60
         $args = $this->resolver->resolveArguments($method);
56
-        if (!isset($args['boot'])) {
61
+        if (!isset($args['boot']))
62
+        {
57 63
             $args['boot'] = $options;
58 64
         }
59 65
 
@@ -65,7 +71,8 @@  discard block
 block discarded – undo
65 71
      */
66 72
     private function fireCallbacks(array $callbacks): void
67 73
     {
68
-        foreach ($callbacks as $callback) {
74
+        foreach ($callbacks as $callback)
75
+        {
69 76
             $this->invoker->invoke($callback);
70 77
         }
71 78
     }
Please login to merge, or discard this patch.
src/Boot/src/AbstractKernel.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         protected readonly ExceptionHandlerInterface $exceptionHandler,
80 80
         protected readonly BootloadManagerInterface $bootloader,
81 81
         array $directories
82
-    ) {
82
+    ){
83 83
         $container->bindSingleton(ExceptionHandlerInterface::class, $exceptionHandler);
84 84
         $container->bindSingleton(ExceptionRendererInterface::class, $exceptionHandler);
85 85
         $container->bindSingleton(ExceptionReporterInterface::class, $exceptionHandler);
@@ -116,38 +116,38 @@  discard block
 block discarded – undo
116 116
     final public static function create(
117 117
         array $directories,
118 118
         bool $handleErrors = true,
119
-        ExceptionHandlerInterface|string|null $exceptionHandler = null,
119
+        ExceptionHandlerInterface | string | null $exceptionHandler = null,
120 120
         Container $container = new Container(),
121
-        BootloadManagerInterface|Autowire|null $bootloadManager = null
121
+        BootloadManagerInterface | Autowire | null $bootloadManager = null
122 122
     ): static {
123 123
         $exceptionHandler ??= ExceptionHandler::class;
124 124
 
125
-        if (\is_string($exceptionHandler)) {
125
+        if (\is_string($exceptionHandler)){
126 126
             $exceptionHandler = $container->make($exceptionHandler);
127 127
         }
128 128
 
129
-        if ($handleErrors) {
129
+        if ($handleErrors){
130 130
             $exceptionHandler->register();
131 131
         }
132 132
 
133 133
         $container->bind(AttributeResolverRegistryInterface::class, AttributeResolver::class);
134 134
 
135
-        if (!$container->has(InitializerInterface::class)) {
135
+        if (!$container->has(InitializerInterface::class)){
136 136
             $container->bind(InitializerInterface::class, Initializer::class);
137 137
         }
138 138
 
139
-        if (!$container->has(InvokerStrategyInterface::class)) {
139
+        if (!$container->has(InvokerStrategyInterface::class)){
140 140
             $container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class);
141 141
         }
142 142
 
143
-        if ($bootloadManager instanceof Autowire) {
143
+        if ($bootloadManager instanceof Autowire){
144 144
             $bootloadManager = $bootloadManager->resolve($container);
145 145
         }
146 146
         $bootloadManager ??= $container->make(StrategyBasedBootloadManager::class);
147 147
         \assert($bootloadManager instanceof BootloadManagerInterface);
148 148
         $container->bind(BootloadManagerInterface::class, $bootloadManager);
149 149
 
150
-        if (!$container->has(BootloaderRegistryInterface::class)) {
150
+        if (!$container->has(BootloaderRegistryInterface::class)){
151 151
             /** @psalm-suppress InvalidArgument */
152 152
             $container->bindSingleton(BootloaderRegistryInterface::class, [self::class, 'initBootloaderRegistry']);
153 153
         }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         $environment ??= new Environment();
178 178
         $this->container->bindSingleton(EnvironmentInterface::class, $environment);
179 179
 
180
-        try {
180
+        try{
181 181
             // will protect any against env overwrite action
182 182
             $this->container->runScope(
183 183
                 [EnvironmentInterface::class => $environment],
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                     $this->fireCallbacks($this->bootstrappedCallbacks);
195 195
                 }
196 196
             );
197
-        } catch (\Throwable $e) {
197
+        }catch (\Throwable $e){
198 198
             $this->exceptionHandler->handleGlobalException($e);
199 199
 
200 200
             return null;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
      */
216 216
     public function running(Closure ...$callbacks): void
217 217
     {
218
-        foreach ($callbacks as $callback) {
218
+        foreach ($callbacks as $callback){
219 219
             $this->runningCallbacks[] = $callback;
220 220
         }
221 221
     }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
      */
231 231
     public function booting(Closure ...$callbacks): void
232 232
     {
233
-        foreach ($callbacks as $callback) {
233
+        foreach ($callbacks as $callback){
234 234
             $this->bootingCallbacks[] = $callback;
235 235
         }
236 236
     }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      */
246 246
     public function booted(Closure ...$callbacks): void
247 247
     {
248
-        foreach ($callbacks as $callback) {
248
+        foreach ($callbacks as $callback){
249 249
             $this->bootedCallbacks[] = $callback;
250 250
         }
251 251
     }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
      */
262 262
     public function bootstrapped(Closure ...$callbacks): void
263 263
     {
264
-        foreach ($callbacks as $callback) {
264
+        foreach ($callbacks as $callback){
265 265
             $this->bootstrappedCallbacks[] = $callback;
266 266
         }
267 267
     }
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
      * @param class-string<DispatcherInterface>|DispatcherInterface $dispatcher The class name or instance
274 274
      * of the dispatcher. Since v4.0, it will only accept the class name.
275 275
      */
276
-    public function addDispatcher(string|DispatcherInterface $dispatcher): self
276
+    public function addDispatcher(string | DispatcherInterface $dispatcher): self
277 277
     {
278
-        if (\is_object($dispatcher)) {
278
+        if (\is_object($dispatcher)){
279 279
             $dispatcher = $dispatcher::class;
280 280
         }
281 281
 
@@ -297,19 +297,19 @@  discard block
 block discarded – undo
297 297
         $eventDispatcher?->dispatch(new Serving());
298 298
 
299 299
         $serving = $servingScope = null;
300
-        foreach ($this->dispatchers as $dispatcher) {
300
+        foreach ($this->dispatchers as $dispatcher){
301 301
             $reflection = new \ReflectionClass($dispatcher);
302 302
 
303 303
             $scope = ($reflection->getAttributes(DispatcherScope::class)[0] ?? null)?->newInstance()->scope;
304 304
             $this->container->getBinder($scope)->bind($dispatcher, $dispatcher);
305 305
 
306
-            if ($serving === null && $this->canServe($reflection)) {
306
+            if ($serving === null && $this->canServe($reflection)){
307 307
                 $serving = $dispatcher;
308 308
                 $servingScope = $scope;
309 309
             }
310 310
         }
311 311
 
312
-        if ($serving === null) {
312
+        if ($serving === null){
313 313
             $eventDispatcher?->dispatch(new DispatcherNotFound());
314 314
             throw new BootException('Unable to locate active dispatcher.');
315 315
         }
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
      */
359 359
     protected function fireCallbacks(array &$callbacks): void
360 360
     {
361
-        if ($callbacks === []) {
361
+        if ($callbacks === []){
362 362
             return;
363 363
         }
364 364
 
365
-        do {
365
+        do{
366 366
             $this->container->invoke(\current($callbacks));
367
-        } while (\next($callbacks));
367
+        }while (\next($callbacks));
368 368
 
369 369
         $callbacks = [];
370 370
     }
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
      */
405 405
     private function canServe(\ReflectionClass $reflection): bool
406 406
     {
407
-        if (!$reflection->hasMethod('canServe')) {
407
+        if (!$reflection->hasMethod('canServe')){
408 408
             throw new BootException('Dispatcher must implement static `canServe` method.');
409 409
         }
410 410
 
Please login to merge, or discard this patch.
Braces   +39 added lines, -19 removed lines patch added patch discarded remove patch
@@ -122,32 +122,38 @@  discard block
 block discarded – undo
122 122
     ): static {
123 123
         $exceptionHandler ??= ExceptionHandler::class;
124 124
 
125
-        if (\is_string($exceptionHandler)) {
125
+        if (\is_string($exceptionHandler))
126
+        {
126 127
             $exceptionHandler = $container->make($exceptionHandler);
127 128
         }
128 129
 
129
-        if ($handleErrors) {
130
+        if ($handleErrors)
131
+        {
130 132
             $exceptionHandler->register();
131 133
         }
132 134
 
133 135
         $container->bind(AttributeResolverRegistryInterface::class, AttributeResolver::class);
134 136
 
135
-        if (!$container->has(InitializerInterface::class)) {
137
+        if (!$container->has(InitializerInterface::class))
138
+        {
136 139
             $container->bind(InitializerInterface::class, Initializer::class);
137 140
         }
138 141
 
139
-        if (!$container->has(InvokerStrategyInterface::class)) {
142
+        if (!$container->has(InvokerStrategyInterface::class))
143
+        {
140 144
             $container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class);
141 145
         }
142 146
 
143
-        if ($bootloadManager instanceof Autowire) {
147
+        if ($bootloadManager instanceof Autowire)
148
+        {
144 149
             $bootloadManager = $bootloadManager->resolve($container);
145 150
         }
146 151
         $bootloadManager ??= $container->make(StrategyBasedBootloadManager::class);
147 152
         \assert($bootloadManager instanceof BootloadManagerInterface);
148 153
         $container->bind(BootloadManagerInterface::class, $bootloadManager);
149 154
 
150
-        if (!$container->has(BootloaderRegistryInterface::class)) {
155
+        if (!$container->has(BootloaderRegistryInterface::class))
156
+        {
151 157
             /** @psalm-suppress InvalidArgument */
152 158
             $container->bindSingleton(BootloaderRegistryInterface::class, [self::class, 'initBootloaderRegistry']);
153 159
         }
@@ -177,7 +183,8 @@  discard block
 block discarded – undo
177 183
         $environment ??= new Environment();
178 184
         $this->container->bindSingleton(EnvironmentInterface::class, $environment);
179 185
 
180
-        try {
186
+        try
187
+        {
181 188
             // will protect any against env overwrite action
182 189
             $this->container->runScope(
183 190
                 [EnvironmentInterface::class => $environment],
@@ -194,7 +201,9 @@  discard block
 block discarded – undo
194 201
                     $this->fireCallbacks($this->bootstrappedCallbacks);
195 202
                 }
196 203
             );
197
-        } catch (\Throwable $e) {
204
+        }
205
+        catch (\Throwable $e)
206
+        {
198 207
             $this->exceptionHandler->handleGlobalException($e);
199 208
 
200 209
             return null;
@@ -215,7 +224,8 @@  discard block
 block discarded – undo
215 224
      */
216 225
     public function running(Closure ...$callbacks): void
217 226
     {
218
-        foreach ($callbacks as $callback) {
227
+        foreach ($callbacks as $callback)
228
+        {
219 229
             $this->runningCallbacks[] = $callback;
220 230
         }
221 231
     }
@@ -230,7 +240,8 @@  discard block
 block discarded – undo
230 240
      */
231 241
     public function booting(Closure ...$callbacks): void
232 242
     {
233
-        foreach ($callbacks as $callback) {
243
+        foreach ($callbacks as $callback)
244
+        {
234 245
             $this->bootingCallbacks[] = $callback;
235 246
         }
236 247
     }
@@ -245,7 +256,8 @@  discard block
 block discarded – undo
245 256
      */
246 257
     public function booted(Closure ...$callbacks): void
247 258
     {
248
-        foreach ($callbacks as $callback) {
259
+        foreach ($callbacks as $callback)
260
+        {
249 261
             $this->bootedCallbacks[] = $callback;
250 262
         }
251 263
     }
@@ -261,7 +273,8 @@  discard block
 block discarded – undo
261 273
      */
262 274
     public function bootstrapped(Closure ...$callbacks): void
263 275
     {
264
-        foreach ($callbacks as $callback) {
276
+        foreach ($callbacks as $callback)
277
+        {
265 278
             $this->bootstrappedCallbacks[] = $callback;
266 279
         }
267 280
     }
@@ -275,7 +288,8 @@  discard block
 block discarded – undo
275 288
      */
276 289
     public function addDispatcher(string|DispatcherInterface $dispatcher): self
277 290
     {
278
-        if (\is_object($dispatcher)) {
291
+        if (\is_object($dispatcher))
292
+        {
279 293
             $dispatcher = $dispatcher::class;
280 294
         }
281 295
 
@@ -297,19 +311,22 @@  discard block
 block discarded – undo
297 311
         $eventDispatcher?->dispatch(new Serving());
298 312
 
299 313
         $serving = $servingScope = null;
300
-        foreach ($this->dispatchers as $dispatcher) {
314
+        foreach ($this->dispatchers as $dispatcher)
315
+        {
301 316
             $reflection = new \ReflectionClass($dispatcher);
302 317
 
303 318
             $scope = ($reflection->getAttributes(DispatcherScope::class)[0] ?? null)?->newInstance()->scope;
304 319
             $this->container->getBinder($scope)->bind($dispatcher, $dispatcher);
305 320
 
306
-            if ($serving === null && $this->canServe($reflection)) {
321
+            if ($serving === null && $this->canServe($reflection))
322
+            {
307 323
                 $serving = $dispatcher;
308 324
                 $servingScope = $scope;
309 325
             }
310 326
         }
311 327
 
312
-        if ($serving === null) {
328
+        if ($serving === null)
329
+        {
313 330
             $eventDispatcher?->dispatch(new DispatcherNotFound());
314 331
             throw new BootException('Unable to locate active dispatcher.');
315 332
         }
@@ -358,11 +375,13 @@  discard block
 block discarded – undo
358 375
      */
359 376
     protected function fireCallbacks(array &$callbacks): void
360 377
     {
361
-        if ($callbacks === []) {
378
+        if ($callbacks === [])
379
+        {
362 380
             return;
363 381
         }
364 382
 
365
-        do {
383
+        do
384
+        {
366 385
             $this->container->invoke(\current($callbacks));
367 386
         } while (\next($callbacks));
368 387
 
@@ -404,7 +423,8 @@  discard block
 block discarded – undo
404 423
      */
405 424
     private function canServe(\ReflectionClass $reflection): bool
406 425
     {
407
-        if (!$reflection->hasMethod('canServe')) {
426
+        if (!$reflection->hasMethod('canServe'))
427
+        {
408 428
             throw new BootException('Dispatcher must implement static `canServe` method.');
409 429
         }
410 430
 
Please login to merge, or discard this patch.
src/Boot/src/Attribute/AbstractMethod.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,5 +19,5 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,5 +19,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Boot/src/Attribute/BindScope.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.