From 837bc05840f115d33971800226f547225608d43f Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 30 May 2018 00:12:06 +0200 Subject: [PATCH] Replace ControllerInterface with PSR-15 interface The custom interface already had the same signature as the one from the standard (except for the return type hint), so why not use that one now? :) --- framework/core/src/Api/Client.php | 8 +++---- .../Controller/AbstractCreateController.php | 3 ++- .../Controller/AbstractDeleteController.php | 7 +++--- .../AbstractSerializeController.php | 7 +++--- .../Controller/ForgotPasswordController.php | 7 +++--- .../SendConfirmationEmailController.php | 7 +++--- .../Controller/SetPermissionController.php | 7 +++--- .../Api/Controller/SetSettingsController.php | 7 +++--- .../src/Api/Controller/TokenController.php | 7 +++--- .../Controller/UpdateExtensionController.php | 7 +++--- .../Controller/AbstractOAuth2Controller.php | 9 ++++---- .../Controller/ConfirmEmailController.php | 9 ++++---- .../src/Forum/Controller/LogInController.php | 7 +++--- .../src/Forum/Controller/LogOutController.php | 9 ++++---- .../Forum/Controller/RegisterController.php | 7 +++--- .../Controller/SavePasswordController.php | 9 ++++---- .../Controller/AbstractHtmlController.php | 6 +++-- .../Http/Controller/ControllerInterface.php | 23 ------------------- .../core/src/Http/ControllerRouteHandler.php | 8 +++---- .../Install/Controller/InstallController.php | 9 ++++---- .../Update/Controller/UpdateController.php | 9 ++++---- .../Api/Controller/ApiControllerTestCase.php | 4 ++-- 22 files changed, 86 insertions(+), 90 deletions(-) delete mode 100644 framework/core/src/Http/Controller/ControllerInterface.php diff --git a/framework/core/src/Api/Client.php b/framework/core/src/Api/Client.php index 18309d3de..4e23bf5a1 100644 --- a/framework/core/src/Api/Client.php +++ b/framework/core/src/Api/Client.php @@ -13,10 +13,10 @@ namespace Flarum\Api; use Exception; use Flarum\Foundation\Application; -use Flarum\Http\Controller\ControllerInterface; use Flarum\User\User; use InvalidArgumentException; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\ServerRequestFactory; class Client @@ -43,7 +43,7 @@ class Client /** * Execute the given API action class, pass the input and return its response. * - * @param string|ControllerInterface $controller + * @param string|RequestHandlerInterface $controller * @param User|null $actor * @param array $queryParams * @param array $body @@ -60,9 +60,9 @@ class Client $controller = $this->app->make($controller); } - if (! ($controller instanceof ControllerInterface)) { + if (! ($controller instanceof RequestHandlerInterface)) { throw new InvalidArgumentException( - 'Endpoint must be an instance of '.ControllerInterface::class + 'Endpoint must be an instance of '.RequestHandlerInterface::class ); } diff --git a/framework/core/src/Api/Controller/AbstractCreateController.php b/framework/core/src/Api/Controller/AbstractCreateController.php index bb31ede70..d8e41b6dc 100644 --- a/framework/core/src/Api/Controller/AbstractCreateController.php +++ b/framework/core/src/Api/Controller/AbstractCreateController.php @@ -11,6 +11,7 @@ namespace Flarum\Api\Controller; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; abstract class AbstractCreateController extends AbstractShowController @@ -18,7 +19,7 @@ abstract class AbstractCreateController extends AbstractShowController /** * {@inheritdoc} */ - public function handle(ServerRequestInterface $request) + public function handle(ServerRequestInterface $request): ResponseInterface { return parent::handle($request)->withStatus(201); } diff --git a/framework/core/src/Api/Controller/AbstractDeleteController.php b/framework/core/src/Api/Controller/AbstractDeleteController.php index 0530a4270..f7dcee241 100644 --- a/framework/core/src/Api/Controller/AbstractDeleteController.php +++ b/framework/core/src/Api/Controller/AbstractDeleteController.php @@ -11,16 +11,17 @@ namespace Flarum\Api\Controller; -use Flarum\Http\Controller\ControllerInterface; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response\EmptyResponse; -abstract class AbstractDeleteController implements ControllerInterface +abstract class AbstractDeleteController implements RequestHandlerInterface { /** * {@inheritdoc} */ - public function handle(ServerRequestInterface $request) + public function handle(ServerRequestInterface $request): ResponseInterface { $this->delete($request); diff --git a/framework/core/src/Api/Controller/AbstractSerializeController.php b/framework/core/src/Api/Controller/AbstractSerializeController.php index d51fa6d00..bc04cacce 100644 --- a/framework/core/src/Api/Controller/AbstractSerializeController.php +++ b/framework/core/src/Api/Controller/AbstractSerializeController.php @@ -14,15 +14,16 @@ namespace Flarum\Api\Controller; use Flarum\Api\Event\WillGetData; use Flarum\Api\Event\WillSerializeData; use Flarum\Api\JsonApiResponse; -use Flarum\Http\Controller\ControllerInterface; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Events\Dispatcher; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; use Tobscure\JsonApi\Document; use Tobscure\JsonApi\Parameters; use Tobscure\JsonApi\SerializerInterface; -abstract class AbstractSerializeController implements ControllerInterface +abstract class AbstractSerializeController implements RequestHandlerInterface { /** * The name of the serializer class to output results with. @@ -86,7 +87,7 @@ abstract class AbstractSerializeController implements ControllerInterface /** * {@inheritdoc} */ - public function handle(ServerRequestInterface $request) + public function handle(ServerRequestInterface $request): ResponseInterface { $document = new Document; diff --git a/framework/core/src/Api/Controller/ForgotPasswordController.php b/framework/core/src/Api/Controller/ForgotPasswordController.php index 341f16d34..ca2aa5b4e 100644 --- a/framework/core/src/Api/Controller/ForgotPasswordController.php +++ b/framework/core/src/Api/Controller/ForgotPasswordController.php @@ -11,14 +11,15 @@ namespace Flarum\Api\Controller; -use Flarum\Http\Controller\ControllerInterface; use Flarum\User\Command\RequestPasswordReset; use Flarum\User\UserRepository; use Illuminate\Contracts\Bus\Dispatcher; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response\EmptyResponse; -class ForgotPasswordController implements ControllerInterface +class ForgotPasswordController implements RequestHandlerInterface { /** * @var \Flarum\User\UserRepository @@ -43,7 +44,7 @@ class ForgotPasswordController implements ControllerInterface /** * {@inheritdoc} */ - public function handle(ServerRequestInterface $request) + public function handle(ServerRequestInterface $request): ResponseInterface { $email = array_get($request->getParsedBody(), 'email'); diff --git a/framework/core/src/Api/Controller/SendConfirmationEmailController.php b/framework/core/src/Api/Controller/SendConfirmationEmailController.php index 2935f0067..54bde47db 100644 --- a/framework/core/src/Api/Controller/SendConfirmationEmailController.php +++ b/framework/core/src/Api/Controller/SendConfirmationEmailController.php @@ -11,7 +11,6 @@ namespace Flarum\Api\Controller; -use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\UrlGenerator; use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\AssertPermissionTrait; @@ -19,11 +18,13 @@ use Flarum\User\EmailToken; use Flarum\User\Exception\PermissionDeniedException; use Illuminate\Contracts\Mail\Mailer; use Illuminate\Mail\Message; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; use Symfony\Component\Translation\TranslatorInterface; use Zend\Diactoros\Response\EmptyResponse; -class SendConfirmationEmailController implements ControllerInterface +class SendConfirmationEmailController implements RequestHandlerInterface { use AssertPermissionTrait; @@ -64,7 +65,7 @@ class SendConfirmationEmailController implements ControllerInterface /** * {@inheritdoc} */ - public function handle(ServerRequestInterface $request) + public function handle(ServerRequestInterface $request): ResponseInterface { $id = array_get($request->getQueryParams(), 'id'); $actor = $request->getAttribute('actor'); diff --git a/framework/core/src/Api/Controller/SetPermissionController.php b/framework/core/src/Api/Controller/SetPermissionController.php index 1171111b1..65ce73fc2 100644 --- a/framework/core/src/Api/Controller/SetPermissionController.php +++ b/framework/core/src/Api/Controller/SetPermissionController.php @@ -12,19 +12,20 @@ namespace Flarum\Api\Controller; use Flarum\Group\Permission; -use Flarum\Http\Controller\ControllerInterface; use Flarum\User\AssertPermissionTrait; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response\EmptyResponse; -class SetPermissionController implements ControllerInterface +class SetPermissionController implements RequestHandlerInterface { use AssertPermissionTrait; /** * {@inheritdoc} */ - public function handle(ServerRequestInterface $request) + public function handle(ServerRequestInterface $request): ResponseInterface { $this->assertAdmin($request->getAttribute('actor')); diff --git a/framework/core/src/Api/Controller/SetSettingsController.php b/framework/core/src/Api/Controller/SetSettingsController.php index 19ddb21ae..f63d83cbd 100644 --- a/framework/core/src/Api/Controller/SetSettingsController.php +++ b/framework/core/src/Api/Controller/SetSettingsController.php @@ -11,16 +11,17 @@ namespace Flarum\Api\Controller; -use Flarum\Http\Controller\ControllerInterface; use Flarum\Settings\Event\Saved; use Flarum\Settings\Event\Serializing; use Flarum\Settings\SettingsRepositoryInterface; use Flarum\User\AssertPermissionTrait; use Illuminate\Contracts\Events\Dispatcher; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response\EmptyResponse; -class SetSettingsController implements ControllerInterface +class SetSettingsController implements RequestHandlerInterface { use AssertPermissionTrait; @@ -46,7 +47,7 @@ class SetSettingsController implements ControllerInterface /** * {@inheritdoc} */ - public function handle(ServerRequestInterface $request) + public function handle(ServerRequestInterface $request): ResponseInterface { $this->assertAdmin($request->getAttribute('actor')); diff --git a/framework/core/src/Api/Controller/TokenController.php b/framework/core/src/Api/Controller/TokenController.php index e0f6f6464..268f4a598 100644 --- a/framework/core/src/Api/Controller/TokenController.php +++ b/framework/core/src/Api/Controller/TokenController.php @@ -12,15 +12,16 @@ namespace Flarum\Api\Controller; use Flarum\Http\AccessToken; -use Flarum\Http\Controller\ControllerInterface; use Flarum\User\Exception\PermissionDeniedException; use Flarum\User\UserRepository; use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher; use Illuminate\Contracts\Events\Dispatcher as EventDispatcher; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response\JsonResponse; -class TokenController implements ControllerInterface +class TokenController implements RequestHandlerInterface { /** * @var \Flarum\User\UserRepository @@ -52,7 +53,7 @@ class TokenController implements ControllerInterface /** * {@inheritdoc} */ - public function handle(ServerRequestInterface $request) + public function handle(ServerRequestInterface $request): ResponseInterface { $body = $request->getParsedBody(); diff --git a/framework/core/src/Api/Controller/UpdateExtensionController.php b/framework/core/src/Api/Controller/UpdateExtensionController.php index 4e0aab79e..404f13e3f 100644 --- a/framework/core/src/Api/Controller/UpdateExtensionController.php +++ b/framework/core/src/Api/Controller/UpdateExtensionController.php @@ -12,12 +12,13 @@ namespace Flarum\Api\Controller; use Flarum\Extension\ExtensionManager; -use Flarum\Http\Controller\ControllerInterface; use Flarum\User\AssertPermissionTrait; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response\EmptyResponse; -class UpdateExtensionController implements ControllerInterface +class UpdateExtensionController implements RequestHandlerInterface { use AssertPermissionTrait; @@ -37,7 +38,7 @@ class UpdateExtensionController implements ControllerInterface /** * {@inheritdoc} */ - public function handle(ServerRequestInterface $request) + public function handle(ServerRequestInterface $request): ResponseInterface { $this->assertAdmin($request->getAttribute('actor')); diff --git a/framework/core/src/Forum/Controller/AbstractOAuth2Controller.php b/framework/core/src/Forum/Controller/AbstractOAuth2Controller.php index ed0946dda..bd6522f64 100644 --- a/framework/core/src/Forum/Controller/AbstractOAuth2Controller.php +++ b/framework/core/src/Forum/Controller/AbstractOAuth2Controller.php @@ -12,12 +12,13 @@ namespace Flarum\Forum\Controller; use Flarum\Forum\AuthenticationResponseFactory; -use Flarum\Http\Controller\ControllerInterface; use League\OAuth2\Client\Provider\ResourceOwnerInterface; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response\RedirectResponse; -abstract class AbstractOAuth2Controller implements ControllerInterface +abstract class AbstractOAuth2Controller implements RequestHandlerInterface { /** * @var AuthenticationResponseFactory @@ -46,9 +47,9 @@ abstract class AbstractOAuth2Controller implements ControllerInterface /** * @param Request $request - * @return \Psr\Http\Message\ResponseInterface|RedirectResponse + * @return ResponseInterface */ - public function handle(Request $request) + public function handle(Request $request): ResponseInterface { $redirectUri = (string) $request->getAttribute('originalUri', $request->getUri())->withQuery(''); diff --git a/framework/core/src/Forum/Controller/ConfirmEmailController.php b/framework/core/src/Forum/Controller/ConfirmEmailController.php index 5889fdfb6..e6e094ef3 100644 --- a/framework/core/src/Forum/Controller/ConfirmEmailController.php +++ b/framework/core/src/Forum/Controller/ConfirmEmailController.php @@ -12,16 +12,17 @@ namespace Flarum\Forum\Controller; use Flarum\Foundation\Application; -use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\SessionAuthenticator; use Flarum\User\Command\ConfirmEmail; use Flarum\User\Exception\InvalidConfirmationTokenException; use Illuminate\Contracts\Bus\Dispatcher; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response\HtmlResponse; use Zend\Diactoros\Response\RedirectResponse; -class ConfirmEmailController implements ControllerInterface +class ConfirmEmailController implements RequestHandlerInterface { /** * @var Dispatcher @@ -52,9 +53,9 @@ class ConfirmEmailController implements ControllerInterface /** * @param Request $request - * @return \Psr\Http\Message\ResponseInterface + * @return ResponseInterface */ - public function handle(Request $request) + public function handle(Request $request): ResponseInterface { try { $token = array_get($request->getQueryParams(), 'token'); diff --git a/framework/core/src/Forum/Controller/LogInController.php b/framework/core/src/Forum/Controller/LogInController.php index e425b06bd..cf62d81e9 100644 --- a/framework/core/src/Forum/Controller/LogInController.php +++ b/framework/core/src/Forum/Controller/LogInController.php @@ -14,14 +14,15 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; use Flarum\Api\Controller\TokenController; use Flarum\Http\AccessToken; -use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Rememberer; use Flarum\Http\SessionAuthenticator; use Flarum\User\Event\LoggedIn; use Flarum\User\UserRepository; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Server\RequestHandlerInterface; -class LogInController implements ControllerInterface +class LogInController implements RequestHandlerInterface { /** * @var \Flarum\User\UserRepository @@ -60,7 +61,7 @@ class LogInController implements ControllerInterface /** * {@inheritdoc} */ - public function handle(Request $request) + public function handle(Request $request): ResponseInterface { $actor = $request->getAttribute('actor'); $body = $request->getParsedBody(); diff --git a/framework/core/src/Forum/Controller/LogOutController.php b/framework/core/src/Forum/Controller/LogOutController.php index 86bb45480..616598c6d 100644 --- a/framework/core/src/Forum/Controller/LogOutController.php +++ b/framework/core/src/Forum/Controller/LogOutController.php @@ -12,7 +12,6 @@ namespace Flarum\Forum\Controller; use Flarum\Foundation\Application; -use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Exception\TokenMismatchException; use Flarum\Http\Rememberer; use Flarum\Http\SessionAuthenticator; @@ -21,11 +20,13 @@ use Flarum\User\AssertPermissionTrait; use Flarum\User\Event\LoggedOut; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\View\Factory; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response\HtmlResponse; use Zend\Diactoros\Response\RedirectResponse; -class LogOutController implements ControllerInterface +class LogOutController implements RequestHandlerInterface { use AssertPermissionTrait; @@ -85,10 +86,10 @@ class LogOutController implements ControllerInterface /** * @param Request $request - * @return \Psr\Http\Message\ResponseInterface + * @return ResponseInterface * @throws TokenMismatchException */ - public function handle(Request $request) + public function handle(Request $request): ResponseInterface { $session = $request->getAttribute('session'); $actor = $request->getAttribute('actor'); diff --git a/framework/core/src/Forum/Controller/RegisterController.php b/framework/core/src/Forum/Controller/RegisterController.php index 1c3c33646..d86e394c3 100644 --- a/framework/core/src/Forum/Controller/RegisterController.php +++ b/framework/core/src/Forum/Controller/RegisterController.php @@ -13,12 +13,13 @@ namespace Flarum\Forum\Controller; use Flarum\Api\Client; use Flarum\Api\Controller\CreateUserController; -use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\Rememberer; use Flarum\Http\SessionAuthenticator; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Server\RequestHandlerInterface; -class RegisterController implements ControllerInterface +class RegisterController implements RequestHandlerInterface { /** * @var Client @@ -50,7 +51,7 @@ class RegisterController implements ControllerInterface /** * {@inheritdoc} */ - public function handle(Request $request) + public function handle(Request $request): ResponseInterface { $controller = CreateUserController::class; $actor = $request->getAttribute('actor'); diff --git a/framework/core/src/Forum/Controller/SavePasswordController.php b/framework/core/src/Forum/Controller/SavePasswordController.php index 8a49831d7..507fdb29d 100644 --- a/framework/core/src/Forum/Controller/SavePasswordController.php +++ b/framework/core/src/Forum/Controller/SavePasswordController.php @@ -12,7 +12,6 @@ namespace Flarum\Forum\Controller; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\SessionAuthenticator; use Flarum\Http\UrlGenerator; use Flarum\User\PasswordToken; @@ -20,10 +19,12 @@ use Flarum\User\UserValidator; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Validation\Factory; use Illuminate\Validation\ValidationException; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response\RedirectResponse; -class SavePasswordController implements ControllerInterface +class SavePasswordController implements RequestHandlerInterface { use DispatchEventsTrait; @@ -64,9 +65,9 @@ class SavePasswordController implements ControllerInterface /** * @param Request $request - * @return RedirectResponse + * @return ResponseInterface */ - public function handle(Request $request) + public function handle(Request $request): ResponseInterface { $input = $request->getParsedBody(); diff --git a/framework/core/src/Http/Controller/AbstractHtmlController.php b/framework/core/src/Http/Controller/AbstractHtmlController.php index 2f56ed7ef..03e8b3613 100644 --- a/framework/core/src/Http/Controller/AbstractHtmlController.php +++ b/framework/core/src/Http/Controller/AbstractHtmlController.php @@ -12,16 +12,18 @@ namespace Flarum\Http\Controller; use Illuminate\Contracts\Support\Renderable; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response\HtmlResponse; -abstract class AbstractHtmlController implements ControllerInterface +abstract class AbstractHtmlController implements RequestHandlerInterface { /** * @param Request $request * @return HtmlResponse */ - public function handle(Request $request) + public function handle(Request $request): ResponseInterface { $view = $this->render($request); diff --git a/framework/core/src/Http/Controller/ControllerInterface.php b/framework/core/src/Http/Controller/ControllerInterface.php deleted file mode 100644 index 4912311f0..000000000 --- a/framework/core/src/Http/Controller/ControllerInterface.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Http\Controller; - -use Psr\Http\Message\ServerRequestInterface; - -interface ControllerInterface -{ - /** - * @param ServerRequestInterface $request - * @return \Psr\Http\Message\ResponseInterface - */ - public function handle(ServerRequestInterface $request); -} diff --git a/framework/core/src/Http/ControllerRouteHandler.php b/framework/core/src/Http/ControllerRouteHandler.php index b65e106de..a37b776ed 100644 --- a/framework/core/src/Http/ControllerRouteHandler.php +++ b/framework/core/src/Http/ControllerRouteHandler.php @@ -11,11 +11,11 @@ namespace Flarum\Http; -use Flarum\Http\Controller\ControllerInterface; use Illuminate\Contracts\Container\Container; use InvalidArgumentException; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; class ControllerRouteHandler { @@ -55,15 +55,15 @@ class ControllerRouteHandler /** * @param string $class - * @return ControllerInterface + * @return RequestHandlerInterface */ protected function resolveController($class) { $controller = $this->container->make($class); - if (! ($controller instanceof ControllerInterface)) { + if (! ($controller instanceof RequestHandlerInterface)) { throw new InvalidArgumentException( - 'Controller must be an instance of '.ControllerInterface::class + 'Controller must be an instance of '.RequestHandlerInterface::class ); } diff --git a/framework/core/src/Install/Controller/InstallController.php b/framework/core/src/Install/Controller/InstallController.php index 5cee7d10f..95cbaa323 100644 --- a/framework/core/src/Install/Controller/InstallController.php +++ b/framework/core/src/Install/Controller/InstallController.php @@ -12,17 +12,18 @@ namespace Flarum\Install\Controller; use Exception; -use Flarum\Http\Controller\ControllerInterface; use Flarum\Http\SessionAuthenticator; use Flarum\Install\Console\DefaultsDataProvider; use Flarum\Install\Console\InstallCommand; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Server\RequestHandlerInterface; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\StreamOutput; use Zend\Diactoros\Response; use Zend\Diactoros\Response\HtmlResponse; -class InstallController implements ControllerInterface +class InstallController implements RequestHandlerInterface { protected $command; @@ -44,9 +45,9 @@ class InstallController implements ControllerInterface /** * @param Request $request - * @return \Psr\Http\Message\ResponseInterface + * @return ResponseInterface */ - public function handle(Request $request) + public function handle(Request $request): ResponseInterface { $input = $request->getParsedBody(); diff --git a/framework/core/src/Update/Controller/UpdateController.php b/framework/core/src/Update/Controller/UpdateController.php index 390aff798..fc6c929ba 100644 --- a/framework/core/src/Update/Controller/UpdateController.php +++ b/framework/core/src/Update/Controller/UpdateController.php @@ -14,14 +14,15 @@ namespace Flarum\Update\Controller; use Exception; use Flarum\Database\Console\MigrateCommand; use Flarum\Foundation\Application; -use Flarum\Http\Controller\ControllerInterface; +use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Server\RequestHandlerInterface; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\StreamOutput; use Zend\Diactoros\Response; use Zend\Diactoros\Response\HtmlResponse; -class UpdateController implements ControllerInterface +class UpdateController implements RequestHandlerInterface { protected $command; @@ -42,9 +43,9 @@ class UpdateController implements ControllerInterface /** * @param Request $request - * @return \Psr\Http\Message\ResponseInterface + * @return ResponseInterface */ - public function handle(Request $request) + public function handle(Request $request): ResponseInterface { $input = $request->getParsedBody(); diff --git a/framework/core/tests/Api/Controller/ApiControllerTestCase.php b/framework/core/tests/Api/Controller/ApiControllerTestCase.php index fa8695fb2..7f807e182 100644 --- a/framework/core/tests/Api/Controller/ApiControllerTestCase.php +++ b/framework/core/tests/Api/Controller/ApiControllerTestCase.php @@ -11,16 +11,16 @@ namespace Flarum\Tests\Api\Controller; -use Flarum\Http\Controller\ControllerInterface; use Flarum\Tests\Test\TestCase; use Flarum\User\User; use Illuminate\Support\Arr; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Server\RequestHandlerInterface; abstract class ApiControllerTestCase extends TestCase { /** - * @var ControllerInterface + * @var RequestHandlerInterface */ protected $controller;