Test Failed
Pull Request — master (#816)
by butschster
06:47
created
src/Router/src/CoreHandler.php 1 patch
Braces   +28 added lines, -12 removed lines patch added patch discarded remove patch
@@ -66,7 +66,8 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function handle(Request $request): Response
68 68
     {
69
-        if ($this->controller === null) {
69
+        if ($this->controller === null)
70
+        {
70 71
             throw new HandlerException('Controller and action pair is not set');
71 72
         }
72 73
 
@@ -76,7 +77,8 @@  discard block
 block discarded – undo
76 77
         $output = $result = null;
77 78
 
78 79
         $response = $this->responseFactory->createResponse(200);
79
-        try {
80
+        try
81
+        {
80 82
             $action = $this->getAction($request);
81 83
 
82 84
             // run the core withing PSR-7 Request/Response scope
@@ -99,14 +101,21 @@  discard block
 block discarded – undo
99 101
                     ]
100 102
                 )
101 103
             );
102
-        } catch (ControllerException $e) {
104
+        }
105
+        catch (ControllerException $e)
106
+        {
103 107
             \ob_get_clean();
104 108
             throw $this->mapException($e);
105
-        } catch (\Throwable $e) {
109
+        }
110
+        catch (\Throwable $e)
111
+        {
106 112
             \ob_get_clean();
107 113
             throw $e;
108
-        } finally {
109
-            while (\ob_get_level() > $outputLevel + 1) {
114
+        }
115
+        finally
116
+        {
117
+            while (\ob_get_level() > $outputLevel + 1)
118
+            {
110 119
                 $output = \ob_get_clean() . $output;
111 120
             }
112 121
         }
@@ -120,7 +129,8 @@  discard block
 block discarded – undo
120 129
 
121 130
     private function getAction(Request $request): string
122 131
     {
123
-        if ($this->verbActions) {
132
+        if ($this->verbActions)
133
+        {
124 134
             return \strtolower($request->getMethod()) . \ucfirst($this->action);
125 135
         }
126 136
 
@@ -136,21 +146,27 @@  discard block
 block discarded – undo
136 146
      */
137 147
     private function wrapResponse(Response $response, mixed $result = null, string $output = ''): Response
138 148
     {
139
-        if ($result instanceof Response) {
140
-            if ($output !== '' && $result->getBody()->isWritable()) {
149
+        if ($result instanceof Response)
150
+        {
151
+            if ($output !== '' && $result->getBody()->isWritable())
152
+            {
141 153
                 $result->getBody()->write($output);
142 154
             }
143 155
 
144 156
             return $result;
145 157
         }
146 158
 
147
-        if ($result instanceof \Generator) {
159
+        if ($result instanceof \Generator)
160
+        {
148 161
             return $response->withBody(new GeneratorStream($result));
149 162
         }
150 163
 
151
-        if (\is_array($result) || $result instanceof \JsonSerializable) {
164
+        if (\is_array($result) || $result instanceof \JsonSerializable)
165
+        {
152 166
             $response = $this->writeJson($response, $result);
153
-        } else {
167
+        }
168
+        else
169
+        {
154 170
             $response->getBody()->write((string)$result);
155 171
         }
156 172
 
Please login to merge, or discard this patch.
src/Router/src/Router.php 1 patch
Braces   +46 added lines, -21 removed lines patch added patch discarded remove patch
@@ -63,14 +63,19 @@  discard block
 block discarded – undo
63 63
 
64 64
         return $this->tracer->trace(
65 65
             name: 'Routing',
66
-            callback: function (SpanInterface $span) use ($request) {
67
-                try {
66
+            callback: function (SpanInterface $span) use ($request)
67
+            {
68
+                try
69
+                {
68 70
                     $route = $this->matchRoute($request, $routeName);
69
-                } catch (RouteException $e) {
71
+                }
72
+                catch (RouteException $e)
73
+                {
70 74
                     throw new RouterException('Invalid route definition', $e->getCode(), $e);
71 75
                 }
72 76
 
73
-                if ($route === null) {
77
+                if ($route === null)
78
+                {
74 79
                     $this->eventDispatcher?->dispatch(new RouteNotFound($request));
75 80
                     throw new RouteNotFoundException($request->getUri());
76 81
                 }
@@ -105,7 +110,8 @@  discard block
 block discarded – undo
105 110
 
106 111
     public function getRoute(string $name): RouteInterface
107 112
     {
108
-        if (isset($this->routes[$name])) {
113
+        if (isset($this->routes[$name]))
114
+        {
109 115
             return $this->routes[$name];
110 116
         }
111 117
 
@@ -114,7 +120,8 @@  discard block
 block discarded – undo
114 120
 
115 121
     public function getRoutes(): array
116 122
     {
117
-        if (!empty($this->default)) {
123
+        if (!empty($this->default))
124
+        {
118 125
             return $this->routes + [null => $this->default];
119 126
         }
120 127
 
@@ -123,9 +130,12 @@  discard block
 block discarded – undo
123 130
 
124 131
     public function uri(string $route, iterable $parameters = []): UriInterface
125 132
     {
126
-        try {
133
+        try
134
+        {
127 135
             return $this->getRoute($route)->uri($parameters);
128
-        } catch (UndefinedRouteException) {
136
+        }
137
+        catch (UndefinedRouteException)
138
+        {
129 139
             //In some cases route name can be provided as controller:action pair, we can try to
130 140
             //generate such route automatically based on our default/fallback route
131 141
             return $this->castRoute($route)->uri($parameters);
@@ -137,9 +147,11 @@  discard block
 block discarded – undo
137 147
         /** @var GroupRegistry $groups */
138 148
         $groups = $this->container->get(GroupRegistry::class);
139 149
 
140
-        foreach ($routes->getCollection() as $name => $configurator) {
150
+        foreach ($routes->getCollection() as $name => $configurator)
151
+        {
141 152
             $target = $configurator->target;
142
-            if ($configurator->core !== null && $target instanceof AbstractTarget) {
153
+            if ($configurator->core !== null && $target instanceof AbstractTarget)
154
+            {
143 155
                 $target = $target->withCore($configurator->core);
144 156
             }
145 157
 
@@ -149,19 +161,23 @@  discard block
 block discarded – undo
149 161
                 $configurator->defaults
150 162
             );
151 163
 
152
-            if ($configurator->middleware !== null) {
164
+            if ($configurator->middleware !== null)
165
+            {
153 166
                 $route = $route->withMiddleware(...$configurator->middleware);
154 167
             }
155 168
 
156
-            if ($configurator->methods !== null) {
169
+            if ($configurator->methods !== null)
170
+            {
157 171
                 $route = $route->withVerbs(...$configurator->methods);
158 172
             }
159 173
 
160
-            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME) {
174
+            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME)
175
+            {
161 176
                 $groups->getGroup($configurator->group ?? $groups->getDefaultGroup())->addRoute($name, $route);
162 177
             }
163 178
 
164
-            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME) {
179
+            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME)
180
+            {
165 181
                 $this->setDefault($route);
166 182
             }
167 183
         }
@@ -172,17 +188,20 @@  discard block
 block discarded – undo
172 188
      */
173 189
     protected function matchRoute(ServerRequestInterface $request, string &$routeName = null): ?RouteInterface
174 190
     {
175
-        foreach ($this->routes as $name => $route) {
191
+        foreach ($this->routes as $name => $route)
192
+        {
176 193
             // Matched route will return new route instance with matched parameters
177 194
             $matched = $route->match($request);
178 195
 
179
-            if ($matched !== null) {
196
+            if ($matched !== null)
197
+            {
180 198
                 $routeName = $name;
181 199
                 return $matched;
182 200
             }
183 201
         }
184 202
 
185
-        if ($this->default !== null) {
203
+        if ($this->default !== null)
204
+        {
186 205
             return $this->default->match($request);
187 206
         }
188 207
 
@@ -195,7 +214,8 @@  discard block
 block discarded – undo
195 214
      */
196 215
     protected function configure(RouteInterface $route): RouteInterface
197 216
     {
198
-        if ($route instanceof ContainerizedInterface && !$route->hasContainer()) {
217
+        if ($route instanceof ContainerizedInterface && !$route->hasContainer())
218
+        {
199 219
             // isolating route in a given container
200 220
             $route = $route->withContainer($this->container);
201 221
         }
@@ -225,11 +245,16 @@  discard block
 block discarded – undo
225 245
             );
226 246
         }
227 247
 
228
-        if (!empty($matches['name'])) {
248
+        if (!empty($matches['name']))
249
+        {
229 250
             $routeObject = $this->getRoute($matches['name']);
230
-        } elseif ($this->default !== null) {
251
+        }
252
+        elseif ($this->default !== null)
253
+        {
231 254
             $routeObject = $this->default;
232
-        } else {
255
+        }
256
+        else
257
+        {
233 258
             throw new UndefinedRouteException(\sprintf('Unable to locate route candidate for `%s`', $route));
234 259
         }
235 260
 
Please login to merge, or discard this patch.
src/Queue/tests/Interceptor/Push/CoreTest.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
20 20
             $queue = m::mock(QueueInterface::class)
21 21
         );
22 22
         $queue->shouldReceive('push')->once()
23
-            ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null) {
23
+            ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null)
24
+            {
24 25
                 return $name === 'foo' && $payload === ['baz' => 'baf'] && $options instanceof Options;
25 26
             });
26 27
 
@@ -59,7 +60,8 @@  discard block
 block discarded – undo
59 60
         $tracer->shouldReceive('getContext')->once()->andReturn(['foo' => ['bar']]);
60 61
 
61 62
         $queue->shouldReceive('push')->once()
62
-            ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null) {
63
+            ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null)
64
+            {
63 65
                 return $name === 'foo'
64 66
                     && $payload === ['baz' => 'baf']
65 67
                     && $options->getHeader('foo') === ['bar'];
@@ -82,7 +84,8 @@  discard block
 block discarded – undo
82 84
         $tracer->shouldNotReceive('getContext');
83 85
 
84 86
         $queue->shouldReceive('push')->once()
85
-            ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null) {
87
+            ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null)
88
+            {
86 89
                 return $name === 'foo'
87 90
                     && $payload === ['baz' => 'baf']
88 91
                     && $options !== null;
Please login to merge, or discard this patch.
src/Queue/src/Interceptor/Push/Core.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,12 +34,15 @@
 block discarded – undo
34 34
         \assert($parameters['options'] === null || $parameters['options'] instanceof OptionsInterface);
35 35
         \assert(\is_array($parameters['payload']));
36 36
 
37
-        if ($parameters['options'] === null) {
37
+        if ($parameters['options'] === null)
38
+        {
38 39
             $parameters['options'] = new Options();
39 40
         }
40 41
 
41
-        if (\method_exists($parameters['options'], 'withHeader')) {
42
-            foreach ($this->tracer->getContext() as $key => $data) {
42
+        if (\method_exists($parameters['options'], 'withHeader'))
43
+        {
44
+            foreach ($this->tracer->getContext() as $key => $data)
45
+            {
43 46
                 $parameters['options'] = $parameters['options']->withHeader($key, $data);
44 47
             }
45 48
         }
Please login to merge, or discard this patch.
src/Prototype/src/Command/DumpCommand.php 1 patch
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,8 @@  discard block
 block discarded – undo
22 22
     public function perform(PrototypeBootloader $prototypeBootloader): int
23 23
     {
24 24
         $dependencies = $this->registry->getPropertyBindings();
25
-        if ($dependencies === []) {
25
+        if ($dependencies === [])
26
+        {
26 27
             $this->writeln('<comment>No prototyped shortcuts found.</comment>');
27 28
 
28 29
             return self::SUCCESS;
@@ -32,7 +33,8 @@  discard block
 block discarded – undo
32 33
 
33 34
         $trait = new \ReflectionClass(PrototypeTrait::class);
34 35
         $docComment = $trait->getDocComment();
35
-        if ($docComment === false) {
36
+        if ($docComment === false)
37
+        {
36 38
             $this->write('<fg=red>DOCComment is missing</fg=red>');
37 39
 
38 40
             return self::FAILURE;
@@ -40,7 +42,8 @@  discard block
 block discarded – undo
40 42
 
41 43
         $filename = $trait->getFileName();
42 44
 
43
-        try {
45
+        try
46
+        {
44 47
             \file_put_contents(
45 48
                 $filename,
46 49
                 \str_replace(
@@ -49,7 +52,9 @@  discard block
 block discarded – undo
49 52
                     \file_get_contents($filename)
50 53
                 )
51 54
             );
52
-        } catch (\Throwable $e) {
55
+        }
56
+        catch (\Throwable $e)
57
+        {
53 58
             $this->write('<fg=red>' . $e->getMessage() . "</fg=red>\n");
54 59
 
55 60
             return self::FAILURE;
@@ -57,10 +62,12 @@  discard block
 block discarded – undo
57 62
 
58 63
         $this->write("<fg=green>complete</fg=green>\n");
59 64
 
60
-        if ($this->isVerbose()) {
65
+        if ($this->isVerbose())
66
+        {
61 67
             $grid = $this->table(['Property:', 'Target:']);
62 68
 
63
-            foreach ($dependencies as $dependency) {
69
+            foreach ($dependencies as $dependency)
70
+            {
64 71
                 $grid->addRow([$dependency->var, $dependency->type->fullName]);
65 72
             }
66 73
 
@@ -78,7 +85,8 @@  discard block
 block discarded – undo
78 85
         );
79 86
         $an->lines[] = new Annotation\Line('');
80 87
 
81
-        foreach ($dependencies as $dependency) {
88
+        foreach ($dependencies as $dependency)
89
+        {
82 90
             $an->lines[] = new Annotation\Line(
83 91
                 \sprintf('\\%s $%s', $dependency->type->fullName, $dependency->var),
84 92
                 'property'
Please login to merge, or discard this patch.
src/Telemetry/src/Config/TelemetryConfig.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function getDefaultDriver(): string
27 27
     {
28
-        if (!\is_string($this->config['default'])) {
28
+        if (!\is_string($this->config['default']))
29
+        {
29 30
             throw new InvalidArgumentException('Default trace driver config value must be a string');
30 31
         }
31 32
 
@@ -39,7 +40,8 @@  discard block
 block discarded – undo
39 40
      */
40 41
     public function getDriverConfig(string $name): string|Autowire|TracerFactoryInterface
41 42
     {
42
-        if (!isset($this->config['drivers'][$name])) {
43
+        if (!isset($this->config['drivers'][$name]))
44
+        {
43 45
             throw new InvalidArgumentException(
44 46
                 \sprintf('Config for telemetry driver `%s` is not defined.', $name)
45 47
             );
@@ -47,11 +49,13 @@  discard block
 block discarded – undo
47 49
 
48 50
         $driver = $this->config['drivers'][$name];
49 51
 
50
-        if ($driver instanceof TracerFactoryInterface) {
52
+        if ($driver instanceof TracerFactoryInterface)
53
+        {
51 54
             return $driver;
52 55
         }
53 56
 
54
-        if (!\is_string($driver) && !$driver instanceof Autowire) {
57
+        if (!\is_string($driver) && !$driver instanceof Autowire)
58
+        {
55 59
             throw new InvalidArgumentException(
56 60
                 \sprintf('Trace type value for `%s` must be a string or %s', $name, Autowire::class)
57 61
             );
Please login to merge, or discard this patch.
src/Telemetry/src/Monolog/TelemetryProcessor.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,8 @@
 block discarded – undo
22 22
 
23 23
         $context = $tracer->getContext();
24 24
 
25
-        if (!empty($context)) {
25
+        if (!empty($context))
26
+        {
26 27
             $record['extra']['telemetry'] = $context;
27 28
         }
28 29
 
Please login to merge, or discard this patch.
src/Http/tests/HttpTest.php 1 patch
Braces   +28 added lines, -14 removed lines patch added patch discarded remove patch
@@ -45,7 +45,8 @@  discard block
 block discarded – undo
45 45
     {
46 46
         $core = $this->getCore();
47 47
 
48
-        $core->setHandler(function () {
48
+        $core->setHandler(function ()
49
+        {
49 50
             return 'hello world';
50 51
         });
51 52
 
@@ -67,7 +68,8 @@  discard block
 block discarded – undo
67 68
     {
68 69
         $core = $this->getCore();
69 70
         $core->setHandler(
70
-            new CallableHandler(function () {
71
+            new CallableHandler(function ()
72
+            {
71 73
                 return 'hello world';
72 74
             }, new ResponseFactory(new HttpConfig(['headers' => []])))
73 75
         );
@@ -80,7 +82,8 @@  discard block
 block discarded – undo
80 82
     {
81 83
         $core = $this->getCore();
82 84
 
83
-        $core->setHandler(function ($req, $resp) {
85
+        $core->setHandler(function ($req, $resp)
86
+        {
84 87
             return $resp->withAddedHeader('hello', 'value');
85 88
         });
86 89
 
@@ -93,7 +96,8 @@  discard block
 block discarded – undo
93 96
     {
94 97
         $core = $this->getCore();
95 98
 
96
-        $core->setHandler(function ($req, $resp) {
99
+        $core->setHandler(function ($req, $resp)
100
+        {
97 101
             echo 'hello!';
98 102
 
99 103
             return $resp->withAddedHeader('hello', 'value');
@@ -109,7 +113,8 @@  discard block
 block discarded – undo
109 113
     {
110 114
         $core = $this->getCore();
111 115
 
112
-        $core->setHandler(function ($req, $resp) {
116
+        $core->setHandler(function ($req, $resp)
117
+        {
113 118
             echo 'hello!';
114 119
             $resp->getBody()->write('world ');
115 120
 
@@ -126,7 +131,8 @@  discard block
 block discarded – undo
126 131
     {
127 132
         $core = $this->getCore();
128 133
 
129
-        $core->setHandler(function () {
134
+        $core->setHandler(function ()
135
+        {
130 136
             ob_start();
131 137
             ob_start();
132 138
             echo 'hello!';
@@ -147,7 +153,8 @@  discard block
 block discarded – undo
147 153
     {
148 154
         $core = $this->getCore();
149 155
 
150
-        $core->setHandler(function () {
156
+        $core->setHandler(function ()
157
+        {
151 158
             return [
152 159
                 'status' => 404,
153 160
                 'message' => 'not found',
@@ -163,7 +170,8 @@  discard block
 block discarded – undo
163 170
     {
164 171
         $core = $this->getCore();
165 172
 
166
-        $core->setHandler(function () {
173
+        $core->setHandler(function ()
174
+        {
167 175
             return new Json([
168 176
                 'status' => 404,
169 177
                 'message' => 'not found',
@@ -179,7 +187,8 @@  discard block
 block discarded – undo
179 187
     {
180 188
         $core = $this->getCore([HeaderMiddleware::class]);
181 189
 
182
-        $core->setHandler(function () {
190
+        $core->setHandler(function ()
191
+        {
183 192
             return 'hello?';
184 193
         });
185 194
 
@@ -196,7 +205,8 @@  discard block
 block discarded – undo
196 205
         $core->getPipeline()->pushMiddleware(new Header2Middleware());
197 206
         $core->getPipeline()->riseMiddleware(new HeaderMiddleware());
198 207
 
199
-        $core->setHandler(function () {
208
+        $core->setHandler(function ()
209
+        {
200 210
             return 'hello?';
201 211
         });
202 212
 
@@ -213,7 +223,8 @@  discard block
 block discarded – undo
213 223
         $core->getPipeline()->pushMiddleware(new HeaderMiddleware());
214 224
         $core->getPipeline()->riseMiddleware(new Header2Middleware());
215 225
 
216
-        $core->setHandler(function () {
226
+        $core->setHandler(function ()
227
+        {
217 228
             return 'hello?';
218 229
         });
219 230
 
@@ -227,7 +238,8 @@  discard block
 block discarded – undo
227 238
     {
228 239
         $core = $this->getCore();
229 240
 
230
-        $core->setHandler(function () {
241
+        $core->setHandler(function ()
242
+        {
231 243
             $this->assertTrue($this->container->has(ServerRequestInterface::class));
232 244
 
233 245
             return 'OK';
@@ -265,7 +277,8 @@  discard block
 block discarded – undo
265 277
 
266 278
         $core = $this->getCore();
267 279
 
268
-        $core->setHandler(function () {
280
+        $core->setHandler(function ()
281
+        {
269 282
             return 'hello world';
270 283
         });
271 284
 
@@ -287,7 +300,8 @@  discard block
 block discarded – undo
287 300
             $tracerFactory = m::mock(TracerFactoryInterface::class),
288 301
         );
289 302
 
290
-        $http->setHandler(function () {
303
+        $http->setHandler(function ()
304
+        {
291 305
             return 'hello world';
292 306
         });
293 307
 
Please login to merge, or discard this patch.
src/Http/src/Http.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@  discard block
 block discarded – undo
33 33
         private readonly ContainerInterface $container,
34 34
         ?TracerFactoryInterface $tracerFactory = null
35 35
     ) {
36
-        foreach ($this->config->getMiddleware() as $middleware) {
36
+        foreach ($this->config->getMiddleware() as $middleware)
37
+        {
37 38
             $this->pipeline->pushMiddleware($this->container->get($middleware));
38 39
         }
39 40
 
@@ -67,7 +68,8 @@  discard block
 block discarded – undo
67 68
 
68 69
             $dispatcher?->dispatch(new RequestReceived($request));
69 70
 
70
-            if ($this->handler === null) {
71
+            if ($this->handler === null)
72
+            {
71 73
                 throw new HttpException('Unable to run HttpCore, no handler is set.');
72 74
             }
73 75
 
@@ -104,7 +106,8 @@  discard block
 block discarded – undo
104 106
             traceKind: TraceKind::SERVER
105 107
         );
106 108
 
107
-        foreach ($tracer->getContext() as $key => $value) {
109
+        foreach ($tracer->getContext() as $key => $value)
110
+        {
108 111
             $response = $response->withHeader($key, $value);
109 112
         }
110 113
 
Please login to merge, or discard this patch.