Conversation
|
I think the token page and the language/operator page should also be update to include a mention/link to this page. Other than that LGTM |
|
May prefer the term "nullsafe operator" over "nullsafe arrow"? |
|
We do call it "nullsafe operator" and "nullsafe object operator" internally. I don't have a preference but I'd stick with one of the two. |
|
I went with nullsafe operator for conciseness, and added it to the token list. The -> operator is not in the operators page as is (one of the comments notes it), and it's not in the precedence list in zend_language_parser.y either, much to my surprise. That seems like a larger question to resolve than I want to get into here. |
I agree that this can be resolved another time. |
cmb69
left a comment
There was a problem hiding this comment.
Thank you! I left a few commits and applied with respective changes.
| As of PHP 8.0.0, properties and methods may also be accessed with the | ||
| "nullsafe" operator instead: <literal>?-></literal>. The nullsafe operator | ||
| works the same as property or method access as above, except that if the | ||
| object being dereferenced is <literal>null</literal> then <literal>null</literal> |
There was a problem hiding this comment.
When referring to the null value, it's usually best to denote it as &null;.
| </para> | ||
| <para> | ||
| <example> | ||
| <title>Class name resolution</title> |
There was a problem hiding this comment.
Interesting example for "class name resolution". ;)
| <![CDATA[ | ||
| <?php | ||
|
|
||
| // This line in PHP 8.0: |
There was a problem hiding this comment.
This gets confusing when PHP 8.1.0 will be released: does it work only for PHP 8.0?
I included a Note giving guidance on when to use it, because I keep fielding "but doesn't this just encourage bad error handling? questions from people. I figure this is a case where some usage guidance is warranted.