@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | $route = $r->bind('foo/bar', function($route) { |
119 | 119 | return 'A'; |
120 | 120 | })->apply(function($request, $response, $next) { |
121 | - return '1' . $next() . '1'; |
|
121 | + return '1'.$next().'1'; |
|
122 | 122 | })->apply(function($request, $response, $next) { |
123 | - return '2' . $next() . '2'; |
|
123 | + return '2'.$next().'2'; |
|
124 | 124 | }); |
125 | 125 | |
126 | 126 | $route = $r->route('foo/bar'); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | 'scheme' => 'https' |
204 | 204 | ]); |
205 | 205 | |
206 | - $link =$route->link([ |
|
206 | + $link = $route->link([ |
|
207 | 207 | 'bar' => 'baz', |
208 | 208 | 'domain' => 'example' |
209 | 209 | ], [ |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | $scope = $this->_scope; |
94 | 94 | |
95 | 95 | if (!empty($options['name'])) { |
96 | - $options['name'] = $scope['name'] ? $scope['name'] . '.' . $options['name'] : $options['name']; |
|
96 | + $options['name'] = $scope['name'] ? $scope['name'].'.'.$options['name'] : $options['name']; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | if (!empty($options['prefix'])) { |
100 | - $options['prefix'] = $scope['prefix'] . trim($options['prefix'], '/'); |
|
101 | - $options['prefix'] = $options['prefix'] ? $options['prefix'] . '/' : ''; |
|
100 | + $options['prefix'] = $scope['prefix'].trim($options['prefix'], '/'); |
|
101 | + $options['prefix'] = $options['prefix'] ? $options['prefix'].'/' : ''; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | if (isset($options['persist'])) { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | if (isset($options['namespace'])) { |
109 | - $options['namespace'] = $scope['namespace'] . trim($options['namespace'], '\\') . '\\'; |
|
109 | + $options['namespace'] = $scope['namespace'].trim($options['namespace'], '\\').'\\'; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | return $options + $scope; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | return false; |
217 | 217 | } |
218 | 218 | |
219 | - if (!preg_match('~^' . $this->getRegex() . '$~', $host, $matches)) { |
|
219 | + if (!preg_match('~^'.$this->getRegex().'$~', $host, $matches)) { |
|
220 | 220 | $hostVariables = null; |
221 | 221 | return false; |
222 | 222 | } |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | $options['host'] = $this->_link($this->getToken(), $params); |
243 | 243 | } |
244 | 244 | |
245 | - $scheme = $options['scheme'] !== '*' ? $options['scheme'] . '://' : '//'; |
|
246 | - return $scheme . $options['host']; |
|
245 | + $scheme = $options['scheme'] !== '*' ? $options['scheme'].'://' : '//'; |
|
246 | + return $scheme.$options['host']; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -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 | } |
@@ -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 | } |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | { |
369 | 369 | $this->_prefix = trim($prefix, '/'); |
370 | 370 | if ($this->_prefix) { |
371 | - $this->_prefix = '/' . $this->_prefix; |
|
371 | + $this->_prefix = '/'.$this->_prefix; |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | return $this; |
@@ -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 | |
@@ -520,10 +520,10 @@ discard block |
||
520 | 520 | $this->_variables = null; |
521 | 521 | |
522 | 522 | if (!$pattern || $pattern[0] !== '[') { |
523 | - $pattern = '/' . trim($pattern, '/'); |
|
523 | + $pattern = '/'.trim($pattern, '/'); |
|
524 | 524 | } |
525 | 525 | |
526 | - $this->_pattern = $this->_prefix . $pattern; |
|
526 | + $this->_pattern = $this->_prefix.$pattern; |
|
527 | 527 | |
528 | 528 | return $this; |
529 | 529 | } |
@@ -637,9 +637,9 @@ discard block |
||
637 | 637 | } |
638 | 638 | } |
639 | 639 | |
640 | - $path = '/' . trim($path, '/'); |
|
640 | + $path = '/'.trim($path, '/'); |
|
641 | 641 | |
642 | - if (!preg_match('~^' . $this->getRegex() . '$~', $path, $matches)) { |
|
642 | + if (!preg_match('~^'.$this->getRegex().'$~', $path, $matches)) { |
|
643 | 643 | return false; |
644 | 644 | } |
645 | 645 | $variables = $this->_buildVariables($matches); |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | } else { |
672 | 672 | $token = $parser::tokenize($pattern, '/'); |
673 | 673 | $rule = $parser::compile($token); |
674 | - if (preg_match_all('~' . $rule[0] . '~', $values[$i], $parts)) { |
|
674 | + if (preg_match_all('~'.$rule[0].'~', $values[$i], $parts)) { |
|
675 | 675 | foreach ($parts[1] as $value) { |
676 | 676 | if (strpos($value, '/') !== false) { |
677 | 677 | $variables[$name][] = explode('/', $value); |
@@ -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 | ); |
@@ -789,24 +789,24 @@ discard block |
||
789 | 789 | |
790 | 790 | $basePath = trim($options['basePath'], '/'); |
791 | 791 | if ($basePath) { |
792 | - $basePath = '/' . $basePath; |
|
792 | + $basePath = '/'.$basePath; |
|
793 | 793 | } |
794 | 794 | $link = isset($link) ? ltrim($link, '/') : ''; |
795 | - $link = $basePath . ($link ? '/' . $link : $link); |
|
796 | - $query = $options['query'] ? '?' . $options['query'] : ''; |
|
797 | - $fragment = $options['fragment'] ? '#' . $options['fragment'] : ''; |
|
795 | + $link = $basePath.($link ? '/'.$link : $link); |
|
796 | + $query = $options['query'] ? '?'.$options['query'] : ''; |
|
797 | + $fragment = $options['fragment'] ? '#'.$options['fragment'] : ''; |
|
798 | 798 | |
799 | 799 | if ($options['absolute']) { |
800 | 800 | if ($this->_host !== null) { |
801 | - $link = $this->_host->link($params, $options) . "{$link}"; |
|
801 | + $link = $this->_host->link($params, $options)."{$link}"; |
|
802 | 802 | } else { |
803 | - $scheme = !empty($options['scheme']) ? $options['scheme'] . '://' : '//'; |
|
803 | + $scheme = !empty($options['scheme']) ? $options['scheme'].'://' : '//'; |
|
804 | 804 | $host = isset($options['host']) ? $options['host'] : 'localhost'; |
805 | 805 | $link = "{$scheme}{$host}{$link}"; |
806 | 806 | } |
807 | 807 | } |
808 | 808 | |
809 | - return $link . $query . $fragment; |
|
809 | + return $link.$query.$fragment; |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -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,12 +854,12 @@ 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 | |
861 | - if (!preg_match('~^' . $child['pattern'] . '$~', $value)) { |
|
862 | - throw new RouterException("Expected `'" . $child['name'] . "'` to match `'" . $child['pattern'] . "'`, but received `'" . $value . "'`."); |
|
861 | + if (!preg_match('~^'.$child['pattern'].'$~', $value)) { |
|
862 | + throw new RouterException("Expected `'".$child['name']."'` to match `'".$child['pattern']."'`, but received `'".$value."'`."); |
|
863 | 863 | } |
864 | 864 | $link .= $value; |
865 | 865 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | public static function tokenize(string $pattern, string $delimiter = '/'): array |
81 | 81 | { |
82 | 82 | // Checks if the pattern has some optional segments. |
83 | - if (count(preg_split('~' . static::PLACEHOLDER_REGEX . '(*SKIP)(*F)|\[~x', $pattern)) > 1) { |
|
83 | + if (count(preg_split('~'.static::PLACEHOLDER_REGEX.'(*SKIP)(*F)|\[~x', $pattern)) > 1) { |
|
84 | 84 | $tokens = static::_tokenizePattern($pattern, $delimiter); |
85 | 85 | } else { |
86 | 86 | $tokens = static::_tokenizeSegment($pattern, $delimiter); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $index = 0; |
149 | 149 | $path = ''; |
150 | 150 | |
151 | - if (preg_match_all('~' . static::PLACEHOLDER_REGEX . '()~x', $pattern, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
151 | + if (preg_match_all('~'.static::PLACEHOLDER_REGEX.'()~x', $pattern, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
152 | 152 | foreach ($matches as $match) { |
153 | 153 | $offset = $match[0][1]; |
154 | 154 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | $variable = $match[1][0]; |
164 | - $capture = $match[2][0] ?: '[^' . $delimiter . ']+'; |
|
164 | + $capture = $match[2][0] ?: '[^'.$delimiter.']+'; |
|
165 | 165 | |
166 | 166 | $tokens[] = [ |
167 | 167 | 'name' => $variable, |
@@ -221,7 +221,7 @@ discard block |
||
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++; |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | if (count($rule[1]) > 1) { |
266 | 266 | throw ParserException::placeholderExceeded(); |
267 | 267 | } |
268 | - $regex .= '((?:' . $rule[0] . ')' . $child['greedy'] . ')'; |
|
268 | + $regex .= '((?:'.$rule[0].')'.$child['greedy'].')'; |
|
269 | 269 | } elseif ($child['optional']) { |
270 | - $regex .= '(?:' . $rule[0] . ')?'; |
|
270 | + $regex .= '(?:'.$rule[0].')?'; |
|
271 | 271 | } |
272 | 272 | foreach ($rule[1] as $name => $pattern) { |
273 | 273 | if (isset($variables[$name])) { |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $regex .= $child['pattern']; |
286 | 286 | } else { |
287 | 287 | $variables[$name] = false; |
288 | - $regex .= '(' . $child['pattern'] . ')'; |
|
288 | + $regex .= '('.$child['pattern'].')'; |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | } |
@@ -214,37 +214,37 @@ |
||
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 | - $patternKey = md5($options['pattern'] . '-' . $options['name']); |
|
228 | + $patternKey = md5($options['pattern'] . '-' . $options['name']); |
|
229 | 229 | |
230 | - if (isset($this->_pattern[$scheme][$host][$patternKey])) { |
|
231 | - $route = $this->_pattern[$scheme][$host][$patternKey]; |
|
232 | - } else { |
|
233 | - $this->_hosts[$scheme][$host] = $route->getHost(); |
|
234 | - } |
|
230 | + if (isset($this->_pattern[$scheme][$host][$patternKey])) { |
|
231 | + $route = $this->_pattern[$scheme][$host][$patternKey]; |
|
232 | + } else { |
|
233 | + $this->_hosts[$scheme][$host] = $route->getHost(); |
|
234 | + } |
|
235 | 235 | |
236 | - if (!isset($this->_pattern[$scheme][$host][$patternKey])) { |
|
237 | - $this->_pattern[$scheme][$host][$patternKey] = $route; |
|
238 | - } |
|
236 | + if (!isset($this->_pattern[$scheme][$host][$patternKey])) { |
|
237 | + $this->_pattern[$scheme][$host][$patternKey] = $route; |
|
238 | + } |
|
239 | 239 | |
240 | - $methods = $route->getMethods(); |
|
241 | - foreach ($methods as $method) { |
|
242 | - $this->_routes[$scheme][$host][strtoupper($method)][] = $route; |
|
243 | - } |
|
240 | + $methods = $route->getMethods(); |
|
241 | + foreach ($methods as $method) { |
|
242 | + $this->_routes[$scheme][$host][strtoupper($method)][] = $route; |
|
243 | + } |
|
244 | 244 | |
245 | - $this->_data[$route->getName()] = $route; |
|
245 | + $this->_data[$route->getName()] = $route; |
|
246 | 246 | |
247 | - return $this; |
|
247 | + return $this; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | public function setBasePath(string $basePath): self |
187 | 187 | { |
188 | 188 | $basePath = trim($basePath, '/'); |
189 | - $this->_basePath = $basePath ? '/' . $basePath : ''; |
|
189 | + $this->_basePath = $basePath ? '/'.$basePath : ''; |
|
190 | 190 | |
191 | 191 | return $this; |
192 | 192 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $options['host'] = $this->_hosts[$scheme][$host]; |
226 | 226 | } |
227 | 227 | |
228 | - $patternKey = md5($options['pattern'] . '-' . $options['name']); |
|
228 | + $patternKey = md5($options['pattern'].'-'.$options['name']); |
|
229 | 229 | |
230 | 230 | if (isset($this->_pattern[$scheme][$host][$patternKey])) { |
231 | 231 | $route = $this->_pattern[$scheme][$host][$patternKey]; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $options['host'] = $this->_hosts[$scheme][$host]; |
290 | 290 | } |
291 | 291 | |
292 | - $patternKey = md5($options['pattern'] . '-' . $options['name']); |
|
292 | + $patternKey = md5($options['pattern'].'-'.$options['name']); |
|
293 | 293 | |
294 | 294 | if (isset($this->_pattern[$scheme][$host][$patternKey])) { |
295 | 295 | $instance = $this->_pattern[$scheme][$host][$patternKey]; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $this->_pattern[$scheme][$host][$patternKey] = $instance; |
304 | 304 | } |
305 | 305 | |
306 | - $methods = $options['methods'] ? (array)$options['methods'] : []; |
|
306 | + $methods = $options['methods'] ? (array) $options['methods'] : []; |
|
307 | 307 | |
308 | 308 | $instance->allow($methods); |
309 | 309 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $request = $parsed + $request; |
431 | 431 | } |
432 | 432 | |
433 | - $request['path'] = (ltrim((string)strtok($request['path'], '?'), '/')); |
|
433 | + $request['path'] = (ltrim((string) strtok($request['path'], '?'), '/')); |
|
434 | 434 | $request['method'] = strtoupper($request['method']); |
435 | 435 | |
436 | 436 | return $request; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | it("matches on methods", function() { |
72 | 72 | |
73 | 73 | $r = $this->router; |
74 | - $r->bind('foo/bar', ['methods' => ['POST', 'PUT']], function () {}); |
|
74 | + $r->bind('foo/bar', ['methods' => ['POST', 'PUT']], function() {}); |
|
75 | 75 | |
76 | 76 | $route = $r->route('foo/bar', 'POST'); |
77 | 77 | expect($route->getMethods())->toBe(['POST', 'PUT']); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | it("supports lowercase method names", function() { |
90 | 90 | |
91 | 91 | $r = $this->router; |
92 | - $r->bind('foo/bar', ['methods' => ['POST', 'PUT']], function () {}); |
|
92 | + $r->bind('foo/bar', ['methods' => ['POST', 'PUT']], function() {}); |
|
93 | 93 | |
94 | 94 | $route = $r->route('foo/bar', 'post'); |
95 | 95 | expect($route->getMethods())->toBe(['POST', 'PUT']); |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | |
107 | 107 | it("matches on same path different methods", function() { |
108 | 108 | $r = $this->router; |
109 | - $r->bind('foo/bar', ['name' => 'foo', 'methods' => ['POST']], function () {}); |
|
110 | - $r->bind('foo/bar', ['name' => 'bar', 'methods' => ['PUT']], function () {}); |
|
109 | + $r->bind('foo/bar', ['name' => 'foo', 'methods' => ['POST']], function() {}); |
|
110 | + $r->bind('foo/bar', ['name' => 'bar', 'methods' => ['PUT']], function() {}); |
|
111 | 111 | |
112 | 112 | $route = $r->route('foo/bar', 'POST'); |
113 | 113 | expect($route->name)->toBe('foo'); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $r->basePath('app'); |
149 | 149 | |
150 | 150 | $r->group(['host' => 'www.{domain}.com', 'scheme' => 'https'], function($r) { |
151 | - $r->bind('foo/{bar}', ['name' => 'foo'], function () {}); |
|
151 | + $r->bind('foo/{bar}', ['name' => 'foo'], function() {}); |
|
152 | 152 | }); |
153 | 153 | |
154 | 154 | $link = $r->link('foo', [ |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $r = $this->router; |
165 | 165 | $r->group('foo', ['name' => 'foz'], function($r) { |
166 | 166 | $r->group('bar', ['name' => 'baz'], function($r) { |
167 | - $r->bind('{var1}', ['name' => 'quz'], function () {}); |
|
167 | + $r->bind('{var1}', ['name' => 'quz'], function() {}); |
|
168 | 168 | }); |
169 | 169 | }); |
170 | 170 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | $r = $this->router; |
179 | 179 | $r->group('{locale:en|fr}', ['persist' => 'locale'], function($r) { |
180 | - $r->bind('{controller}/{action}[/{id}]', ['name' => 'controller'], function () {}); |
|
180 | + $r->bind('{controller}/{action}[/{id}]', ['name' => 'controller'], function() {}); |
|
181 | 181 | }); |
182 | 182 | |
183 | 183 | $r->route('fr/post/index'); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | $r = $this->router; |
204 | 204 | $r->group('{locale:en|fr}', ['persist' => 'locale'], function($r) { |
205 | - $r->bind('{controller}/{action}[/{id}]', ['name' => 'controller'], function () {}); |
|
205 | + $r->bind('{controller}/{action}[/{id}]', ['name' => 'controller'], function() {}); |
|
206 | 206 | }); |
207 | 207 | |
208 | 208 | $r->route('fr/post/index'); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | it("routes on a simple route", function() { |
234 | 234 | |
235 | 235 | $r = $this->router; |
236 | - $r->bind('foo/bar', function () {}); |
|
236 | + $r->bind('foo/bar', function() {}); |
|
237 | 237 | |
238 | 238 | $route = $r->route('foo/bar', 'GET'); |
239 | 239 | expect($this->export($route->request))->toEqual([ |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | it("routes on a named route", function() { |
254 | 254 | |
255 | 255 | $r = $this->router; |
256 | - $r->bind('foo/bar', ['name' => 'foo'], function () {}); |
|
256 | + $r->bind('foo/bar', ['name' => 'foo'], function() {}); |
|
257 | 257 | |
258 | 258 | $route = $r->route('foo/bar', 'GET'); |
259 | 259 | expect($route->name)->toBe('foo'); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | it("supports empty as index route", function() { |
269 | 269 | |
270 | 270 | $r = $this->router; |
271 | - $r->bind('', function () {}); |
|
271 | + $r->bind('', function() {}); |
|
272 | 272 | |
273 | 273 | $route = $r->route('', 'GET'); |
274 | 274 | expect($this->export($route->request))->toEqual([ |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | it("supports a slash as indes route", function() { |
284 | 284 | |
285 | 285 | $r = $this->router; |
286 | - $r->bind('/', function () {}); |
|
286 | + $r->bind('/', function() {}); |
|
287 | 287 | |
288 | 288 | $route = $r->route('', 'GET'); |
289 | 289 | expect($this->export($route->request))->toEqual([ |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | $r->get('foo/{var1:\d+}', ['host' => '{subdomain:foo}.{domain}.bar'], function() {}); |
426 | 426 | |
427 | 427 | $route = $r->route('foo/25', 'GET', 'foo.biz.bar'); |
428 | - expect($route->params)->toBe([ 'subdomain' => 'foo', 'domain' => 'biz', 'var1' => '25']); |
|
428 | + expect($route->params)->toBe(['subdomain' => 'foo', 'domain' => 'biz', 'var1' => '25']); |
|
429 | 429 | |
430 | 430 | try { |
431 | 431 | $route = $r->route('foo/bar', 'GET', 'foo.biz.bar'); |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | it("supports RESTful routes", function() { |
454 | 454 | |
455 | 455 | $r = $this->router; |
456 | - $r->get('foo/bar', function () {}); |
|
457 | - $r->head('foo/bar', function () {}); |
|
458 | - $r->post('foo/bar', function () {}); |
|
459 | - $r->put('foo/bar', function () {}); |
|
460 | - $r->patch('foo/bar', function () {}); |
|
461 | - $r->delete('foo/bar', function () {}); |
|
462 | - $r->options('foo/bar', function () {}); |
|
456 | + $r->get('foo/bar', function() {}); |
|
457 | + $r->head('foo/bar', function() {}); |
|
458 | + $r->post('foo/bar', function() {}); |
|
459 | + $r->put('foo/bar', function() {}); |
|
460 | + $r->patch('foo/bar', function() {}); |
|
461 | + $r->delete('foo/bar', function() {}); |
|
462 | + $r->options('foo/bar', function() {}); |
|
463 | 463 | |
464 | 464 | $methods = ['OPTIONS', 'DELETE', 'PATCH', 'PUT', 'POST', 'HEAD', 'GET']; |
465 | 465 | |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | it("matches relationships based routes", function() { |
490 | 490 | |
491 | 491 | $r = $this->router; |
492 | - $r->get('[/{relations:[^/]+/[^/:][^/]*}]*/comment[/{id:[^/:][^/]*}][/:{action}]', function () {}); |
|
492 | + $r->get('[/{relations:[^/]+/[^/:][^/]*}]*/comment[/{id:[^/:][^/]*}][/:{action}]', function() {}); |
|
493 | 493 | |
494 | 494 | $route = $r->route('blog/1/post/22/comment/:show', 'GET'); |
495 | 495 | expect($route->params)->toBe([ |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | it("dispatches HEAD requests on matching GET routes if the HEAD routes are missing", function() { |
507 | 507 | |
508 | 508 | $r = $this->router; |
509 | - $r->get('foo/bar', function () { return 'GET'; }); |
|
509 | + $r->get('foo/bar', function() { return 'GET'; }); |
|
510 | 510 | |
511 | 511 | $route = $r->route('foo/bar', 'HEAD'); |
512 | 512 | expect($route->getMethods())->toBe(['GET']); |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | |
518 | 518 | $r = $this->router; |
519 | 519 | |
520 | - $r->head('foo/bar', function () { return 'HEAD'; }); |
|
521 | - $r->get('foo/bar', function () { return 'GET'; }); |
|
520 | + $r->head('foo/bar', function() { return 'HEAD'; }); |
|
521 | + $r->get('foo/bar', function() { return 'GET'; }); |
|
522 | 522 | |
523 | 523 | $route = $r->route('foo/bar', 'HEAD'); |
524 | 524 | expect($route->getMethods())->toBe(['GET', 'HEAD']); |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | it("supports requests as a list of arguments", function() { |
529 | 529 | |
530 | 530 | $r = $this->router; |
531 | - $r->bind('foo/bar', function () {}); |
|
531 | + $r->bind('foo/bar', function() {}); |
|
532 | 532 | |
533 | 533 | $route = $r->route('foo/bar', 'GET'); |
534 | 534 | expect($this->export($route->request))->toEqual([ |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | |
543 | 543 | it("supports requests as an object", function() { |
544 | 544 | $r = $this->router; |
545 | - $r->bind('foo/bar', function () {}); |
|
545 | + $r->bind('foo/bar', function() {}); |
|
546 | 546 | |
547 | 547 | $request = Double::instance(['implements' => ServerRequestInterface::class]); |
548 | 548 | $uri = Double::instance(['implements' => UriInterface::class]); |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | it("supports requests as an array", function() { |
563 | 563 | |
564 | 564 | $r = $this->router; |
565 | - $r->bind('foo/bar', function () {}); |
|
565 | + $r->bind('foo/bar', function() {}); |
|
566 | 566 | |
567 | 567 | $route = $r->route(['path' =>'foo/bar'], 'GET'); |
568 | 568 | expect($this->export($route->request))->toEqual([ |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | |
611 | 611 | $r = $this->router; |
612 | 612 | $r->group('foo', function($r) { |
613 | - $r->bind('{var1}', function () {}); |
|
613 | + $r->bind('{var1}', function() {}); |
|
614 | 614 | }); |
615 | 615 | |
616 | 616 | }); |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | |
624 | 624 | }); |
625 | 625 | |
626 | - it("throws an exception when the prefix does not match", function () { |
|
626 | + it("throws an exception when the prefix does not match", function() { |
|
627 | 627 | |
628 | - $closure = function () { |
|
628 | + $closure = function() { |
|
629 | 629 | $r = $this->router; |
630 | 630 | $route = $r->route('bar/foo', 'GET'); |
631 | 631 | }; |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | |
641 | 641 | $r = $this->router; |
642 | 642 | $r->group('foo', function($r) { |
643 | - $r->bind('[{var1}]', function () {}); |
|
643 | + $r->bind('[{var1}]', function() {}); |
|
644 | 644 | }); |
645 | 645 | |
646 | 646 | }); |
@@ -653,9 +653,9 @@ discard block |
||
653 | 653 | |
654 | 654 | }); |
655 | 655 | |
656 | - it("throws an exception when the prefix does not match", function () { |
|
656 | + it("throws an exception when the prefix does not match", function() { |
|
657 | 657 | |
658 | - $closure = function () { |
|
658 | + $closure = function() { |
|
659 | 659 | $r = $this->router; |
660 | 660 | $route = $r->route('bar/foo', 'GET'); |
661 | 661 | }; |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | $r = $this->router; |
672 | 672 | $r->group('foo', ['host' => 'foo.{domain}.bar'], function($r) { |
673 | 673 | $r->group('bar', function($r) { |
674 | - $r->bind('{var1}', function () {}); |
|
674 | + $r->bind('{var1}', function() {}); |
|
675 | 675 | }); |
676 | 676 | }); |
677 | 677 | |
@@ -688,9 +688,9 @@ discard block |
||
688 | 688 | |
689 | 689 | }); |
690 | 690 | |
691 | - it("throws an exception when the host does not match", function () { |
|
691 | + it("throws an exception when the host does not match", function() { |
|
692 | 692 | |
693 | - $closure = function () { |
|
693 | + $closure = function() { |
|
694 | 694 | $r = $this->router; |
695 | 695 | $route = $r->route('http://bar.hello.foo/foo/bar/baz', 'GET'); |
696 | 696 | }; |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | $r = $this->router; |
707 | 707 | $r->group('foo', ['scheme' => 'http'], function($r) { |
708 | 708 | $r->group('bar', function($r) { |
709 | - $r->bind('{var1}', function () {}); |
|
709 | + $r->bind('{var1}', function() {}); |
|
710 | 710 | }); |
711 | 711 | }); |
712 | 712 | |
@@ -722,9 +722,9 @@ discard block |
||
722 | 722 | |
723 | 723 | }); |
724 | 724 | |
725 | - it("throws an exception when route is not found", function () { |
|
725 | + it("throws an exception when route is not found", function() { |
|
726 | 726 | |
727 | - $closure = function () { |
|
727 | + $closure = function() { |
|
728 | 728 | $r = $this->router; |
729 | 729 | $route = $r->route('https://domain.com/foo/bar/baz', 'GET'); |
730 | 730 | }; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | $r = $this->router; |
739 | 739 | $r->group('foo', ['namespace' => 'My'], function($r) { |
740 | 740 | $r->group('bar', ['namespace' => 'Name'], function($r) { |
741 | - $r->bind('{var1}', ['namespace' => 'Space'], function () {}); |
|
741 | + $r->bind('{var1}', ['namespace' => 'Space'], function() {}); |
|
742 | 742 | }); |
743 | 743 | }); |
744 | 744 | |
@@ -767,10 +767,10 @@ discard block |
||
767 | 767 | $r = $this->router; |
768 | 768 | |
769 | 769 | $mw1 = function($request, $response, $next) { |
770 | - return '1' . $next() . '1'; |
|
770 | + return '1'.$next().'1'; |
|
771 | 771 | }; |
772 | 772 | $mw2 = function($request, $response, $next) { |
773 | - return '2' . $next() . '2'; |
|
773 | + return '2'.$next().'2'; |
|
774 | 774 | }; |
775 | 775 | |
776 | 776 | $r->apply($mw1, $mw2); |
@@ -797,9 +797,9 @@ discard block |
||
797 | 797 | $r = $this->router; |
798 | 798 | |
799 | 799 | $r->apply(function($request, $response, $next) { |
800 | - return '1' . $next() . '1'; |
|
800 | + return '1'.$next().'1'; |
|
801 | 801 | })->apply(function($request, $response, $next) { |
802 | - return '2' . $next() . '2'; |
|
802 | + return '2'.$next().'2'; |
|
803 | 803 | }); |
804 | 804 | |
805 | 805 | $route = $r->bind('/foo/bar', function($route) { |
@@ -818,19 +818,19 @@ discard block |
||
818 | 818 | $r = $this->router; |
819 | 819 | |
820 | 820 | $r->apply(function($request, $response, $next) { |
821 | - return '1' . $next() . '1'; |
|
821 | + return '1'.$next().'1'; |
|
822 | 822 | }); |
823 | 823 | |
824 | - $r->bind('foo/{foo}', ['name' => 'foo'], function () { |
|
824 | + $r->bind('foo/{foo}', ['name' => 'foo'], function() { |
|
825 | 825 | return 'A'; |
826 | 826 | }); |
827 | 827 | |
828 | 828 | $r->group('bar', function($r) { |
829 | - $r->bind('{bar}', ['name' => 'bar'], function () { |
|
829 | + $r->bind('{bar}', ['name' => 'bar'], function() { |
|
830 | 830 | return 'A'; |
831 | 831 | }); |
832 | 832 | })->apply(function($request, $response, $next) { |
833 | - return '2' . $next() . '2'; |
|
833 | + return '2'.$next().'2'; |
|
834 | 834 | }); |
835 | 835 | |
836 | 836 | $route = $r->route('foo/foo'); |