> $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']

Atenciosamente,
David Rodrigues


Em sex., 15 de abr. de 2022 às 18:41, Mark Randall <marand...@php.net>
escreveu:

> On 06/04/2022 19:38, Larry Garfield wrote:
> > On the last point, regarding stdClass, I think the question is whether
> we want it to be consistent with classed object properties (throw) or with
> associative arrays (warnings).  stdClass is kind of an uncomfortable middle
> between those two.  I'm not sure which is better to align with, although I
> almost never use stdClass and tell others to avoid it as well so it doesn't
> really matter to me. :-)
>
>
> My preference is to treat it like any other property, but I am open to
> hearing additional comments on this.
>
> I'm not sure how much conversation we can expect on this one, if it
> remains quiet I intend to open the vote in a week or so.
>
> As a tangent, R11 has had some comments made about a better method for
> indicating which property / array keys are expected to be missing, such as:
>
> $foo[?'maynotexist'] // returns null and emits no warning
>
> Down the line this might allow us to fix up arrays as well, but that's a
> question for a different RFC.
>
> Mark Randall
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>

Reply via email to