> > https://wiki.php.net/rfc/typehint_array_desctructuring
>

Thanks, Enno, I like it a lot!
I hope the implementation won't find any blocker.



> I fear that if you go that path people would automatically expect it to be
> possible to write:
>
> int $id = $data['id'];
> int $id = getIdFromData($data);
>

That would be a nice addition I guess - maybe for a separate RFC to keep
the focus clear on this one.



> And then expect the $id to behave more like typed property with type guard.
>

I would not expect the type guard on my side, like function arguments don't
provide type guards and also because this is PHP: runtime checks slow down
the engine. Thus I would expect this to be guarded by static type analyzers
for ppl who care (I'm not sure it matters personally, see SSA
transformations), and on assignation otherwise to balance perf vs runtime
overhead. (Note that the expectation you describe is a valid one, I'm just
explaining that a different expectation exists, and why)

Nicolas

Reply via email to