Skip to content

Conversation

@clarkewing
Copy link

This PR seeks to improve the Laravel 11 Upgrade Guide by documenting the breaking changes introduced in laravel/framework#49642.

It suggests macros for applications which require seeded shuffles.

This PR seeks to improve the Laravel 11 Upgrade Guide by documenting the breaking changes introduced in laravel/framework#49642.

It suggests macros for applications which require seeded shuffles.
use Illuminate\Support\Collection;

Arr::macro('shuffleWithSeed', function (array $array, ?int $seed = null): array {
if (is_null($seed)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid using a function here:

Suggested change
if (is_null($seed)) {
if ($seed === null) {

@taylorotwell
Copy link
Member

I'm not sure entirely we should recommend this as it could be insecure.

@clarkewing
Copy link
Author

@taylorotwell Would you be open to merging if I were to remove the recommended macros?
Users could then figure this part out themselves should they require it in non security-sensitive areas of their apps (predictably shuffling quiz answers is an example in an app I'm working on).

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.

3 participants