Test Failed
Pull Request — master (#963)
by butschster
08:40
created
src/Boot/src/AbstractKernel.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         protected readonly ExceptionHandlerInterface $exceptionHandler,
71 71
         protected readonly BootloadManagerInterface $bootloader,
72 72
         array $directories
73
-    ) {
73
+    ){
74 74
         $container->bindSingleton(ExceptionHandlerInterface::class, $exceptionHandler);
75 75
         $container->bindSingleton(ExceptionRendererInterface::class, $exceptionHandler);
76 76
         $container->bindSingleton(ExceptionReporterInterface::class, $exceptionHandler);
@@ -107,28 +107,28 @@  discard block
 block discarded – undo
107 107
     final public static function create(
108 108
         array $directories,
109 109
         bool $handleErrors = true,
110
-        ExceptionHandlerInterface|string|null $exceptionHandler = null,
110
+        ExceptionHandlerInterface | string | null $exceptionHandler = null,
111 111
         Container $container = new Container(),
112
-        BootloadManagerInterface|Autowire|null $bootloadManager = null
112
+        BootloadManagerInterface | Autowire | null $bootloadManager = null
113 113
     ): static {
114 114
         $exceptionHandler ??= ExceptionHandler::class;
115 115
 
116
-        if (\is_string($exceptionHandler)) {
116
+        if (\is_string($exceptionHandler)){
117 117
             $exceptionHandler = $container->make($exceptionHandler);
118 118
         }
119 119
 
120
-        if ($handleErrors) {
120
+        if ($handleErrors){
121 121
             $exceptionHandler->register();
122 122
         }
123 123
 
124
-        if (!$container->has(InitializerInterface::class)) {
124
+        if (!$container->has(InitializerInterface::class)){
125 125
             $container->bind(InitializerInterface::class, Initializer::class);
126 126
         }
127
-        if (!$container->has(InvokerStrategyInterface::class)) {
127
+        if (!$container->has(InvokerStrategyInterface::class)){
128 128
             $container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class);
129 129
         }
130 130
 
131
-        if ($bootloadManager instanceof Autowire) {
131
+        if ($bootloadManager instanceof Autowire){
132 132
             $bootloadManager = $bootloadManager->resolve($container);
133 133
         }
134 134
         $bootloadManager ??= $container->make(StrategyBasedBootloadManager::class);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $environment ??= new Environment();
161 161
         $this->container->bindSingleton(EnvironmentInterface::class, $environment);
162 162
 
163
-        try {
163
+        try{
164 164
             // will protect any against env overwrite action
165 165
             $this->container->runScope(
166 166
                 [EnvironmentInterface::class => $environment],
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
                     $this->fireCallbacks($this->bootstrappedCallbacks);
175 175
                 }
176 176
             );
177
-        } catch (\Throwable $e) {
177
+        }catch (\Throwable $e){
178 178
             $this->exceptionHandler->handleGlobalException($e);
179 179
 
180 180
             return null;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      */
196 196
     public function running(Closure ...$callbacks): void
197 197
     {
198
-        foreach ($callbacks as $callback) {
198
+        foreach ($callbacks as $callback){
199 199
             $this->runningCallbacks[] = $callback;
200 200
         }
201 201
     }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      */
211 211
     public function booting(Closure ...$callbacks): void
212 212
     {
213
-        foreach ($callbacks as $callback) {
213
+        foreach ($callbacks as $callback){
214 214
             $this->bootingCallbacks[] = $callback;
215 215
         }
216 216
     }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      */
226 226
     public function booted(Closure ...$callbacks): void
227 227
     {
228
-        foreach ($callbacks as $callback) {
228
+        foreach ($callbacks as $callback){
229 229
             $this->bootedCallbacks[] = $callback;
230 230
         }
231 231
     }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public function bootstrapped(Closure ...$callbacks): void
243 243
     {
244
-        foreach ($callbacks as $callback) {
244
+        foreach ($callbacks as $callback){
245 245
             $this->bootstrappedCallbacks[] = $callback;
246 246
         }
247 247
     }
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
         $eventDispatcher = $this->getEventDispatcher();
270 270
         $eventDispatcher?->dispatch(new Serving());
271 271
 
272
-        foreach ($this->dispatchers as $dispatcher) {
273
-            if ($dispatcher->canServe()) {
272
+        foreach ($this->dispatchers as $dispatcher){
273
+            if ($dispatcher->canServe()){
274 274
                 return $this->container->runScope(
275 275
                     [DispatcherInterface::class => $dispatcher],
276 276
                     static function () use ($dispatcher, $eventDispatcher): mixed {
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
      */
322 322
     protected function fireCallbacks(array &$callbacks): void
323 323
     {
324
-        if ($callbacks === []) {
324
+        if ($callbacks === []){
325 325
             return;
326 326
         }
327 327
 
328
-        do {
328
+        do{
329 329
             $this->container->invoke(\current($callbacks));
330
-        } while (\next($callbacks));
330
+        }while (\next($callbacks));
331 331
 
332 332
         $callbacks = [];
333 333
     }
Please login to merge, or discard this patch.
Braces   +31 added lines, -15 removed lines patch added patch discarded remove patch
@@ -113,22 +113,27 @@  discard block
 block discarded – undo
113 113
     ): static {
114 114
         $exceptionHandler ??= ExceptionHandler::class;
115 115
 
116
-        if (\is_string($exceptionHandler)) {
116
+        if (\is_string($exceptionHandler))
117
+        {
117 118
             $exceptionHandler = $container->make($exceptionHandler);
118 119
         }
119 120
 
120
-        if ($handleErrors) {
121
+        if ($handleErrors)
122
+        {
121 123
             $exceptionHandler->register();
122 124
         }
123 125
 
124
-        if (!$container->has(InitializerInterface::class)) {
126
+        if (!$container->has(InitializerInterface::class))
127
+        {
125 128
             $container->bind(InitializerInterface::class, Initializer::class);
126 129
         }
127
-        if (!$container->has(InvokerStrategyInterface::class)) {
130
+        if (!$container->has(InvokerStrategyInterface::class))
131
+        {
128 132
             $container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class);
129 133
         }
130 134
 
131
-        if ($bootloadManager instanceof Autowire) {
135
+        if ($bootloadManager instanceof Autowire)
136
+        {
132 137
             $bootloadManager = $bootloadManager->resolve($container);
133 138
         }
134 139
         $bootloadManager ??= $container->make(StrategyBasedBootloadManager::class);
@@ -160,7 +165,8 @@  discard block
 block discarded – undo
160 165
         $environment ??= new Environment();
161 166
         $this->container->bindSingleton(EnvironmentInterface::class, $environment);
162 167
 
163
-        try {
168
+        try
169
+        {
164 170
             // will protect any against env overwrite action
165 171
             $this->container->runScope(
166 172
                 [EnvironmentInterface::class => $environment],
@@ -174,7 +180,9 @@  discard block
 block discarded – undo
174 180
                     $this->fireCallbacks($this->bootstrappedCallbacks);
175 181
                 }
176 182
             );
177
-        } catch (\Throwable $e) {
183
+        }
184
+        catch (\Throwable $e)
185
+        {
178 186
             $this->exceptionHandler->handleGlobalException($e);
179 187
 
180 188
             return null;
@@ -195,7 +203,8 @@  discard block
 block discarded – undo
195 203
      */
196 204
     public function running(Closure ...$callbacks): void
197 205
     {
198
-        foreach ($callbacks as $callback) {
206
+        foreach ($callbacks as $callback)
207
+        {
199 208
             $this->runningCallbacks[] = $callback;
200 209
         }
201 210
     }
@@ -210,7 +219,8 @@  discard block
 block discarded – undo
210 219
      */
211 220
     public function booting(Closure ...$callbacks): void
212 221
     {
213
-        foreach ($callbacks as $callback) {
222
+        foreach ($callbacks as $callback)
223
+        {
214 224
             $this->bootingCallbacks[] = $callback;
215 225
         }
216 226
     }
@@ -225,7 +235,8 @@  discard block
 block discarded – undo
225 235
      */
226 236
     public function booted(Closure ...$callbacks): void
227 237
     {
228
-        foreach ($callbacks as $callback) {
238
+        foreach ($callbacks as $callback)
239
+        {
229 240
             $this->bootedCallbacks[] = $callback;
230 241
         }
231 242
     }
@@ -241,7 +252,8 @@  discard block
 block discarded – undo
241 252
      */
242 253
     public function bootstrapped(Closure ...$callbacks): void
243 254
     {
244
-        foreach ($callbacks as $callback) {
255
+        foreach ($callbacks as $callback)
256
+        {
245 257
             $this->bootstrappedCallbacks[] = $callback;
246 258
         }
247 259
     }
@@ -269,8 +281,10 @@  discard block
 block discarded – undo
269 281
         $eventDispatcher = $this->getEventDispatcher();
270 282
         $eventDispatcher?->dispatch(new Serving());
271 283
 
272
-        foreach ($this->dispatchers as $dispatcher) {
273
-            if ($dispatcher->canServe()) {
284
+        foreach ($this->dispatchers as $dispatcher)
285
+        {
286
+            if ($dispatcher->canServe())
287
+            {
274 288
                 return $this->container->runScope(
275 289
                     [DispatcherInterface::class => $dispatcher],
276 290
                     static function () use ($dispatcher, $eventDispatcher): mixed {
@@ -321,11 +335,13 @@  discard block
 block discarded – undo
321 335
      */
322 336
     protected function fireCallbacks(array &$callbacks): void
323 337
     {
324
-        if ($callbacks === []) {
338
+        if ($callbacks === [])
339
+        {
325 340
             return;
326 341
         }
327 342
 
328
-        do {
343
+        do
344
+        {
329 345
             $this->container->invoke(\current($callbacks));
330 346
         } while (\next($callbacks));
331 347
 
Please login to merge, or discard this patch.
src/Framework/Bootloader/Attributes/AttributesBootloader.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
     public function __construct(
32 32
         private readonly ConfiguratorInterface $config,
33
-    ) {
33
+    ){
34 34
     }
35 35
 
36 36
     public function init(EnvironmentInterface $env): void
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
     private function initInstantiator(AttributesConfig $config): InstantiatorInterface
49 49
     {
50
-        if ($config->isAnnotationsReaderEnabled()) {
50
+        if ($config->isAnnotationsReaderEnabled()){
51 51
             return new Facade();
52 52
         }
53 53
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     ): ReaderInterface {
63 63
         $reader = new AttributeReader($instantiator);
64 64
 
65
-        if ($container->has(CacheInterface::class)) {
65
+        if ($container->has(CacheInterface::class)){
66 66
             $cache = $container->get(CacheInterface::class);
67 67
             \assert($cache instanceof CacheInterface);
68 68
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 
72 72
         $supportAnnotations = $config->isAnnotationsReaderEnabled();
73 73
 
74
-        if ($supportAnnotations) {
75
-            if (!\interface_exists(DoctrineReaderInterface::class)) {
74
+        if ($supportAnnotations){
75
+            if (!\interface_exists(DoctrineReaderInterface::class)){
76 76
                 throw new InitializationException(
77 77
                     'Doctrine annotations reader is not available, please install "doctrine/annotations" package',
78 78
                 );
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@  discard block
 block discarded – undo
47 47
 
48 48
     private function initInstantiator(AttributesConfig $config): InstantiatorInterface
49 49
     {
50
-        if ($config->isAnnotationsReaderEnabled()) {
50
+        if ($config->isAnnotationsReaderEnabled())
51
+        {
51 52
             return new Facade();
52 53
         }
53 54
 
@@ -62,7 +63,8 @@  discard block
 block discarded – undo
62 63
     ): ReaderInterface {
63 64
         $reader = new AttributeReader($instantiator);
64 65
 
65
-        if ($container->has(CacheInterface::class)) {
66
+        if ($container->has(CacheInterface::class))
67
+        {
66 68
             $cache = $container->get(CacheInterface::class);
67 69
             \assert($cache instanceof CacheInterface);
68 70
 
@@ -71,8 +73,10 @@  discard block
 block discarded – undo
71 73
 
72 74
         $supportAnnotations = $config->isAnnotationsReaderEnabled();
73 75
 
74
-        if ($supportAnnotations) {
75
-            if (!\interface_exists(DoctrineReaderInterface::class)) {
76
+        if ($supportAnnotations)
77
+        {
78
+            if (!\interface_exists(DoctrineReaderInterface::class))
79
+            {
76 80
                 throw new InitializationException(
77 81
                     'Doctrine annotations reader is not available, please install "doctrine/annotations" package',
78 82
                 );
Please login to merge, or discard this patch.
src/Tokenizer/src/Bootloader/TokenizerListenerBootloader.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         ClassesLoaderInterface $loader,
124 124
         ListenerInvoker $invoker,
125 125
     ): void {
126
-        if ($config->isLoadClassesEnabled()) {
126
+        if ($config->isLoadClassesEnabled()){
127 127
             $this->loadReflections($invoker, $classes->getClasses(...), $loader->loadClasses(...));
128 128
         }
129 129
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         EnumsLoaderInterface $loader,
135 135
         ListenerInvoker $invoker,
136 136
     ): void {
137
-        if ($config->isLoadEnumsEnabled()) {
137
+        if ($config->isLoadEnumsEnabled()){
138 138
             $this->loadReflections($invoker, $enums->getEnums(...), $loader->loadEnums(...));
139 139
         }
140 140
     }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         InterfacesLoaderInterface $loader,
146 146
         ListenerInvoker $invoker,
147 147
     ): void {
148
-        if ($config->isLoadInterfacesEnabled()) {
148
+        if ($config->isLoadInterfacesEnabled()){
149 149
             $this->loadReflections($invoker, $interfaces->getInterfaces(...), $loader->loadInterfaces(...));
150 150
         }
151 151
     }
@@ -163,15 +163,15 @@  discard block
 block discarded – undo
163 163
 
164 164
         // First, we check if the listener has been cached. If it has, we will load the classes/enums/interfaces
165 165
         // from the cache.
166
-        foreach ($listeners as $i => $listener) {
167
-            if (call_user_func($loader, $listener)) {
166
+        foreach ($listeners as $i => $listener){
167
+            if (call_user_func($loader, $listener)){
168 168
                 unset($listeners[$i]);
169 169
             }
170 170
         }
171 171
 
172 172
         // If there are no listeners left, we don't need to use static analysis at all and save
173 173
         // valuable time.
174
-        if ($listeners === []) {
174
+        if ($listeners === []){
175 175
             return;
176 176
         }
177 177
 
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
         // Please note that this is a very expensive operation and should be avoided if possible.
180 180
         // Use #[TargetClass] or #[TargetAttribute] attributes in your listeners to cache the classes/enums/interfaces.
181 181
         $classes = call_user_func($reflections);
182
-        foreach ($listeners as $listener) {
182
+        foreach ($listeners as $listener){
183 183
             $invoker->invoke($listener, $classes);
184 184
         }
185 185
     }
186 186
 
187 187
     private function finalizeListeners(): void
188 188
     {
189
-        foreach ($this->listeners as $listener) {
189
+        foreach ($this->listeners as $listener){
190 190
             $listener->finalize();
191 191
         }
192 192
         // We don't need the listeners anymore, so we will clear them from memory.
Please login to merge, or discard this patch.
src/Tokenizer/src/Bootloader/TokenizerBootloader.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function __construct(
47 47
         private readonly ConfiguratorInterface $config,
48
-    ) {
48
+    ){
49 49
     }
50 50
 
51 51
     public function init(BinderInterface $binder, DirectoriesInterface $dirs, EnvironmentInterface $env): void
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
                     'migrations',
68 68
                 ],
69 69
                 'cache' => [
70
-                    'directory' => $dirs->get('runtime') . 'cache/listeners',
70
+                    'directory' => $dirs->get('runtime').'cache/listeners',
71 71
                     'enabled' => \filter_var($env->get('TOKENIZER_CACHE_TARGETS', false), \FILTER_VALIDATE_BOOL),
72 72
                 ],
73 73
             ],
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function addScopedDirectory(string $scope, string $directory): void
92 92
     {
93
-        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])) {
93
+        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])){
94 94
             $this->config->modify(
95 95
                 TokenizerConfig::CONFIG,
96 96
                 new Append('scopes', $scope, []),
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
         $this->config->modify(
101 101
             TokenizerConfig::CONFIG,
102
-            new Append('scopes.' . $scope, null, $directory),
102
+            new Append('scopes.'.$scope, null, $directory),
103 103
         );
104 104
     }
105 105
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,8 @@
 block discarded – undo
90 90
      */
91 91
     public function addScopedDirectory(string $scope, string $directory): void
92 92
     {
93
-        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])) {
93
+        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope]))
94
+        {
94 95
             $this->config->modify(
95 96
                 TokenizerConfig::CONFIG,
96 97
                 new Append('scopes', $scope, []),
Please login to merge, or discard this patch.
src/Framework/Command/Tokenizer/InfoCommand.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
     {
20 20
         $this->info('Included directories:');
21 21
         $grid = $this->table(['Directory', 'Scope']);
22
-        foreach ($config->getDirectories() as $directory) {
22
+        foreach ($config->getDirectories() as $directory){
23 23
             $grid->addRow([\str_replace($dirs->get('root'), '', $directory), '']);
24 24
         }
25
-        foreach ($config->getScopes() as $scope => $data) {
26
-            foreach ($data['directories'] ?? [] as $directory) {
25
+        foreach ($config->getScopes() as $scope => $data){
26
+            foreach ($data['directories'] ?? [] as $directory){
27 27
                 $grid->addRow([\str_replace($dirs->get('root'), '', $directory), $scope]);
28 28
             }
29 29
         }
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
 
35 35
         $this->info('Excluded directories:');
36 36
         $grid = $this->table(['Directory', 'Scope']);
37
-        foreach ($config->getExcludes() as $directory) {
37
+        foreach ($config->getExcludes() as $directory){
38 38
             $grid->addRow([\str_replace($dirs->get('root'), '', $directory), '']);
39 39
         }
40
-        foreach ($config->getScopes() as $scope => $data) {
41
-            foreach ($data['exclude'] ?? [] as $directory) {
40
+        foreach ($config->getScopes() as $scope => $data){
41
+            foreach ($data['exclude'] ?? [] as $directory){
42 42
                 $grid->addRow([\str_replace($dirs->get('root'), '', $directory), $scope]);
43 43
             }
44 44
         }
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $this->info(
50 50
             \sprintf('Tokenizer cache: %s', $config->isCacheEnabled() ? '<success>enabled</>' : '<error>disabled</>'),
51 51
         );
52
-        if (!$config->isCacheEnabled()) {
52
+        if (!$config->isCacheEnabled()){
53 53
             $this->comment('To enable cache, add "TOKENIZER_CACHE_TARGETS=true" to your .env file.');
54 54
             $this->comment('Read more at https://spiral.dev/docs/advanced-tokenizer/#class-listeners');
55 55
         }
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,11 +19,14 @@  discard block
 block discarded – undo
19 19
     {
20 20
         $this->info('Included directories:');
21 21
         $grid = $this->table(['Directory', 'Scope']);
22
-        foreach ($config->getDirectories() as $directory) {
22
+        foreach ($config->getDirectories() as $directory)
23
+        {
23 24
             $grid->addRow([\str_replace($dirs->get('root'), '', $directory), '']);
24 25
         }
25
-        foreach ($config->getScopes() as $scope => $data) {
26
-            foreach ($data['directories'] ?? [] as $directory) {
26
+        foreach ($config->getScopes() as $scope => $data)
27
+        {
28
+            foreach ($data['directories'] ?? [] as $directory)
29
+            {
27 30
                 $grid->addRow([\str_replace($dirs->get('root'), '', $directory), $scope]);
28 31
             }
29 32
         }
@@ -34,11 +37,14 @@  discard block
 block discarded – undo
34 37
 
35 38
         $this->info('Excluded directories:');
36 39
         $grid = $this->table(['Directory', 'Scope']);
37
-        foreach ($config->getExcludes() as $directory) {
40
+        foreach ($config->getExcludes() as $directory)
41
+        {
38 42
             $grid->addRow([\str_replace($dirs->get('root'), '', $directory), '']);
39 43
         }
40
-        foreach ($config->getScopes() as $scope => $data) {
41
-            foreach ($data['exclude'] ?? [] as $directory) {
44
+        foreach ($config->getScopes() as $scope => $data)
45
+        {
46
+            foreach ($data['exclude'] ?? [] as $directory)
47
+            {
42 48
                 $grid->addRow([\str_replace($dirs->get('root'), '', $directory), $scope]);
43 49
             }
44 50
         }
@@ -49,7 +55,8 @@  discard block
 block discarded – undo
49 55
         $this->info(
50 56
             \sprintf('Tokenizer cache: %s', $config->isCacheEnabled() ? '<success>enabled</>' : '<error>disabled</>'),
51 57
         );
52
-        if (!$config->isCacheEnabled()) {
58
+        if (!$config->isCacheEnabled())
59
+        {
53 60
             $this->comment('To enable cache, add "TOKENIZER_CACHE_TARGETS=true" to your .env file.');
54 61
             $this->comment('Read more at https://spiral.dev/docs/advanced-tokenizer/#class-listeners');
55 62
         }
Please login to merge, or discard this patch.