-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[5.3] Add split method to collection class #15302
Conversation
@@ -921,6 +921,23 @@ public function slice($offset, $length = null) | |||
} | |||
|
|||
/** | |||
* Split a collection into a certain number of groups. | |||
* | |||
* @param int $numberOfGroups |
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.
missing space
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.
Sorry about that, fixed.
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.
Still not correct?
@@ -920,6 +920,23 @@ public function slice($offset, $length = null) | |||
return new static(array_slice($this->items, $offset, $length, true)); | |||
} | |||
|
|||
/** |
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.
This whole block is indented by one too many spaces
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.
Honest mistake, fixed now (using the patch file from style ci)
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.
Still incorrect.
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.
StyleCI aligned it to your method definition which is also indented incorrectly.
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.
Wut? Can StyleCI be incorrect? 😄
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.
StyleCI is correct according to Laravel's rules. The phpdoc must be aligned to match the method. There is no fixer to change the alignment of the actual method definition yet.
/** | ||
* Split a collection into a certain number of groups. | ||
* | ||
* @param int $numberOfGroups |
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.
When I said a missing space, I really did mean exactly one space was missing.
Please put exactly two spaces inbetween int
and $
.
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.
Done, my apologies for all the trouble.
public function split($numberOfGroups) | ||
{ | ||
if ($this->isEmpty()) { | ||
return $this; |
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.
should return a new instance here
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.
yup
Refs #10889 |
This PR adds a
split
method toIlluminate\Support\Collection
that splits a collection into the given number of groups.