@@ -161,6 +161,7 @@ discard block |
||
161 | 161 | * @param string $action |
162 | 162 | * @param int $returnType |
163 | 163 | * @param string $alias |
164 | + * @param string $requestMethods |
|
164 | 165 | * @throws InvalidArgumentException |
165 | 166 | * @throws UnexpectedValueException |
166 | 167 | */ |
@@ -272,6 +273,9 @@ discard block |
||
272 | 273 | return new FastRoute\Dispatcher\GroupCountBased($routeCollector->getData()); |
273 | 274 | } |
274 | 275 | |
276 | + /** |
|
277 | + * @param FastRoute\RouteCollector $routeCollector |
|
278 | + */ |
|
275 | 279 | private function createCachedRoute($routeCollector ) : void |
276 | 280 | { |
277 | 281 | if ($this->cachedFile !== null && !file_exists($this->cachedFile)) { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | string $method, |
124 | 124 | string $requestedPath, |
125 | 125 | string $folder = '', |
126 | - ?string $cachedFile = null |
|
126 | + ? string $cachedFile = null |
|
127 | 127 | ) { |
128 | 128 | if (!in_array($method, self::$validRequestMethods, true)) { |
129 | 129 | $message = sprintf('%s is not valid Http request method.', $method); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | $this->method = $method; |
133 | 133 | $this->requestedPath = $this->extractFolder($requestedPath, $folder); |
134 | - $this->defaultReturnType = ($defaultReturnType >=1 && $defaultReturnType <=7) ? $defaultReturnType : self::HTML; |
|
134 | + $this->defaultReturnType = ($defaultReturnType >= 1 && $defaultReturnType <= 7) ? $defaultReturnType : self::HTML; |
|
135 | 135 | $this->cachedFile = $cachedFile; |
136 | 136 | } |
137 | 137 | |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | $requestMethods, |
169 | 169 | string $route, |
170 | 170 | string $action, |
171 | - ?int $returnType = null, |
|
172 | - ?string $alias = null |
|
171 | + ? int $returnType = null, |
|
172 | + ? string $alias = null |
|
173 | 173 | ) : void { |
174 | 174 | |
175 | 175 | $requestMethodsGiven = is_array($requestMethods) ? (array) $requestMethods : [0 => $requestMethods]; |
@@ -207,12 +207,12 @@ discard block |
||
207 | 207 | * @param int|null $returnType |
208 | 208 | * @return int |
209 | 209 | */ |
210 | - private function determineReturnType(?int $returnType) : int |
|
210 | + private function determineReturnType(? int $returnType) : int |
|
211 | 211 | { |
212 | 212 | if ($returnType === null) { |
213 | 213 | return $this->defaultReturnType; |
214 | 214 | } |
215 | - return ($returnType >=1 && $returnType <=7) ? $returnType : self::HTML; |
|
215 | + return ($returnType >= 1 && $returnType <= 7) ? $returnType : self::HTML; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | return new FastRoute\Dispatcher\GroupCountBased($routeCollector->getData()); |
273 | 273 | } |
274 | 274 | |
275 | - private function createCachedRoute($routeCollector ) : void |
|
275 | + private function createCachedRoute($routeCollector) : void |
|
276 | 276 | { |
277 | 277 | if ($this->cachedFile !== null && !file_exists($this->cachedFile)) { |
278 | 278 | /** |
@@ -303,23 +303,23 @@ discard block |
||
303 | 303 | */ |
304 | 304 | private function addRoutes(FastRoute\RouteCollector $route) : void |
305 | 305 | { |
306 | - $routeIndex=0; |
|
306 | + $routeIndex = 0; |
|
307 | 307 | foreach ($this->routes as $definedRoute) { |
308 | 308 | $definedRoute[3] = $definedRoute[3] ?? $this->defaultReturnType; |
309 | - $routeName = 'routeClosure'.$routeIndex; |
|
309 | + $routeName = 'routeClosure' . $routeIndex; |
|
310 | 310 | $route->addRoute(strtoupper($definedRoute[0]), $definedRoute[1], $routeName); |
311 | 311 | $routeIndex++; |
312 | 312 | } |
313 | 313 | } |
314 | 314 | private function setRouteClosures() : void |
315 | 315 | { |
316 | - $routeIndex=0; |
|
316 | + $routeIndex = 0; |
|
317 | 317 | foreach ($this->routes as $definedRoute) { |
318 | 318 | $definedRoute[3] = $definedRoute[3] ?? $this->defaultReturnType; |
319 | - $routeName = 'routeClosure'.$routeIndex; |
|
319 | + $routeName = 'routeClosure' . $routeIndex; |
|
320 | 320 | [$requestMedhod, $url, $controller, $returnType] = $definedRoute; |
321 | - $returnType = ($returnType >=1 && $returnType <=7) ? $returnType : $this->defaultReturnType; |
|
322 | - $this->routerClosures[$routeName]= function ($args) use ($controller, $returnType) { |
|
321 | + $returnType = ($returnType >= 1 && $returnType <= 7) ? $returnType : $this->defaultReturnType; |
|
322 | + $this->routerClosures[$routeName] = function($args) use ($controller, $returnType) { |
|
323 | 323 | return ['controller' => $controller, 'returnType'=> $returnType, 'args'=> $args]; |
324 | 324 | }; |
325 | 325 | $routeIndex++; |