[12.x] Add parameter validation to Collection::sliding() method.#57875
Merged
Conversation
shaedrich
reviewed
Nov 23, 2025
Comment on lines
1285
to
1286
| * @param int $size | ||
| * @param int $step |
Contributor
There was a problem hiding this comment.
You can narrow this further down then:
Suggested change
| * @param int $size | |
| * @param int $step | |
| * @param positive-int $size | |
| * @param positive-int $step |
| @@ -1285,9 +1285,19 @@ public function shuffle() | |||
| * @param int $size | |||
| * @param int $step | |||
| * @return static<int, static> | |||
Contributor
There was a problem hiding this comment.
You might even reflect that in the return type:
Suggested change
| * @return static<int, static> | |
| * @return $size is positive-int ? $step is positive-int ? static<int, static> : never : never |
akyrey
pushed a commit
to akyrey/framework
that referenced
this pull request
Dec 29, 2025
…avel#57875) * [12.x] Add parameter validation to Collection::sliding() method * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds parameter validations to
Collection::sliding()andLazyCollection::sliding()methods.The methods will throw an
InvalidArgumentExceptionwhen the$stepsand$sizeparameters are <1.With that way we have 2 issues fixed.
Thank you.