>>Why not allow nullable types on parameters to avoid that wonkiness >>caused by default values of null? >> >> function foo(Bar | Null $b, $not_optional_param); >> >>This is much better. > > Yes but still a code smell to me. I'd need to know more about the > programmer's intent for `foo(null, "value")`. It might be better to swap > order, or change the method name, or add another method... Who knows? Need > to take each case individually.
Having a separate method instead of `foo(null, "value")` makes it difficult to use for the result of a function. Assume `bar()` returns `Bar | Null`; this would no longer work if they were separated: foo(bar(), "value") Functions are often composed so if something is the output of one function it will likely be the input to another. Thus if returning optionally null values is important to you so should optionally null parameters. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php