getReference and typehinting in the Entity fail #5756

Closed
opened 2026-01-22 15:16:49 +01:00 by admin · 2 comments
Owner

Originally created by @michsk on GitHub (Nov 2, 2017).

When i use getReference to use in a filter. I get a Exception because my getId is typehinted in the Entity but the value set for the property is a string.

Return value of Foo\\Domain\\Entity\\Project\\Project::getId() must be an instance of Foo\\Domain\\Value\\Id\\ProjectId, string returned.

Originally created by @michsk on GitHub (Nov 2, 2017). When i use `getReference` to use in a filter. I get a Exception because my `getId` is typehinted in the Entity but the value set for the property is a string. `Return value of Foo\\Domain\\Entity\\Project\\Project::getId() must be an instance of Foo\\Domain\\Value\\Id\\ProjectId, string returned`.
admin closed this issue 2026-01-22 15:16:50 +01:00
Author
Owner

@Ocramius commented on GitHub (Nov 2, 2017):

Are you passing the appropriate values to getReference? The ORM won't
cast them for you, so you are responsible for using the correct types.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On Thu, Nov 2, 2017 at 8:15 AM, Michal-sk notifications@github.com wrote:

When i use getReference to use in a filter. I get a Exception because my
getId is typehinted in the Entity but the value set for the property is a
string.

Return value of Foo\Domain\Entity\Project\Project::getId() must be an
instance of Foo\Domain\Value\Id\ProjectId, string returned.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/6806, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakM7UZ841wMlMqXda3g48GoOVV--bks5syWwkgaJpZM4QPQaC
.

@Ocramius commented on GitHub (Nov 2, 2017): Are you passing the appropriate values to `getReference`? The ORM won't cast them for you, so you are responsible for using the correct types. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On Thu, Nov 2, 2017 at 8:15 AM, Michal-sk <notifications@github.com> wrote: > When i use getReference to use in a filter. I get a Exception because my > getId is typehinted in the Entity but the value set for the property is a > string. > > Return value of Foo\\Domain\\Entity\\Project\\Project::getId() must be an > instance of Foo\\Domain\\Value\\Id\\ProjectId, string returned. > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/6806>, or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakM7UZ841wMlMqXda3g48GoOVV--bks5syWwkgaJpZM4QPQaC> > . >
Author
Owner

@michsk commented on GitHub (Nov 2, 2017):

Ok, wasn't aware of that. Tought the ProxyFactory would ue the anotations in my Entity. Thanks this will fix it than.

@michsk commented on GitHub (Nov 2, 2017): Ok, wasn't aware of that. Tought the ProxyFactory would ue the anotations in my Entity. Thanks this will fix it than.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5756