@@ -160,6 +160,7 @@ |
||
| 160 | 160 | * @param string $action |
| 161 | 161 | * @param int $returnType |
| 162 | 162 | * @param string $alias |
| 163 | + * @param string $requestMethods |
|
| 163 | 164 | * @throws InvalidArgumentException |
| 164 | 165 | * @throws UnexpectedValueException |
| 165 | 166 | */ |
@@ -267,8 +267,8 @@ discard block |
||
| 267 | 267 | 'routeCollector' => FastRoute\RouteCollector::class, |
| 268 | 268 | ]; |
| 269 | 269 | /** |
| 270 | - * @var \FastRoute\RouteCollector $routeCollector |
|
| 271 | - */ |
|
| 270 | + * @var \FastRoute\RouteCollector $routeCollector |
|
| 271 | + */ |
|
| 272 | 272 | $routeCollector = new $options['routeCollector']( |
| 273 | 273 | new $options['routeParser'], new $options['dataGenerator'] |
| 274 | 274 | ); |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | ); |
| 298 | 298 | $this->addRoutes($routeCollector); |
| 299 | 299 | /** |
| 300 | - * @var FastRoute\RouteCollector $routeCollector |
|
| 301 | - */ |
|
| 300 | + * @var FastRoute\RouteCollector $routeCollector |
|
| 301 | + */ |
|
| 302 | 302 | $dispatchData = $routeCollector->getData(); |
| 303 | 303 | file_put_contents( |
| 304 | 304 | $this->cachedFile, |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | string $method, |
| 123 | 123 | string $requestedPath, |
| 124 | 124 | string $folder = '', |
| 125 | - ?string $cachedFile = null |
|
| 125 | + ? string $cachedFile = null |
|
| 126 | 126 | ) { |
| 127 | 127 | if (!in_array($method, self::$validRequestMethods, true)) { |
| 128 | 128 | $message = sprintf('%s is not valid Http request method.', $method); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | $this->method = $method; |
| 132 | 132 | $this->requestedPath = $this->extractFolder($requestedPath, $folder); |
| 133 | - $this->defaultReturnType = ($defaultReturnType >=1 && $defaultReturnType <=7) ? $defaultReturnType : self::HTML; |
|
| 133 | + $this->defaultReturnType = ($defaultReturnType >= 1 && $defaultReturnType <= 7) ? $defaultReturnType : self::HTML; |
|
| 134 | 134 | $this->cachedFile = $cachedFile; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | $requestMethods, |
| 168 | 168 | string $route, |
| 169 | 169 | string $action, |
| 170 | - ?int $returnType = null, |
|
| 171 | - ?string $alias = null |
|
| 170 | + ? int $returnType = null, |
|
| 171 | + ? string $alias = null |
|
| 172 | 172 | ) : void { |
| 173 | 173 | |
| 174 | 174 | $requestMethodsGiven = is_array($requestMethods) ? (array) $requestMethods : [0 => $requestMethods]; |
@@ -206,12 +206,12 @@ discard block |
||
| 206 | 206 | * @param int|null $returnType |
| 207 | 207 | * @return int |
| 208 | 208 | */ |
| 209 | - private function determineReturnType(?int $returnType) : int |
|
| 209 | + private function determineReturnType(? int $returnType) : int |
|
| 210 | 210 | { |
| 211 | 211 | if ($returnType === null) { |
| 212 | 212 | return $this->defaultReturnType; |
| 213 | 213 | } |
| 214 | - return ($returnType >=1 && $returnType <=7) ? $returnType : self::HTML; |
|
| 214 | + return ($returnType >= 1 && $returnType <= 7) ? $returnType : self::HTML; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | $this->cachedFile, |
| 305 | 305 | '<?php return ' . var_export($dispatchData, true) . ';' |
| 306 | 306 | ); |
| 307 | - return new $options['dispatcher']($dispatchData ); |
|
| 307 | + return new $options['dispatcher']($dispatchData); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -314,23 +314,23 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | private function addRoutes(FastRoute\RouteCollector $route) : void |
| 316 | 316 | { |
| 317 | - $routeIndex=0; |
|
| 317 | + $routeIndex = 0; |
|
| 318 | 318 | foreach ($this->routes as $definedRoute) { |
| 319 | 319 | $definedRoute[3] = $definedRoute[3] ?? $this->defaultReturnType; |
| 320 | - $routeName = 'routeClosure'.$routeIndex; |
|
| 320 | + $routeName = 'routeClosure' . $routeIndex; |
|
| 321 | 321 | $route->addRoute(strtoupper($definedRoute[0]), $definedRoute[1], $routeName); |
| 322 | 322 | $routeIndex++; |
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | private function setRouteClosures() : void |
| 326 | 326 | { |
| 327 | - $routeIndex=0; |
|
| 327 | + $routeIndex = 0; |
|
| 328 | 328 | foreach ($this->routes as $definedRoute) { |
| 329 | 329 | $definedRoute[3] = $definedRoute[3] ?? $this->defaultReturnType; |
| 330 | - $routeName = 'routeClosure'.$routeIndex; |
|
| 330 | + $routeName = 'routeClosure' . $routeIndex; |
|
| 331 | 331 | [$requestMedhod, $url, $controller, $returnType] = $definedRoute; |
| 332 | - $returnType = ($returnType >=1 && $returnType <=7) ? $returnType : $this->defaultReturnType; |
|
| 333 | - $this->routerClosures[$routeName]= function ($args) use ($controller, $returnType) { |
|
| 332 | + $returnType = ($returnType >= 1 && $returnType <= 7) ? $returnType : $this->defaultReturnType; |
|
| 333 | + $this->routerClosures[$routeName] = function($args) use ($controller, $returnType) { |
|
| 334 | 334 | return ['controller' => $controller, 'returnType'=> $returnType, 'args'=> $args]; |
| 335 | 335 | }; |
| 336 | 336 | $routeIndex++; |