Skip to content
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

Query result type inference often not working with getOneOrNullResult #271

Closed
janedbal opened this issue Jan 27, 2022 · 4 comments
Closed

Comments

@janedbal
Copy link
Contributor

See failures in #270, all the new getOneOrNullResult are infered as mixed even though the getResult works fine.

E.g. here

@ondrejmirtes
Copy link
Member

/cc @arnaud-lb

@arnaud-lb
Copy link
Contributor

Hi @janedbal

Currently, Query result type inference supports only HYDRATE_OBJECT mode. What happens here is that we don't know the hydration mode of getOneOrNullResult() when called with 0 arguments, because it defaults to $this->_hydrationMode.

getResult() is different because its default hydration mode is HYDRATE_OBJECT.

One way to get type inference out of getOneOrNullResult() is to specify the hydration mode when calling it: getOneOrNullResult(Query::HYDRATE_OBJECT).

(See #232 (comment) for details on how each getResult() variant is supported.)

@janedbal
Copy link
Contributor Author

I see, thanks for response, I'll force passing hydration type to getOneOrNullResult in our codebase to make it analysable.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2022
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

3 participants