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

Zend\Stdlib\Hydrator is not fully backwards-compatible with Zend\Hydrator #34

Closed
prolic opened this issue Oct 15, 2015 · 2 comments
Closed

Comments

@prolic
Copy link
Contributor

prolic commented Oct 15, 2015

See for reference:
phpro/zf-doctrine-hydration-module#20

also related:
zfcampus/zf-apigility-doctrine#234

@boesing
Copy link
Member

boesing commented Jan 9, 2017

Actually, the AbstractHydrator of v2.7.0 has BC breaks to v2.6.0 as it doesn't implement zendframework/zend-stdlib interfaces like StrategyEnabledInterface, e.g.

Therefore, any code that depends on those interfaces (e.g. by typehinting them in method definitions), cannot upgrade to v2.7.0.

Bad example but this might show the problem pretty clear:

<?php

class MyHydratorWhichAlwaysHadStrategyEnabledInterfaceFromStdlib extends \Zend\Stdlib\Hydrator\AbstractHydrator
{
    // Implementation
}


class Service
{

    private $hydrator;

    public function __construct(MyHydratorWhichAlwaysHadStrategyEnabledInterfaceFromStdlib $hydrator)
    {
        // Yes we could use interface typehinting but however
        $this->hydrator = $hydrator;
    }

    public function doSomething()
    {
        // do some fancy stuff

        // Attach some custom strategies
        $this->attachCustomStrategies($this->hydrator);
    }

    private function attachCustomStrategies(\Zend\Stdlib\Hydrator\StrategyEnabledInterface $hydrator)
    {
        // Work with that interface
    }
}

Well now, the argumentation could be "Why wont you just check the interface before using the Method. Okay, I could do that, but anyways, the code wont getting executed at all then.

Proper way would be to migrate our code to the new interfaces introduced with zendframework/zend-hydrator but actually this could have side-effects in our code which contains more than a few lines.

However, any reasons why the interfaces are not implemented in zendframework/zend-stdlib AbstractHydrator? Just wondering, this would've been the best way to ensure BC.
Dont wont to start a discussion, just a little hint to understand these changes for myself.

@PowerKiKi
Copy link

Related issues have all have been closed, and this one should be closed too, because it now is obsolete.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants