Re: Implicit isset/isempty check on short-ternary operator

From: Date: Thu, 07 Apr 2011 23:02:51 +0000
Subject: Re: Implicit isset/isempty check on short-ternary operator
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-51831@lists.php.net to get a copy of this message
Hi!
      $value = isset($a[$key]) ? $a[$key] : 'Not set';
which is exactly the situation I had before it was introduced.
Not sure why you would have that expectation. The long ternary doesn't do that, and there is nothing about the short ternary that changes that.
It is true, however I think the amount of boilerplate code produces by this paradigm is staggering, and it's about time we fixed that. We had a chance of doing it with ?: but for one reason or another it was passed, but the need is still there. I think actually the idea of "expr ?? expr2", meaning (isset($expr)?$expr:$expr2) is not bad. Anybody sees any holes in it? And yes, I wouldn't be disappointed too much if ?: didn't generate notices either. With modern IDEs times when it helped catch typos are mostly gone, and now these warnings are just a very annoying reason to write boilerplate code. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

« previous php.internals (#51831) next »