-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReflectionHydrator is hard to extend due to the use of self::. #113
Labels
Bug
Something isn't working
Comments
ianef
added a commit
to ianef/laminas-hydrator
that referenced
this issue
Oct 1, 2023
ianef
added a commit
to ianef/laminas-hydrator
that referenced
this issue
Oct 1, 2023
This reverts commit f7c9c35.
ianef
added a commit
to ianef/laminas-hydrator
that referenced
this issue
Oct 1, 2023
ianef
added a commit
to ianef/laminas-hydrator
that referenced
this issue
Oct 1, 2023
Signed-off-by: Ian Foulds <[email protected]>
ianef
added a commit
to ianef/laminas-hydrator
that referenced
this issue
Oct 3, 2023
Signed-off-by: Ian Foulds <[email protected]>
ianef
added a commit
to ianef/laminas-hydrator
that referenced
this issue
Oct 3, 2023
This reverts commit f7c9c35. Signed-off-by: Ian Foulds <[email protected]>
ianef
added a commit
to ianef/laminas-hydrator
that referenced
this issue
Oct 3, 2023
Bug fix for issue laminas#113 - Use static instead of self.
ianef
added a commit
to ianef/laminas-hydrator
that referenced
this issue
Oct 10, 2023
Signed-off-by: Ian Foulds <[email protected]>
ianef
added a commit
to ianef/laminas-hydrator
that referenced
this issue
Oct 10, 2023
This reverts commit f7c9c35. Signed-off-by: Ian Foulds <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
I have written a hydrator that hydrates Doctrine entities from arrays and the Request object. It also handles associations within the entity, and nested associations within that. It uses Reflection to determine the target type from property types, type hints, and @var annotations.
When hydrating associations, Doctrine returns a Proxy class which inherits from the entity class we are working with. The problem is that the ReflectionHydrator uses ReflectionClass to obtain the properties of the object, but this does not return the properties of the base entity class which are marked as private, just the immediate properties of the Proxy class.
I have tried to extend ReflectionHydrator and override getReflProperties() so that I can use the parent class reflection for proxy entities, but that does not work as calls to getReflProperties are made using the self operator.
I am proposing replacing the use of
self::
withstatic::
in method calls so that extended methods will use the overridden getReflProperties method I need to customise.Summary
Extending ReflectionHydrator to override getReflProperties for custom ReflectionClass handling does not work as expected because calls to this method within ReflectionHydrator are made using self::.
Current behavior
Code in the extended ReflectionHydrator ::getReflProperties method is not called from the hydrate() or extract() methods.
Expected behavior
Code in the extended ReflectionHydrator ::getReflProperties method should be called from the hydrate() and extract() methods.
Suggested fix
The text was updated successfully, but these errors were encountered: