@@ -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 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $route->belong($this); // Attach grouping to route. |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - ++$this->countRoutes; |
|
| 73 | + ++ $this->countRoutes; |
|
| 74 | 74 | |
| 75 | 75 | return $route; |
| 76 | 76 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $routes['routes'][] = $route->bind($this->generateRouteName($route, $prefix . $namedGroup, $unnamedRoutes)); |
| 94 | 94 | $this->processRouteMaps($route, $routes->countRoutes, $routes); |
| 95 | 95 | |
| 96 | - ++$routes->countRoutes; |
|
| 96 | + ++ $routes->countRoutes; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | if ($group->offsetExists('group')) { |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $name = $route->generateRouteName(''); |
| 124 | 124 | |
| 125 | 125 | if (isset($unnamedRoutes[$name])) { |
| 126 | - $name .= ('_' !== $name[-1] ? '_' : '') . ++$unnamedRoutes[$name]; |
|
| 126 | + $name .= ('_' !== $name[- 1] ? '_' : '') . ++$unnamedRoutes[$name]; |
|
| 127 | 127 | } else { |
| 128 | 128 | $unnamedRoutes[$name] = 0; |
| 129 | 129 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $requirements = $route->get('patterns'); |
| 104 | 104 | |
| 105 | 105 | // Strip supported browser prefix of $routePath ... |
| 106 | - $routePath = \rtrim($routePath = $route->get('path'), Route::URL_PREFIX_SLASHES[$routePath[-1]] ?? '/'); |
|
| 106 | + $routePath = \rtrim($routePath = $route->get('path'), Route::URL_PREFIX_SLASHES[$routePath[- 1]] ?? '/'); |
|
| 107 | 107 | |
| 108 | 108 | if (!empty($routePath) && '/' === $routePath[0]) { |
| 109 | 109 | $routePath = \substr($routePath, 1); |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $regex = \substr($regex, 2); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if ('$' === $regex[-1]) { |
|
| 210 | + if ('$' === $regex[- 1]) { |
|
| 211 | 211 | $regex = \substr($regex, 0, -1); |
| 212 | 212 | } elseif (\strlen($regex) - 2 === \strpos($regex, '\\z')) { |
| 213 | 213 | $regex = \substr($regex, 0, -2); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function match(string $method, UriInterface $uri): ?Route |
| 90 | 90 | { |
| 91 | - $requestPath = \rtrim($pathInfo = $uri->getPath(), Route::URL_PREFIX_SLASHES[$pathInfo[-1]] ?? '/') ?: '/'; |
|
| 91 | + $requestPath = \rtrim($pathInfo = $uri->getPath(), Route::URL_PREFIX_SLASHES[$pathInfo[- 1]] ?? '/') ?: '/'; |
|
| 92 | 92 | |
| 93 | 93 | if (isset($this->staticRouteMap[$requestPath])) { |
| 94 | 94 | $staticRoute = $this->staticRouteMap[$requestPath]; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $matchVar = 0; |
| 149 | 149 | |
| 150 | 150 | foreach ($this->dynamicRouteMap[1][$routeId] ?? [] as $key => $value) { |
| 151 | - $route->argument($key, $matches[++$matchVar] ?? $value); |
|
| 151 | + $route->argument($key, $matches[++ $matchVar] ?? $value); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return $route->match($method, $uri); |
@@ -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 | } |