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

chore: more specific return type for chunk() method #351

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rela589n
Copy link
Contributor

Follows from #350

Copy link

what-the-diff bot commented Nov 26, 2024

PR Summary

  • Modified Return Type in chunk Method
    This PR updates the type of data that the chunk method returns. Previously, it could return a list that might be empty. Now, it ensures that the list returned will always contain at least one item. This adjustment improves the method's reliability and predictability in our system.

@drupol
Copy link
Collaborator

drupol commented Nov 26, 2024

I think there are some new errors to fix.

@rela589n
Copy link
Contributor Author

Do you mean this CI error?

image

Unfortunately I could not get my local environment ready for the development (If I remember correctly, if I try to run tests on the main branch, some of them fail) yet

@rela589n rela589n force-pushed the 350-more-specific-chunk-return-type branch 2 times, most recently from 5f228d2 to 1da16de Compare November 30, 2024 13:25
Comment on lines +37 to +38
$chunkIndex = 0;
$chunk = [];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@drupol , I have slightly changed the variables names here, since it took me around 15 minutes to figure out what $i, $values, and $sizes variables mean and what the code below does. If you wish, I could revert it back to the previous version, but in my opinion the current implementation is better

Copy link
Collaborator

Choose a reason for hiding this comment

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

No no it's fine, it's actually a good idea.

Comment on lines 55 to 56
/** @var non-empty-list<T> $chunk */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

without this @var annotation psalm won't be able to infer the fact that chunk is never empty when it is yielded

@@ -18,47 +18,49 @@
final class Chunk extends AbstractOperation
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@drupol , frankly speaking I have no clue what these errors are all about

image

@rela589n rela589n force-pushed the 350-more-specific-chunk-return-type branch from 1da16de to ce28b5a Compare November 30, 2024 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants