On Sat, Apr 16, 2022 at 12:01 AM David Rodrigues <[email protected]> wrote:
> > $foo[?'maynotexist'] // returns null and emits no warning > > In JS we have some like: > > foo['maynotexist'] > foo?.['maynotexist'] > > In PHP could be: > > $foo['maynotexist'] > $foo?->['maynotexist'] > You seem to be confusing two different things (in short, ?-> vs ->?): 1. In PHP *too* we *already* have "*nullsafe* property access" $objectThatMayBeNull?->property (but no "nullsafe array access" $arrayThatMayBeNull?['key'], see https://wiki.php.net/rfc/nullsafe_operator#future_scope) since PHP 8.0 (see https://www.php.net/releases/8.0/en.php, https://www.php.net/manual/en/migration80.new-features.php etc.) 2. What may be proposed (in another RFC) is something like $object->?propertyThatMayNotExist and/or $array[?'keyThatMayNotExist'] (call it e.g. "*lenient* property/array access"?) (JS is lenient by default) But let's not deviate further. Regards, -- Guilliam Xavier
