>
>
>>  We need to be careful about changing the beahviour of existing
> operators.
>

Indeed.

The '?' character already is special, so using '??' seems like a safe,
practical approach. However, I'd prefer maintaining the form of the standard
ternary operator with the colon ($value = $var['bar'] ?? : 'Bar was not
set'; // value ="Bar was not) so the '??' operator could be applied in any
situation that one would normally use the standard ternary operator.

// standard
$value = isset($a[$key]) ? $a[$key] : 'Not set';

// new ?? double ternary that performs isset check and omits second
expression
$value = $a[$key] ?? : 'Not set';

// new ?? double ternary that performs isset check and uses second
expression
$value = $a[$key] ?? strtoupper($a[$key]) : 'Not set';

Granted, the last example might be infrequent, but I think there's also a
value in keeping the form of the double ternary (if used at all) the same as
the standard ternary operator for consistency sake.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

Reply via email to