Doc #80971 [Com]: func_get_args() didnt work when using named args

From: Date: Sat, 06 May 2023 03:00:51 +0000
Subject: Doc #80971 [Com]: func_get_args() didnt work when using named args
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19608@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80971&edit=1

 ID:                 80971
 Comment by:         timkeller at aol 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:

(https://moderndogmagazine.com/articles/best-online-dog-training-courses)github.com


Previous Comments:
------------------------------------------------------------------------
[2021-06-03 02:28:22] lufei@php.net

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] cmb@php.net

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


Thread (5 messages)

« previous php.doc.bugs (#19608) next »