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

Reindex collection array after filtering values #87

Merged
merged 1 commit into from
Jun 11, 2021

Conversation

endelwar
Copy link
Contributor

IterableImplementation relies on a zero-indexed offset; when filtering a collection $collection->periods array isn't reindexed, causing collection iteration to stop at the first hole in the index.
Applying array_values to array_filter results fixes the bug.
array_values performs better than splat-packing.

@freekmurze freekmurze merged commit bf62abc into spatie:master Jun 11, 2021
@freekmurze
Copy link
Member

Thanks!

@endelwar
Copy link
Contributor Author

Glad to help!

@endelwar endelwar deleted the fix-foreach-after-filter branch June 11, 2021 20:11
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