Doc #80971 [Com]: func_get_args() didnt work when using named args
[email protected] ("ta dot nnaowens6 at googlemail dot com") Fri, 29 Sep 2023 06:41:24 +0000
| Newsgroups | php.doc.bugs |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=80971&edit=1 ID: 80971 Comment by: ta dot nnaowens6 at googlemail dot com Reported by: antoni at friki dot cat Summary: func_get_args() didnt work when using named args Status: Open Type: Documentation Problem Package: Documentation problem PHP Version: 8.0.3 Block user comment: N Private report: N New Comment: Thanks for sharing this, this is amazing. i like it. (https://github.com)(https://www.subwaygiftcardbalance.online/) Previous Comments: ------------------------------------------------------------------------ [2023-05-06 03:00:50] timkeller at aol dot com (https://moderndogmagazine.com/articles/best-online-dog-training-courses)github.com ------------------------------------------------------------------------ [2021-06-03 02:28:22] [email protected] The following pull request has been associated: Patch Name: Fix 80971: func_get_args() didnt work when using named args On GitHub: https://github.com/php/doc-en/pull/650 Patch: https://github.com/php/doc-en/pull/650.patch ------------------------------------------------------------------------ [2021-04-20 17:00:23] [email protected] This is expected, but apparently undocumented. From the RFC[1]: | All three functions are oblivious to the collection of unknown | named arguments by variadics. func_get_args() will not return the | collected values and func_num_args() will not include them in the | argument count. Collected unknown named arguments can only be | accessed through the variadic parameter. [1] <https://wiki.php.net/rfc/named_params#func_get_args_and_friends> ------------------------------------------------------------------------ [2021-04-20 16:38:25] antoni at friki dot cat Description: ------------ func_get_args() in combination with named args returns an empty array. Test script: --------------- <?php function foo(...$args) { //var_dump($args); var_dump(func_get_args()); } foo(a: 9, b: 99, c: 999); Expected result: ---------------- I expected an array with 3 elements. Probably: array(3) { ["a"]=> int(9) ["b"]=> int(99) ["c"]=> int(999) } Or: array(3) { [0]=> int(9) [1]=> int(99) [2]=> int(999) } Actual result: -------------- array(0) { } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80971&edit=1