Passed
Pull Request — master (#828)
by Maxim
06:41
created
src/Router/src/RouteCollection.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __clone()
15 15
     {
16
-        foreach ($this->routes as $name => $route) {
16
+        foreach ($this->routes as $name => $route){
17 17
             $this->routes[$name] = clone $route;
18 18
         }
19 19
     }
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @param string|string[] $name The route name or an array of route names
74 74
      */
75
-    public function remove(string|array $name)
75
+    public function remove(string | array $name)
76 76
     {
77
-        foreach ((array) $name as $n) {
77
+        foreach ((array)$name as $n){
78 78
             unset($this->routes[$n]);
79 79
         }
80 80
     }
81 81
 
82 82
     public function addCollection(self $collection)
83 83
     {
84
-        foreach ($collection->all() as $name => $route) {
84
+        foreach ($collection->all() as $name => $route){
85 85
             $this->routes[$name] = $route;
86 86
         }
87 87
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function group(string $group)
93 93
     {
94
-        foreach ($this->routes as $route) {
94
+        foreach ($this->routes as $route){
95 95
             $route->group($group);
96 96
         }
97 97
     }
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,7 +13,8 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __clone()
15 15
     {
16
-        foreach ($this->routes as $name => $route) {
16
+        foreach ($this->routes as $name => $route)
17
+        {
17 18
             $this->routes[$name] = clone $route;
18 19
         }
19 20
     }
@@ -74,14 +75,16 @@  discard block
 block discarded – undo
74 75
      */
75 76
     public function remove(string|array $name)
76 77
     {
77
-        foreach ((array) $name as $n) {
78
+        foreach ((array) $name as $n)
79
+        {
78 80
             unset($this->routes[$n]);
79 81
         }
80 82
     }
81 83
 
82 84
     public function addCollection(self $collection)
83 85
     {
84
-        foreach ($collection->all() as $name => $route) {
86
+        foreach ($collection->all() as $name => $route)
87
+        {
85 88
             $this->routes[$name] = $route;
86 89
         }
87 90
     }
@@ -91,7 +94,8 @@  discard block
 block discarded – undo
91 94
      */
92 95
     public function group(string $group)
93 96
     {
94
-        foreach ($this->routes as $route) {
97
+        foreach ($this->routes as $route)
98
+        {
95 99
             $route->group($group);
96 100
         }
97 101
     }
Please login to merge, or discard this patch.
src/Router/src/Traits/VerbsTrait.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@
 block discarded – undo
19 19
      */
20 20
     public function withVerbs(string ...$verbs): RouteInterface
21 21
     {
22
-        foreach ($verbs as &$verb) {
22
+        foreach ($verbs as &$verb){
23 23
             $verb = \strtoupper($verb);
24
-            if (!\in_array($verb, RouteInterface::VERBS, true)) {
24
+            if (!\in_array($verb, RouteInterface::VERBS, true)){
25 25
                 throw new RouteException(\sprintf('Invalid HTTP verb `%s`', $verb));
26 26
             }
27 27
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,9 +19,11 @@
 block discarded – undo
19 19
      */
20 20
     public function withVerbs(string ...$verbs): RouteInterface
21 21
     {
22
-        foreach ($verbs as &$verb) {
22
+        foreach ($verbs as &$verb)
23
+        {
23 24
             $verb = \strtoupper($verb);
24
-            if (!\in_array($verb, RouteInterface::VERBS, true)) {
25
+            if (!\in_array($verb, RouteInterface::VERBS, true))
26
+            {
25 27
                 throw new RouteException(\sprintf('Invalid HTTP verb `%s`', $verb));
26 28
             }
27 29
 
Please login to merge, or discard this patch.
src/Router/src/Traits/PipelineTrait.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
         $route = clone $this;
43 43
 
44 44
         // array fallback
45
-        if (\count($middleware) === 1 && \is_array($middleware[0])) {
45
+        if (\count($middleware) === 1 && \is_array($middleware[0])){
46 46
             $middleware = $middleware[0];
47 47
         }
48 48
 
49 49
         /** @var MiddlewareType[] $middleware */
50
-        foreach ($middleware as $item) {
50
+        foreach ($middleware as $item){
51 51
             $route->middleware[] = $item;
52 52
         }
53 53
 
54
-        if ($route->pipeline !== null) {
54
+        if ($route->pipeline !== null){
55 55
             $route->pipeline = $route->makePipeline();
56 56
         }
57 57
 
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
      */
76 76
     protected function makePipeline(): Pipeline
77 77
     {
78
-        try {
78
+        try{
79 79
             return $this->container
80 80
                 ->get(PipelineFactory::class)
81 81
                 ->createWithMiddleware($this->middleware);
82
-        } catch (ContainerExceptionInterface $e) {
82
+        }catch (ContainerExceptionInterface $e){
83 83
             throw new RouteException($e->getMessage(), $e->getCode(), $e);
84 84
         }
85 85
     }
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,16 +42,19 @@  discard block
 block discarded – undo
42 42
         $route = clone $this;
43 43
 
44 44
         // array fallback
45
-        if (\count($middleware) === 1 && \is_array($middleware[0])) {
45
+        if (\count($middleware) === 1 && \is_array($middleware[0]))
46
+        {
46 47
             $middleware = $middleware[0];
47 48
         }
48 49
 
49 50
         /** @var MiddlewareType[] $middleware */
50
-        foreach ($middleware as $item) {
51
+        foreach ($middleware as $item)
52
+        {
51 53
             $route->middleware[] = $item;
52 54
         }
53 55
 
54
-        if ($route->pipeline !== null) {
56
+        if ($route->pipeline !== null)
57
+        {
55 58
             $route->pipeline = $route->makePipeline();
56 59
         }
57 60
 
@@ -75,11 +78,14 @@  discard block
 block discarded – undo
75 78
      */
76 79
     protected function makePipeline(): Pipeline
77 80
     {
78
-        try {
81
+        try
82
+        {
79 83
             return $this->container
80 84
                 ->get(PipelineFactory::class)
81 85
                 ->createWithMiddleware($this->middleware);
82
-        } catch (ContainerExceptionInterface $e) {
86
+        }
87
+        catch (ContainerExceptionInterface $e)
88
+        {
83 89
             throw new RouteException($e->getMessage(), $e->getCode(), $e);
84 90
         }
85 91
     }
Please login to merge, or discard this patch.
src/Router/src/Event/Routing.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,6 +10,6 @@
 block discarded – undo
10 10
 {
11 11
     public function __construct(
12 12
         public readonly ServerRequestInterface $request
13
-    ) {
13
+    ){
14 14
     }
15 15
 }
Please login to merge, or discard this patch.
src/Router/src/Event/RouteMatched.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
     public function __construct(
13 13
         public readonly ServerRequestInterface $request,
14 14
         public readonly RouteInterface $route,
15
-    ) {
15
+    ){
16 16
     }
17 17
 }
Please login to merge, or discard this patch.
src/Router/src/Autofill.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct(
10 10
         private readonly string $value
11
-    ) {
11
+    ){
12 12
     }
13 13
 
14 14
     public function __toString(): string
Please login to merge, or discard this patch.
src/Router/src/RouteGroup.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         private readonly ContainerInterface $container,
31 31
         private readonly RouterInterface $router,
32 32
         private readonly UriHandler $handler
33
-    ) {
33
+    ){
34 34
     }
35 35
 
36 36
     /**
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
         return $this;
55 55
     }
56 56
 
57
-    public function setCore(Autowire|CoreInterface|string $core): self
57
+    public function setCore(Autowire | CoreInterface | string $core): self
58 58
     {
59
-        if (!$core instanceof CoreInterface) {
59
+        if (!$core instanceof CoreInterface){
60 60
             $core = $this->container->get($core);
61 61
         }
62 62
         $this->core = $core;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     /**
71 71
      * @param MiddlewareInterface|Autowire|class-string<MiddlewareInterface>|non-empty-string $middleware
72 72
      */
73
-    public function addMiddleware(MiddlewareInterface|Autowire|string $middleware): self
73
+    public function addMiddleware(MiddlewareInterface | Autowire | string $middleware): self
74 74
     {
75 75
         $this->middleware[] = $middleware;
76 76
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function flushRoutes(): void
89 89
     {
90
-        foreach ($this->routes as $name) {
90
+        foreach ($this->routes as $name){
91 91
             $this->router->setRoute($name, $this->applyGroupParams($this->router->getRoute($name)));
92 92
         }
93 93
     }
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 
107 107
     private function applyGroupParams(Route $route): Route
108 108
     {
109
-        if ($this->core !== null) {
109
+        if ($this->core !== null){
110 110
             $target = $route->getTarget();
111 111
 
112
-            if ($target instanceof AbstractTarget) {
112
+            if ($target instanceof AbstractTarget){
113 113
                 $route = $route->withTarget($target->withCore($this->core));
114 114
             }
115 115
         }
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,7 +56,8 @@  discard block
 block discarded – undo
56 56
 
57 57
     public function setCore(Autowire|CoreInterface|string $core): self
58 58
     {
59
-        if (!$core instanceof CoreInterface) {
59
+        if (!$core instanceof CoreInterface)
60
+        {
60 61
             $core = $this->container->get($core);
61 62
         }
62 63
         $this->core = $core;
@@ -87,7 +88,8 @@  discard block
 block discarded – undo
87 88
      */
88 89
     public function flushRoutes(): void
89 90
     {
90
-        foreach ($this->routes as $name) {
91
+        foreach ($this->routes as $name)
92
+        {
91 93
             $this->router->setRoute($name, $this->applyGroupParams($this->router->getRoute($name)));
92 94
         }
93 95
     }
@@ -106,10 +108,12 @@  discard block
 block discarded – undo
106 108
 
107 109
     private function applyGroupParams(Route $route): Route
108 110
     {
109
-        if ($this->core !== null) {
111
+        if ($this->core !== null)
112
+        {
110 113
             $target = $route->getTarget();
111 114
 
112
-            if ($target instanceof AbstractTarget) {
115
+            if ($target instanceof AbstractTarget)
116
+            {
113 117
                 $route = $route->withTarget($target->withCore($this->core));
114 118
             }
115 119
         }
Please login to merge, or discard this patch.
src/Router/src/UriHandler.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         'integer' => '\d+',
26 26
         'uuid'    => '[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}',
27 27
     ];
28
-    private const URI_FIXERS       = [
28
+    private const URI_FIXERS = [
29 29
         '[]'  => '',
30 30
         '[/]' => '',
31 31
         '['   => '',
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function __construct(
50 50
         private readonly UriFactoryInterface $uriFactory,
51 51
         SlugifyInterface $slugify = null
52
-    ) {
52
+    ){
53 53
         $this->slugify = $slugify ?? new Slugify();
54 54
     }
55 55
 
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function match(UriInterface $uri, array $defaults): ?array
110 110
     {
111
-        if (!$this->isCompiled()) {
111
+        if (!$this->isCompiled()){
112 112
             $this->compile();
113 113
         }
114 114
 
115 115
         $matches = [];
116 116
 
117
-        if (!\preg_match($this->compiled, $this->fetchTarget($uri), $matches)) {
117
+        if (!\preg_match($this->compiled, $this->fetchTarget($uri), $matches)){
118 118
             return null;
119 119
         }
120 120
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     public function uri(iterable $parameters = [], array $defaults = []): UriInterface
130 130
     {
131
-        if (!$this->isCompiled()) {
131
+        if (!$this->isCompiled()){
132 132
             $this->compile();
133 133
         }
134 134
 
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
             $this->fetchOptions($parameters, $query)
139 139
         );
140 140
 
141
-        foreach ($this->constrains as $key => $_) {
142
-            if (empty($parameters[$key])) {
141
+        foreach ($this->constrains as $key => $_){
142
+            if (empty($parameters[$key])){
143 143
                 throw new UriHandlerException(\sprintf('Unable to generate Uri, parameter `%s` is missing', $key));
144 144
             }
145 145
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         $path = $this->interpolate($this->template, $parameters);
149 149
 
150 150
         //Uri with added prefix
151
-        $uri = $this->uriFactory->createUri(($this->matchHost ? '' : $this->prefix) . trim($path, '/'));
151
+        $uri = $this->uriFactory->createUri(($this->matchHost ? '' : $this->prefix).trim($path, '/'));
152 152
 
153 153
         return empty($query) ? $uri : $uri->withQuery(\http_build_query($query));
154 154
     }
@@ -163,18 +163,18 @@  discard block
 block discarded – undo
163 163
         $allowed = \array_keys($this->options);
164 164
 
165 165
         $result = [];
166
-        foreach ($parameters as $key => $parameter) {
167
-            if (\is_int($key) && isset($allowed[$key])) {
166
+        foreach ($parameters as $key => $parameter){
167
+            if (\is_int($key) && isset($allowed[$key])){
168 168
                 // this segment fetched keys from given parameters either by name or by position
169 169
                 $key = $allowed[$key];
170
-            } elseif (!\array_key_exists($key, $this->options) && \is_array($parameters)) {
170
+            } elseif (!\array_key_exists($key, $this->options) && \is_array($parameters)){
171 171
                 // all additional parameters given in array form can be glued to query string
172 172
                 $query[$key] = $parameter;
173 173
                 continue;
174 174
             }
175 175
 
176 176
             //String must be normalized here
177
-            if (\is_string($parameter) && !\preg_match('/^[a-z\-_0-9]+$/i', $parameter)) {
177
+            if (\is_string($parameter) && !\preg_match('/^[a-z\-_0-9]+$/i', $parameter)){
178 178
                 $result[$key] = $this->slugify->slugify($parameter);
179 179
                 continue;
180 180
             }
@@ -192,15 +192,15 @@  discard block
 block discarded – undo
192 192
     {
193 193
         $path = $uri->getPath();
194 194
 
195
-        if (empty($path) || $path[0] !== '/') {
196
-            $path = '/' . $path;
195
+        if (empty($path) || $path[0] !== '/'){
196
+            $path = '/'.$path;
197 197
         }
198 198
 
199
-        if ($this->matchHost) {
200
-            $uriString = $uri->getHost() . $path;
201
-        } else {
199
+        if ($this->matchHost){
200
+            $uriString = $uri->getHost().$path;
201
+        }else{
202 202
             $uriString = \substr($path, \strlen($this->prefix));
203
-            if ($uriString === false) {
203
+            if ($uriString === false){
204 204
                 $uriString = '';
205 205
             }
206 206
         }
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      */
214 214
     private function compile(): void
215 215
     {
216
-        if ($this->pattern === null) {
216
+        if ($this->pattern === null){
217 217
             throw new UriHandlerException('Unable to compile UriHandler, pattern is not set');
218 218
         }
219 219
 
@@ -222,14 +222,14 @@  discard block
 block discarded – undo
222 222
         $pattern = \rtrim(\ltrim($this->pattern, ':/'), '/');
223 223
 
224 224
         // correct [/ first occurrence]
225
-        if (\str_starts_with($pattern, '[/')) {
226
-            $pattern = '[' . \substr($pattern, 2);
225
+        if (\str_starts_with($pattern, '[/')){
226
+            $pattern = '['.\substr($pattern, 2);
227 227
         }
228 228
 
229
-        if (\preg_match_all('/<(\w+):?(.*?)?>/', $pattern, $matches)) {
229
+        if (\preg_match_all('/<(\w+):?(.*?)?>/', $pattern, $matches)){
230 230
             $variables = \array_combine($matches[1], $matches[2]);
231 231
 
232
-            foreach ($variables as $key => $segment) {
232
+            foreach ($variables as $key => $segment){
233 233
                 $segment = $this->prepareSegment($key, $segment);
234 234
                 $replaces[\sprintf('<%s>', $key)] = \sprintf('(?P<%s>%s)', $key, $segment);
235 235
                 $options[] = $key;
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
         $template = \preg_replace('/<(\w+):?.*?>/', '<\1>', $pattern);
240 240
         $options = \array_fill_keys($options, null);
241 241
 
242
-        foreach ($this->constrains as $key => $value) {
243
-            if ($value instanceof Autofill) {
242
+        foreach ($this->constrains as $key => $value){
243
+            if ($value instanceof Autofill){
244 244
                 // only forces value replacement, not required to be presented as parameter
245 245
                 continue;
246 246
             }
247 247
 
248
-            if (!\array_key_exists($key, $options) && !isset($this->defaults[$key])) {
248
+            if (!\array_key_exists($key, $options) && !isset($this->defaults[$key])){
249 249
                 throw new ConstrainException(
250 250
                     \sprintf(
251 251
                         'Route `%s` does not define routing parameter `<%s>`.',
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
             }
257 257
         }
258 258
 
259
-        $this->compiled = '/^' . \strtr($template, $replaces + self::PATTERN_REPLACES) . '$/iu';
259
+        $this->compiled = '/^'.\strtr($template, $replaces + self::PATTERN_REPLACES).'$/iu';
260 260
         $this->template = \stripslashes(\str_replace('?', '', $template));
261 261
         $this->options = $options;
262 262
     }
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
     private function interpolate(string $string, array $values): string
268 268
     {
269 269
         $replaces = [];
270
-        foreach ($values as $key => $value) {
270
+        foreach ($values as $key => $value){
271 271
             $replaces[\sprintf('<%s>', $key)] = match (true) {
272
-                $value instanceof \Stringable || \is_scalar($value) => (string) $value,
272
+                $value instanceof \Stringable || \is_scalar($value) => (string)$value,
273 273
                 default => '',
274 274
             };
275 275
         }
Please login to merge, or discard this patch.
Braces   +44 added lines, -21 removed lines patch added patch discarded remove patch
@@ -108,13 +108,15 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function match(UriInterface $uri, array $defaults): ?array
110 110
     {
111
-        if (!$this->isCompiled()) {
111
+        if (!$this->isCompiled())
112
+        {
112 113
             $this->compile();
113 114
         }
114 115
 
115 116
         $matches = [];
116 117
 
117
-        if (!\preg_match($this->compiled, $this->fetchTarget($uri), $matches)) {
118
+        if (!\preg_match($this->compiled, $this->fetchTarget($uri), $matches))
119
+        {
118 120
             return null;
119 121
         }
120 122
 
@@ -128,7 +130,8 @@  discard block
 block discarded – undo
128 130
      */
129 131
     public function uri(iterable $parameters = [], array $defaults = []): UriInterface
130 132
     {
131
-        if (!$this->isCompiled()) {
133
+        if (!$this->isCompiled())
134
+        {
132 135
             $this->compile();
133 136
         }
134 137
 
@@ -138,8 +141,10 @@  discard block
 block discarded – undo
138 141
             $this->fetchOptions($parameters, $query)
139 142
         );
140 143
 
141
-        foreach ($this->constrains as $key => $_) {
142
-            if (empty($parameters[$key])) {
144
+        foreach ($this->constrains as $key => $_)
145
+        {
146
+            if (empty($parameters[$key]))
147
+            {
143 148
                 throw new UriHandlerException(\sprintf('Unable to generate Uri, parameter `%s` is missing', $key));
144 149
             }
145 150
         }
@@ -163,18 +168,23 @@  discard block
 block discarded – undo
163 168
         $allowed = \array_keys($this->options);
164 169
 
165 170
         $result = [];
166
-        foreach ($parameters as $key => $parameter) {
167
-            if (\is_int($key) && isset($allowed[$key])) {
171
+        foreach ($parameters as $key => $parameter)
172
+        {
173
+            if (\is_int($key) && isset($allowed[$key]))
174
+            {
168 175
                 // this segment fetched keys from given parameters either by name or by position
169 176
                 $key = $allowed[$key];
170
-            } elseif (!\array_key_exists($key, $this->options) && \is_array($parameters)) {
177
+            }
178
+            elseif (!\array_key_exists($key, $this->options) && \is_array($parameters))
179
+            {
171 180
                 // all additional parameters given in array form can be glued to query string
172 181
                 $query[$key] = $parameter;
173 182
                 continue;
174 183
             }
175 184
 
176 185
             //String must be normalized here
177
-            if (\is_string($parameter) && !\preg_match('/^[a-z\-_0-9]+$/i', $parameter)) {
186
+            if (\is_string($parameter) && !\preg_match('/^[a-z\-_0-9]+$/i', $parameter))
187
+            {
178 188
                 $result[$key] = $this->slugify->slugify($parameter);
179 189
                 continue;
180 190
             }
@@ -192,15 +202,20 @@  discard block
 block discarded – undo
192 202
     {
193 203
         $path = $uri->getPath();
194 204
 
195
-        if (empty($path) || $path[0] !== '/') {
205
+        if (empty($path) || $path[0] !== '/')
206
+        {
196 207
             $path = '/' . $path;
197 208
         }
198 209
 
199
-        if ($this->matchHost) {
210
+        if ($this->matchHost)
211
+        {
200 212
             $uriString = $uri->getHost() . $path;
201
-        } else {
213
+        }
214
+        else
215
+        {
202 216
             $uriString = \substr($path, \strlen($this->prefix));
203
-            if ($uriString === false) {
217
+            if ($uriString === false)
218
+            {
204 219
                 $uriString = '';
205 220
             }
206 221
         }
@@ -213,7 +228,8 @@  discard block
 block discarded – undo
213 228
      */
214 229
     private function compile(): void
215 230
     {
216
-        if ($this->pattern === null) {
231
+        if ($this->pattern === null)
232
+        {
217 233
             throw new UriHandlerException('Unable to compile UriHandler, pattern is not set');
218 234
         }
219 235
 
@@ -222,14 +238,17 @@  discard block
 block discarded – undo
222 238
         $pattern = \rtrim(\ltrim($this->pattern, ':/'), '/');
223 239
 
224 240
         // correct [/ first occurrence]
225
-        if (\str_starts_with($pattern, '[/')) {
241
+        if (\str_starts_with($pattern, '[/'))
242
+        {
226 243
             $pattern = '[' . \substr($pattern, 2);
227 244
         }
228 245
 
229
-        if (\preg_match_all('/<(\w+):?(.*?)?>/', $pattern, $matches)) {
246
+        if (\preg_match_all('/<(\w+):?(.*?)?>/', $pattern, $matches))
247
+        {
230 248
             $variables = \array_combine($matches[1], $matches[2]);
231 249
 
232
-            foreach ($variables as $key => $segment) {
250
+            foreach ($variables as $key => $segment)
251
+            {
233 252
                 $segment = $this->prepareSegment($key, $segment);
234 253
                 $replaces[\sprintf('<%s>', $key)] = \sprintf('(?P<%s>%s)', $key, $segment);
235 254
                 $options[] = $key;
@@ -239,13 +258,16 @@  discard block
 block discarded – undo
239 258
         $template = \preg_replace('/<(\w+):?.*?>/', '<\1>', $pattern);
240 259
         $options = \array_fill_keys($options, null);
241 260
 
242
-        foreach ($this->constrains as $key => $value) {
243
-            if ($value instanceof Autofill) {
261
+        foreach ($this->constrains as $key => $value)
262
+        {
263
+            if ($value instanceof Autofill)
264
+            {
244 265
                 // only forces value replacement, not required to be presented as parameter
245 266
                 continue;
246 267
             }
247 268
 
248
-            if (!\array_key_exists($key, $options) && !isset($this->defaults[$key])) {
269
+            if (!\array_key_exists($key, $options) && !isset($this->defaults[$key]))
270
+            {
249 271
                 throw new ConstrainException(
250 272
                     \sprintf(
251 273
                         'Route `%s` does not define routing parameter `<%s>`.',
@@ -267,7 +289,8 @@  discard block
 block discarded – undo
267 289
     private function interpolate(string $string, array $values): string
268 290
     {
269 291
         $replaces = [];
270
-        foreach ($values as $key => $value) {
292
+        foreach ($values as $key => $value)
293
+        {
271 294
             $replaces[\sprintf('<%s>', $key)] = match (true) {
272 295
                 $value instanceof \Stringable || \is_scalar($value) => (string) $value,
273 296
                 default => '',
Please login to merge, or discard this patch.
src/Router/src/Target/Controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
         private readonly string $controller,
16 16
         int $options = 0,
17 17
         string $defaultAction = 'index'
18
-    ) {
18
+    ){
19 19
         parent::__construct(
20 20
             ['action' => null],
21 21
             ['action' => null],
Please login to merge, or discard this patch.