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

Use more precise return type for count method #355

Merged
merged 2 commits into from Dec 8, 2022
Merged

Use more precise return type for count method #355

merged 2 commits into from Dec 8, 2022

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Dec 8, 2022

Countable is supposed to return

@return int<0, max>

(vimeo/psalm#8861)

So I would say it's better to rely on inherit doc rather than overriding the return tag ?
@greg0ire

@VincentLanglet VincentLanglet marked this pull request as ready for review December 8, 2022 15:04
@greg0ire
Copy link
Member

greg0ire commented Dec 8, 2022

If it doesn't break what #353 solves, that looks good indeed.

@VincentLanglet
Copy link
Contributor Author

If it doesn't break what #353 solves, that looks good indeed.

Yeah, I was wondering if I needed the @return int<0, max> for this...
Is there any test about it ?

Because the LazyCollection use inherit
https://github.com/doctrine/collections/blob/2.1.x/src/AbstractLazyCollection.php#L31-L35

@VincentLanglet
Copy link
Contributor Author

I just tried in my project @greg0ire and the @return is needed.
So I updated it to @return int<0, max> then. (I get no deprecation this way)

@VincentLanglet VincentLanglet changed the title Rely on inherit doc Use more precise return type for count method Dec 8, 2022
Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

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

Thanks for triple checking, Vincent 🙏

@greg0ire greg0ire added this to the 2.1.1 milestone Dec 8, 2022
@greg0ire
Copy link
Member

greg0ire commented Dec 8, 2022

Technically not a bugfix, but it's OK to target 2.1 IMO because the things it's improving is not released yet.

@greg0ire greg0ire merged commit 425857d into doctrine:2.1.x Dec 8, 2022
@VincentLanglet VincentLanglet deleted the count branch December 8, 2022 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants