@@ -109,7 +109,7 @@ |
||
109 | 109 | */ |
110 | 110 | public function setCollection(callable $routeDefinitionCallback, $routeCollector = RouteCollection::class): void |
111 | 111 | { |
112 | - $this->collection = static function () use ($routeDefinitionCallback, $routeCollector): RouteMapInterface { |
|
112 | + $this->collection = static function() use ($routeDefinitionCallback, $routeCollector): RouteMapInterface { |
|
113 | 113 | $routeCollector = new $routeCollector(); |
114 | 114 | \assert($routeCollector instanceof RouteMapInterface); |
115 | 115 |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | public function namespace(string $namespace): self |
258 | 258 | { |
259 | 259 | if ('' !== $namespace) { |
260 | - if ('\\' === $namespace[-1]) { |
|
260 | + if ('\\' === $namespace[- 1]) { |
|
261 | 261 | throw new InvalidControllerException(\sprintf('Namespace "%s" provided for routes must not end with a "\\".', $namespace)); |
262 | 262 | } |
263 | 263 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | \sprintf('Invalid call for "%s" in %s(\'%1$s\'), try any of [%s].', $name, __METHOD__, \implode(',', \array_keys(static::$getter))) |
360 | 360 | ); |
361 | 361 | |
362 | - if ('*' === $name[-1]) { |
|
362 | + if ('*' === $name[- 1]) { |
|
363 | 363 | return \array_unique($this->data[\substr($name, 0, -1)] ?? []); |
364 | 364 | } |
365 | 365 | |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function getData(): array |
375 | 375 | { |
376 | - return \array_map(function (string $property) { |
|
377 | - if ('*' === $property[-1]) { |
|
376 | + return \array_map(function(string $property) { |
|
377 | + if ('*' === $property[- 1]) { |
|
378 | 378 | $property = \substr($property, 0, -1); |
379 | 379 | } |
380 | 380 |
@@ -109,12 +109,12 @@ |
||
109 | 109 | return $uri; |
110 | 110 | } |
111 | 111 | |
112 | - if (isset(self::URL_PREFIX_SLASHES[$prefix[-1]], self::URL_PREFIX_SLASHES[$uri[0]])) { |
|
112 | + if (isset(self::URL_PREFIX_SLASHES[$prefix[- 1]], self::URL_PREFIX_SLASHES[$uri[0]])) { |
|
113 | 113 | return $prefix . \ltrim($uri, \implode('', self::URL_PREFIX_SLASHES)); |
114 | 114 | } |
115 | 115 | |
116 | 116 | // browser supported slashes ... |
117 | - $slashExist = self::URL_PREFIX_SLASHES[$prefix[-1]] ?? self::URL_PREFIX_SLASHES[$uri[0]] ?? null; |
|
117 | + $slashExist = self::URL_PREFIX_SLASHES[$prefix[- 1]] ?? self::URL_PREFIX_SLASHES[$uri[0]] ?? null; |
|
118 | 118 | |
119 | 119 | if (null === $slashExist) { |
120 | 120 | $prefix .= '/'; |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | $route = $request->getAttribute(Route::class); |
70 | 70 | |
71 | 71 | if ($route instanceof Route) { |
72 | - $routeEndTail = BaseRoute::URL_PREFIX_SLASHES[$route->get('path')[-1]] ?? null; |
|
73 | - $requestEndTail = BaseRoute::URL_PREFIX_SLASHES[$trimmedPath[-1]] ?? null; |
|
72 | + $routeEndTail = BaseRoute::URL_PREFIX_SLASHES[$route->get('path')[- 1]] ?? null; |
|
73 | + $requestEndTail = BaseRoute::URL_PREFIX_SLASHES[$trimmedPath[- 1]] ?? null; |
|
74 | 74 | |
75 | 75 | if ($routeEndTail === $requestEndTail) { |
76 | 76 | return $response; |
@@ -95,6 +95,6 @@ discard block |
||
95 | 95 | |
96 | 96 | private static function getTrimmedPath(string $requestPath): string |
97 | 97 | { |
98 | - return \preg_replace('#(?|\\' . \implode('|\\', BaseRoute::URL_PREFIX_SLASHES) . ')+$#', $requestPath[-1], $requestPath); |
|
98 | + return \preg_replace('#(?|\\' . \implode('|\\', BaseRoute::URL_PREFIX_SLASHES) . ')+$#', $requestPath[- 1], $requestPath); |
|
99 | 99 | } |
100 | 100 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | { |
97 | 97 | $requestPath = $uri->getPath(); |
98 | 98 | |
99 | - if (isset(BaseRoute::URL_PREFIX_SLASHES[$requestPath[-1]])) { |
|
99 | + if (isset(BaseRoute::URL_PREFIX_SLASHES[$requestPath[- 1]])) { |
|
100 | 100 | $requestPath = \substr($requestPath, 0, -1) ?: '/'; |
101 | 101 | } |
102 | 102 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $routes = $this->routes; |
158 | 158 | |
159 | 159 | if (null !== $this->generatedRegex) { |
160 | - \array_walk($routes, static function (&$data): void { |
|
160 | + \array_walk($routes, static function(&$data): void { |
|
161 | 161 | $data = $data[0]; |
162 | 162 | }); |
163 | 163 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | foreach ($variables as $key => $value) { |
185 | - $route->argument($key, $matches[++$matchVar] ?? $matches[$key] ?? $hostsVar[$key] ?? $value); |
|
185 | + $route->argument($key, $matches[++ $matchVar] ?? $matches[$key] ?? $hostsVar[$key] ?? $value); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $route->match($method, $uri); |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | if ('(' === $prefix[$j]) { |
158 | - ++$n; |
|
158 | + ++ $n; |
|
159 | 159 | } elseif (')' === $prefix[$j]) { |
160 | - --$n; |
|
161 | - } elseif ('\\' === $prefix[$j] && (++$j === $end || $prefix[$j] !== $anotherPrefix[$j])) { |
|
162 | - --$j; |
|
160 | + -- $n; |
|
161 | + } elseif ('\\' === $prefix[$j] && (++ $j === $end || $prefix[$j] !== $anotherPrefix[$j])) { |
|
162 | + -- $j; |
|
163 | 163 | |
164 | 164 | break; |
165 | 165 | } |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | break; |
180 | 180 | } |
181 | 181 | $i = $j - 1; |
182 | - } elseif ('\\' === $prefix[$i] && (++$i === $end || $prefix[$i] !== $anotherPrefix[$i])) { |
|
183 | - --$i; |
|
182 | + } elseif ('\\' === $prefix[$i] && (++ $i === $end || $prefix[$i] !== $anotherPrefix[$i])) { |
|
183 | + -- $i; |
|
184 | 184 | |
185 | 185 | break; |
186 | 186 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | if ($i < $end && 0b10 === (\ord($prefix[$i]) >> 6) && \preg_match('//u', $prefix . ' ' . $anotherPrefix)) { |
191 | 191 | do { |
192 | 192 | // Prevent cutting in the middle of an UTF-8 characters |
193 | - --$i; |
|
193 | + -- $i; |
|
194 | 194 | } while (0b10 === (\ord($prefix[$i]) >> 6)); |
195 | 195 | } |
196 | 196 |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $variables = []; // The vars found in path and hosts regex. |
111 | 111 | |
112 | 112 | // Strip supported browser prefix of $routePath ... |
113 | - if (isset(BaseRoute::URL_PREFIX_SLASHES[@$routePath[-1]])) { |
|
113 | + if (isset(BaseRoute::URL_PREFIX_SLASHES[@$routePath[- 1]])) { |
|
114 | 114 | $routePath = \substr($routePath, 0, -1); |
115 | 115 | } |
116 | 116 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | } |
326 | 326 | |
327 | 327 | return \implode('|', \array_map( |
328 | - static function (string $segment) use ($name): string { |
|
328 | + static function(string $segment) use ($name): string { |
|
329 | 329 | return self::sanitizeRequirement($name, $segment); |
330 | 330 | }, |
331 | 331 | $segment |
@@ -378,11 +378,11 @@ discard block |
||
378 | 378 | { |
379 | 379 | $sortRegex = '#^[\w+' . \implode('\\', Routes\Route::URL_PREFIX_SLASHES) . ']+$#'; |
380 | 380 | |
381 | - \usort($routes, static function (Routes\FastRoute $a, Routes\FastRoute $b) use ($sortRegex): int { |
|
381 | + \usort($routes, static function(Routes\FastRoute $a, Routes\FastRoute $b) use ($sortRegex): int { |
|
382 | 382 | $aRegex = \preg_match($sortRegex, $a->get('path')); |
383 | 383 | $bRegex = \preg_match($sortRegex, $b->get('path')); |
384 | 384 | |
385 | - return $aRegex == $bRegex ? 0 : ($aRegex < $bRegex ? +1 : -1); |
|
385 | + return $aRegex == $bRegex ? 0 : ($aRegex < $bRegex ? + 1 : -1); |
|
386 | 386 | }); |
387 | 387 | |
388 | 388 | return $routes; |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $name = $route->generateRouteName(''); |
434 | 434 | |
435 | 435 | if (isset($unnamedRoutes[$name])) { |
436 | - $name .= ('_' !== $name[-1] ? '_' : '') . ++$unnamedRoutes[$name]; |
|
436 | + $name .= ('_' !== $name[- 1] ? '_' : '') . ++$unnamedRoutes[$name]; |
|
437 | 437 | } else { |
438 | 438 | $unnamedRoutes[$name] = 0; |
439 | 439 | } |