rfc:null-propagation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
rfc:null-propagation [2018/01/23 09:17] – created daverandomrfc:null-propagation [2018/01/23 10:14] daverandom
Line 1: Line 1:
 ====== PHP RFC: Null Propagation Operator ====== ====== PHP RFC: Null Propagation Operator ======
-  * Version: 0.9+  * Version: 0.1
   * Date: 2018-01-23   * Date: 2018-01-23
   * Author: Chris Wright, daverandom@php.net   * Author: Chris Wright, daverandom@php.net
Line 42: Line 42:
  
 <code php> <code php>
 +$foo = new Foo(null);
 $result = $foo->getBar()?->method(); $result = $foo->getBar()?->method();
 +var_dump($result); // NULL
 </code> </code>
 +
 +This operator does not suppress any errors that are generated by the left hand side of the expression, it only short-circuits the right hand side.
  
 ===== Examples in other languages ===== ===== Examples in other languages =====
 +  * [[https://docs.hhvm.com/hack/operators/null-safe|Hack]]
   * [[https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operators|C# and Visual Basic]]   * [[https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operators|C# and Visual Basic]]
-  * [[https://github.com/tc39/proposal-optional-chaining|ECMA Script]] (Stage 1 proposal)+  * [[https://github.com/tc39/proposal-optional-chaining|ECMAScript]] (Stage 1 proposal)
   * [[http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/|Ruby]]   * [[http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/|Ruby]]
  
rfc/null-propagation.txt · Last modified: 2018/01/29 16:33 by levim