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.5] Use of argument (un)packing in throw_if/unless helpers #19255

Merged
merged 2 commits into from
May 18, 2017
Merged

[5.5] Use of argument (un)packing in throw_if/unless helpers #19255

merged 2 commits into from
May 18, 2017

Conversation

kduma
Copy link
Contributor

@kduma kduma commented May 18, 2017

This change allows to pass more than one argument to the exception class.

For example base exception class accepts message and code, so after this PR we can do this:

throw_if($is_error, \Exception::class, $message, $code);

@kduma kduma changed the title Use of argument (un)packing in throw_if/unless helpers [5.5] Use of argument (un)packing in throw_if/unless helpers May 18, 2017
* @return void
*/
function throw_if($boolean, $exception, $message = '')
function throw_if($boolean, $exception, ...$arguments)
Copy link
Member

Choose a reason for hiding this comment

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

I would rename this to $parameters.

Copy link
Contributor Author

@kduma kduma May 18, 2017

Choose a reason for hiding this comment

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

True. At least I've learned something 😄

Copy link
Member

Choose a reason for hiding this comment

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

Uh... I've got that backwards.

I was simply saying that I'd use $parameters because that's what we use all over in our __call methods. I wasn't thinking from a semantic perspective.

From a semantic perspective, $arguments actually makes more sense.

So I take back what I said originally. I now believe that $arguments is actually a better name 🙈

because "argument is the value/variable/reference being passed in, parameter is the receiving variable used w/in the function/block" :)
@taylorotwell taylorotwell merged commit d2f57e9 into laravel:master May 18, 2017
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.

None yet

3 participants