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

reduce method: more accurate types #394

Merged
merged 1 commit into from
Feb 22, 2024
Merged

Conversation

gharlan
Copy link
Contributor

@gharlan gharlan commented Feb 21, 2024

No description provided.

* @psalm-param Closure(TReturn|TInitial|null, T):(TInitial|TReturn) $func
* @psalm-param TInitial|null $initial
* @psalm-param Closure(TReturn|TInitial, T):TReturn $func
* @psalm-param TInitial $initial
Copy link
Contributor Author

@gharlan gharlan Feb 21, 2024

Choose a reason for hiding this comment

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

If $initial is not null, the closure does not need to accept null value for first param.

@greg0ire
Copy link
Member

This was introduced in #252
@VincentLanglet please review 🙏

@VincentLanglet
Copy link
Contributor

This was introduced in #252 @VincentLanglet please review 🙏

I dunno where I found the types, but i copied them from somewhere else,
like vimeo/psalm#5574 for example.

Searching for similar types in psalm, I found
https://github.com/vimeo/psalm/blob/c401490265497fd9d025459b5d3dbe29d80394fe/stubs/extensions/ds.phpstub#L196-L203
https://github.com/phpstan/phpstan-src/blob/0f9fda8461421672e5b2f90807289d9207796c7f/stubs/arrayFunctions.stub#L3-L13

This PR seems to go in the right direction

@greg0ire greg0ire merged commit 2ccb7c5 into doctrine:2.1.x Feb 22, 2024
8 checks passed
@greg0ire
Copy link
Member

Thanks @gharlan !

@greg0ire greg0ire added this to the 2.1.5 milestone Feb 26, 2024
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.

4 participants