@@ -221,7 +221,7 @@ |
||
| 221 | 221 | $opened--; |
| 222 | 222 | if ($opened === 0) { |
| 223 | 223 | $greedy = '?'; |
| 224 | - if ($i < $len -1) { |
|
| 224 | + if ($i < $len - 1) { |
|
| 225 | 225 | if ($pattern[$i + 1] === '*' || $pattern[$i + 1] === '+') { |
| 226 | 226 | $greedy = $pattern[$i + 1]; |
| 227 | 227 | $i++; |
@@ -80,16 +80,16 @@ |
||
| 80 | 80 | public function match($request, &$variables = null, &$hostVariables = null): bool; |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * Returns the route's link. |
|
| 84 | - * |
|
| 85 | - * @param array $params The route parameters. |
|
| 86 | - * @param array $options Options for generating the proper prefix. Accepted values are: |
|
| 87 | - * - `'absolute'` _boolean_: `true` or `false`. - `'scheme'` |
|
| 88 | - * _string_ : The scheme. - `'host'` _string_ : The host |
|
| 89 | - * name. - `'basePath'` _string_ : The base path. - `'query'` |
|
| 90 | - * _string_ : The query string. - `'fragment'` _string_ : The |
|
| 91 | - * fragment string. |
|
| 92 | - * @return string The link. |
|
| 93 | - */ |
|
| 94 | - public function link(array $params = [], array $options = []): string; |
|
| 83 | + * Returns the route's link. |
|
| 84 | + * |
|
| 85 | + * @param array $params The route parameters. |
|
| 86 | + * @param array $options Options for generating the proper prefix. Accepted values are: |
|
| 87 | + * - `'absolute'` _boolean_: `true` or `false`. - `'scheme'` |
|
| 88 | + * _string_ : The scheme. - `'host'` _string_ : The host |
|
| 89 | + * name. - `'basePath'` _string_ : The base path. - `'query'` |
|
| 90 | + * _string_ : The query string. - `'fragment'` _string_ : The |
|
| 91 | + * fragment string. |
|
| 92 | + * @return string The link. |
|
| 93 | + */ |
|
| 94 | + public function link(array $params = [], array $options = []): string; |
|
| 95 | 95 | } |
@@ -214,35 +214,35 @@ |
||
| 214 | 214 | * @return \Lead\Router\RouterInterface |
| 215 | 215 | */ |
| 216 | 216 | public function addRoute(RouteInterface $route): RouterInterface { |
| 217 | - $options['pattern'] = $pattern = $route->getPattern(); |
|
| 218 | - $options['handler'] = $route->getHandler(); |
|
| 219 | - $options['scope'] = $route->getScope(); |
|
| 217 | + $options['pattern'] = $pattern = $route->getPattern(); |
|
| 218 | + $options['handler'] = $route->getHandler(); |
|
| 219 | + $options['scope'] = $route->getScope(); |
|
| 220 | 220 | |
| 221 | - $scheme = $options['scheme']; |
|
| 222 | - $host = $options['host']; |
|
| 221 | + $scheme = $options['scheme']; |
|
| 222 | + $host = $options['host']; |
|
| 223 | 223 | |
| 224 | - if (isset($this->_hosts[$scheme][$host])) { |
|
| 225 | - $options['host'] = $this->_hosts[$scheme][$host]; |
|
| 226 | - } |
|
| 224 | + if (isset($this->_hosts[$scheme][$host])) { |
|
| 225 | + $options['host'] = $this->_hosts[$scheme][$host]; |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - if (isset($this->_pattern[$scheme][$host][$pattern])) { |
|
| 229 | - $route = $this->_pattern[$scheme][$host][$pattern]; |
|
| 230 | - } else { |
|
| 231 | - $this->_hosts[$scheme][$host] = $route->getHost(); |
|
| 232 | - } |
|
| 228 | + if (isset($this->_pattern[$scheme][$host][$pattern])) { |
|
| 229 | + $route = $this->_pattern[$scheme][$host][$pattern]; |
|
| 230 | + } else { |
|
| 231 | + $this->_hosts[$scheme][$host] = $route->getHost(); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - if (!isset($this->_pattern[$scheme][$host][$pattern])) { |
|
| 235 | - $this->_pattern[$scheme][$host][$pattern] = $route; |
|
| 236 | - } |
|
| 234 | + if (!isset($this->_pattern[$scheme][$host][$pattern])) { |
|
| 235 | + $this->_pattern[$scheme][$host][$pattern] = $route; |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - $methods = $route->getMethods(); |
|
| 239 | - foreach ($methods as $method) { |
|
| 240 | - $this->_routes[$scheme][$host][strtoupper($method)][] = $route; |
|
| 241 | - } |
|
| 238 | + $methods = $route->getMethods(); |
|
| 239 | + foreach ($methods as $method) { |
|
| 240 | + $this->_routes[$scheme][$host][strtoupper($method)][] = $route; |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | - $this->_data[$route->getName()] = $route; |
|
| 243 | + $this->_data[$route->getName()] = $route; |
|
| 244 | 244 | |
| 245 | - return $this; |
|
| 245 | + return $this; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $this->_pattern[$scheme][$host][$pattern] = $instance; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - $methods = $options['methods'] ? (array)$options['methods'] : []; |
|
| 302 | + $methods = $options['methods'] ? (array) $options['methods'] : []; |
|
| 303 | 303 | |
| 304 | 304 | $instance->allow($methods); |
| 305 | 305 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | $request = $parsed + $request; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - $request['path'] = (ltrim((string)strtok($request['path'], '?'), '/')); |
|
| 429 | + $request['path'] = (ltrim((string) strtok($request['path'], '?'), '/')); |
|
| 430 | 430 | $request['method'] = strtoupper($request['method']); |
| 431 | 431 | |
| 432 | 432 | return $request; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $this->setMethods($config['methods']); |
| 178 | 178 | $this->setScope($config['scope']); |
| 179 | 179 | $this->setPattern($config['pattern']); |
| 180 | - $this->setMiddleware((array)$config['middleware']); |
|
| 180 | + $this->setMiddleware((array) $config['middleware']); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function setMiddleware(array $middleware) |
| 190 | 190 | { |
| 191 | - $this->_middleware = (array)$middleware; |
|
| 191 | + $this->_middleware = (array) $middleware; |
|
| 192 | 192 | |
| 193 | 193 | return $this; |
| 194 | 194 | } |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | */ |
| 438 | 438 | public function setMethods($methods): self |
| 439 | 439 | { |
| 440 | - $methods = $methods ? (array)$methods : []; |
|
| 440 | + $methods = $methods ? (array) $methods : []; |
|
| 441 | 441 | $methods = array_map('strtoupper', $methods); |
| 442 | 442 | $methods = array_fill_keys($methods, true); |
| 443 | 443 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | */ |
| 461 | 461 | public function allow($methods = []) |
| 462 | 462 | { |
| 463 | - $methods = $methods ? (array)$methods : []; |
|
| 463 | + $methods = $methods ? (array) $methods : []; |
|
| 464 | 464 | $methods = array_map('strtoupper', $methods); |
| 465 | 465 | $methods = array_fill_keys($methods, true) + $this->_methods; |
| 466 | 466 | |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | |
| 703 | 703 | $generator = $this->middleware(); |
| 704 | 704 | |
| 705 | - $next = function () use ($request, $response, $generator, &$next) { |
|
| 705 | + $next = function() use ($request, $response, $generator, &$next) { |
|
| 706 | 706 | $handler = $generator->current(); |
| 707 | 707 | $generator->next(); |
| 708 | 708 | |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | } |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - yield function () { |
|
| 733 | + yield function() { |
|
| 734 | 734 | $handler = $this->getHandler(); |
| 735 | 735 | if ($handler === null) { |
| 736 | 736 | return null; |
@@ -777,7 +777,7 @@ discard block |
||
| 777 | 777 | ]; |
| 778 | 778 | |
| 779 | 779 | $options = array_filter( |
| 780 | - $options, function ($value) { |
|
| 780 | + $options, function($value) { |
|
| 781 | 781 | return $value !== '*'; |
| 782 | 782 | } |
| 783 | 783 | ); |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | if (isset($child['tokens'])) { |
| 828 | 828 | if ($child['repeat']) { |
| 829 | 829 | $name = $child['repeat']; |
| 830 | - $values = isset($params[$name]) && $params[$name] !== null ? (array)$params[$name] : []; |
|
| 830 | + $values = isset($params[$name]) && $params[$name] !== null ? (array) $params[$name] : []; |
|
| 831 | 831 | if (!$values && !$child['optional']) { |
| 832 | 832 | throw new RouterException("Missing parameters `'{$name}'` for route: `'{$this->name}#{$this->_pattern}'`."); |
| 833 | 833 | } |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | $parts = []; |
| 855 | 855 | } |
| 856 | 856 | foreach ($parts as $key => $value) { |
| 857 | - $parts[$key] = rawurlencode((string)$value); |
|
| 857 | + $parts[$key] = rawurlencode((string) $value); |
|
| 858 | 858 | } |
| 859 | 859 | $value = join('/', $parts); |
| 860 | 860 | |