diff --git a/module/Core/src/Config/NotFoundRedirectResolver.php b/module/Core/src/Config/NotFoundRedirectResolver.php index caa100c3..3ab2e740 100644 --- a/module/Core/src/Config/NotFoundRedirectResolver.php +++ b/module/Core/src/Config/NotFoundRedirectResolver.php @@ -13,7 +13,9 @@ use Shlinkio\Shlink\Core\ErrorHandler\Model\NotFoundType; use Shlinkio\Shlink\Core\Util\RedirectResponseHelperInterface; use function Functional\compose; +use function Functional\id; use function str_replace; +use function urlencode; class NotFoundRedirectResolver implements NotFoundRedirectResolverInterface { @@ -71,10 +73,10 @@ class NotFoundRedirectResolver implements NotFoundRedirectResolverInterface $replacePlaceholderForPattern(self::ORIGINAL_PATH_PLACEHOLDER, $path, $modifier), ); $replacePlaceholdersInPath = compose( - $replacePlaceholders('\Functional\id'), - static fn (?string $path) => $path === null ? null : str_replace('//', '/', $path), // Fix duplicated bars + $replacePlaceholders(id(...)), + static fn (?string $path) => $path === null ? null : str_replace('//', '/', $path), ); - $replacePlaceholdersInQuery = $replacePlaceholders('\urlencode'); + $replacePlaceholdersInQuery = $replacePlaceholders(urlencode(...)); return $redirectUri ->withPath($replacePlaceholdersInPath($redirectUri->getPath())) diff --git a/module/Rest/src/Action/AbstractRestAction.php b/module/Rest/src/Action/AbstractRestAction.php index da8b6d80..f330bab1 100644 --- a/module/Rest/src/Action/AbstractRestAction.php +++ b/module/Rest/src/Action/AbstractRestAction.php @@ -8,8 +8,6 @@ use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; use Psr\Http\Server\RequestHandlerInterface; -use function array_merge; - abstract class AbstractRestAction implements RequestHandlerInterface, RequestMethodInterface, StatusCodeInterface { protected const ROUTE_PATH = ''; @@ -19,7 +17,7 @@ abstract class AbstractRestAction implements RequestHandlerInterface, RequestMet { return [ 'name' => static::class, - 'middleware' => array_merge($prevMiddleware, [static::class], $postMiddleware), + 'middleware' => [...$prevMiddleware, static::class, ...$postMiddleware], 'path' => static::ROUTE_PATH, 'allowed_methods' => static::ROUTE_ALLOWED_METHODS, ]; diff --git a/module/Rest/src/Middleware/CrossDomainMiddleware.php b/module/Rest/src/Middleware/CrossDomainMiddleware.php index b0d63dc7..d6a51a0c 100644 --- a/module/Rest/src/Middleware/CrossDomainMiddleware.php +++ b/module/Rest/src/Middleware/CrossDomainMiddleware.php @@ -11,7 +11,6 @@ use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; -use function array_merge; use function implode; class CrossDomainMiddleware implements MiddlewareInterface, RequestMethodInterface @@ -45,7 +44,7 @@ class CrossDomainMiddleware implements MiddlewareInterface, RequestMethodInterfa ]; // Options requests should always be empty and have a 204 status code - return EmptyResponse::withHeaders(array_merge($response->getHeaders(), $corsHeaders)); + return EmptyResponse::withHeaders([...$response->getHeaders(), ...$corsHeaders]); } private function resolveCorsAllowedMethods(ResponseInterface $response): string