Skip to content

Commit

Permalink
Stringify Zend related class references so that composer-require-chec…
Browse files Browse the repository at this point in the history
…ker doesn't complain about them

Signed-off-by: George Steel <george@net-glue.co.uk>
  • Loading branch information
gsteel committed Jan 13, 2022
1 parent 5c34b2c commit a57dd1e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 52 deletions.
72 changes: 36 additions & 36 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/Helper/Navigation/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/Helper/Service/IdentityFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
22 changes: 14 additions & 8 deletions test/Helper/Service/IdentityFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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']);

Expand Down

0 comments on commit a57dd1e

Please sign in to comment.