Passed
Push — master ( 0bca4d...c76e78 )
by butschster
06:16 queued 17s
created
src/Tokenizer/src/Attribute/TargetAttribute.php 1 patch
Braces   +44 added lines, -22 removed lines patch added patch discarded remove patch
@@ -45,25 +45,32 @@  discard block
 block discarded – undo
45 45
             ? (new Factory())->create()
46 46
             : new AttributeReader($this->namedArguments ? new NamedArgumentsInstantiator() : null);
47 47
 
48
-        if ($attribute === null) {
48
+        if ($attribute === null)
49
+        {
49 50
             return;
50 51
         }
51 52
 
52 53
         $attribute = $attribute->newInstance();
53 54
 
54
-        foreach ($classes as $class) {
55
+        foreach ($classes as $class)
56
+        {
55 57
             // If attribute is defined on class level and class has target attribute
56 58
             // then we can add it to the list of classes
57
-            if ($attribute->flags & \Attribute::TARGET_CLASS) {
58
-                if ($reader->firstClassMetadata($class, $target->getName())) {
59
+            if ($attribute->flags & \Attribute::TARGET_CLASS)
60
+            {
61
+                if ($reader->firstClassMetadata($class, $target->getName()))
62
+                {
59 63
                     yield $class->getName();
60 64
                     continue;
61 65
                 }
62 66
 
63
-                if ($this->scanParents) {
67
+                if ($this->scanParents)
68
+                {
64 69
                     // Interfaces
65
-                    foreach ($class->getInterfaces() as $interface) {
66
-                        if ($reader->firstClassMetadata($interface, $target->getName())) {
70
+                    foreach ($class->getInterfaces() as $interface)
71
+                    {
72
+                        if ($reader->firstClassMetadata($interface, $target->getName()))
73
+                        {
67 74
                             yield $class->getName();
68 75
                             continue 2;
69 76
                         }
@@ -71,8 +78,10 @@  discard block
 block discarded – undo
71 78
 
72 79
                     // Parents
73 80
                     $parent = $class->getParentClass();
74
-                    while ($parent !== false) {
75
-                        if ($reader->firstClassMetadata($parent, $target->getName())) {
81
+                    while ($parent !== false)
82
+                    {
83
+                        if ($reader->firstClassMetadata($parent, $target->getName()))
84
+                        {
76 85
                             yield $class->getName();
77 86
                             continue 2;
78 87
                         }
@@ -83,9 +92,12 @@  discard block
 block discarded – undo
83 92
 
84 93
             // If attribute is defined on method level and class methods has target attribute
85 94
             // then we can add it to the list of classes
86
-            if ($attribute->flags & \Attribute::TARGET_METHOD) {
87
-                foreach ($class->getMethods() as $method) {
88
-                    if ($reader->firstFunctionMetadata($method, $target->getName())) {
95
+            if ($attribute->flags & \Attribute::TARGET_METHOD)
96
+            {
97
+                foreach ($class->getMethods() as $method)
98
+                {
99
+                    if ($reader->firstFunctionMetadata($method, $target->getName()))
100
+                    {
89 101
                         yield $class->getName();
90 102
                         continue 2;
91 103
                     }
@@ -94,9 +106,12 @@  discard block
 block discarded – undo
94 106
 
95 107
             // If attribute is defined on property level and class properties has target attribute
96 108
             // then we can add it to the list of classes
97
-            if ($attribute->flags & \Attribute::TARGET_PROPERTY) {
98
-                foreach ($class->getProperties() as $property) {
99
-                    if ($reader->firstPropertyMetadata($property, $target->getName())) {
109
+            if ($attribute->flags & \Attribute::TARGET_PROPERTY)
110
+            {
111
+                foreach ($class->getProperties() as $property)
112
+                {
113
+                    if ($reader->firstPropertyMetadata($property, $target->getName()))
114
+                    {
100 115
                         yield $class->getName();
101 116
                         continue 2;
102 117
                     }
@@ -106,9 +121,12 @@  discard block
 block discarded – undo
106 121
 
107 122
             // If attribute is defined on constant level and class constants has target attribute
108 123
             // then we can add it to the list of classes
109
-            if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) {
110
-                foreach ($class->getReflectionConstants() as $constant) {
111
-                    if ($reader->firstConstantMetadata($constant, $target->getName())) {
124
+            if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT)
125
+            {
126
+                foreach ($class->getReflectionConstants() as $constant)
127
+                {
128
+                    if ($reader->firstConstantMetadata($constant, $target->getName()))
129
+                    {
112 130
                         yield $class->getName();
113 131
                         continue 2;
114 132
                     }
@@ -118,10 +136,14 @@  discard block
 block discarded – undo
118 136
 
119 137
             // If attribute is defined on method parameters level and class method parameter has target attribute
120 138
             // then we can add it to the list of classes
121
-            if ($attribute->flags & \Attribute::TARGET_PARAMETER) {
122
-                foreach ($class->getMethods() as $method) {
123
-                    foreach ($method->getParameters() as $parameter) {
124
-                        if ($reader->firstParameterMetadata($parameter, $target->getName())) {
139
+            if ($attribute->flags & \Attribute::TARGET_PARAMETER)
140
+            {
141
+                foreach ($class->getMethods() as $method)
142
+                {
143
+                    foreach ($method->getParameters() as $parameter)
144
+                    {
145
+                        if ($reader->firstParameterMetadata($parameter, $target->getName()))
146
+                        {
125 147
                             yield $class->getName();
126 148
                             continue 3;
127 149
                         }
Please login to merge, or discard this patch.
src/Boot/src/AbstractKernel.php 1 patch
Braces   +39 added lines, -19 removed lines patch added patch discarded remove patch
@@ -120,29 +120,35 @@  discard block
 block discarded – undo
120 120
     ): static {
121 121
         $exceptionHandler ??= ExceptionHandler::class;
122 122
 
123
-        if (\is_string($exceptionHandler)) {
123
+        if (\is_string($exceptionHandler))
124
+        {
124 125
             $exceptionHandler = $container->make($exceptionHandler);
125 126
         }
126 127
 
127
-        if ($handleErrors) {
128
+        if ($handleErrors)
129
+        {
128 130
             $exceptionHandler->register();
129 131
         }
130 132
 
131
-        if (!$container->has(InitializerInterface::class)) {
133
+        if (!$container->has(InitializerInterface::class))
134
+        {
132 135
             $container->bind(InitializerInterface::class, Initializer::class);
133 136
         }
134
-        if (!$container->has(InvokerStrategyInterface::class)) {
137
+        if (!$container->has(InvokerStrategyInterface::class))
138
+        {
135 139
             $container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class);
136 140
         }
137 141
 
138
-        if ($bootloadManager instanceof Autowire) {
142
+        if ($bootloadManager instanceof Autowire)
143
+        {
139 144
             $bootloadManager = $bootloadManager->resolve($container);
140 145
         }
141 146
         $bootloadManager ??= $container->make(StrategyBasedBootloadManager::class);
142 147
         \assert($bootloadManager instanceof BootloadManagerInterface);
143 148
         $container->bind(BootloadManagerInterface::class, $bootloadManager);
144 149
 
145
-        if (!$container->has(BootloaderRegistryInterface::class)) {
150
+        if (!$container->has(BootloaderRegistryInterface::class))
151
+        {
146 152
             /** @psalm-suppress InvalidArgument */
147 153
             $container->bindSingleton(BootloaderRegistryInterface::class, [self::class, 'initBootloaderRegistry']);
148 154
         }
@@ -172,7 +178,8 @@  discard block
 block discarded – undo
172 178
         $environment ??= new Environment();
173 179
         $this->container->bindSingleton(EnvironmentInterface::class, $environment);
174 180
 
175
-        try {
181
+        try
182
+        {
176 183
             // will protect any against env overwrite action
177 184
             $this->container->runScope(
178 185
                 [EnvironmentInterface::class => $environment],
@@ -189,7 +196,9 @@  discard block
 block discarded – undo
189 196
                     $this->fireCallbacks($this->bootstrappedCallbacks);
190 197
                 }
191 198
             );
192
-        } catch (\Throwable $e) {
199
+        }
200
+        catch (\Throwable $e)
201
+        {
193 202
             $this->exceptionHandler->handleGlobalException($e);
194 203
 
195 204
             return null;
@@ -210,7 +219,8 @@  discard block
 block discarded – undo
210 219
      */
211 220
     public function running(Closure ...$callbacks): void
212 221
     {
213
-        foreach ($callbacks as $callback) {
222
+        foreach ($callbacks as $callback)
223
+        {
214 224
             $this->runningCallbacks[] = $callback;
215 225
         }
216 226
     }
@@ -225,7 +235,8 @@  discard block
 block discarded – undo
225 235
      */
226 236
     public function booting(Closure ...$callbacks): void
227 237
     {
228
-        foreach ($callbacks as $callback) {
238
+        foreach ($callbacks as $callback)
239
+        {
229 240
             $this->bootingCallbacks[] = $callback;
230 241
         }
231 242
     }
@@ -240,7 +251,8 @@  discard block
 block discarded – undo
240 251
      */
241 252
     public function booted(Closure ...$callbacks): void
242 253
     {
243
-        foreach ($callbacks as $callback) {
254
+        foreach ($callbacks as $callback)
255
+        {
244 256
             $this->bootedCallbacks[] = $callback;
245 257
         }
246 258
     }
@@ -256,7 +268,8 @@  discard block
 block discarded – undo
256 268
      */
257 269
     public function bootstrapped(Closure ...$callbacks): void
258 270
     {
259
-        foreach ($callbacks as $callback) {
271
+        foreach ($callbacks as $callback)
272
+        {
260 273
             $this->bootstrappedCallbacks[] = $callback;
261 274
         }
262 275
     }
@@ -270,7 +283,8 @@  discard block
 block discarded – undo
270 283
      */
271 284
     public function addDispatcher(string|DispatcherInterface $dispatcher): self
272 285
     {
273
-        if (\is_object($dispatcher)) {
286
+        if (\is_object($dispatcher))
287
+        {
274 288
             $dispatcher = $dispatcher::class;
275 289
         }
276 290
 
@@ -292,19 +306,22 @@  discard block
 block discarded – undo
292 306
         $eventDispatcher?->dispatch(new Serving());
293 307
 
294 308
         $serving = $servingScope = null;
295
-        foreach ($this->dispatchers as $dispatcher) {
309
+        foreach ($this->dispatchers as $dispatcher)
310
+        {
296 311
             $reflection = new \ReflectionClass($dispatcher);
297 312
 
298 313
             $scope = ($reflection->getAttributes(DispatcherScope::class)[0] ?? null)?->newInstance()->scope;
299 314
             $this->container->getBinder($scope)->bind($dispatcher, $dispatcher);
300 315
 
301
-            if ($serving === null && $this->canServe($reflection)) {
316
+            if ($serving === null && $this->canServe($reflection))
317
+            {
302 318
                 $serving = $dispatcher;
303 319
                 $servingScope = $scope;
304 320
             }
305 321
         }
306 322
 
307
-        if ($serving === null) {
323
+        if ($serving === null)
324
+        {
308 325
             $eventDispatcher?->dispatch(new DispatcherNotFound());
309 326
             throw new BootException('Unable to locate active dispatcher.');
310 327
         }
@@ -353,11 +370,13 @@  discard block
 block discarded – undo
353 370
      */
354 371
     protected function fireCallbacks(array &$callbacks): void
355 372
     {
356
-        if ($callbacks === []) {
373
+        if ($callbacks === [])
374
+        {
357 375
             return;
358 376
         }
359 377
 
360
-        do {
378
+        do
379
+        {
361 380
             $this->container->invoke(\current($callbacks));
362 381
         } while (\next($callbacks));
363 382
 
@@ -399,7 +418,8 @@  discard block
 block discarded – undo
399 418
      */
400 419
     private function canServe(\ReflectionClass $reflection): bool
401 420
     {
402
-        if (!$reflection->hasMethod('canServe')) {
421
+        if (!$reflection->hasMethod('canServe'))
422
+        {
403 423
             throw new BootException('Dispatcher must implement static `canServe` method.');
404 424
         }
405 425
 
Please login to merge, or discard this patch.