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

fix some iterator stubs #6970

Merged
merged 8 commits into from Jan 30, 2022
Merged

fix some iterator stubs #6970

merged 8 commits into from Jan 30, 2022

Conversation

orklah
Copy link
Collaborator

@orklah orklah commented Nov 22, 2021

This fixes some iterator stubs, directly inspired from phpstan/phpstan-src#796

@weirdan can you review this? In particular, I was not sure if I should have used @template-covariant somewhere

Copy link
Collaborator

@weirdan weirdan left a comment

Choose a reason for hiding this comment

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

I think all of those need to pass through the TIterator type parameter:

./stubs/CoreGenericIterators.phpstub|139| class AppendIterator extends IteratorIterator {
./stubs/CoreGenericIterators.phpstub|325| class FilterIterator extends IteratorIterator {
./stubs/CoreGenericIterators.phpstub|349| class CachingIterator extends IteratorIterator implements OuterIterator , ArrayAccess , Countable  {
./stubs/CoreGenericIterators.phpstub|533| class InfiniteIterator extends IteratorIterator {
./stubs/CoreGenericIterators.phpstub|560| class LimitIterator extends IteratorIterator implements OuterIterator {
./stubs/CoreGenericIterators.phpstub|587| class NoRewindIterator extends IteratorIterator {

@orklah
Copy link
Collaborator Author

orklah commented Nov 24, 2021

I'm out of luck! Some time ago I used one of those in a test(https://github.com/vimeo/psalm/runs/4293084567?check_suite_focus=true#step:7:133) to show we could use a Generator to populate the templates of the Iterator.

This was quite obvious when there was two templates in the Iterator, now that there's three, I'm not sure anymore.

I'll see when PHPStan merge the PR what it looks like when I run the test in it and I'll advise

@orklah orklah marked this pull request as draft December 11, 2021 22:15
@orklah orklah added release:fix The PR will be included in 'Fixes' section of the release notes PR: Need review and removed PR: Needs work labels Jan 23, 2022
@orklah orklah requested a review from weirdan January 23, 2022 07:28
@orklah orklah marked this pull request as ready for review January 23, 2022 07:33
@orklah
Copy link
Collaborator Author

orklah commented Jan 28, 2022

@weirdan mind looking at this one? If it's okay, I'll merge it

@weirdan
Copy link
Collaborator

weirdan commented Jan 28, 2022

@orklah it's on my todo list along with several other PRs.

stubs/CoreGenericIterators.phpstub Outdated Show resolved Hide resolved
stubs/CoreGenericIterators.phpstub Outdated Show resolved Hide resolved
stubs/CoreGenericIterators.phpstub Outdated Show resolved Hide resolved
stubs/CoreGenericIterators.phpstub Outdated Show resolved Hide resolved
stubs/CoreGenericIterators.phpstub Outdated Show resolved Hide resolved
stubs/CoreGenericIterators.phpstub Outdated Show resolved Hide resolved
stubs/CoreGenericIterators.phpstub Outdated Show resolved Hide resolved
stubs/CoreGenericIterators.phpstub Outdated Show resolved Hide resolved
stubs/CoreGenericIterators.phpstub Outdated Show resolved Hide resolved
stubs/CoreGenericIterators.phpstub Outdated Show resolved Hide resolved
@orklah orklah merged commit 1220320 into vimeo:master Jan 30, 2022
@drupol
Copy link
Contributor

drupol commented Jun 3, 2022

Hey hi,

I'm testing Psalm 5b1 and I have this new issue:

ERROR: MissingTemplateParam - src/SimpleCachingIteratorAggregate.php:30:13 - CachingIterator has missing template params, expecting 3 (see https://psalm.dev/182)

This comes from there: https://github.com/loophp/iterators/blob/main/src/SimpleCachingIteratorAggregate.php#L28

I'm trying to understand why does \CachingIterator needs 3 template parameters ?
Therefore, how to fix this then ? https://psalm.dev/r/17b32189e1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Need review release:fix The PR will be included in 'Fixes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants