From fb010bab49d42a191e2cbcba9356828a85b36d5e Mon Sep 17 00:00:00 2001 From: Wilt Date: Fri, 15 Jul 2016 11:31:03 +0200 Subject: [PATCH 1/4] Php doc improvements, removed some unused class declarations. --- src/Collection.php | 7 ++++--- src/Factory/HalViewHelperFactory.php | 5 +++++ src/Factory/LinkUrlBuilderFactory.php | 2 ++ src/Link/PaginationInjectorInterface.php | 1 + src/Link/SelfLinkInjector.php | 1 - src/Link/SelfLinkInjectorInterface.php | 2 -- src/Module.php | 10 ++++++++-- src/Plugin/Hal.php | 3 ++- src/RendererOptions.php | 2 +- src/ResourceFactory.php | 8 ++++---- src/View/HalJsonStrategy.php | 2 +- 11 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/Collection.php b/src/Collection.php index e27c30e..2dfd1b6 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -8,6 +8,7 @@ use Traversable; use Zend\Stdlib\ArrayUtils; +use Zend\Paginator\Paginator; /** * Model a collection for use with HAL payloads @@ -24,7 +25,7 @@ class Collection implements Link\LinkCollectionAwareInterface protected $attributes = []; /** - * @var array|Traversable|\Zend\Paginator\Paginator + * @var array|Traversable|Paginator */ protected $collection; @@ -99,7 +100,7 @@ class Collection implements Link\LinkCollectionAwareInterface protected $entityRouteParams = []; /** - * @param array|Traversable|\Zend\Paginator\Paginator $collection + * @param array|Traversable|Paginator $collection * @param string $entityRoute * @param array|Traversable $entityRouteParams * @param array|Traversable $entityRouteOptions @@ -491,7 +492,7 @@ public function getAttributes() /** * Collection * - * @return array|Traversable|\Zend\Paginator\Paginator + * @return array|Traversable|Paginator */ public function getCollection() { diff --git a/src/Factory/HalViewHelperFactory.php b/src/Factory/HalViewHelperFactory.php index 659d1fa..2fad790 100644 --- a/src/Factory/HalViewHelperFactory.php +++ b/src/Factory/HalViewHelperFactory.php @@ -7,6 +7,8 @@ namespace ZF\Hal\Factory; use Interop\Container\ContainerInterface; +use Zend\Hydrator\HydratorInterface; +use Zend\Hydrator\HydratorPluginManager; use Zend\ServiceManager\AbstractPluginManager; use ZF\Hal\Exception; use ZF\Hal\Extractor\LinkCollectionExtractor; @@ -28,6 +30,8 @@ public function __invoke(ContainerInterface $container) /* @var $rendererOptions \ZF\Hal\RendererOptions */ $rendererOptions = $container->get('ZF\Hal\RendererOptions'); $metadataMap = $container->get('ZF\Hal\MetadataMap'); + + /** @var HydratorPluginManager $hydrators */ $hydrators = $metadataMap->getHydratorManager(); $helper = new Plugin\Hal($hydrators); @@ -48,6 +52,7 @@ public function __invoke(ContainerInterface $container) )); } + /** @var HydratorInterface $hydrator */ $hydrator = $hydrators->get($defaultHydrator); $helper->setDefaultHydrator($hydrator); } diff --git a/src/Factory/LinkUrlBuilderFactory.php b/src/Factory/LinkUrlBuilderFactory.php index 8ae2814..20adc4c 100644 --- a/src/Factory/LinkUrlBuilderFactory.php +++ b/src/Factory/LinkUrlBuilderFactory.php @@ -6,6 +6,7 @@ namespace ZF\Hal\Factory; +use Zend\View\Helper\ServerUrl; use ZF\Hal\Link\LinkUrlBuilder; class LinkUrlBuilderFactory @@ -20,6 +21,7 @@ public function __invoke($container) $viewHelperManager = $container->get('ViewHelperManager'); + /** @var ServerUrl $serverUrlHelper */ $serverUrlHelper = $viewHelperManager->get('ServerUrl'); if (isset($halConfig['options']['use_proxy'])) { $serverUrlHelper->setUseProxy($halConfig['options']['use_proxy']); diff --git a/src/Link/PaginationInjectorInterface.php b/src/Link/PaginationInjectorInterface.php index 9ba73f0..54038ad 100644 --- a/src/Link/PaginationInjectorInterface.php +++ b/src/Link/PaginationInjectorInterface.php @@ -7,6 +7,7 @@ namespace ZF\Hal\Link; use ZF\Hal\Collection; +use ZF\ApiProblem\ApiProblem; interface PaginationInjectorInterface { diff --git a/src/Link/SelfLinkInjector.php b/src/Link/SelfLinkInjector.php index 3dffcdd..94565cd 100644 --- a/src/Link/SelfLinkInjector.php +++ b/src/Link/SelfLinkInjector.php @@ -6,7 +6,6 @@ namespace ZF\Hal\Link; -use ZF\Hal\Link\LinkCollectionAwareInterface; use ZF\Hal\Collection; use ZF\Hal\Entity; diff --git a/src/Link/SelfLinkInjectorInterface.php b/src/Link/SelfLinkInjectorInterface.php index 5e832fb..1451969 100644 --- a/src/Link/SelfLinkInjectorInterface.php +++ b/src/Link/SelfLinkInjectorInterface.php @@ -6,8 +6,6 @@ namespace ZF\Hal\Link; -use ZF\Hal\Link\LinkCollectionAwareInterface; - interface SelfLinkInjectorInterface { /** diff --git a/src/Module.php b/src/Module.php index 01435a9..18a3fbf 100644 --- a/src/Module.php +++ b/src/Module.php @@ -6,6 +6,7 @@ namespace ZF\Hal; +use Zend\Mvc\Application; use Zend\Mvc\MvcEvent; use ZF\Hal\View\HalJsonStrategy; @@ -30,7 +31,9 @@ public function getConfig() */ public function onBootstrap(MvcEvent $e) { - $events = $e->getTarget()->getEventManager(); + /** @var Application $application */ + $application = $e->getTarget(); + $events = $application->getEventManager(); $events->attach(MvcEvent::EVENT_RENDER, [$this, 'onRender'], 100); } @@ -48,11 +51,14 @@ public function onRender(MvcEvent $e) return; } - $services = $e->getTarget()->getServiceManager(); + /** @var Application $application */ + $application = $e->getTarget(); + $services = $application->getServiceManager(); $events = $services->get('View')->getEventManager(); // register at high priority, to "beat" normal json strategy registered // via view manager + /** @var HalJsonStrategy $halStrategy */ $halStrategy = $services->get('ZF\Hal\JsonStrategy'); $halStrategy->attach($events, 200); } diff --git a/src/Plugin/Hal.php b/src/Plugin/Hal.php index ef5c69c..4b2e521 100644 --- a/src/Plugin/Hal.php +++ b/src/Plugin/Hal.php @@ -39,6 +39,7 @@ use ZF\Hal\Metadata\MetadataMap; use ZF\Hal\Resource; use ZF\Hal\ResourceFactory; +use Traversable; /** * Generate links for use with HAL payloads @@ -941,7 +942,7 @@ public function createCollection($collection, $route = null) } /** - * @param object $object + * @param array|Traversable|Paginator $object * @param Metadata $metadata * @return Collection */ diff --git a/src/RendererOptions.php b/src/RendererOptions.php index 96a9257..7870669 100644 --- a/src/RendererOptions.php +++ b/src/RendererOptions.php @@ -87,7 +87,7 @@ public function setHydrators(array $hydrators) } /** - * @return string + * @return array */ public function getHydrators() { diff --git a/src/ResourceFactory.php b/src/ResourceFactory.php index 5bcd2d8..3e7095f 100644 --- a/src/ResourceFactory.php +++ b/src/ResourceFactory.php @@ -7,13 +7,13 @@ namespace ZF\Hal; use Closure; -use ZF\Hal\Collection; -use ZF\Hal\Entity; use ZF\Hal\Extractor\EntityExtractor; use ZF\Hal\Exception; use ZF\Hal\Link\Link; use ZF\Hal\Link\LinkCollection; use ZF\Hal\Metadata\Metadata; +use Traversable; +use Zend\Paginator\Paginator; class ResourceFactory { @@ -40,7 +40,7 @@ public function __construct(EntityHydratorManager $entityHydratorManager, Entity /** * Create a entity and/or collection based on a metadata map * - * @param object $object + * @param object|array|Traversable|Paginator $object * @param Metadata $metadata * @param bool $renderEmbeddedEntities * @return Entity|Collection @@ -89,7 +89,7 @@ public function createEntityFromMetadata($object, Metadata $metadata, $renderEmb } /** - * @param object $object + * @param array|Traversable|Paginator $object * @param Metadata $metadata * @return Collection */ diff --git a/src/View/HalJsonStrategy.php b/src/View/HalJsonStrategy.php index 887ca85..0d6dd41 100644 --- a/src/View/HalJsonStrategy.php +++ b/src/View/HalJsonStrategy.php @@ -32,7 +32,7 @@ class HalJsonStrategy extends JsonStrategy */ public function __construct(HalJsonRenderer $renderer) { - $this->renderer = $renderer; + parent::__construct($renderer); } /** From 1e0f853f28566eaaf6c8e70921f380717221b7e7 Mon Sep 17 00:00:00 2001 From: Wilt Date: Mon, 8 Aug 2016 15:47:41 +0200 Subject: [PATCH 2/4] Changed class declarations to alphabetical order --- src/Collection.php | 2 +- src/Link/PaginationInjectorInterface.php | 2 +- src/Plugin/Hal.php | 2 +- src/ResourceFactory.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Collection.php b/src/Collection.php index 2dfd1b6..8b41650 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -7,8 +7,8 @@ namespace ZF\Hal; use Traversable; -use Zend\Stdlib\ArrayUtils; use Zend\Paginator\Paginator; +use Zend\Stdlib\ArrayUtils; /** * Model a collection for use with HAL payloads diff --git a/src/Link/PaginationInjectorInterface.php b/src/Link/PaginationInjectorInterface.php index 54038ad..9de0c5e 100644 --- a/src/Link/PaginationInjectorInterface.php +++ b/src/Link/PaginationInjectorInterface.php @@ -6,8 +6,8 @@ namespace ZF\Hal\Link; -use ZF\Hal\Collection; use ZF\ApiProblem\ApiProblem; +use ZF\Hal\Collection; interface PaginationInjectorInterface { diff --git a/src/Plugin/Hal.php b/src/Plugin/Hal.php index 4b2e521..c4a5d21 100644 --- a/src/Plugin/Hal.php +++ b/src/Plugin/Hal.php @@ -8,6 +8,7 @@ use ArrayObject; use Countable; +use Traversable; use Zend\EventManager\Event; use Zend\EventManager\EventInterface; use Zend\EventManager\EventManagerAwareInterface; @@ -39,7 +40,6 @@ use ZF\Hal\Metadata\MetadataMap; use ZF\Hal\Resource; use ZF\Hal\ResourceFactory; -use Traversable; /** * Generate links for use with HAL payloads diff --git a/src/ResourceFactory.php b/src/ResourceFactory.php index 3e7095f..55e83be 100644 --- a/src/ResourceFactory.php +++ b/src/ResourceFactory.php @@ -7,13 +7,13 @@ namespace ZF\Hal; use Closure; +use Traversable; +use Zend\Paginator\Paginator; use ZF\Hal\Extractor\EntityExtractor; use ZF\Hal\Exception; use ZF\Hal\Link\Link; use ZF\Hal\Link\LinkCollection; use ZF\Hal\Metadata\Metadata; -use Traversable; -use Zend\Paginator\Paginator; class ResourceFactory { From c7f665c6f7ecbc08e770e476e217ab1ffdcb49f7 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 11 Oct 2016 13:01:26 -0500 Subject: [PATCH 3/4] Typehint on ApplicationInterface, not Application. --- src/Module.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module.php b/src/Module.php index 18a3fbf..0a47c8f 100644 --- a/src/Module.php +++ b/src/Module.php @@ -6,7 +6,7 @@ namespace ZF\Hal; -use Zend\Mvc\Application; +use Zend\Mvc\ApplicationInterface; use Zend\Mvc\MvcEvent; use ZF\Hal\View\HalJsonStrategy; @@ -31,7 +31,7 @@ public function getConfig() */ public function onBootstrap(MvcEvent $e) { - /** @var Application $application */ + /** @var ApplicationInterface $application */ $application = $e->getTarget(); $events = $application->getEventManager(); $events->attach(MvcEvent::EVENT_RENDER, [$this, 'onRender'], 100); From 16c73d058c66073c0ab6d94f709ee699f2abd429 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 11 Oct 2016 13:02:26 -0500 Subject: [PATCH 4/4] Revert change to HalJsonStrategy constructor --- src/View/HalJsonStrategy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/View/HalJsonStrategy.php b/src/View/HalJsonStrategy.php index 0d6dd41..887ca85 100644 --- a/src/View/HalJsonStrategy.php +++ b/src/View/HalJsonStrategy.php @@ -32,7 +32,7 @@ class HalJsonStrategy extends JsonStrategy */ public function __construct(HalJsonRenderer $renderer) { - parent::__construct($renderer); + $this->renderer = $renderer; } /**