> On Jun 24, 2024, at 3:31 AM, Robert Landers <[email protected]> wrote:
>
>
> There's no need to use ?
to check for existence on a key, so this:
>
> $arr is ['a' => string, ?'b' => string, ...];
>
> should be this:
>
> $arr is ['a' => string, 'b' => ?string, ...];
>
> because $arr['non-existent-key'] is NULL.
>
The first means b is an optional key, but if it’s there, can only be a string. The second says b
is a required key, but it may be a string or null. If there were a binding involved, that determines
the type of the binding in incompatible ways. I’m fine with requiring bindings to be nullable for
optional keys, but it strikes me as strictly less flexible and not consistent with the rest of
PHP’s behavior, at least not under E_ALL.
(Sorry for any dups. juggling sender addresses to make the listserv happy, fixed an incomplete
thought while I was at it)
Cheers,
chuck