On Wed, Jul 18, 2012 at 7:20 AM, Anthony Ferrara <ircmax...@gmail.com>wrote:
> > On Wed, Jul 18, 2012 at 10:15 AM, Rafael Dohms <lis...@rafaeldohms.com.br > >wrote: > > > [...] > > > > This is basically because the ternary operator does not do a internal > > implicit isset, only an empty. > > > > It does not do an empty. Empty would avoid notices as well. All it does is > an implicit bool cast... > > > > Does this seem like a possible improvement we can work on? Anyone > > interested in championing the change? > > > > I like it in principle. My only concern is *why* wasn't it done this way in > the first place... Is there a reason? > It changes the semantics. If the variable is set to a falsey value and ?: uses an implicit isset, the value of the expression will be the falsey value. $config['width'] = '' $width = $config['width'] ?: 300 # $width == '' If !empty were used instead of isset, you could preserve semantics ($a ?: dflt = !empty($a) ? $a : dflt).