Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fixes #700; add TResult usage to AbstractQuery.stub #701

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

Closed
arderyp wants to merge 1 commit into phpstan:2.0.x from arderyp:2.0.x

Conversation

@arderyp
Copy link

@arderyp arderyp commented Oct 24, 2025

Copy link
Member

Please add a failing test showing what kind of problem this solves.

Copy link
Contributor

@VincentLanglet VincentLanglet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

arderyp commented Oct 25, 2025

And yet it doesn't work in my environment. @ondrejmirtes Thought it was because I didn't have the config right, but I did have config according to docs as noted above.

So, maybe something is off in my environment, but I have looked in vain for months. May be some issue that arrived when there is lots of abstraction, inheritance, and generics

If you have an idea let me know, but I've provided examples above

Copy link
Member

The OP's issue isn't "TResult is unused". His issue is "getOneOrNullResult returns mixed".

Which is by design because today we do not know the hydration mode.

arderyp reacted with thumbs up emoji

Copy link
Author

arderyp commented Oct 25, 2025

Yeah that sounds right. My issue is mixed returns. The real ripening being discovered

Copy link
Contributor

If you have an idea let me know, but I've provided examples above

I saw your example #700 (comment)

And I think it should work with

->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT);

As explained by ondrej, currently we annot be sure about ->getOneOrNullResult(), because it rely on the default value
https://github.com/doctrine/orm/blob/4f36f0129a55aff44d474089c2c777f8544b1397/src/AbstractQuery.php#L106
but:

  • You can use your own Query with a different value
  • You can write something like
$qb->getQuery()->setHydrationMode(AbstractQuery::HYDRATE_SCALAR)->getOneOrNullResult();

I assume this would require a third template parameter on the Query stub...

Copy link
Author

arderyp commented Oct 25, 2025

This is very interesting. I will test this next week and get back to you!

Copy link
Contributor

This is very interesting. I will test this next week and get back to you!

I'll try to improve this situation with #702

arderyp reacted with laugh emoji

Copy link
Author

arderyp commented Oct 26, 2025

holy crap, @VincentLanglet, that solved the headache I've been working around for many months now! How silly of me to not see that option, I am so grateful that you chimed in to point me in the right direction!! If #702 is workable, it seems like a great idea, as hydrating the object seems like a logical default assumption for this package.

Thanks again, you make my week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@VincentLanglet VincentLanglet VincentLanglet left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /