Hi Peter > Wouldn't it make more sense to make `isset` smarter? So that it can > handle these situations just like it would with array access. That > way you could use the null coalescing operator as well.
Both of those are valid approaches. I do prefer the ?-> operator for two reasons. 1. ?? is more error prone (e.g. you won't get an error if a variable or property is undefined) 2. You can see immediately which sub-expressions can be null and which cannot (or rather must not) That is not to say that there aren't also benefits to ?? 1. No new syntax to learn 2. You can see more clearly where the short circuiting chain ends > I don't see many situations where you would be selective in which > method in the chain you would want to make nullsafe and which ones you > wouldn't. IMO you should only use ?-> exactly where you expect null values. Using ?? would ignore null (as well as undefined) everywhere in any sub-expression even if unexpected. > I don't recall ever having to nest three levels like that example. I agree. Take the example with a grain of salt. It's hard to come up with a relatable, meaningful, short example. > Sorry if I come off a bit harsh, but I don't see the need for this as > other solutions to this problem are more favourable IMHO. Not in the slightest. That's why it's called a "request for feedback" and not "request for praise", you're free to disagree :) > As much as it can be annoying sometimes, the `Call to a member > function foo() on null` is a very useful error. Absolutely. To clarify: The idea is not to sprinkle ?-> everywhere. Only use ?-> when null is an expected and acceptable value. Ilija -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php