Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Hydrator/HydratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
namespace Zend\Stdlib\Hydrator;

use Zend\Stdlib\Extractor\ExtractionInterface;
use Zend\Hydrator\HydratorInterface as BaseHydratorInterface;

/**
* @deprecated Use Zend\Hydrator\HydratorInterface from zendframework/zend-hydrator instead.
*/
interface HydratorInterface extends HydrationInterface, ExtractionInterface
interface HydratorInterface extends BaseHydratorInterface, HydrationInterface, ExtractionInterface
{
}
33 changes: 33 additions & 0 deletions test/HydratorDeprecationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,37 @@ public function testPassingHydratorExtendingStdlibAbstractHydratorToTypehintedMe
$hydratorInjected->setHydrator($hydrator);
$this->assertSame($hydrator, $hydratorInjected->hydrator);
}

public function testDeprecatedHydratorInterfaceIsAcceptedByMethodsTypehintedWithNewInterface()
{
$hydratorInjected = new TestAsset\HydratorInjectedObjectUsingDeprecatedInterfaceTypehint();
$hydrator = new TestAsset\DeprecatedInterfaceHydrator();
set_error_handler(function ($errno, $errstr) {
$this->fail('Catchable fatal error was triggered: ' . $errstr);
}, E_RECOVERABLE_ERROR);
$hydratorInjected->setHydrator($hydrator);
$this->assertSame($hydrator, $hydratorInjected->hydrator);
}

public function testDeprecatedHydratorInterfaceIsAcceptedByMethodsTypehintedWithDeprecatedHydrationInterface()
{
$hydratorInjected = new TestAsset\HydratorInjectedObjectUsingDeprecatedHydrationInterfaceTypehint();
$hydrator = new TestAsset\DeprecatedInterfaceHydrator();
set_error_handler(function ($errno, $errstr) {
$this->fail('Catchable fatal error was triggered: ' . $errstr);
}, E_RECOVERABLE_ERROR);
$hydratorInjected->setHydrator($hydrator);
$this->assertSame($hydrator, $hydratorInjected->hydrator);
}

public function testDeprecatedHydratorInterfaceIsAcceptedByMethodsTypehintedWithDeprecatedExtractionInterface()
{
$hydratorInjected = new TestAsset\HydratorInjectedObjectUsingDeprecatedExtractionInterfaceTypehint();
$hydrator = new TestAsset\DeprecatedInterfaceHydrator();
set_error_handler(function ($errno, $errstr) {
$this->fail('Catchable fatal error was triggered: ' . $errstr);
}, E_RECOVERABLE_ERROR);
$hydratorInjected->setExtractor($hydrator);
$this->assertSame($hydrator, $hydratorInjected->extractor);
}
}
34 changes: 34 additions & 0 deletions test/TestAsset/DeprecatedInterfaceHydrator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* @see http://github.com/zendframework/zend-stdlib for the canonical source repository
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-stdlib/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Stdlib\TestAsset;

use Zend\Stdlib\Hydrator\HydratorInterface;

class DeprecatedInterfaceHydrator implements HydratorInterface
{
/**
* Hydrate $object with the provided $data.
*
* @param array $data
* @param object $object
* @return object
*/
public function hydrate(array $data, $object)
{
}

/**
* Extract values from an object
*
* @param object $object
* @return array
*/
public function extract($object)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* @see http://github.com/zendframework/zend-stdlib for the canonical source repository
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-stdlib/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Stdlib\TestAsset;

use Zend\Stdlib\Extractor\ExtractionInterface;

/**
* This test asset exists to see how deprecation works; it is associated with
* the test ZendTest\Stdlib\HydratorDeprecationTest.
*/
class HydratorInjectedObjectUsingDeprecatedExtractionInterfaceTypehint
{
public $extractor;

public function setExtractor(ExtractionInterface $extractor)
{
$this->extractor = $extractor;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* @see http://github.com/zendframework/zend-stdlib for the canonical source repository
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-stdlib/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Stdlib\TestAsset;

use Zend\Stdlib\Hydrator\HydrationInterface;

/**
* This test asset exists to see how deprecation works; it is associated with
* the test ZendTest\Stdlib\HydratorDeprecationTest.
*/
class HydratorInjectedObjectUsingDeprecatedHydrationInterfaceTypehint
{
public $hydrator;

public function setHydrator(HydrationInterface $hydrator)
{
$this->hydrator = $hydrator;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* @see http://github.com/zendframework/zend-stdlib for the canonical source repository
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-stdlib/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Stdlib\TestAsset;

use Zend\Hydrator\HydratorInterface;

/**
* This test asset exists to see how deprecation works; it is associated with
* the test ZendTest\Stdlib\HydratorDeprecationTest.
*/
class HydratorInjectedObjectUsingDeprecatedInterfaceTypehint
{
public $hydrator;

public function setHydrator(HydratorInterface $hydrator)
{
$this->hydrator = $hydrator;
}
}