diff --git a/Civi/Funding/Event/Remote/RemotePageRequestEvent.php b/Civi/Funding/Event/Remote/RemotePageRequestEvent.php index 570d63b2a..92a748a3d 100644 --- a/Civi/Funding/Event/Remote/RemotePageRequestEvent.php +++ b/Civi/Funding/Event/Remote/RemotePageRequestEvent.php @@ -19,21 +19,22 @@ namespace Civi\Funding\Event\Remote; +use Civi\Funding\Page\AbstractRemoteControllerPage; use Symfony\Component\HttpFoundation\Request; use Symfony\Contracts\EventDispatcher\Event; final class RemotePageRequestEvent extends Event { - private \CRM_Funding_Page_AbstractRemotePage $page; + private AbstractRemoteControllerPage $page; private Request $request; - public function __construct(\CRM_Funding_Page_AbstractRemotePage $page, Request $request) { + public function __construct(AbstractRemoteControllerPage $page, Request $request) { $this->page = $page; $this->request = $request; } - public function getPage(): \CRM_Funding_Page_AbstractRemotePage { + public function getPage(): AbstractRemoteControllerPage { return $this->page; } diff --git a/CRM/Funding/Page/AbstractPage.php b/Civi/Funding/Page/AbstractControllerPage.php similarity index 94% rename from CRM/Funding/Page/AbstractPage.php rename to Civi/Funding/Page/AbstractControllerPage.php index da3eea093..6f34fae60 100644 --- a/CRM/Funding/Page/AbstractPage.php +++ b/Civi/Funding/Page/AbstractControllerPage.php @@ -17,6 +17,8 @@ declare(strict_types = 1); +namespace Civi\Funding\Page; + use Civi\Funding\Controller\PageControllerInterface; use Civi\RemoteTools\RequestContext\RequestContextInterface; use Symfony\Component\HttpFoundation\Request; @@ -25,10 +27,8 @@ /** * @codeCoverageIgnore - * - * phpcs:disable Generic.NamingConventions.AbstractClassNamePrefix.Missing */ -abstract class CRM_Funding_Page_AbstractPage extends \CRM_Core_Page { +abstract class AbstractControllerPage extends \CRM_Core_Page { public function run(): void { $request = Request::createFromGlobals(); diff --git a/CRM/Funding/Page/AbstractRemotePage.php b/Civi/Funding/Page/AbstractRemoteControllerPage.php similarity index 93% rename from CRM/Funding/Page/AbstractRemotePage.php rename to Civi/Funding/Page/AbstractRemoteControllerPage.php index d8b8aaae3..2e2112b37 100644 --- a/CRM/Funding/Page/AbstractRemotePage.php +++ b/Civi/Funding/Page/AbstractRemoteControllerPage.php @@ -17,6 +17,8 @@ declare(strict_types = 1); +namespace Civi\Funding\Page; + use Civi\Funding\Event\Remote\RemotePageRequestEvent; use Civi\RemoteTools\RequestContext\RequestContextInterface; use Symfony\Component\HttpFoundation\Request; @@ -27,7 +29,7 @@ * * phpcs:disable Generic.NamingConventions.AbstractClassNamePrefix.Missing */ -abstract class CRM_Funding_Page_AbstractRemotePage extends CRM_Funding_Page_AbstractPage { +abstract class AbstractRemoteControllerPage extends AbstractControllerPage { protected function handle(Request $request): Response { /** @var \Civi\RemoteTools\RequestContext\RequestContextInterface $requestContext */ diff --git a/CRM/Funding/Page/DrawdownAccept.php b/Civi/Funding/Page/DrawdownAcceptPage.php similarity index 76% rename from CRM/Funding/Page/DrawdownAccept.php rename to Civi/Funding/Page/DrawdownAcceptPage.php index 08cf46e03..2e8a6e93c 100644 --- a/CRM/Funding/Page/DrawdownAccept.php +++ b/Civi/Funding/Page/DrawdownAcceptPage.php @@ -2,13 +2,15 @@ declare(strict_types = 1); -use Civi\Funding\Controller\PageControllerInterface; +namespace Civi\Funding\Page; + use Civi\Funding\Controller\DrawdownAcceptController; +use Civi\Funding\Controller\PageControllerInterface; /** * @codeCoverageIgnore */ -class CRM_Funding_Page_DrawdownAccept extends CRM_Funding_Page_AbstractPage { +final class DrawdownAcceptPage extends AbstractControllerPage { protected function getController(): PageControllerInterface { return \Civi::service(DrawdownAcceptController::class); diff --git a/CRM/Funding/Page/DrawdownDocumentDownload.php b/Civi/Funding/Page/DrawdownDocumentDownloadPage.php similarity index 75% rename from CRM/Funding/Page/DrawdownDocumentDownload.php rename to Civi/Funding/Page/DrawdownDocumentDownloadPage.php index 4794103b9..4c1a30ef6 100644 --- a/CRM/Funding/Page/DrawdownDocumentDownload.php +++ b/Civi/Funding/Page/DrawdownDocumentDownloadPage.php @@ -2,13 +2,15 @@ declare(strict_types = 1); +namespace Civi\Funding\Page; + use Civi\Funding\Controller\PageControllerInterface; use Civi\Funding\Controller\DrawdownDocumentDownloadController; /** * @codeCoverageIgnore */ -class CRM_Funding_Page_DrawdownDocumentDownload extends CRM_Funding_Page_AbstractPage { +final class DrawdownDocumentDownloadPage extends AbstractControllerPage { protected function getController(): PageControllerInterface { return \Civi::service(DrawdownDocumentDownloadController::class); diff --git a/CRM/Funding/Page/DrawdownReject.php b/Civi/Funding/Page/DrawdownRejectPage.php similarity index 76% rename from CRM/Funding/Page/DrawdownReject.php rename to Civi/Funding/Page/DrawdownRejectPage.php index eff72366f..126540762 100644 --- a/CRM/Funding/Page/DrawdownReject.php +++ b/Civi/Funding/Page/DrawdownRejectPage.php @@ -2,13 +2,15 @@ declare(strict_types = 1); +namespace Civi\Funding\Page; + use Civi\Funding\Controller\PageControllerInterface; use Civi\Funding\Controller\DrawdownRejectController; /** * @codeCoverageIgnore */ -class CRM_Funding_Page_DrawdownReject extends CRM_Funding_Page_AbstractPage { +final class DrawdownRejectPage extends AbstractControllerPage { protected function getController(): PageControllerInterface { return \Civi::service(DrawdownRejectController::class); diff --git a/CRM/Funding/Page/RemoteApplicationTemplateRender.php b/Civi/Funding/Page/RemoteApplicationTemplateRenderPage.php similarity index 73% rename from CRM/Funding/Page/RemoteApplicationTemplateRender.php rename to Civi/Funding/Page/RemoteApplicationTemplateRenderPage.php index 9aefd5e92..7bc2a43da 100644 --- a/CRM/Funding/Page/RemoteApplicationTemplateRender.php +++ b/Civi/Funding/Page/RemoteApplicationTemplateRenderPage.php @@ -2,13 +2,15 @@ declare(strict_types = 1); -use Civi\Funding\Controller\PageControllerInterface; +namespace Civi\Funding\Page; + use Civi\Funding\Controller\ApplicationTemplateRenderController; +use Civi\Funding\Controller\PageControllerInterface; /** * @codeCoverageIgnore */ -final class CRM_Funding_Page_RemoteApplicationTemplateRender extends CRM_Funding_Page_AbstractRemotePage { +final class RemoteApplicationTemplateRenderPage extends AbstractRemoteControllerPage { protected function getController(): PageControllerInterface { return \Civi::service(ApplicationTemplateRenderController::class); diff --git a/CRM/Funding/Page/RemoteTransferContractDownload.php b/Civi/Funding/Page/RemoteTransferContractDownloadPage.php similarity index 74% rename from CRM/Funding/Page/RemoteTransferContractDownload.php rename to Civi/Funding/Page/RemoteTransferContractDownloadPage.php index dabd5da3b..137657da1 100644 --- a/CRM/Funding/Page/RemoteTransferContractDownload.php +++ b/Civi/Funding/Page/RemoteTransferContractDownloadPage.php @@ -2,13 +2,15 @@ declare(strict_types = 1); +namespace Civi\Funding\Page; + use Civi\Funding\Controller\PageControllerInterface; use Civi\Funding\Controller\TransferContractDownloadController; /** * @codeCoverageIgnore */ -class CRM_Funding_Page_RemoteTransferContractDownload extends CRM_Funding_Page_AbstractRemotePage { +class RemoteTransferContractDownloadPage extends AbstractRemoteControllerPage { protected function getController(): PageControllerInterface { return \Civi::service(TransferContractDownloadController::class); diff --git a/CRM/Funding/Page/TransferContractDownload.php b/Civi/Funding/Page/TransferContractDownloadPage.php similarity index 75% rename from CRM/Funding/Page/TransferContractDownload.php rename to Civi/Funding/Page/TransferContractDownloadPage.php index 3acb5d375..cc55f0927 100644 --- a/CRM/Funding/Page/TransferContractDownload.php +++ b/Civi/Funding/Page/TransferContractDownloadPage.php @@ -2,13 +2,15 @@ declare(strict_types = 1); +namespace Civi\Funding\Page; + use Civi\Funding\Controller\PageControllerInterface; use Civi\Funding\Controller\TransferContractDownloadController; /** * @codeCoverageIgnore */ -class CRM_Funding_Page_TransferContractDownload extends CRM_Funding_Page_AbstractPage { +final class TransferContractDownloadPage extends AbstractControllerPage { protected function getController(): PageControllerInterface { return \Civi::service(TransferContractDownloadController::class); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index bcccd230a..68ed57b1d 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -47,7 +47,7 @@ parameters: ignoreErrors: # Note paths are prefixed with "*/" to work with inspections in PHPStorm because of: # https://youtrack.jetbrains.com/issue/WI-63891/PHPStan-ignoreErrors-configuration-isnt-working-with-inspections - - '#^Method CRM_Funding_Page_[^\s]+::getController\(\) should return Civi\\Funding\\Controller\\PageControllerInterface but returns mixed.$#' + - '#^Method Civi\\Funding\\Page\\[^\s]+Page::getController\(\) should return Civi\\Funding\\Controller\\PageControllerInterface but returns mixed.$#' - '#^Method Civi\\Funding\\FundingCaseTypeServiceLocator::[^\s]+ should return [^\s]+ but returns mixed.$#' - message: '#has an uninitialized property#' diff --git a/tests/phpunit/Civi/Funding/EventSubscriber/Remote/RemotePageRequestSubscriberTest.php b/tests/phpunit/Civi/Funding/EventSubscriber/Remote/RemotePageRequestSubscriberTest.php index aaecd74be..fc4934bcf 100644 --- a/tests/phpunit/Civi/Funding/EventSubscriber/Remote/RemotePageRequestSubscriberTest.php +++ b/tests/phpunit/Civi/Funding/EventSubscriber/Remote/RemotePageRequestSubscriberTest.php @@ -22,6 +22,7 @@ use Civi\Funding\Contact\FundingRemoteContactIdResolverInterface; use Civi\Funding\Event\Remote\RemotePageRequestEvent; use Civi\Funding\Mock\RequestContext\TestRequestContext; +use Civi\Funding\Page\AbstractRemoteControllerPage; use Civi\RemoteTools\Exception\ResolveContactIdFailedException; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -66,7 +67,7 @@ public function testGetSubscribedEvents(): void { } public function test(): void { - $pageMock = $this->createMock(\CRM_Funding_Page_AbstractRemotePage::class); + $pageMock = $this->createMock(AbstractRemoteControllerPage::class); $request = new Request(); $request->headers->set('X-Civi-Remote-Contact-Id', 'abc'); $event = new RemotePageRequestEvent($pageMock, $request); @@ -79,7 +80,7 @@ public function test(): void { } public function testRemoteContactIdMissing(): void { - $pageMock = $this->createMock(\CRM_Funding_Page_AbstractRemotePage::class); + $pageMock = $this->createMock(AbstractRemoteControllerPage::class); $request = new Request(); $event = new RemotePageRequestEvent($pageMock, $request); @@ -89,7 +90,7 @@ public function testRemoteContactIdMissing(): void { } public function testRemoteContactIdResolveFailed(): void { - $pageMock = $this->createMock(\CRM_Funding_Page_AbstractRemotePage::class); + $pageMock = $this->createMock(AbstractRemoteControllerPage::class); $request = new Request(); $request->headers->set('X-Civi-Remote-Contact-Id', 'abc'); $event = new RemotePageRequestEvent($pageMock, $request); diff --git a/xml/Menu/funding.xml b/xml/Menu/funding.xml index 21694d90b..827974fe0 100644 --- a/xml/Menu/funding.xml +++ b/xml/Menu/funding.xml @@ -2,37 +2,37 @@ civicrm/funding/remote/application/render - CRM_Funding_Page_RemoteApplicationTemplateRender + Civi\Funding\Page\RemoteApplicationTemplateRenderPage RemoteApplicationTemplateRender access Remote Funding civicrm/funding/transfer-contract/download - CRM_Funding_Page_TransferContractDownload + Civi\Funding\Page\TransferContractDownloadPage TransferContractDownload access Funding;administer Funding civicrm/funding/remote/transfer-contract/download - CRM_Funding_Page_RemoteTransferContractDownload + Civi\Funding\Page\RemoteTransferContractDownloadPage RemoteTransferContractDownload access Remote Funding civicrm/funding/drawdown/accept - CRM_Funding_Page_DrawdownAccept + Civi\Funding\Page\DrawdownAcceptPage DrawdownAccept access Funding;administer Funding civicrm/funding/drawdown/reject - CRM_Funding_Page_DrawdownReject + Civi\Funding\Page\DrawdownRejectPage DrawdownReject access Funding;administer Funding civicrm/funding/drawdown-document/download - CRM_Funding_Page_DrawdownDocumentDownload + Civi\Funding\Page\DrawdownDocumentDownloadPage DrawdownDocumentDownload access Funding;administer Funding