Passed
Pull Request — master (#1205)
by Aleksei
15:01 queued 03:15
created
src/Http/tests/PipelineTest.php 2 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,8 @@  discard block
 block discarded – undo
60 60
 
61 61
     public function testMiddlewareProcessingEventShouldBeDispatched(): void
62 62
     {
63
-        $middleware = new class implements MiddlewareInterface {
63
+        $middleware = new class implements MiddlewareInterface
64
+        {
64 65
             public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
65 66
             {
66 67
                 return (new ResponseFactory(new HttpConfig(['headers' => []])))->createResponse(200);
@@ -89,7 +90,8 @@  discard block
 block discarded – undo
89 90
         $this->container->getBinder('http')
90 91
             ->bind(ServerRequestInterface::class, static fn(CurrentRequest $cr): ?ServerRequestInterface => $cr->get());
91 92
 
92
-        $middleware = new class implements MiddlewareInterface {
93
+        $middleware = new class implements MiddlewareInterface
94
+        {
93 95
             public function process(
94 96
                 ServerRequestInterface $request,
95 97
                 RequestHandlerInterface $handler,
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
         self::assertSame(200, $response->getStatusCode());
35 35
         self::assertSame('OK', $response->getReasonPhrase());
36
-        self::assertSame('response', (string) $response->getBody());
36
+        self::assertSame('response', (string)$response->getBody());
37 37
     }
38 38
 
39 39
     public function testHandle(): void
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
         self::assertSame(200, $response->getStatusCode());
48 48
         self::assertSame('OK', $response->getReasonPhrase());
49
-        self::assertSame('response', (string) $response->getBody());
49
+        self::assertSame('response', (string)$response->getBody());
50 50
     }
51 51
 
52 52
     public function testHandleException(): void
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
     public function testMiddlewareProcessingEventShouldBeDispatched(): void
61 61
     {
62
-        $middleware = new class implements MiddlewareInterface {
62
+        $middleware = new class implements MiddlewareInterface{
63 63
             public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
64 64
             {
65 65
                 return (new ResponseFactory(new HttpConfig(['headers' => []])))->createResponse(200);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         $this->container->getBinder('http')
89 89
             ->bind(ServerRequestInterface::class, static fn(CurrentRequest $cr): ?ServerRequestInterface => $cr->get());
90 90
 
91
-        $middleware = new class implements MiddlewareInterface {
91
+        $middleware = new class implements MiddlewareInterface{
92 92
             public function process(
93 93
                 ServerRequestInterface $request,
94 94
                 RequestHandlerInterface $handler,
Please login to merge, or discard this patch.
src/Distribution/src/Bootloader/DistributionBootloader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
             static function (DistributionConfig $config): DistributionInterface {
49 49
                 $manager = new Manager($config->getDefaultDriver());
50 50
 
51
-                foreach ($config->getResolvers() as $name => $resolver) {
51
+                foreach ($config->getResolvers() as $name => $resolver){
52 52
                     $manager->add($name, $resolver);
53 53
                 }
54 54
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,8 @@
 block discarded – undo
48 48
             static function (DistributionConfig $config): DistributionInterface {
49 49
                 $manager = new Manager($config->getDefaultDriver());
50 50
 
51
-                foreach ($config->getResolvers() as $name => $resolver) {
51
+                foreach ($config->getResolvers() as $name => $resolver)
52
+                {
52 53
                     $manager->add($name, $resolver);
53 54
                 }
54 55
 
Please login to merge, or discard this patch.
src/Router/src/Router.php 2 patches
Braces   +49 added lines, -22 removed lines patch added patch discarded remove patch
@@ -68,13 +68,17 @@  discard block
 block discarded – undo
68 68
         return $this->tracer->trace(
69 69
             name: 'Routing',
70 70
             callback: function (SpanInterface $span) use ($request): ResponseInterface {
71
-                try {
71
+                try
72
+                {
72 73
                     $route = $this->matchRoute($request, $routeName);
73
-                } catch (RouteException $e) {
74
+                }
75
+                catch (RouteException $e)
76
+                {
74 77
                     throw new RouterException('Invalid route definition', $e->getCode(), $e);
75 78
                 }
76 79
 
77
-                if ($route === null) {
80
+                if ($route === null)
81
+                {
78 82
                     $this->eventDispatcher?->dispatch(new RouteNotFound($request));
79 83
                     throw new RouteNotFoundException($request->getUri());
80 84
                 }
@@ -109,7 +113,8 @@  discard block
 block discarded – undo
109 113
 
110 114
     public function getRoute(string $name): RouteInterface
111 115
     {
112
-        if (isset($this->routes[$name])) {
116
+        if (isset($this->routes[$name]))
117
+        {
113 118
             return $this->routes[$name];
114 119
         }
115 120
 
@@ -118,7 +123,8 @@  discard block
 block discarded – undo
118 123
 
119 124
     public function getRoutes(): array
120 125
     {
121
-        if (!empty($this->default)) {
126
+        if (!empty($this->default))
127
+        {
122 128
             return $this->routes + [null => $this->default];
123 129
         }
124 130
 
@@ -127,9 +133,12 @@  discard block
 block discarded – undo
127 133
 
128 134
     public function uri(string $route, iterable $parameters = []): UriInterface
129 135
     {
130
-        try {
136
+        try
137
+        {
131 138
             return $this->getRoute($route)->uri($parameters);
132
-        } catch (UndefinedRouteException) {
139
+        }
140
+        catch (UndefinedRouteException)
141
+        {
133 142
             //In some cases route name can be provided as controller:action pair, we can try to
134 143
             //generate such route automatically based on our default/fallback route
135 144
             return $this->castRoute($route)->uri($parameters);
@@ -141,9 +150,11 @@  discard block
 block discarded – undo
141 150
         /** @var GroupRegistry $groups */
142 151
         $groups = $this->container->get(GroupRegistry::class);
143 152
 
144
-        foreach ($routes->getCollection() as $name => $configurator) {
153
+        foreach ($routes->getCollection() as $name => $configurator)
154
+        {
145 155
             $target = $configurator->target;
146
-            if ($configurator->core !== null && $target instanceof AbstractTarget) {
156
+            if ($configurator->core !== null && $target instanceof AbstractTarget)
157
+            {
147 158
                 $target = $target->withCore($configurator->core);
148 159
             }
149 160
 
@@ -152,21 +163,25 @@  discard block
 block discarded – undo
152 163
                 : \ltrim($configurator->pattern, '/');
153 164
             $route = new Route($pattern, $target, $configurator->defaults);
154 165
 
155
-            if ($configurator->middleware !== null) {
166
+            if ($configurator->middleware !== null)
167
+            {
156 168
                 $route = $route->withMiddleware(...$configurator->middleware);
157 169
             }
158 170
 
159
-            if ($configurator->methods !== null) {
171
+            if ($configurator->methods !== null)
172
+            {
160 173
                 $route = $route->withVerbs(...$configurator->methods);
161 174
             }
162 175
 
163
-            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME) {
176
+            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME)
177
+            {
164 178
                 $group = $groups->getGroup($configurator->group ?? $groups->getDefaultGroup());
165 179
                 $group->setPrefix($configurator->prefix);
166 180
                 $group->addRoute($name, $route);
167 181
             }
168 182
 
169
-            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME) {
183
+            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME)
184
+            {
170 185
                 $this->setDefault($route);
171 186
             }
172 187
         }
@@ -177,17 +192,20 @@  discard block
 block discarded – undo
177 192
      */
178 193
     protected function matchRoute(ServerRequestInterface $request, ?string &$routeName = null): ?RouteInterface
179 194
     {
180
-        foreach ($this->routes as $name => $route) {
195
+        foreach ($this->routes as $name => $route)
196
+        {
181 197
             // Matched route will return new route instance with matched parameters
182 198
             $matched = $route->match($request);
183 199
 
184
-            if ($matched !== null) {
200
+            if ($matched !== null)
201
+            {
185 202
                 $routeName = $name;
186 203
                 return $matched;
187 204
             }
188 205
         }
189 206
 
190
-        if ($this->default !== null) {
207
+        if ($this->default !== null)
208
+        {
191 209
             return $this->default->match($request);
192 210
         }
193 211
 
@@ -200,14 +218,18 @@  discard block
 block discarded – undo
200 218
      */
201 219
     protected function configure(RouteInterface $route): RouteInterface
202 220
     {
203
-        if ($route instanceof ContainerizedInterface && !$route->hasContainer()) {
221
+        if ($route instanceof ContainerizedInterface && !$route->hasContainer())
222
+        {
204 223
             // isolating route in a given container
205 224
             $route = $route->withContainer($this->container);
206 225
         }
207 226
 
208
-        try {
227
+        try
228
+        {
209 229
             $uriHandler = $route->getUriHandler();
210
-        } catch (\Throwable) {
230
+        }
231
+        catch (\Throwable)
232
+        {
211 233
             $uriHandler = $this->uriHandler;
212 234
         }
213 235
 
@@ -239,11 +261,16 @@  discard block
 block discarded – undo
239 261
         /**
240 262
          * @var Matches $matches
241 263
          */
242
-        if (!empty($matches['name'])) {
264
+        if (!empty($matches['name']))
265
+        {
243 266
             $routeObject = $this->getRoute($matches['name']);
244
-        } elseif ($this->default !== null) {
267
+        }
268
+        elseif ($this->default !== null)
269
+        {
245 270
             $routeObject = $this->default;
246
-        } else {
271
+        }
272
+        else
273
+        {
247 274
             throw new UndefinedRouteException(\sprintf('Unable to locate route candidate for `%s`', $route));
248 275
         }
249 276
 
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
         private readonly ContainerInterface $container,
53 53
         private readonly ?EventDispatcherInterface $eventDispatcher = null,
54 54
         ?TracerInterface $tracer = null,
55
-    ) {
55
+    ){
56 56
         $this->tracer = $tracer ?? new NullTracer();
57
-        $this->basePath = '/' . \ltrim($basePath, '/');
57
+        $this->basePath = '/'.\ltrim($basePath, '/');
58 58
     }
59 59
 
60 60
     /**
@@ -68,19 +68,19 @@  discard block
 block discarded – undo
68 68
         return $this->tracer->trace(
69 69
             name: 'Routing',
70 70
             callback: function (SpanInterface $span) use ($request): ResponseInterface {
71
-                try {
71
+                try{
72 72
                     $route = $this->matchRoute($request, $routeName);
73
-                } catch (RouteException $e) {
73
+                }catch (RouteException $e){
74 74
                     throw new RouterException('Invalid route definition', $e->getCode(), $e);
75 75
                 }
76 76
 
77
-                if ($route === null) {
77
+                if ($route === null){
78 78
                     $this->eventDispatcher?->dispatch(new RouteNotFound($request));
79 79
                     throw new RouteNotFoundException($request->getUri());
80 80
                 }
81 81
 
82 82
                 $span
83
-                    ->setAttribute('request.uri', (string) $request->getUri())
83
+                    ->setAttribute('request.uri', (string)$request->getUri())
84 84
                     ->setAttribute('route.name', $routeName)
85 85
                     ->setAttribute('route.matches', $route->getMatches() ?? []);
86 86
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
     public function getRoute(string $name): RouteInterface
111 111
     {
112
-        if (isset($this->routes[$name])) {
112
+        if (isset($this->routes[$name])){
113 113
             return $this->routes[$name];
114 114
         }
115 115
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
     public function getRoutes(): array
120 120
     {
121
-        if (!empty($this->default)) {
121
+        if (!empty($this->default)){
122 122
             return $this->routes + [null => $this->default];
123 123
         }
124 124
 
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 
128 128
     public function uri(string $route, iterable $parameters = []): UriInterface
129 129
     {
130
-        try {
130
+        try{
131 131
             return $this->getRoute($route)->uri($parameters);
132
-        } catch (UndefinedRouteException) {
132
+        }catch (UndefinedRouteException){
133 133
             //In some cases route name can be provided as controller:action pair, we can try to
134 134
             //generate such route automatically based on our default/fallback route
135 135
             return $this->castRoute($route)->uri($parameters);
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
         /** @var GroupRegistry $groups */
142 142
         $groups = $this->container->get(GroupRegistry::class);
143 143
 
144
-        foreach ($routes->getCollection() as $name => $configurator) {
144
+        foreach ($routes->getCollection() as $name => $configurator){
145 145
             $target = $configurator->target;
146
-            if ($configurator->core !== null && $target instanceof AbstractTarget) {
146
+            if ($configurator->core !== null && $target instanceof AbstractTarget){
147 147
                 $target = $target->withCore($configurator->core);
148 148
             }
149 149
 
@@ -152,21 +152,21 @@  discard block
 block discarded – undo
152 152
                 : \ltrim($configurator->pattern, '/');
153 153
             $route = new Route($pattern, $target, $configurator->defaults);
154 154
 
155
-            if ($configurator->middleware !== null) {
155
+            if ($configurator->middleware !== null){
156 156
                 $route = $route->withMiddleware(...$configurator->middleware);
157 157
             }
158 158
 
159
-            if ($configurator->methods !== null) {
159
+            if ($configurator->methods !== null){
160 160
                 $route = $route->withVerbs(...$configurator->methods);
161 161
             }
162 162
 
163
-            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME) {
163
+            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME){
164 164
                 $group = $groups->getGroup($configurator->group ?? $groups->getDefaultGroup());
165 165
                 $group->setPrefix($configurator->prefix);
166 166
                 $group->addRoute($name, $route);
167 167
             }
168 168
 
169
-            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME) {
169
+            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME){
170 170
                 $this->setDefault($route);
171 171
             }
172 172
         }
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
      */
178 178
     protected function matchRoute(ServerRequestInterface $request, ?string &$routeName = null): ?RouteInterface
179 179
     {
180
-        foreach ($this->routes as $name => $route) {
180
+        foreach ($this->routes as $name => $route){
181 181
             // Matched route will return new route instance with matched parameters
182 182
             $matched = $route->match($request);
183 183
 
184
-            if ($matched !== null) {
184
+            if ($matched !== null){
185 185
                 $routeName = $name;
186 186
                 return $matched;
187 187
             }
188 188
         }
189 189
 
190
-        if ($this->default !== null) {
190
+        if ($this->default !== null){
191 191
             return $this->default->match($request);
192 192
         }
193 193
 
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
      */
201 201
     protected function configure(RouteInterface $route): RouteInterface
202 202
     {
203
-        if ($route instanceof ContainerizedInterface && !$route->hasContainer()) {
203
+        if ($route instanceof ContainerizedInterface && !$route->hasContainer()){
204 204
             // isolating route in a given container
205 205
             $route = $route->withContainer($this->container);
206 206
         }
207 207
 
208
-        try {
208
+        try{
209 209
             $uriHandler = $route->getUriHandler();
210
-        } catch (\Throwable) {
210
+        }catch (\Throwable){
211 211
             $uriHandler = $this->uriHandler;
212 212
         }
213 213
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                 $route,
231 231
                 $matches,
232 232
             )
233
-        ) {
233
+        ){
234 234
             throw new UndefinedRouteException(
235 235
                 "Unable to locate route or use default route with 'name/controller:action' pattern",
236 236
             );
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
         /**
240 240
          * @var Matches $matches
241 241
          */
242
-        if (!empty($matches['name'])) {
242
+        if (!empty($matches['name'])){
243 243
             $routeObject = $this->getRoute($matches['name']);
244
-        } elseif ($this->default !== null) {
244
+        } elseif ($this->default !== null){
245 245
             $routeObject = $this->default;
246
-        } else {
246
+        }else{
247 247
             throw new UndefinedRouteException(\sprintf('Unable to locate route candidate for `%s`', $route));
248 248
         }
249 249
 
Please login to merge, or discard this patch.
src/Core/tests/ExceptionsTest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
     {
136 136
         $container = new Container();
137 137
 
138
-        try {
138
+        try{
139 139
             $container->get('invalid');
140
-        } catch (ContainerException $e) {
140
+        }catch (ContainerException $e){
141 141
             self::assertSame(<<<MARKDOWN
142 142
                 Can't resolve `invalid`: undefined class or binding `invalid`.
143 143
                 Container trace list:
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
     {
167 167
         $this->expectException(ContainerException::class);
168 168
 
169
-        try {
169
+        try{
170 170
             $container->get(ClassWithUndefinedDependency::class);
171
-        } catch (ContainerException $e) {
171
+        }catch (ContainerException $e){
172 172
             self::assertSame($message, $e->getMessage());
173 173
 
174 174
             throw $e;
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -135,9 +135,12 @@  discard block
 block discarded – undo
135 135
     {
136 136
         $container = new Container();
137 137
 
138
-        try {
138
+        try
139
+        {
139 140
             $container->get('invalid');
140
-        } catch (ContainerException $e) {
141
+        }
142
+        catch (ContainerException $e)
143
+        {
141 144
             self::assertSame(<<<MARKDOWN
142 145
                 Can't resolve `invalid`: undefined class or binding `invalid`.
143 146
                 Container trace list:
@@ -166,9 +169,12 @@  discard block
 block discarded – undo
166 169
     {
167 170
         $this->expectException(ContainerException::class);
168 171
 
169
-        try {
172
+        try
173
+        {
170 174
             $container->get(ClassWithUndefinedDependency::class);
171
-        } catch (ContainerException $e) {
175
+        }
176
+        catch (ContainerException $e)
177
+        {
172 178
             self::assertSame($message, $e->getMessage());
173 179
 
174 180
             throw $e;
Please login to merge, or discard this patch.
src/Core/tests/Scope/SideEffectTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
         $logger = $root->runScope(
63 63
             new Scope('test'),
64
-            static fn(?ScopeIndicatorLogger $logger): ?ScopeIndicatorLogger => $logger,
64
+            static fn(?ScopeIndicatorLogger $logger) : ?ScopeIndicatorLogger => $logger,
65 65
         );
66 66
 
67 67
         self::assertNotNull($logger);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
         $logger = $root->runScope(
79 79
             new Scope('test'),
80
-            static fn(?ScopeIndicatorLogger $logger): ?ScopeIndicatorLogger => $logger,
80
+            static fn(?ScopeIndicatorLogger $logger) : ?ScopeIndicatorLogger => $logger,
81 81
         );
82 82
 
83 83
         self::assertNotNull($logger);
Please login to merge, or discard this patch.
src/Core/tests/SingletonsTest.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -181,7 +181,9 @@  discard block
 block discarded – undo
181 181
     public function testHasShouldReturnTrueWhenSingletonIsAlreadyConstructed(): void
182 182
     {
183 183
         $container = new Container();
184
-        $class = new #[Singleton] class {};
184
+        $class = new #[Singleton] class
185
+        {
186
+};
185 187
 
186 188
         self::assertFalse($container->has($class::class));
187 189
 
@@ -194,7 +196,8 @@  discard block
 block discarded – undo
194 196
     {
195 197
         return new
196 198
         #[Singleton]
197
-        class {
199
+        class
200
+        {
198 201
             public string $baz = 'baz';
199 202
         };
200 203
     }
Please login to merge, or discard this patch.
src/Tokenizer/tests/Bootloader/TokenizerListenerBootloaderTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
         $kernel = TestCoreWithTokenizer::create(directories: ['root' => __DIR__], container: $container);
58 58
         $kernel->run();
59 59
 
60
-        self::assertContains(\dirname(__DIR__) . '/Fixtures/Bootloader', $container->get(TokenizerConfig::class)->getDirectories());
60
+        self::assertContains(\dirname(__DIR__).'/Fixtures/Bootloader', $container->get(TokenizerConfig::class)->getDirectories());
61 61
     }
62 62
 
63 63
 }
Please login to merge, or discard this patch.
src/Tokenizer/tests/Attribute/TargetAttributeTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@
 block discarded – undo
20 20
     public function testToString(): void
21 21
     {
22 22
         $attribute = new TargetAttribute('foo');
23
-        self::assertSame('3dc18b19eed74479a03c069dec2e8724', (string) $attribute);
23
+        self::assertSame('3dc18b19eed74479a03c069dec2e8724', (string)$attribute);
24 24
 
25 25
         $attribute = new TargetAttribute('foo', 'bar');
26
-        self::assertSame('52ec767c53f3898bf6de6f6e88125dc8', (string) $attribute);
26
+        self::assertSame('52ec767c53f3898bf6de6f6e88125dc8', (string)$attribute);
27 27
     }
28 28
 
29 29
     public function testFilterAttrWithArgs(): void
Please login to merge, or discard this patch.
src/Tokenizer/tests/Attribute/TargetClassTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@
 block discarded – undo
12 12
     public function testToString(): void
13 13
     {
14 14
         $attribute = new TargetClass('foo');
15
-        self::assertSame('3319d33aad20ad375d27dcd03c879454', (string) $attribute);
15
+        self::assertSame('3319d33aad20ad375d27dcd03c879454', (string)$attribute);
16 16
 
17 17
         $attribute = new TargetClass('foo', 'bar');
18
-        self::assertSame('a95c8a2cfc901290939df93183ce98d6', (string) $attribute);
18
+        self::assertSame('a95c8a2cfc901290939df93183ce98d6', (string)$attribute);
19 19
     }
20 20
 }
21 21
\ No newline at end of file
Please login to merge, or discard this patch.