[5.7] Fix a unsuspected result from the split function in the Collection class #24088
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See: #22090
This will change the result of the split function to return the requested amount of collections (except the total of items is less then the requested number)
Example
collect(['a', 'b', 'c', 'd'])->split(3);
// expected and new result
[['a', 'b'], ['c'], ['d']]
// result before this change
[['a', 'b'], ['c', 'd']]
It will change the split function and add 3 new tests to test some edge cases that are fixed with this change.
This was already provided for the 5.6 branch where @taylorotwell point out that he will not change this in a point release (See #24083 ). That is something that I understand.
I think it is good to change this in the next release or explain it in the documentation.