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

refactor: Update Init operation in point free style. #186

Merged
merged 3 commits into from
Aug 24, 2021

Conversation

drupol
Copy link
Collaborator

@drupol drupol commented Aug 23, 2021

This PR:

  • Update Init in point free style.
  • Includes a minor out of scope change in TakeWhile operation.

@drupol drupol added the enhancement New feature or request label Aug 23, 2021
@drupol drupol force-pushed the refactor/update-init-operation branch from 252517c to d5deebd Compare August 24, 2021 06:44
@drupol drupol force-pushed the refactor/update-init-operation branch from d5deebd to 253f077 Compare August 24, 2021 06:46
@drupol drupol marked this pull request as ready for review August 24, 2021 06:47
* @param TKey $key
* @param CachingIterator<TKey, T> $iterator
*/
static fn ($value, $key, CachingIterator $iterator): bool => $iterator->getInnerIterator()->valid();
Copy link
Collaborator

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)

Copy link
Collaborator Author

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!

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I should submit this to PSalm.

image

Copy link
Collaborator Author

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.

Copy link
Collaborator

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

Copy link
Collaborator Author

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.

@drupol drupol merged commit 31b27cc into master Aug 24, 2021
@drupol drupol deleted the refactor/update-init-operation branch August 24, 2021 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants