-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[10.x] Create EmptyArgument
class
#44042
Conversation
`null` can have different meanings when used in different contexts. in a lot of places in the framework, it is used to mean "ignore this parameter when no argument is passed, and execute different behavior than if a value had been passed". for the most part this is fine, but it limits us slightly by not be able to check for a desired `null` value. this new empty marker class allows us to specifically designate we wish to treat the method call as if the argument was not passed, without conflating the use of `null`.
Hmm - not totally sold on this one yet 😄 We can detect if null was actually passed vs. "empty argument" using func_num_args()... we do that in a few places in the framework. |
@browner12 cool solution. I actually toyed around with |
Thanks for the heads-up on I'd offer two counterpoints.
|
@browner12, I mistyped, I meant |
Thanks for the clarification. I think the point still stands, as @taylorotwell is referencing the use of Also, I believe you'd run into the same implicit issues with |
@browner12, sure. I'm only pointing out that it can be done with |
null
can have different meanings when used in different contexts. in a lot of places in the framework, it is used to mean "ignore this parameter when no argument is passed, and execute different behavior than if a value had been passed". for the most part this is fine, but it limits us slightly by not be able to check for a desirednull
value. this new empty marker class allows us to specifically designate we wish to treat the method call as if the argument was not passed, without conflating the use ofnull
.this must go to
master
because it requires a new feature of PHP 8.1 (https://www.php.net/manual/en/functions.arguments.php)credit to @jasonmccreary for sparking this idea in #43923
there are a lot of places in the framework this would be useful, but I limited this PR to just the one usage change. if this gets merged, I'd PR some more of those changes in.