Skip to content
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.8] Improvements regarding arguments passed to the Gate callbacks #28079

Merged
merged 2 commits into from
Apr 1, 2019

Conversation

sebdesign
Copy link
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