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

Commit 130eaa8

Browse files
committed
Merge branch 'hotfix/26'
Close #26
2 parents bc2d70f + d1138a5 commit 130eaa8

7 files changed

+146
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
## 2.7.2 - TBD
5+
## 2.7.2 - 2015-09-23
66

77
### Added
88

@@ -18,7 +18,10 @@ All notable changes to this project will be documented in this file, in reverse
1818

1919
### Fixed
2020

21-
- Nothing.
21+
- [#26](https://github.com/zendframework/zend-stdlib/pull/26) fixes a subtle
22+
inheritance issue with deprecation in the hydrators, and updates the
23+
`HydratorInterface` to also extend the zend-hydrator `HydratorInterface` to
24+
ensure LSP is preserved.
2225

2326
## 2.7.1 - 2015-09-22
2427

src/Hydrator/HydratorInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
namespace Zend\Stdlib\Hydrator;
1111

1212
use Zend\Stdlib\Extractor\ExtractionInterface;
13+
use Zend\Hydrator\HydratorInterface as BaseHydratorInterface;
1314

1415
/**
1516
* @deprecated Use Zend\Hydrator\HydratorInterface from zendframework/zend-hydrator instead.
1617
*/
17-
interface HydratorInterface extends HydrationInterface, ExtractionInterface
18+
interface HydratorInterface extends BaseHydratorInterface, HydrationInterface, ExtractionInterface
1819
{
1920
}

test/HydratorDeprecationTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,37 @@ public function testPassingHydratorExtendingStdlibAbstractHydratorToTypehintedMe
2323
$hydratorInjected->setHydrator($hydrator);
2424
$this->assertSame($hydrator, $hydratorInjected->hydrator);
2525
}
26+
27+
public function testDeprecatedHydratorInterfaceIsAcceptedByMethodsTypehintedWithNewInterface()
28+
{
29+
$hydratorInjected = new TestAsset\HydratorInjectedObjectUsingDeprecatedInterfaceTypehint();
30+
$hydrator = new TestAsset\DeprecatedInterfaceHydrator();
31+
set_error_handler(function ($errno, $errstr) {
32+
$this->fail('Catchable fatal error was triggered: ' . $errstr);
33+
}, E_RECOVERABLE_ERROR);
34+
$hydratorInjected->setHydrator($hydrator);
35+
$this->assertSame($hydrator, $hydratorInjected->hydrator);
36+
}
37+
38+
public function testDeprecatedHydratorInterfaceIsAcceptedByMethodsTypehintedWithDeprecatedHydrationInterface()
39+
{
40+
$hydratorInjected = new TestAsset\HydratorInjectedObjectUsingDeprecatedHydrationInterfaceTypehint();
41+
$hydrator = new TestAsset\DeprecatedInterfaceHydrator();
42+
set_error_handler(function ($errno, $errstr) {
43+
$this->fail('Catchable fatal error was triggered: ' . $errstr);
44+
}, E_RECOVERABLE_ERROR);
45+
$hydratorInjected->setHydrator($hydrator);
46+
$this->assertSame($hydrator, $hydratorInjected->hydrator);
47+
}
48+
49+
public function testDeprecatedHydratorInterfaceIsAcceptedByMethodsTypehintedWithDeprecatedExtractionInterface()
50+
{
51+
$hydratorInjected = new TestAsset\HydratorInjectedObjectUsingDeprecatedExtractionInterfaceTypehint();
52+
$hydrator = new TestAsset\DeprecatedInterfaceHydrator();
53+
set_error_handler(function ($errno, $errstr) {
54+
$this->fail('Catchable fatal error was triggered: ' . $errstr);
55+
}, E_RECOVERABLE_ERROR);
56+
$hydratorInjected->setExtractor($hydrator);
57+
$this->assertSame($hydrator, $hydratorInjected->extractor);
58+
}
2659
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* @see http://github.com/zendframework/zend-stdlib for the canonical source repository
4+
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-stdlib/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Stdlib\TestAsset;
9+
10+
use Zend\Stdlib\Hydrator\HydratorInterface;
11+
12+
class DeprecatedInterfaceHydrator implements HydratorInterface
13+
{
14+
/**
15+
* Hydrate $object with the provided $data.
16+
*
17+
* @param array $data
18+
* @param object $object
19+
* @return object
20+
*/
21+
public function hydrate(array $data, $object)
22+
{
23+
}
24+
25+
/**
26+
* Extract values from an object
27+
*
28+
* @param object $object
29+
* @return array
30+
*/
31+
public function extract($object)
32+
{
33+
}
34+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* @see http://github.com/zendframework/zend-stdlib for the canonical source repository
4+
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-stdlib/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Stdlib\TestAsset;
9+
10+
use Zend\Stdlib\Extractor\ExtractionInterface;
11+
12+
/**
13+
* This test asset exists to see how deprecation works; it is associated with
14+
* the test ZendTest\Stdlib\HydratorDeprecationTest.
15+
*/
16+
class HydratorInjectedObjectUsingDeprecatedExtractionInterfaceTypehint
17+
{
18+
public $extractor;
19+
20+
public function setExtractor(ExtractionInterface $extractor)
21+
{
22+
$this->extractor = $extractor;
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* @see http://github.com/zendframework/zend-stdlib for the canonical source repository
4+
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-stdlib/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Stdlib\TestAsset;
9+
10+
use Zend\Stdlib\Hydrator\HydrationInterface;
11+
12+
/**
13+
* This test asset exists to see how deprecation works; it is associated with
14+
* the test ZendTest\Stdlib\HydratorDeprecationTest.
15+
*/
16+
class HydratorInjectedObjectUsingDeprecatedHydrationInterfaceTypehint
17+
{
18+
public $hydrator;
19+
20+
public function setHydrator(HydrationInterface $hydrator)
21+
{
22+
$this->hydrator = $hydrator;
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* @see http://github.com/zendframework/zend-stdlib for the canonical source repository
4+
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-stdlib/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Stdlib\TestAsset;
9+
10+
use Zend\Hydrator\HydratorInterface;
11+
12+
/**
13+
* This test asset exists to see how deprecation works; it is associated with
14+
* the test ZendTest\Stdlib\HydratorDeprecationTest.
15+
*/
16+
class HydratorInjectedObjectUsingDeprecatedInterfaceTypehint
17+
{
18+
public $hydrator;
19+
20+
public function setHydrator(HydratorInterface $hydrator)
21+
{
22+
$this->hydrator = $hydrator;
23+
}
24+
}

0 commit comments

Comments
 (0)