Passed
Pull Request — master (#840)
by Maxim
06:37
created
src/Boot/src/AbstractKernel.php 1 patch
Braces   +27 added lines, -13 removed lines patch added patch discarded remove patch
@@ -106,15 +106,18 @@  discard block
 block discarded – undo
106 106
     ): static {
107 107
         $exceptionHandler ??= ExceptionHandler::class;
108 108
 
109
-        if (\is_string($exceptionHandler)) {
109
+        if (\is_string($exceptionHandler))
110
+        {
110 111
             $exceptionHandler = $container->make($exceptionHandler);
111 112
         }
112 113
 
113
-        if ($handleErrors) {
114
+        if ($handleErrors)
115
+        {
114 116
             $exceptionHandler->register();
115 117
         }
116 118
 
117
-        if (!$container->has(InitializerInterface::class)) {
119
+        if (!$container->has(InitializerInterface::class))
120
+        {
118 121
             $container->bind(InitializerInterface::class, Initializer::class);
119 122
         }
120 123
 
@@ -149,7 +152,8 @@  discard block
 block discarded – undo
149 152
 
150 153
         $this->fireCallbacks($this->runningCallbacks);
151 154
 
152
-        try {
155
+        try
156
+        {
153 157
             // will protect any against env overwrite action
154 158
             $this->container->runScope(
155 159
                 [EnvironmentInterface::class => $environment],
@@ -160,7 +164,9 @@  discard block
 block discarded – undo
160 164
                     $this->fireCallbacks($this->bootstrappedCallbacks);
161 165
                 }
162 166
             );
163
-        } catch (\Throwable $e) {
167
+        }
168
+        catch (\Throwable $e)
169
+        {
164 170
             $this->exceptionHandler->handleGlobalException($e);
165 171
 
166 172
             return null;
@@ -181,7 +187,8 @@  discard block
 block discarded – undo
181 187
      */
182 188
     public function running(Closure ...$callbacks): void
183 189
     {
184
-        foreach ($callbacks as $callback) {
190
+        foreach ($callbacks as $callback)
191
+        {
185 192
             $this->runningCallbacks[] = $callback;
186 193
         }
187 194
     }
@@ -196,7 +203,8 @@  discard block
 block discarded – undo
196 203
      */
197 204
     public function booting(Closure ...$callbacks): void
198 205
     {
199
-        foreach ($callbacks as $callback) {
206
+        foreach ($callbacks as $callback)
207
+        {
200 208
             $this->bootingCallbacks[] = $callback;
201 209
         }
202 210
     }
@@ -211,7 +219,8 @@  discard block
 block discarded – undo
211 219
      */
212 220
     public function booted(Closure ...$callbacks): void
213 221
     {
214
-        foreach ($callbacks as $callback) {
222
+        foreach ($callbacks as $callback)
223
+        {
215 224
             $this->bootedCallbacks[] = $callback;
216 225
         }
217 226
     }
@@ -227,7 +236,8 @@  discard block
 block discarded – undo
227 236
      */
228 237
     public function bootstrapped(Closure ...$callbacks): void
229 238
     {
230
-        foreach ($callbacks as $callback) {
239
+        foreach ($callbacks as $callback)
240
+        {
231 241
             $this->bootstrappedCallbacks[] = $callback;
232 242
         }
233 243
     }
@@ -255,8 +265,10 @@  discard block
 block discarded – undo
255 265
         $eventDispatcher = $this->getEventDispatcher();
256 266
         $eventDispatcher?->dispatch(new Serving());
257 267
 
258
-        foreach ($this->dispatchers as $dispatcher) {
259
-            if ($dispatcher->canServe()) {
268
+        foreach ($this->dispatchers as $dispatcher)
269
+        {
270
+            if ($dispatcher->canServe())
271
+            {
260 272
                 return $this->container->runScope(
261 273
                     [DispatcherInterface::class => $dispatcher],
262 274
                     static function () use ($dispatcher, $eventDispatcher): mixed {
@@ -297,11 +309,13 @@  discard block
 block discarded – undo
297 309
      */
298 310
     protected function fireCallbacks(array &$callbacks): void
299 311
     {
300
-        if ($callbacks === []) {
312
+        if ($callbacks === [])
313
+        {
301 314
             return;
302 315
         }
303 316
 
304
-        do {
317
+        do
318
+        {
305 319
             $this->container->invoke(\current($callbacks));
306 320
         } while (\next($callbacks));
307 321
 
Please login to merge, or discard this patch.
src/Boot/src/BootloadManager/Initializer.php 1 patch
Braces   +29 added lines, -14 removed lines patch added patch discarded remove patch
@@ -33,34 +33,42 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function init(array $classes): \Generator
35 35
     {
36
-        foreach ($classes as $bootloader => $options) {
36
+        foreach ($classes as $bootloader => $options)
37
+        {
37 38
             // default bootload syntax as simple array
38
-            if (\is_string($options) || $options instanceof BootloaderInterface) {
39
+            if (\is_string($options) || $options instanceof BootloaderInterface)
40
+            {
39 41
                 $bootloader = $options;
40 42
                 $options = [];
41 43
             }
42 44
 
43 45
             // Replace class aliases with source classes
44
-            try {
46
+            try
47
+            {
45 48
                 $ref = (new \ReflectionClass($bootloader));
46 49
                 $className = $ref->getName();
47
-            } catch (\ReflectionException) {
50
+            }
51
+            catch (\ReflectionException)
52
+            {
48 53
                 throw new ClassNotFoundException(
49 54
                     \sprintf('Bootloader class `%s` is not exist.', $bootloader)
50 55
                 );
51 56
             }
52 57
 
53
-            if ($this->bootloaders->isBooted($className) || $ref->isAbstract()) {
58
+            if ($this->bootloaders->isBooted($className) || $ref->isAbstract())
59
+            {
54 60
                 continue;
55 61
             }
56 62
 
57 63
             $this->bootloaders->register($className);
58 64
 
59
-            if (!$bootloader instanceof BootloaderInterface) {
65
+            if (!$bootloader instanceof BootloaderInterface)
66
+            {
60 67
                 $bootloader = $this->container->get($bootloader);
61 68
             }
62 69
 
63
-            if (!$this->isBootloader($bootloader)) {
70
+            if (!$this->isBootloader($bootloader))
71
+            {
64 72
                 continue;
65 73
             }
66 74
 
@@ -80,7 +88,8 @@  discard block
 block discarded – undo
80 88
      */
81 89
     protected function initBootloader(BootloaderInterface $bootloader): iterable
82 90
     {
83
-        if ($bootloader instanceof DependedInterface) {
91
+        if ($bootloader instanceof DependedInterface)
92
+        {
84 93
             yield from $this->init($this->getDependencies($bootloader));
85 94
         }
86 95
 
@@ -98,11 +107,13 @@  discard block
 block discarded – undo
98 107
      */
99 108
     protected function initBindings(array $bindings, array $singletons): void
100 109
     {
101
-        foreach ($bindings as $aliases => $resolver) {
110
+        foreach ($bindings as $aliases => $resolver)
111
+        {
102 112
             $this->binder->bind($aliases, $resolver);
103 113
         }
104 114
 
105
-        foreach ($singletons as $aliases => $resolver) {
115
+        foreach ($singletons as $aliases => $resolver)
116
+        {
106 117
             $this->binder->bindSingleton($aliases, $resolver);
107 118
         }
108 119
     }
@@ -115,8 +126,10 @@  discard block
 block discarded – undo
115 126
 
116 127
         $methodsDeps = [];
117 128
 
118
-        foreach (Methods::cases() as $method) {
119
-            if ($reflectionClass->hasMethod($method->value)) {
129
+        foreach (Methods::cases() as $method)
130
+        {
131
+            if ($reflectionClass->hasMethod($method->value))
132
+            {
120 133
                 $methodsDeps[] = $this->findBootloaderClassesInMethod(
121 134
                     $reflectionClass->getMethod($method->value)
122 135
                 );
@@ -129,9 +142,11 @@  discard block
 block discarded – undo
129 142
     protected function findBootloaderClassesInMethod(\ReflectionMethod $method): array
130 143
     {
131 144
         $args = [];
132
-        foreach ($method->getParameters() as $parameter) {
145
+        foreach ($method->getParameters() as $parameter)
146
+        {
133 147
             $type = $parameter->getType();
134
-            if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)) {
148
+            if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type))
149
+            {
135 150
                 $args[] = $type->getName();
136 151
             }
137 152
         }
Please login to merge, or discard this patch.