From a57dd1ecc176e32f507867b219cd82a4687bbb53 Mon Sep 17 00:00:00 2001 From: George Steel Date: Thu, 13 Jan 2022 09:19:08 +0000 Subject: [PATCH] Stringify Zend related class references so that composer-require-checker doesn't complain about them Signed-off-by: George Steel --- src/ConfigProvider.php | 72 ++++++++++----------- src/Helper/Navigation/ConfigProvider.php | 8 +-- src/Helper/Service/IdentityFactory.php | 10 +-- test/Helper/Service/IdentityFactoryTest.php | 22 ++++--- 4 files changed, 60 insertions(+), 52 deletions(-) diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php index 382226890..7746f25fd 100644 --- a/src/ConfigProvider.php +++ b/src/ConfigProvider.php @@ -122,42 +122,42 @@ private static function zendFrameworkHelperAliases(): array { return [ // @codingStandardsIgnoreStart - \Zend\View\Helper\Asset::class => Helper\Asset::class, - \Zend\View\Helper\FlashMessenger::class => Helper\FlashMessenger::class, - \Zend\View\Helper\Identity::class => Helper\Identity::class, - \Zend\View\Helper\BasePath::class => Helper\BasePath::class, - \Zend\View\Helper\Cycle::class => Helper\Cycle::class, - \Zend\View\Helper\DeclareVars::class => Helper\DeclareVars::class, - \Zend\View\Helper\Doctype::class => Helper\Doctype::class, - \Zend\View\Helper\EscapeHtml::class => Helper\EscapeHtml::class, - \Zend\View\Helper\EscapeHtmlAttr::class => Helper\EscapeHtmlAttr::class, - \Zend\View\Helper\EscapeJs::class => Helper\EscapeJs::class, - \Zend\View\Helper\EscapeCss::class => Helper\EscapeCss::class, - \Zend\View\Helper\EscapeUrl::class => Helper\EscapeUrl::class, - \Zend\View\Helper\Gravatar::class => Helper\Gravatar::class, - \Zend\View\Helper\HtmlTag::class => Helper\HtmlTag::class, - \Zend\View\Helper\HeadLink::class => Helper\HeadLink::class, - \Zend\View\Helper\HeadMeta::class => Helper\HeadMeta::class, - \Zend\View\Helper\HeadScript::class => Helper\HeadScript::class, - \Zend\View\Helper\HeadStyle::class => Helper\HeadStyle::class, - \Zend\View\Helper\HeadTitle::class => Helper\HeadTitle::class, - \Zend\View\Helper\HtmlFlash::class => Helper\HtmlFlash::class, - \Zend\View\Helper\HtmlList::class => Helper\HtmlList::class, - \Zend\View\Helper\HtmlObject::class => Helper\HtmlObject::class, - \Zend\View\Helper\HtmlPage::class => Helper\HtmlPage::class, - \Zend\View\Helper\HtmlQuicktime::class => Helper\HtmlQuicktime::class, - \Zend\View\Helper\InlineScript::class => Helper\InlineScript::class, - \Zend\View\Helper\Json::class => Helper\Json::class, - \Zend\View\Helper\Layout::class => Helper\Layout::class, - \Zend\View\Helper\PaginationControl::class => Helper\PaginationControl::class, - \Zend\View\Helper\PartialLoop::class => Helper\PartialLoop::class, - \Zend\View\Helper\Partial::class => Helper\Partial::class, - \Zend\View\Helper\Placeholder::class => Helper\Placeholder::class, - \Zend\View\Helper\RenderChildModel::class => Helper\RenderChildModel::class, - \Zend\View\Helper\RenderToPlaceholder::class => Helper\RenderToPlaceholder::class, - \Zend\View\Helper\ServerUrl::class => Helper\ServerUrl::class, - \Zend\View\Helper\Url::class => Helper\Url::class, - \Zend\View\Helper\ViewModel::class => Helper\ViewModel::class, + 'Zend\View\Helper\Asset' => Helper\Asset::class, + 'Zend\View\Helper\FlashMessenger' => Helper\FlashMessenger::class, + 'Zend\View\Helper\Identity' => Helper\Identity::class, + 'Zend\View\Helper\BasePath' => Helper\BasePath::class, + 'Zend\View\Helper\Cycle' => Helper\Cycle::class, + 'Zend\View\Helper\DeclareVars' => Helper\DeclareVars::class, + 'Zend\View\Helper\Doctype' => Helper\Doctype::class, + 'Zend\View\Helper\EscapeHtml' => Helper\EscapeHtml::class, + 'Zend\View\Helper\EscapeHtmlAttr' => Helper\EscapeHtmlAttr::class, + 'Zend\View\Helper\EscapeJs' => Helper\EscapeJs::class, + 'Zend\View\Helper\EscapeCss' => Helper\EscapeCss::class, + 'Zend\View\Helper\EscapeUrl' => Helper\EscapeUrl::class, + 'Zend\View\Helper\Gravatar' => Helper\Gravatar::class, + 'Zend\View\Helper\HtmlTag' => Helper\HtmlTag::class, + 'Zend\View\Helper\HeadLink' => Helper\HeadLink::class, + 'Zend\View\Helper\HeadMeta' => Helper\HeadMeta::class, + 'Zend\View\Helper\HeadScript' => Helper\HeadScript::class, + 'Zend\View\Helper\HeadStyle' => Helper\HeadStyle::class, + 'Zend\View\Helper\HeadTitle' => Helper\HeadTitle::class, + 'Zend\View\Helper\HtmlFlash' => Helper\HtmlFlash::class, + 'Zend\View\Helper\HtmlList' => Helper\HtmlList::class, + 'Zend\View\Helper\HtmlObject' => Helper\HtmlObject::class, + 'Zend\View\Helper\HtmlPage' => Helper\HtmlPage::class, + 'Zend\View\Helper\HtmlQuicktime' => Helper\HtmlQuicktime::class, + 'Zend\View\Helper\InlineScript' => Helper\InlineScript::class, + 'Zend\View\Helper\Json' => Helper\Json::class, + 'Zend\View\Helper\Layout' => Helper\Layout::class, + 'Zend\View\Helper\PaginationControl' => Helper\PaginationControl::class, + 'Zend\View\Helper\PartialLoop' => Helper\PartialLoop::class, + 'Zend\View\Helper\Partial' => Helper\Partial::class, + 'Zend\View\Helper\Placeholder' => Helper\Placeholder::class, + 'Zend\View\Helper\RenderChildModel' => Helper\RenderChildModel::class, + 'Zend\View\Helper\RenderToPlaceholder' => Helper\RenderToPlaceholder::class, + 'Zend\View\Helper\ServerUrl' => Helper\ServerUrl::class, + 'Zend\View\Helper\Url' => Helper\Url::class, + 'Zend\View\Helper\ViewModel' => Helper\ViewModel::class, // @codingStandardsIgnoreEnd // v2 normalized FQCNs diff --git a/src/Helper/Navigation/ConfigProvider.php b/src/Helper/Navigation/ConfigProvider.php index 51e490e61..f652fbbf6 100644 --- a/src/Helper/Navigation/ConfigProvider.php +++ b/src/Helper/Navigation/ConfigProvider.php @@ -42,10 +42,10 @@ public static function defaultViewHelperAliases(): array // Legacy Zend Framework aliases // @codingStandardsIgnoreStart - \Zend\View\Helper\Navigation\Breadcrumbs::class => Breadcrumbs::class, - \Zend\View\Helper\Navigation\Links::class => Links::class, - \Zend\View\Helper\Navigation\Menu::class => Menu::class, - \Zend\View\Helper\Navigation\Sitemap::class => Sitemap::class, + 'Zend\View\Helper\Navigation\Breadcrumbs' => Breadcrumbs::class, + 'Zend\View\Helper\Navigation\Links' => Links::class, + 'Zend\View\Helper\Navigation\Menu' => Menu::class, + 'Zend\View\Helper\Navigation\Sitemap' => Sitemap::class, // @codingStandardsIgnoreEnd // v2 normalized FQCNs diff --git a/src/Helper/Service/IdentityFactory.php b/src/Helper/Service/IdentityFactory.php index 9e0e8c296..56d5d2953 100644 --- a/src/Helper/Service/IdentityFactory.php +++ b/src/Helper/Service/IdentityFactory.php @@ -50,14 +50,16 @@ private function discoverAuthenticationService(ContainerInterface $container) return $container->get(AuthenticationService::class); } - if ($container->has(\Zend\Authentication\AuthenticationService::class)) { - return $container->get(\Zend\Authentication\AuthenticationService::class); + // @codingStandardsIgnoreStart - Because of non ::class references for Zend + if ($container->has('Zend\Authentication\AuthenticationService')) { + return $container->get('Zend\Authentication\AuthenticationService'); } return $container->has(AuthenticationServiceInterface::class) ? $container->get(AuthenticationServiceInterface::class) - : ($container->has(\Zend\Authentication\AuthenticationServiceInterface::class) - ? $container->get(\Zend\Authentication\AuthenticationServiceInterface::class) + : ($container->has('Zend\Authentication\AuthenticationServiceInterface') + ? $container->get('Zend\Authentication\AuthenticationServiceInterface') : null); + // @codingStandardsIgnoreEnd } } diff --git a/test/Helper/Service/IdentityFactoryTest.php b/test/Helper/Service/IdentityFactoryTest.php index 89fccc0ea..5158fecc8 100644 --- a/test/Helper/Service/IdentityFactoryTest.php +++ b/test/Helper/Service/IdentityFactoryTest.php @@ -44,13 +44,15 @@ public function testFactoryReturnsEmptyIdentityIfNoAuthenticationServicePresent( { $this->services->has(AuthenticationService::class)->willReturn(false); - $this->services->has(\Zend\Authentication\AuthenticationService::class)->willReturn(false); + // @codingStandardsIgnoreStart - Because of non ::class references for Zend + $this->services->has('Zend\Authentication\AuthenticationService')->willReturn(false); $this->services->get(AuthenticationService::class)->shouldNotBeCalled(); - $this->services->get(\Zend\Authentication\AuthenticationService::class)->shouldNotBeCalled(); + $this->services->get('Zend\Authentication\AuthenticationService')->shouldNotBeCalled(); $this->services->has(AuthenticationServiceInterface::class)->willReturn(false); - $this->services->has(\Zend\Authentication\AuthenticationServiceInterface::class)->willReturn(false); + $this->services->has('Zend\Authentication\AuthenticationServiceInterface')->willReturn(false); $this->services->get(AuthenticationServiceInterface::class)->shouldNotBeCalled(); - $this->services->get(\Zend\Authentication\AuthenticationServiceInterface::class)->shouldNotBeCalled(); + $this->services->get('Zend\Authentication\AuthenticationServiceInterface')->shouldNotBeCalled(); + // @codingStandardsIgnoreEnd $factory = new IdentityFactory(); @@ -67,9 +69,11 @@ public function testFactoryReturnsIdentityWithConfiguredAuthenticationServiceWhe $this->services->has(AuthenticationService::class)->willReturn(true); $this->services->get(AuthenticationService::class)->will([$authentication, 'reveal']); $this->services->has(AuthenticationServiceInterface::class)->willReturn(false); - $this->services->has(\Zend\Authentication\AuthenticationServiceInterface::class)->willReturn(false); $this->services->get(AuthenticationServiceInterface::class)->shouldNotBeCalled(); - $this->services->get(\Zend\Authentication\AuthenticationServiceInterface::class)->shouldNotBeCalled(); + // @codingStandardsIgnoreStart - Because of non ::class references for Zend + $this->services->has('Zend\Authentication\AuthenticationServiceInterface')->willReturn(false); + $this->services->get('Zend\Authentication\AuthenticationServiceInterface')->shouldNotBeCalled(); + // @codingStandardsIgnoreEnd $factory = new IdentityFactory(); @@ -85,9 +89,11 @@ public function testFactoryReturnsIdentityWithConfiguredAuthenticationServiceInt $this->services->has(AuthenticationService::class)->willReturn(false); - $this->services->has(\Zend\Authentication\AuthenticationService::class)->willReturn(false); + // @codingStandardsIgnoreStart - Because of non ::class references for Zend + $this->services->has('Zend\Authentication\AuthenticationService')->willReturn(false); + $this->services->get('Zend\Authentication\AuthenticationService')->shouldNotBeCalled(); + // @codingStandardsIgnoreEnd $this->services->get(AuthenticationService::class)->shouldNotBeCalled(); - $this->services->get(\Zend\Authentication\AuthenticationService::class)->shouldNotBeCalled(); $this->services->has(AuthenticationServiceInterface::class)->willReturn(true); $this->services->get(AuthenticationServiceInterface::class)->will([$authentication, 'reveal']);