-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
refactor: Update Init
operation in point free style.
#186
Conversation
252517c
to
d5deebd
Compare
d5deebd
to
253f077
Compare
src/Operation/Init.php
Outdated
* @param TKey $key | ||
* @param CachingIterator<TKey, T> $iterator | ||
*/ | ||
static fn ($value, $key, CachingIterator $iterator): bool => $iterator->getInnerIterator()->valid(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason Psalm thinks that getInnerIterator
returns Traversable
here instead of Iterator
, but I cannot replicate it in the playground: https://psalm.dev/r/037fdbb040. The trace shows Iterator
there.
But in this project:
INFO: Trace - src/Operation/Init.php:42:17 - $inner: Traversable (see https://psalm.dev/224)
/** @psalm-trace $inner */
$inner = $iterator->getInnerIterator();
Could it be the Psalm version? (we must be using an older one)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha ! I almost made the same Psalm example to try it out on my own :)
I don't know where the issue comes from yet, I'm investigating!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only happens with PHP 8. Weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird. Using CachingIterator::hasNext()
fixed the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should open an issue on Psalm with that, sounds like a problem in PHP 8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did here: vimeo/psalm#6359 we'll see how it goes.
This PR:
Init
in point free style.TakeWhile
operation.