From 9d96f541e38b7e4ad70c1e865d59117b4a774229 Mon Sep 17 00:00:00 2001 From: fiachra mcdermott Date: Mon, 21 Jun 2021 17:34:46 -0700 Subject: [PATCH] refactor: extract registerHandlers to method --- src/Plugin.php | 57 ++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index d5f5976..f97ad7a 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -42,31 +42,7 @@ class Plugin implements PluginEntryPointInterface return; } - require_once 'ReturnTypeProvider/AuthReturnTypeProvider.php'; - $registration->registerHooksFromClass(ReturnTypeProvider\AuthReturnTypeProvider::class); - require_once 'ReturnTypeProvider/TransReturnTypeProvider.php'; - $registration->registerHooksFromClass(ReturnTypeProvider\TransReturnTypeProvider::class); - require_once 'ReturnTypeProvider/RedirectReturnTypeProvider.php'; - $registration->registerHooksFromClass(ReturnTypeProvider\RedirectReturnTypeProvider::class); - require_once 'ReturnTypeProvider/ViewReturnTypeProvider.php'; - $registration->registerHooksFromClass(ReturnTypeProvider\ViewReturnTypeProvider::class); - require_once 'ReturnTypeProvider/AppReturnTypeProvider.php'; - $registration->registerHooksFromClass(ReturnTypeProvider\AppReturnTypeProvider::class); - require_once 'Handlers/Application/ContainerHandler.php'; - $registration->registerHooksFromClass(ContainerHandler::class); - require_once 'Handlers/Application/OffsetHandler.php'; - $registration->registerHooksFromClass(OffsetHandler::class); - require_once 'PropertyProvider/ModelPropertyProvider.php'; - $registration->registerHooksFromClass(PropertyProvider\ModelPropertyProvider::class); - require_once 'ReturnTypeProvider/UrlReturnTypeProvider.php'; - $registration->registerHooksFromClass(UrlReturnTypeProvider::class); - require_once 'ReturnTypeProvider/ModelReturnTypeProvider.php'; - $registration->registerHooksFromClass(ModelReturnTypeProvider::class); - require_once 'ReturnTypeProvider/RelationReturnTypeProvider.php'; - $registration->registerHooksFromClass(RelationReturnTypeProvider::class); - require_once 'ReturnTypeProvider/PathHelpersReturnTypeProvider.php'; - $registration->registerHooksFromClass(PathHelpersReturnTypeProvider::class); - + $this->registerHandlers($registration); $this->addOurStubs($registration); } @@ -222,4 +198,35 @@ class Plugin implements PluginEntryPointInterface $registration->addStubFile($stubFilePath); } } + + /** + * @param \Psalm\Plugin\RegistrationInterface $registration + */ + private function registerHandlers(RegistrationInterface $registration): void + { + require_once 'ReturnTypeProvider/AuthReturnTypeProvider.php'; + $registration->registerHooksFromClass(ReturnTypeProvider\AuthReturnTypeProvider::class); + require_once 'ReturnTypeProvider/TransReturnTypeProvider.php'; + $registration->registerHooksFromClass(ReturnTypeProvider\TransReturnTypeProvider::class); + require_once 'ReturnTypeProvider/RedirectReturnTypeProvider.php'; + $registration->registerHooksFromClass(ReturnTypeProvider\RedirectReturnTypeProvider::class); + require_once 'ReturnTypeProvider/ViewReturnTypeProvider.php'; + $registration->registerHooksFromClass(ReturnTypeProvider\ViewReturnTypeProvider::class); + require_once 'ReturnTypeProvider/AppReturnTypeProvider.php'; + $registration->registerHooksFromClass(ReturnTypeProvider\AppReturnTypeProvider::class); + require_once 'Handlers/Application/ContainerHandler.php'; + $registration->registerHooksFromClass(ContainerHandler::class); + require_once 'Handlers/Application/OffsetHandler.php'; + $registration->registerHooksFromClass(OffsetHandler::class); + require_once 'PropertyProvider/ModelPropertyProvider.php'; + $registration->registerHooksFromClass(PropertyProvider\ModelPropertyProvider::class); + require_once 'ReturnTypeProvider/UrlReturnTypeProvider.php'; + $registration->registerHooksFromClass(UrlReturnTypeProvider::class); + require_once 'ReturnTypeProvider/ModelReturnTypeProvider.php'; + $registration->registerHooksFromClass(ModelReturnTypeProvider::class); + require_once 'ReturnTypeProvider/RelationReturnTypeProvider.php'; + $registration->registerHooksFromClass(RelationReturnTypeProvider::class); + require_once 'ReturnTypeProvider/PathHelpersReturnTypeProvider.php'; + $registration->registerHooksFromClass(PathHelpersReturnTypeProvider::class); + } }