mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Added some PHP 8.1 features
This commit is contained in:
parent
54a23cc7fa
commit
e79391907a
3 changed files with 7 additions and 8 deletions
|
@ -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()))
|
||||
|
|
|
@ -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,
|
||||
];
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue