Skip to content

Support php 8.0's nullsafe operator (?->) #330

Closed
@TysonAndre

Description

@TysonAndre

https://wiki.php.net/rfc/nullsafe_operator

   $foo = $a?->b();
// --------------- chain 1
//        -------- chain 2
// If $a is null chain 2 is aborted, method b() isn't called, null is assigned to $foo
 
   $a?->b($c->d());
// --------------- chain 1
//        -------  chain 2
// If $a is null chain 1 is aborted, method b() isn't called, the expression `$c->d()` is not evaluated
 
   $a->b($c?->d());
// --------------- chain 1
//       --------  chain 2
// If $c is null chain 2 is aborted, method d() isn't called, null is passed to `$a->b()`

This appears to be straightforward - T_NULLSAFE_OBJECT_OPERATOR looks to have the same precedence and places it can occur as T_OBJECT_OPERATOR(->)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions