Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge 97b481d into a5828b3
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Nov 20, 2018
2 parents a5828b3 + 97b481d commit 44e3d0f
Show file tree
Hide file tree
Showing 131 changed files with 915 additions and 1,244 deletions.
37 changes: 5 additions & 32 deletions .travis.yml
Expand Up @@ -13,53 +13,26 @@ env:

matrix:
include:
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- DEPS=locked
- LEGACY_DEPS="phpunit/phpunit"
- php: 5.6
env:
- DEPS=latest
- php: 7
env:
- DEPS=lowest
- php: 7
env:
- DEPS=locked
- LEGACY_DEPS="phpunit/phpunit"
- php: 7
env:
- DEPS=latest
- php: 7.1
- php: 7.2
env:
- DEPS=lowest
- php: 7.1
- php: 7.2
env:
- DEPS=locked
- CS_CHECK=true
- TEST_COVERAGE=true
- php: 7.1
env:
- DEPS=latest
- php: 7.2
env:
- DEPS=lowest
- php: 7.2
env:
- DEPS=locked
- php: 7.2
- DEPS=latest
- php: nightly
env:
- DEPS=latest

before_install:
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi

install:
- travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs
- if [[ $LEGACY_DEPS != '' ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
- travis_retry composer install $COMPOSER_ARGS
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Expand Up @@ -16,21 +16,21 @@
"forum": "https://discourse.zendframework.com/c/questions/components"
},
"require": {
"php": "^5.6 || ^7.0",
"php": "^7.2",
"zendframework/zend-stdlib": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2",
"phpunit/phpunit": "^7.1.2",
"phpspec/prophecy": "^1.7.4",
"zendframework/zend-coding-standard": "~1.0.0",
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
"zendframework/zend-eventmanager": "^3.0",
"zendframework/zend-serializer": "^2.6.1",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3"
"zendframework/zend-servicemanager": "^3.0.3"
},
"suggest": {
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0, to support aggregate hydrator usage",
"zendframework/zend-filter": "^2.6, to support naming strategy hydrator usage",
"zendframework/zend-eventmanager": "^3.0, to support aggregate hydrator usage",
"zendframework/zend-serializer": "^2.6.1, to use the SerializableStrategy",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3, to support hydrator plugin manager usage"
"zendframework/zend-servicemanager": "^3.0.3, to support hydrator plugin manager usage"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 39 additions & 63 deletions src/AbstractHydrator.php
@@ -1,12 +1,12 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see https://github.com/zendframework/zend-hydrator for the canonical source repository
* @copyright Copyright (c) 2010-2018 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-hydrator/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace Zend\Hydrator;

use ArrayObject;
Expand Down Expand Up @@ -51,15 +51,15 @@ public function __construct()
* Gets the strategy with the given name.
*
* @param string $name The name of the strategy to get.
*
* @throws Exception\InvalidArgumentException
* @return Strategy\StrategyInterface
*/
public function getStrategy($name)
public function getStrategy(string $name) : Strategy\StrategyInterface
{
if (isset($this->strategies[$name])) {
return $this->strategies[$name];
} elseif ($this->hasNamingStrategy()
}

if ($this->hasNamingStrategy()
&& ($hydrated = $this->getNamingStrategy()->hydrate($name))
&& isset($this->strategies[$hydrated])
) {
Expand All @@ -81,9 +81,8 @@ public function getStrategy($name)
* Checks if the strategy with the given name exists.
*
* @param string $name The name of the strategy to check for.
* @return bool
*/
public function hasStrategy($name)
public function hasStrategy(string $name) : bool
{
if (array_key_exists($name, $this->strategies)) {
return true;
Expand All @@ -103,35 +102,31 @@ public function hasStrategy($name)
*
* @param string $name The name of the strategy to register.
* @param Strategy\StrategyInterface $strategy The strategy to register.
* @return AbstractHydrator
*/
public function addStrategy($name, Strategy\StrategyInterface $strategy)
public function addStrategy(string $name, Strategy\StrategyInterface $strategy) : void
{
$this->strategies[$name] = $strategy;
return $this;
}

/**
* Removes the strategy with the given name.
*
* @param string $name The name of the strategy to remove.
* @return HydratorInterface
*/
public function removeStrategy($name)
public function removeStrategy(string $name) : void
{
unset($this->strategies[$name]);
return $this;
}

/**
* Converts a value for extraction. If no strategy exists the plain value is returned.
*
* @param string $name The name of the strategy to use.
* @param mixed $value The value that should be converted.
* @param mixed $object The object is optionally provided as context.
* @param string $name The name of the strategy to use.
* @param mixed $value The value that should be converted.
* @param null|object $object The object is optionally provided as context.
* @return mixed
*/
public function extractValue($name, $value, $object = null)
public function extractValue(string $name, $value, ?object $object = null)
{
if ($this->hasStrategy($name)) {
$strategy = $this->getStrategy($name);
Expand All @@ -143,12 +138,12 @@ public function extractValue($name, $value, $object = null)
/**
* Converts a value for hydration. If no strategy exists the plain value is returned.
*
* @param string $name The name of the strategy to use.
* @param mixed $value The value that should be converted.
* @param array $data The whole data is optionally provided as context.
* @param string $name The name of the strategy to use.
* @param mixed $value The value that should be converted.
* @param null|array $data The whole data is optionally provided as context.
* @return mixed
*/
public function hydrateValue($name, $value, $data = null)
public function hydrateValue(string $name, $value, ?array $data = null)
{
if ($this->hasStrategy($name)) {
$strategy = $this->getStrategy($name);
Expand All @@ -160,11 +155,11 @@ public function hydrateValue($name, $value, $data = null)
/**
* Convert a name for extraction. If no naming strategy exists, the plain value is returned.
*
* @param string $name The name to convert.
* @param null $object The object is optionally provided as context.
* @param string $name The name to convert.
* @param null $object The object is optionally provided as context.
* @return mixed
*/
public function extractName($name, $object = null)
public function extractName(string $name, $object = null)
{
if ($this->hasNamingStrategy()) {
$name = $this->getNamingStrategy()->extract($name, $object);
Expand All @@ -175,11 +170,10 @@ public function extractName($name, $object = null)
/**
* Converts a value for hydration. If no naming strategy exists, the plain value is returned.
*
* @param string $name The name to convert.
* @param array $data The whole data is optionally provided as context.
* @return mixed
* @param string $name The name to convert.
* @param array $data The whole data is optionally provided as context.
*/
public function hydrateName($name, $data = null)
public function hydrateName(string $name, ?array $data = null) : string
{
if ($this->hasNamingStrategy()) {
$name = $this->getNamingStrategy()->hydrate($name, $data);
Expand All @@ -189,10 +183,8 @@ public function hydrateName($name, $data = null)

/**
* Get the filter instance
*
* @return Filter\FilterComposite
*/
public function getFilter()
public function getFilter() : Filter\FilterInterface
{
return $this->filterComposite;
}
Expand All @@ -215,83 +207,67 @@ public function getFilter()
*
* @param string $name Index in the composite
* @param callable|Filter\FilterInterface $filter
* @param int $condition
* @return Filter\FilterComposite
*/
public function addFilter($name, $filter, $condition = Filter\FilterComposite::CONDITION_OR)
public function addFilter(string $name, $filter, int $condition = Filter\FilterComposite::CONDITION_OR) : void
{
return $this->filterComposite->addFilter($name, $filter, $condition);
$this->filterComposite->addFilter($name, $filter, $condition);
}

/**
* Check whether a specific filter exists at key $name or not
*
* @param string $name Index in the composite
* @return bool
* @param string $name Index/name in the composite
*/
public function hasFilter($name)
public function hasFilter(string $name) : bool
{
return $this->filterComposite->hasFilter($name);
}

/**
* Remove a filter from the composition.
* To not extract "has" methods, you simply need to unregister it
*
* To not extract "has" methods, unregister the filter.
*
* <code>
* $filterComposite->removeFilter('has');
* </code>
*
* @param $name
* @return Filter\FilterComposite
*/
public function removeFilter($name)
public function removeFilter(string $name) : void
{
return $this->filterComposite->removeFilter($name);
$this->filterComposite->removeFilter($name);
}

/**
* Adds the given naming strategy
*
* @param NamingStrategy\NamingStrategyInterface $strategy The naming to register.
* @return self
*/
public function setNamingStrategy(NamingStrategy\NamingStrategyInterface $strategy)
public function setNamingStrategy(NamingStrategy\NamingStrategyInterface $strategy) : void
{
$this->namingStrategy = $strategy;

return $this;
}

/**
* Gets the naming strategy.
*
* @return NamingStrategy\NamingStrategyInterface
*/
public function getNamingStrategy()
public function getNamingStrategy() : NamingStrategy\NamingStrategyInterface
{
return $this->namingStrategy;
}

/**
* Checks if a naming strategy exists.
*
* @return bool
*/
public function hasNamingStrategy()
public function hasNamingStrategy() : bool
{
return isset($this->namingStrategy);
}

/**
* Removes the naming strategy
*
* @return self
*/
public function removeNamingStrategy()
public function removeNamingStrategy() : void
{
$this->namingStrategy = null;

return $this;
}
}

0 comments on commit 44e3d0f

Please sign in to comment.