From 3a387411faf14c0e5d700ac41ced7aa1c1d8fa39 Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 7 Sep 2020 19:24:34 +0300 Subject: [PATCH] refactor(cors): update code according to coding doctrine coding standard --- src/flextype/Foundation/Cors.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/flextype/Foundation/Cors.php b/src/flextype/Foundation/Cors.php index dd1381e9..2e66812c 100644 --- a/src/flextype/Foundation/Cors.php +++ b/src/flextype/Foundation/Cors.php @@ -9,7 +9,11 @@ declare(strict_types=1); namespace Flextype\Foundation; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; + use function count; +use function flextype; use function implode; class Cors @@ -17,18 +21,18 @@ class Cors /** * Init CORS */ - public function init() : void + public function init(): void { if (! flextype('registry')->get('flextype.settings.cors.enabled')) { return; } - flextype()->options('/{routes:.+}', function ($request, $response) { + flextype()->options('/{routes:.+}', function (ServerRequestInterface $request, ResponseInterface $response) { return $response; }); - flextype()->add(function ($req, $res, $next) { - $response = $next($req, $res); + flextype()->add(function (ServerRequestInterface $request, ResponseInterface $response, callable $next) { + $response = $next($request, $response); // Set variables $origin = flextype('registry')->get('flextype.settings.cors.origin');