php / doc-en

English PHP documentation
498 stars 729 forks source link

Reflection calls with ...Args should support associative arrays for PHP 8 #3355

Open Zekfad opened 5 months ago

Zekfad commented 5 months ago

Description

With PHP 8 we have named arguments and support for arbitrary arguments order. Making ReflectionClass::newInstanceArgs and ReflectionMethod::invokeArgs support associative arrays will mirror that functionality from reflection. Use case is for skipping retrieval of optional parameters and simplifying managements of arguments array.

nielsdos commented 5 months ago

I'm not sure I understand, this works: https://3v4l.org/Wtas7

Zekfad commented 5 months ago

Yes, it seems like I was hitting different user-land bug. It would be nice to mention thank in documentation, because there's and old note on ReflectionClass::newInstanceArgs claiming otherwise.

nielsdos commented 5 months ago

I'll be moving this issue to the docs repo then.

It would be nice to mention thank in documentation, because there's and old note on ReflectionClass::newInstanceArgs claiming otherwise.

Indeed, and it's the top note even... I'll remove it.