@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | /** |
| 183 | 183 | * Reflect Controller construct and get parameters. |
| 184 | 184 | * |
| 185 | - * @param $controllerName |
|
| 185 | + * @param string $controllerName |
|
| 186 | 186 | * @internal |
| 187 | 187 | * |
| 188 | 188 | * @return \ReflectionParameter[] |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | /** |
| 309 | 309 | * Checks controller instance against whitelist. |
| 310 | 310 | * |
| 311 | - * @param $controller |
|
| 311 | + * @param string $controller |
|
| 312 | 312 | * @param $options |
| 313 | 313 | * @throws DispatchException |
| 314 | 314 | */ |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | /** |
| 343 | 343 | * Checks controller instance against blacklist. |
| 344 | 344 | * |
| 345 | - * @param $controller |
|
| 345 | + * @param string $controller |
|
| 346 | 346 | * @param $options |
| 347 | 347 | * @throws DispatchException |
| 348 | 348 | */ |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | /** |
| 375 | 375 | * With Class Namespace. |
| 376 | 376 | * |
| 377 | - * @param $namespace |
|
| 377 | + * @param string $namespace |
|
| 378 | 378 | * @return Dispatcher |
| 379 | 379 | */ |
| 380 | 380 | public function withNamespace($namespace) |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | /** |
| 388 | 388 | * With class Namespaces. |
| 389 | 389 | * |
| 390 | - * @param array $namespaces |
|
| 390 | + * @param string[] $namespaces |
|
| 391 | 391 | * @return Dispatcher |
| 392 | 392 | */ |
| 393 | 393 | public function withNamespaces(array $namespaces) |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $handler = 'my-handler'; |
| 35 | 35 | $routes = $this->collection; |
| 36 | - $routes->group('/path', function () use ($routes, $handler) { |
|
| 36 | + $routes->group('/path', function() use ($routes, $handler) { |
|
| 37 | 37 | $routes->addRoute(['GET', 'POST'], '/foo', $handler, ['global']); |
| 38 | - $routes->group('/sub-dir', function () use ($routes, $handler) { |
|
| 38 | + $routes->group('/sub-dir', function() use ($routes, $handler) { |
|
| 39 | 39 | $routes->addRoute(['GET'], '/sub-page', $handler, ['sub-dir']); |
| 40 | 40 | }); |
| 41 | 41 | }); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | public function testMergeCollection() |
| 176 | 176 | { |
| 177 | 177 | $handler = 'handler::string'; |
| 178 | - $names = ['routes','names']; |
|
| 178 | + $names = ['routes', 'names']; |
|
| 179 | 179 | $collection = new RouteCollection(); |
| 180 | 180 | $collection->addRoute('GET', '/path', $handler, $names); |
| 181 | 181 | $collection->addRoute('GET', '/another', $handler, $names); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | { |
| 195 | 195 | $this->setExpectedException(RouteException::class); |
| 196 | 196 | $handler = 'handler::string'; |
| 197 | - $names = ['routes','names']; |
|
| 197 | + $names = ['routes', 'names']; |
|
| 198 | 198 | $collection = new RouteCollection(); |
| 199 | 199 | $collection->addRoute('GET', '/path', $handler, $names); |
| 200 | 200 | $collection->addRoute('GET', '/another', $handler, $names); |
@@ -245,11 +245,11 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function testMergeGroupNames() |
| 247 | 247 | { |
| 248 | - $expected = ['route-name','group-name']; |
|
| 248 | + $expected = ['route-name', 'group-name']; |
|
| 249 | 249 | $handler = 'myhandler'; |
| 250 | 250 | $routes = $this->collection; |
| 251 | 251 | |
| 252 | - $routes->group('/path', function () use ($routes, $handler) { |
|
| 252 | + $routes->group('/path', function() use ($routes, $handler) { |
|
| 253 | 253 | $routes->addRoute(['GET', 'POST'], '/foo', $handler, ['route-name']); |
| 254 | 254 | }, ['group-name']); |
| 255 | 255 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | /** |
| 261 | 261 | * Test that the namespace is matched to the handler and returned. |
| 262 | 262 | */ |
| 263 | - public function testFindHandlerNamespace(){ |
|
| 263 | + public function testFindHandlerNamespace() { |
|
| 264 | 264 | |
| 265 | 265 | $routeCollection = new RouteCollection(); |
| 266 | 266 | $routeCollection->addNamespace('\Rs\Router'); |
@@ -272,13 +272,13 @@ discard block |
||
| 272 | 272 | $reflectionMethod->setAccessible(true); |
| 273 | 273 | $actual = $reflectionMethod->invoke($routeCollection, $handler); |
| 274 | 274 | |
| 275 | - $this->assertEquals($expected,$actual); |
|
| 275 | + $this->assertEquals($expected, $actual); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
| 279 | 279 | * Test that backlash is added to start of namespace on response. |
| 280 | 280 | */ |
| 281 | - public function testFindHandlerNamespaceNoBacklash(){ |
|
| 281 | + public function testFindHandlerNamespaceNoBacklash() { |
|
| 282 | 282 | |
| 283 | 283 | $routeCollection = new RouteCollection(); |
| 284 | 284 | $routeCollection->addNamespace('Rs\Router'); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $reflectionMethod->setAccessible(true); |
| 291 | 291 | $actual = $reflectionMethod->invoke($routeCollection, $handler); |
| 292 | 292 | |
| 293 | - $this->assertEquals($expected,$actual); |
|
| 293 | + $this->assertEquals($expected, $actual); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | } |
@@ -77,7 +77,7 @@ |
||
| 77 | 77 | ->with($this->collection, $method, $path) |
| 78 | 78 | ->willReturn($actual); |
| 79 | 79 | |
| 80 | - $expected = $this->router->getRouterResponseFromPath($method,$path); |
|
| 80 | + $expected = $this->router->getRouterResponseFromPath($method, $path); |
|
| 81 | 81 | $this->assertEquals($expected, $actual); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @param string $handler |
| 101 | 101 | * @return RouterResponse |
| 102 | 102 | */ |
| 103 | - public function withHandler(string $handler){ |
|
| 103 | + public function withHandler(string $handler) { |
|
| 104 | 104 | $new = clone $this; |
| 105 | 105 | $new->handler = $handler; |
| 106 | 106 | return $new; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param array $vars |
| 111 | 111 | * @return RouterResponse |
| 112 | 112 | */ |
| 113 | - public function withVars(array $vars){ |
|
| 113 | + public function withVars(array $vars) { |
|
| 114 | 114 | $new = clone $this; |
| 115 | 115 | $new->vars = $vars; |
| 116 | 116 | return $new; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @param int $code |
| 121 | 121 | * @return RouterResponse |
| 122 | 122 | */ |
| 123 | - public function withStatusCode(int $code){ |
|
| 123 | + public function withStatusCode(int $code) { |
|
| 124 | 124 | $new = clone $this; |
| 125 | 125 | $new->statusCode = $code; |
| 126 | 126 | return $new; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @param array $names |
| 131 | 131 | * @return RouterResponse |
| 132 | 132 | */ |
| 133 | - public function withNames(array $names){ |
|
| 133 | + public function withNames(array $names) { |
|
| 134 | 134 | $new = clone $this; |
| 135 | 135 | $new->names = $names; |
| 136 | 136 | return $new; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $this->adaptor = $adaptor; |
| 54 | 54 | $this->collection = $collection; |
| 55 | 55 | |
| 56 | - if (isset($options['ignoreTrailingSlash'])){ |
|
| 56 | + if (isset($options['ignoreTrailingSlash'])) { |
|
| 57 | 57 | $this->ignoreTrailingSlash = (bool)$options['ignoreTrailingSlash']; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | $requestUri = $request->getUri()->getPath(); |
| 69 | 69 | |
| 70 | 70 | |
| 71 | - if ($this->ignoreTrailingSlash === true && $requestUri !== '/'){ |
|
| 72 | - $requestUri = rtrim($requestUri,'/'); |
|
| 71 | + if ($this->ignoreTrailingSlash === true && $requestUri !== '/') { |
|
| 72 | + $requestUri = rtrim($requestUri, '/'); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return $this->adaptor->match( |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | /** |
| 154 | 154 | * @param bool $ignore |
| 155 | 155 | */ |
| 156 | - public function disableTrailingSlash($ignore = true){ |
|
| 156 | + public function disableTrailingSlash($ignore = true) { |
|
| 157 | 157 | $this->ignoreTrailingSlash = $ignore; |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function addNamespace(string $namespace) |
| 83 | 83 | { |
| 84 | - $formattedNamespace = '\\'.ltrim($namespace,'\\'); |
|
| 84 | + $formattedNamespace = '\\' . ltrim($namespace, '\\'); |
|
| 85 | 85 | $this->namespace[] = $formattedNamespace; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $route = \implode('', $this->group) . $routePattern; |
| 232 | 232 | |
| 233 | - if (substr($route, -1) === '/' && strlen($route) > 1){ |
|
| 234 | - $route = rtrim($route,'/'); |
|
| 233 | + if (substr($route, -1) === '/' && strlen($route) > 1) { |
|
| 234 | + $route = rtrim($route, '/'); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | return $route; |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | ) |
| 254 | 254 | ); |
| 255 | 255 | $new->collection[] = $addRoute; |
| 256 | - } catch (\Exception $e) { |
|
| 256 | + }catch (\Exception $e) { |
|
| 257 | 257 | if ($throw) { |
| 258 | 258 | throw new RouteException($e->getMessage()); |
| 259 | 259 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | $this->options = $options; |
| 136 | 136 | |
| 137 | 137 | return \FastRoute\cachedDispatcher( |
| 138 | - function (RouteCollector $fastRouteCollector) use ($routes) { |
|
| 138 | + function(RouteCollector $fastRouteCollector) use ($routes) { |
|
| 139 | 139 | /** |
| 140 | 140 | * @var $route RouteInterface |
| 141 | 141 | */ |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $routes = (array)require $cacheFile; |
| 234 | 234 | |
| 235 | 235 | foreach ($routes[0] as $routeMethod => $routeData) { |
| 236 | - foreach ($routeData as $routePattern => $routeContent){ |
|
| 236 | + foreach ($routeData as $routePattern => $routeContent) { |
|
| 237 | 237 | $routePath = \rtrim($context, '/') . DIRECTORY_SEPARATOR . \ltrim($routePattern, '/'); |
| 238 | 238 | $collection->addRoute($routeMethod, $routePath, $routeContent['content'], $routeContent['name']); |
| 239 | 239 | } |