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

Commit b894a85

Browse files
committed
Merge branch 'hotfix/7672' into release-2.7
Close #54
2 parents e0a88d2 + d782694 commit b894a85

File tree

6 files changed

+178
-7
lines changed

6 files changed

+178
-7
lines changed

Diff for: .travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ matrix:
2323
- php: 7
2424
- php: hhvm
2525
allow_failures:
26-
- php: 7
2726
- php: hhvm
2827

2928
notifications:
@@ -36,7 +35,7 @@ before_install:
3635
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
3736

3837
install:
39-
- travis_retry composer install --no-interaction --ignore-platform-reqs
38+
- COMPOSER_ROOT_VERSION=2.7.99 travis_retry composer install --no-interaction --ignore-platform-reqs
4039

4140
script:
4241
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi

Diff for: CHANGELOG.md

+21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 2.7.5 - 2016-02-16
6+
7+
### Added
8+
9+
- Nothing.
10+
11+
### Deprecated
12+
13+
- Nothing.
14+
15+
### Removed
16+
17+
- Nothing.
18+
19+
### Fixed
20+
21+
- [#54](https://github.com/zendframework/zend-stdlib/pull/54) updates the
22+
`HelperPluginManager` implementation to return zend-stdlib-specific instances
23+
(instead of zend-hydrator instances), to ensure backwards compatibility when
24+
typehinting against the zend-stdlib types.
25+
526
## 2.7.4 - 2015-10-15
627

728
### Added

Diff for: composer.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}
1414
},
1515
"require": {
16-
"php": ">=5.5",
16+
"php": "^5.5 || ^7.0",
1717
"zendframework/zend-hydrator": "~1.0"
1818
},
1919
"require-dev": {
@@ -37,8 +37,9 @@
3737
"prefer-stable": true,
3838
"extra": {
3939
"branch-alias": {
40-
"dev-master": "2.7-dev",
41-
"dev-develop": "2.8-dev"
40+
"dev-release-2.7": "2.7-dev",
41+
"dev-master": "3.0-dev",
42+
"dev-develop": "3.1-dev"
4243
}
4344
},
4445
"autoload-dev": {

Diff for: src/Hydrator/DelegatingHydratorFactory.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@
99

1010
namespace Zend\Stdlib\Hydrator;
1111

12-
use Zend\Hydrator\DelegatingHydratorFactory as BaseDelegatingHydratorFactory;
12+
use Zend\ServiceManager\FactoryInterface;
13+
use Zend\ServiceManager\ServiceLocatorInterface;
1314

1415
/**
1516
* @deprecated Use Zend\Hydrator\DelegatingHydratorFactory from zendframework/zend-hydrator instead.
1617
*/
17-
class DelegatingHydratorFactory extends BaseDelegatingHydratorFactory
18+
class DelegatingHydratorFactory implements FactoryInterface
1819
{
20+
public function createService(ServiceLocatorInterface $serviceLocator)
21+
{
22+
// Assume that this factory is registered with the HydratorManager,
23+
// and just pass it directly on.
24+
return new DelegatingHydrator($serviceLocator);
25+
}
1926
}

Diff for: src/Hydrator/HydratorPluginManager.php

+30
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,34 @@
2020
*/
2121
class HydratorPluginManager extends BaseHydratorPluginManager
2222
{
23+
/**
24+
* Default aliases
25+
*
26+
* @var array
27+
*/
28+
protected $aliases = [
29+
'delegatinghydrator' => 'Zend\Stdlib\Hydrator\DelegatingHydrator',
30+
];
31+
32+
/**
33+
* Default set of adapters
34+
*
35+
* @var array
36+
*/
37+
protected $invokableClasses = [
38+
'arrayserializable' => 'Zend\Stdlib\Hydrator\ArraySerializable',
39+
'classmethods' => 'Zend\Stdlib\Hydrator\ClassMethods',
40+
'objectproperty' => 'Zend\Stdlib\Hydrator\ObjectProperty',
41+
'reflection' => 'Zend\Stdlib\Hydrator\Reflection'
42+
];
43+
44+
/**
45+
* Default factory-based adapters
46+
*
47+
* @var array
48+
*/
49+
protected $factories = [
50+
'Zend\Stdlib\Hydrator\DelegatingHydrator' => 'Zend\Stdlib\Hydrator\DelegatingHydratorFactory',
51+
'zendstdlibhydratordelegatinghydrator' => 'Zend\Stdlib\Hydrator\DelegatingHydratorFactory',
52+
];
2353
}

Diff for: test/Hydrator/HydratorPluginManagerTest.php

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
/**
3+
* Zend Framework (http://framework.zend.com/)
4+
*
5+
* @link http://github.com/zendframework/zend-stdlib for the canonical source repository
6+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
7+
* @license http://framework.zend.com/license/new-bsd New BSD License
8+
*/
9+
10+
namespace ZendTest\Stdlib\Hydrator;
11+
12+
use PHPUnit_Framework_TestCase as TestCase;
13+
use ReflectionProperty;
14+
use Zend\Hydrator\HydratorPluginManager as BasePluginManager;
15+
use Zend\Stdlib\Hydrator\HydratorInterface;
16+
use Zend\Stdlib\Hydrator\HydratorPluginManager;
17+
18+
class HydratorPluginManagerTest extends TestCase
19+
{
20+
public function setUp()
21+
{
22+
$this->hydrators = new HydratorPluginManager();
23+
}
24+
25+
public function testExtendsZendHydratorPluginManager()
26+
{
27+
$this->assertInstanceOf(BasePluginManager::class, $this->hydrators);
28+
}
29+
30+
public function aliases()
31+
{
32+
$hydrators = new HydratorPluginManager();
33+
$r = new ReflectionProperty($hydrators, 'aliases');
34+
$r->setAccessible(true);
35+
foreach ($r->getValue($hydrators) as $alias => $target) {
36+
yield $alias => [$alias, $target];
37+
}
38+
}
39+
40+
/**
41+
* @dataProvider aliases
42+
*/
43+
public function testAllAliasesReturnStdlibEquivalents($alias, $expected)
44+
{
45+
$this->assertContains('\\Stdlib\\', $expected, 'Alias target is not a Stdlib class?');
46+
47+
$hydrator = $this->hydrators->get($alias);
48+
$this->assertInstanceOf(
49+
$expected,
50+
$hydrator,
51+
sprintf('Alias %s did not retrieve expected %s instance; got %s', $alias, $expected, get_class($hydrator))
52+
);
53+
$this->assertInstanceOf(
54+
HydratorInterface::class,
55+
$hydrator,
56+
sprintf('Alias %s resolved to %s, which is not a HydratorInterface instance', $alias, get_class($hydrator))
57+
);
58+
}
59+
60+
public function invokables()
61+
{
62+
$hydrators = new HydratorPluginManager();
63+
$r = new ReflectionProperty($hydrators, 'invokableClasses');
64+
$r->setAccessible(true);
65+
foreach ($r->getValue($hydrators) as $name => $target) {
66+
yield $name => [$name, $target];
67+
}
68+
}
69+
70+
/**
71+
* @dataProvider invokables
72+
*/
73+
public function testAllInvokablesReturnStdlibInstances($name, $expected)
74+
{
75+
$this->assertContains('\\Stdlib\\', $expected, 'Invokable target is not a Stdlib class?');
76+
77+
$hydrator = $this->hydrators->get($name);
78+
$this->assertInstanceOf($expected, $hydrator, sprintf(
79+
'Invokable %s did not retrieve expected %s instance; got %s',
80+
$name,
81+
$expected,
82+
get_class($hydrator)
83+
));
84+
$this->assertInstanceOf(HydratorInterface::class, $hydrator, sprintf(
85+
'Invokable %s resolved to %s, which is not a HydratorInterface instance',
86+
$name,
87+
get_class($hydrator)
88+
));
89+
}
90+
91+
public function factories()
92+
{
93+
$hydrators = new HydratorPluginManager();
94+
$r = new ReflectionProperty($hydrators, 'factories');
95+
$r->setAccessible(true);
96+
foreach ($r->getValue($hydrators) as $name => $factory) {
97+
yield $name => [$name, $factory];
98+
}
99+
}
100+
101+
/**
102+
* @dataProvider factories
103+
*/
104+
public function testAllFactoriesReturnStdlibInstances($name, $factory)
105+
{
106+
$hydrator = $this->hydrators->get($name);
107+
$this->assertInstanceOf(HydratorInterface::class, $hydrator, sprintf(
108+
'Factory for %s resolved to %s, which is not a HydratorInterface instance',
109+
$name,
110+
get_class($hydrator)
111+
));
112+
}
113+
}

0 commit comments

Comments
 (0)