Skip to content

Conversation

@faissaloux
Copy link
Contributor

@faissaloux faissaloux commented Jun 2, 2024

Helloo 👋🏻

In this PR I have fixed the collection shift() behaviour when trying to shift less than one item.

Fixes #51684


$count = 0

Current

$collection = new Collection(['foo', 'bar', 'baz']); echo $collection->shift(0); // ['foo', 'bar'] echo $collection; // ['baz']

Expected

$collection = new Collection(['foo', 'bar', 'baz']); echo $collection->shift(0); // [] echo $collection; // ['foo', 'bar', 'baz']

$count < 0

Current

$collection = new Collection(['foo', 'bar', 'baz']); echo $collection->shift(-1); // ['foo', 'bar', 'baz'] echo $collection; // []

Expected

$collection = new Collection(['foo', 'bar', 'baz']); echo $collection->shift(-1); // InvalidArgumentException
@faissaloux faissaloux changed the title [10.x] Fix collection shift less than 1 [10.x] Fix collection shift less than one item Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants