Skip to content

[5.8] Improvements regarding arguments passed to the Gate callbacks#28079

Merged
taylorotwell merged 2 commits into
laravel:5.8from
sebdesign:5.8
Apr 1, 2019
Merged

[5.8] Improvements regarding arguments passed to the Gate callbacks#28079
taylorotwell merged 2 commits into
laravel:5.8from
sebdesign:5.8

Conversation

@sebdesign
Copy link
Copy Markdown
Contributor

Simplify the arguments passed to the before callbacks

This commit removes some legacy code that was laying around since #12305 was merged.

Before that PR, the arguments were spread out before being passed to the callbacks,
so the user and the ability were merged with the other arguments, before being passed to the callback.

Since then, the arguments are being passed as an array,
so instead of merging the user and the ability with the array of arguments, which is superfluous,
we can directly pass the user, the ability, and the arguments directly to the callback.

This commit doesn't change the existing functionality, and it keeps backwards compatibility.

I have also added some assertions to the tests, since the arguments in the before callbacks were never tested.

Improve tests for arguments in ability checks

Use assertSame because assertEquals doesn't compare object references.

Add assertions that the arguments are passed to the after callbacks.

This commit removes some legacy code that was laying around since laravel#12305 was merged.

Before that PR, the arguments were spread out before being passed to the callbacks,
so the user and the ability were merged with the other arguments, before being passed to the callback.

Since then, the arguments are being passed as an array,
so instead of merging the user and the ability with the array of arguments, which is superfluous,
we can directly pass the user, the ability, and the arguments directly to the callback.

This commit doesn't change the existing functionality, and it keeps backwards compatibility.

I have also added some assertions to the tests, since the arguments in the before callbacks were never tested.
Use `assertSame` because `assertEquals` doesn't compare object references.

Add assertions that the arguments are passed to the after callbacks.
@taylorotwell taylorotwell merged commit dbfec10 into laravel:5.8 Apr 1, 2019
@GrahamCampbell GrahamCampbell changed the title Improvements regarding arguments passed to the Gate callbacks [5.8] Improvements regarding arguments passed to the Gate callbacks Apr 6, 2019
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.

2 participants