@@ -56,7 +56,7 @@ |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * @return callable |
|
| 59 | + * @return string[] |
|
| 60 | 60 | * |
| 61 | 61 | * @SuppressWarnings(PHPMD.StaticAccess) |
| 62 | 62 | */ |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | - * @return callable |
|
| 150 | + * @return string[] |
|
| 151 | 151 | */ |
| 152 | 152 | public static function getDefaultRequestFactory(): callable |
| 153 | 153 | { |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | 215 | * @param LimoncelloContainerInterface $container |
| 216 | - * @param callable[]|null $globalConfigurators |
|
| 216 | + * @param callable[] $globalConfigurators |
|
| 217 | 217 | * @param callable[]|null $routeConfigurators |
| 218 | 218 | * |
| 219 | 219 | * @return void |
@@ -138,8 +138,7 @@ discard block |
||
| 138 | 138 | $this->addMiddlewareChain($handler, $container, $globalMiddleware, $routeMiddleware) : $handler; |
| 139 | 139 | |
| 140 | 140 | $request = $requestFactory === null && $hasMiddleware === false && $matchCode === RouterInterface::MATCH_FOUND ? |
| 141 | - null : |
|
| 142 | - $this->createRequest($this->sapi, $container, $requestFactory ?? static::getDefaultRequestFactory()); |
|
| 141 | + null : $this->createRequest($this->sapi, $container, $requestFactory ?? static::getDefaultRequestFactory()); |
|
| 143 | 142 | |
| 144 | 143 | // Execute the pipeline by sending `Request` down all middleware (global then route's then |
| 145 | 144 | // terminal handler in `Controller` and back) and then send `Response` to SAPI |
@@ -206,7 +205,7 @@ discard block |
||
| 206 | 205 | /** |
| 207 | 206 | * @return RouterInterface|null |
| 208 | 207 | */ |
| 209 | - protected function getRouter(): ?RouterInterface |
|
| 208 | + protected function getRouter(): ? RouterInterface |
|
| 210 | 209 | { |
| 211 | 210 | return $this->router; |
| 212 | 211 | } |
@@ -278,7 +277,7 @@ discard block |
||
| 278 | 277 | ['array', PsrContainerInterface::class, ServerRequestInterface::class], |
| 279 | 278 | ResponseInterface::class |
| 280 | 279 | ), |
| 281 | - 'Handler method should have signature ' . |
|
| 280 | + 'Handler method should have signature '. |
|
| 282 | 281 | '`public static methodName(array, PsrContainerInterface, ServerRequestInterface): ResponseInterface`' |
| 283 | 282 | ); |
| 284 | 283 | |
@@ -326,7 +325,7 @@ discard block |
||
| 326 | 325 | [SapiInterface::class, PsrContainerInterface::class], |
| 327 | 326 | ServerRequestInterface::class |
| 328 | 327 | ), |
| 329 | - 'Factory method should have signature ' . |
|
| 328 | + 'Factory method should have signature '. |
|
| 330 | 329 | '`public static methodName(SapiInterface, PsrContainerInterface): ServerRequestInterface`' |
| 331 | 330 | ); |
| 332 | 331 | |
@@ -347,7 +346,7 @@ discard block |
||
| 347 | 346 | array $handlerParams, |
| 348 | 347 | PsrContainerInterface $container |
| 349 | 348 | ): Closure { |
| 350 | - return function (ServerRequestInterface $request = null) use ($handler, $handlerParams, $container) { |
|
| 349 | + return function(ServerRequestInterface $request = null) use ($handler, $handlerParams, $container) { |
|
| 351 | 350 | return $this->callHandler($handler, $handlerParams, $container, $request); |
| 352 | 351 | }; |
| 353 | 352 | } |
@@ -360,7 +359,7 @@ discard block |
||
| 360 | 359 | private function createMethodNotAllowedTerminalHandler(array $allowedMethods): Closure |
| 361 | 360 | { |
| 362 | 361 | // 405 Method Not Allowed |
| 363 | - return function () use ($allowedMethods) { |
|
| 362 | + return function() use ($allowedMethods) { |
|
| 364 | 363 | return $this->createEmptyResponse(405, ['Accept' => implode(',', $allowedMethods)]); |
| 365 | 364 | }; |
| 366 | 365 | } |
@@ -371,7 +370,7 @@ discard block |
||
| 371 | 370 | private function createNotFoundTerminalHandler(): Closure |
| 372 | 371 | { |
| 373 | 372 | // 404 Not Found |
| 374 | - return function () { |
|
| 373 | + return function() { |
|
| 375 | 374 | return $this->createEmptyResponse(404); |
| 376 | 375 | }; |
| 377 | 376 | } |
@@ -415,11 +414,11 @@ discard block |
||
| 415 | 414 | [ServerRequestInterface::class, Closure::class, PsrContainerInterface::class], |
| 416 | 415 | ResponseInterface::class |
| 417 | 416 | ), |
| 418 | - 'Middleware method should have signature ' . |
|
| 417 | + 'Middleware method should have signature '. |
|
| 419 | 418 | '`public static methodName(ServerRequestInterface, Closure, PsrContainerInterface): ResponseInterface`' |
| 420 | 419 | ); |
| 421 | 420 | |
| 422 | - return function (ServerRequestInterface $request) use ($next, $middleware, $container): ResponseInterface { |
|
| 421 | + return function(ServerRequestInterface $request) use ($next, $middleware, $container): ResponseInterface { |
|
| 423 | 422 | return call_user_func($middleware, $request, $next, $container); |
| 424 | 423 | }; |
| 425 | 424 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $methodParam = $methodParams[$index]; |
| 85 | 85 | if (is_string($parameter) === true) { |
| 86 | 86 | $methodType = $methodParam->getType(); |
| 87 | - if ($methodType === null || (string)$methodType !== $parameter) { |
|
| 87 | + if ($methodType === null || (string) $methodType !== $parameter) { |
|
| 88 | 88 | $isParamOk = false; |
| 89 | 89 | } |
| 90 | 90 | } elseif ($parameter === null) { |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $isReturnTypeOk = true; |
| 113 | 113 | if ($areAllParamsOk === true && $returnType !== null) { |
| 114 | 114 | $methodRetType = $reflectionMethod->getReturnType(); |
| 115 | - $isReturnTypeOk = $methodRetType !== null && (string)$methodRetType === $returnType; |
|
| 115 | + $isReturnTypeOk = $methodRetType !== null && (string) $methodRetType === $returnType; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | $isOk = $areAllParamsOk === true && $isReturnTypeOk === true; |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | protected function normalizeUri(string $uri, bool $trailingSlash): string |
| 31 | 31 | { |
| 32 | 32 | // add starting '/' and cut ending '/' if necessary |
| 33 | - $uri = strlen($uri) > 0 && $uri[0] === '/' ? $uri : '/' . $uri; |
|
| 33 | + $uri = strlen($uri) > 0 && $uri[0] === '/' ? $uri : '/'.$uri; |
|
| 34 | 34 | $prefixLen = strlen($uri); |
| 35 | 35 | $uri = $prefixLen > 1 && substr($uri, -1) === '/' ? substr($uri, 0, $prefixLen - 1) : $uri; |
| 36 | 36 | |
| 37 | 37 | // feature: trailing slashes are possible when asked |
| 38 | - $uri = $trailingSlash === true && substr($uri, -1) !== '/' ? $uri . '/' : $uri; |
|
| 38 | + $uri = $trailingSlash === true && substr($uri, -1) !== '/' ? $uri.'/' : $uri; |
|
| 39 | 39 | |
| 40 | 40 | return $uri; |
| 41 | 41 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | // only one has '/' |
| 55 | 55 | if ($fEndsWithSlash xor $sStartsWithSlash) { |
| 56 | - return $uri1 . $uri2; |
|
| 56 | + return $uri1.$uri2; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // either both have '/' nor both don't have |
| 60 | 60 | |
| 61 | - $result = $fEndsWithSlash === true ? $uri1 . substr($uri2, 1) : $uri1 . '/' . $uri2; |
|
| 61 | + $result = $fEndsWithSlash === true ? $uri1.substr($uri2, 1) : $uri1.'/'.$uri2; |
|
| 62 | 62 | |
| 63 | 63 | return $result; |
| 64 | 64 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | protected function getCallableToCacheMessage(): string |
| 28 | 28 | { |
| 29 | - return 'Value either not callable or cannot be cached or do not meet method signature requirements. ' . |
|
| 29 | + return 'Value either not callable or cannot be cached or do not meet method signature requirements. '. |
|
| 30 | 30 | 'Use callable in form of \'ClassName::methodName\' or [ClassName::class, \'methodName\'].'; |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | /** |
| 119 | 119 | * @inheritdoc |
| 120 | 120 | */ |
| 121 | - public function parentGroup(): ?GroupInterface |
|
| 121 | + public function parentGroup(): ? GroupInterface |
|
| 122 | 122 | { |
| 123 | 123 | return $this->parent; |
| 124 | 124 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | /** |
| 140 | 140 | * @inheritdoc |
| 141 | 141 | */ |
| 142 | - public function getName(): ?string |
|
| 142 | + public function getName(): ? string |
|
| 143 | 143 | { |
| 144 | 144 | return $this->name; |
| 145 | 145 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | /** |
| 168 | 168 | * @inheritdoc |
| 169 | 169 | */ |
| 170 | - public function getRequestFactory(): ?callable |
|
| 170 | + public function getRequestFactory(): ? callable |
|
| 171 | 171 | { |
| 172 | 172 | if ($this->isRequestFactorySet() === true) { |
| 173 | 173 | return $this->requestFactory; |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | /** |
| 381 | 381 | * @return null|string |
| 382 | 382 | */ |
| 383 | - private function getParentUriPrefix(): ?string |
|
| 383 | + private function getParentUriPrefix(): ? string |
|
| 384 | 384 | { |
| 385 | 385 | $parent = $this->parentGroup(); |
| 386 | 386 | $result = $parent === null ? null : $parent->getUriPrefix(); |
@@ -146,11 +146,11 @@ discard block |
||
| 146 | 146 | /** |
| 147 | 147 | * @inheritdoc |
| 148 | 148 | */ |
| 149 | - public function getUriPath(string $routeName): ?string |
|
| 149 | + public function getUriPath(string $routeName): ? string |
|
| 150 | 150 | { |
| 151 | 151 | $this->checkRoutesLoaded(); |
| 152 | 152 | |
| 153 | - list(, , $namedRouteUriPaths) = $this->cachedRoutes; |
|
| 153 | + list(,, $namedRouteUriPaths) = $this->cachedRoutes; |
|
| 154 | 154 | |
| 155 | 155 | $result = array_key_exists($routeName, $namedRouteUriPaths) === true ? $namedRouteUriPaths[$routeName] : null; |
| 156 | 156 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | ): string { |
| 169 | 169 | $path = $this->getUriPath($routeName); |
| 170 | 170 | $path = $path === null ? $path : $this->replacePlaceholders($path, $placeholders); |
| 171 | - $url = empty($queryParams) === true ? "$hostUri$path" : "$hostUri$path?" . http_build_query($queryParams); |
|
| 171 | + $url = empty($queryParams) === true ? "$hostUri$path" : "$hostUri$path?".http_build_query($queryParams); |
|
| 172 | 172 | |
| 173 | 173 | return $url; |
| 174 | 174 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | break; |
| 228 | 228 | case '}': |
| 229 | 229 | $result .= array_key_exists($curPlaceholder, $placeholders) === true ? |
| 230 | - $placeholders[$curPlaceholder] : '{' . $curPlaceholder . '}'; |
|
| 230 | + $placeholders[$curPlaceholder] : '{'.$curPlaceholder.'}'; |
|
| 231 | 231 | $inPlaceholder = false; |
| 232 | 232 | $curPlaceholder = null; |
| 233 | 233 | $inPlaceholderName = false; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | /** |
| 151 | 151 | * @inheritdoc |
| 152 | 152 | */ |
| 153 | - public function getRequestFactory(): ?callable |
|
| 153 | + public function getRequestFactory(): ? callable |
|
| 154 | 154 | { |
| 155 | 155 | if ($this->isUseGroupRequestFactory() === true) { |
| 156 | 156 | return $this->getGroup()->getRequestFactory(); |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | /** |
| 183 | 183 | * @inheritdoc |
| 184 | 184 | */ |
| 185 | - public function getName(): ?string |
|
| 185 | + public function getName(): ? string |
|
| 186 | 186 | { |
| 187 | - $result = $this->name !== null ? (string)$this->getGroup()->getName() . $this->name : null; |
|
| 187 | + $result = $this->name !== null ? (string) $this->getGroup()->getName().$this->name : null; |
|
| 188 | 188 | |
| 189 | 189 | return $result; |
| 190 | 190 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | /** |
| 49 | 49 | * @inheritdoc |
| 50 | 50 | */ |
| 51 | - public function parentGroup(): ?GroupInterface |
|
| 51 | + public function parentGroup(): ? GroupInterface |
|
| 52 | 52 | { |
| 53 | 53 | $group = parent::parentGroup(); |
| 54 | 54 | |