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

Zend\Stdlib\Hydrator interfaces no longer accepted by Zend\Form #25

Closed
adamlundrigan opened this issue Sep 23, 2015 · 5 comments
Closed

Comments

@adamlundrigan
Copy link
Contributor

I happened to do a "composer update" on one of my projects very soon after Zend\Form 2.6.0 was released, and because of my version constraint (~2.5) it was installed...and then my form broke with this error:

Argument 1 passed to Zend\Form\Fieldset::setHydrator() must implement interface Zend\Hydrator\HydratorInterface, instance of ******\UserQueryHydrator given

Since my custom hydrator implemented the Zend\Stdlib\Hydrator\HydratorInterface directly instead of inheriting from AbstractHydrator I could no longer use my custom hydrator in forms.

The fix was simple (replace references to "Stdlib\Hydrator" with "Hydrator") but it's still a break. IMO the better way to fix it would be to update the interfaces in Zend\Stdlib\Hydrator to extend the new ones from the Zend\Hydrator namespace. If that's an acceptable solution I can send a PR

@weierophinney
Copy link
Member

They already do! 2.6.0 depends on stdlib 2.7, which keeps all existing
classes and interfaces, and has then extend the zend-hydrator equivalents.
I've even tested extensively with Apigility to ensure that they fulfill the
liskov substitution principle.

It sounds almost like stdlib want updated properly; can you verify the
version of that library?
On Sep 22, 2015 7:21 PM, "Adam Lundrigan" notifications@github.com wrote:

I happened to do a "composer update" on one of my projects very soon after
Zend\Form 2.6.0 was released, and because of my version constraint (~2.5)
it was installed...and then my form broke with this error:

Argument 1 passed to Zend\Form\Fieldset::setHydrator() must implement
interface Zend\Hydrator\HydratorInterface, instance of
******\UserQueryHydrator given

Since my custom hydrator implemented the
Zend\Stdlib\Hydrator\HydratorInterface directly instead of inheriting from
AbstractHydrator I could no longer use my custom hydrator in forms.

The fix was simple (replace references to "Stdlib\Hydrator" with
"Hydrator") but it's still a break. IMO the better way to fix it would be
to update the interfaces in Zend\Stdlib\Hydrator to extend the new ones
from the Zend\Hydrator namespace. If that's an acceptable solution I can
send a PR


Reply to this email directly or view it on GitHub
#25.

@adamlundrigan
Copy link
Contributor Author

I have zend-stdlib 2.7.1 and in it Zend\Stdlib\Hydrator\HydratorInterface doesn't directly extend Zend\Hydrator\HydratorInterface and so isn't accepted by the Form::setHydrator typehint. It extends Zend\Hydrator\HydrationInterface (through deprecated Zend\Stdlib\Hydrator\HydrationInterface) and Zend\Hydrator\ExtractionInterface (through deprecated Zend\Stdlib\Extractor\ExtractionInterface).

The plural "...interfaces in Zend\Stdlib\Hydrator..." in my original post wasn't warranted...it's only the HydratorInterface that's affected. The Hydration and Extraction interfaces are OK.

@weierophinney
Copy link
Member

Oof, can't believe I missed that one! Yes, please do a PR, and I'll get it
merged and cut a release as soon as I can.

Thanks, Adam!
On Sep 22, 2015 8:32 PM, "Adam Lundrigan" notifications@github.com wrote:

I have zend-stdlib 2.7.1 and in it Zend\Stdlib\Hydrator\HydratorInterface
https://github.com/zendframework/zend-stdlib/blob/master/src/Hydrator/HydratorInterface.php
doesn't directly extend Zend\Hydrator\HydratorInterface and so isn't
accepted by the Form::setHydrator typehint
https://github.com/zendframework/zend-form/blob/master/src/Form.php#L14.
It extends Zend\Hydrator\HydrationInterface (through deprecated
Zend\Stdlib\Hydrator\HydrationInterface) and
Zend\Hydrator\ExtractionInterface (through deprecated
Zend\Stdlib\Extractor\ExtractionInterface).

The plural "...interface_s_ n Zend\Stdlib\Hydrator.." in my original post
wasn't warranted...it's only the HydratorInterface that's affected. The
Hydration and Extraction interfaces are OK.


Reply to this email directly or view it on GitHub
#25 (comment)
.

@adamlundrigan
Copy link
Contributor Author

It was a tricky one, took some headscratching and a few runs through the inheritance chain to spot it.

PR to fix is in #26

@weierophinney
Copy link
Member

Closed with #26.

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

2 participants