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

Add NoRewindIterator stub. #1453

Merged
merged 3 commits into from Jun 23, 2022
Merged

Add NoRewindIterator stub. #1453

merged 3 commits into from Jun 23, 2022

Conversation

drupol
Copy link
Contributor

@drupol drupol commented Jun 22, 2022

No description provided.

@ondrejmirtes
Copy link
Member

Hi, please just add one stub, make the build green, and wait for feedback.

@drupol
Copy link
Contributor Author

drupol commented Jun 22, 2022

Ok will split this in multiple PRs.

@drupol drupol marked this pull request as ready for review June 22, 2022 07:21
Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

Also - this class needs to be added to parameters.featureToggles.skipCheckGenericClasses in conf/config.neon.

*
* @template-extends IteratorIterator<TKey, TValue, TIterator>
*/
class NoRewindIterator extends IteratorIterator {
Copy link
Member

Choose a reason for hiding this comment

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

This stub is different from the one in Psalm: https://github.com/vimeo/psalm/blob/36d5a2a83c1d7b3e2aca1cfe9e9dcc916619e962/stubs/CoreGenericIterators.phpstub#L581-L604 (This one uses three template types, Psalm uses two). We need to be cross-compatible here.

Copy link
Contributor

@orklah orklah Jun 22, 2022

Choose a reason for hiding this comment

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

Note that NoRewindIterator has three templates in the next major of Psalm: https://github.com/vimeo/psalm/blob/master/stubs/CoreGenericIterators.phpstub#L593

(as well as every child of IteratorIterator IIRC)

EDIT: more context here: vimeo/psalm#6970 it originated from a change in phpstan that we duplicated in Psalm but only on our master branch

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I didn't realize that. So I'll recheck the stubs against master.

Copy link
Contributor Author

@drupol drupol Jun 22, 2022

Choose a reason for hiding this comment

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

Indeed, I inspired those PRs from what's in PSalm (@master branch)

@ondrejmirtes
Copy link
Member

All the other PRs have exactly the same problems so I'm not gonna repeat the reviews there.

@ondrejmirtes
Copy link
Member

(That's why I asked you to submit only one stub and wait for feedback.)

@drupol
Copy link
Contributor Author

drupol commented Jun 22, 2022

In the end, should IteratorIterator have 2 or 3 parameters? Thanks!

@ondrejmirtes
Copy link
Member

In both Psalm and PHPStan it currently has three (https://github.com/vimeo/psalm/blob/36d5a2a83c1d7b3e2aca1cfe9e9dcc916619e962/stubs/CoreGenericIterators.phpstub#L104-L113) so I don't know why you think it needs to change?

@drupol
Copy link
Contributor Author

drupol commented Jun 22, 2022

Just to be sure, nothing else.

@ondrejmirtes ondrejmirtes merged commit adf7313 into phpstan:1.7.x Jun 23, 2022
@ondrejmirtes
Copy link
Member

Thank you.

@drupol drupol deleted the iterators/add-norewinditerator branch June 23, 2022 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants