Edit report at https://bugs.php.net/bug.php?id=50945&edit=1

 ID:                 50945
 User updated by:    robert at binalan dot com
 Reported by:        robert at binalan dot com
 Summary:            [PATCH] func_get_args(offset=0)
 Status:             Open
 Type:               Feature/Change Request
 Package:            *General Issues
 Operating System:   FreeBSD
 PHP Version:        5.2.12
 Block user comment: N
 Private report:     N

 New Comment:

I've posted this over two years ago. Nice someone still replies to it.

Changes often goes slow. I mean we have to wait till >= 5.3 so func_get_args() 
is finally able to be used as a function argument. Which I think is ridiculous 
by the way.

I still believe an offset argument is well at place in func_get args(), as part 
of function handling functions. I hope and wonder if this suggestion is 
considered by PHP.

But knowing the speed in which suggestions for enhancements will make it to the 
surface, it would probably take that extra beneficial planet alignment again 
for having that briliant moment in which the (damn) offset param is added. That 
alignment should be there again somewhere around PHP 8.5 in 2020... so hang in 
there guys! ;-)


Previous Comments:
------------------------------------------------------------------------
[2012-03-31 03:19:43] phristen at yahoo dot com

Exactly, array_slice is what you wanna do.
Which is why it would probably be best to add 2 optional parameters to 
func_get_args, and not just one. So it will behave exactly like array_slice.

------------------------------------------------------------------------
[2010-08-28 14:29:48] + at ni-po dot com

@kwilson: Maybe this is a reason why he doesn't like to use array_shift: You 
already used it wrong! To make it work you would need to write:

$data = func_get_args();
array_shift($data);
array_shift($data);

Better use array_slice:

$data = array_slice(func_get_args(), 2);

(This only works as of PHP 5.3, in PHP 5.2 you need to write: $data = 
func_get_args(); $data = array_slice($data, 2);.)

I do support the introduction of this additional parameter. It is annoying to 
always array_shift / array_slice some stuff from the arguments ;)

------------------------------------------------------------------------
[2010-03-06 12:50:28] [email protected]

The following patch has been added/updated:

Patch Name: func-get-args-with-offset
Revision:   1267876228
URL:        
http://bugs.php.net/patch-display.php?bug=50945&patch=func-get-args-with-offset&revision=1267876228&display=1

------------------------------------------------------------------------
[2010-02-16 21:30:46] kwilson at shuttlebox dot net

Why wouldn't you just use array_shift? The PHP folks don't seem to like to 
implement features when there is already an approach to accomplish the task in 
few steps:

function moduleNotify($module, $message/*, ...args*/)
{
        $data = array_shift(array_shift(func_get_args()));

        switch($module){
        case 'Database':
                list($host, $user, $pass, $base) = $data;
        break;
        case 'UserLogin':
                list($user, $pass, $iris, $lang) = $data;
        break;
}

------------------------------------------------------------------------
[2010-02-06 07:53:23] robert at binalan dot com

Description:
------------
function moduleNotify($module, $message/*, ...args*/)
{
        switch($module){
        case 'Database':
                list($host, $user, $pass, $base) = func_get_args(2);
        break;
        case 'UserLogin':
                list($user, $pass, $iris, $lang) = func_get_args(2);
        break;
}
/*
feature request:
func_get_args(offset=0)
returns arguments in same zero based array from a given offset in the argument 
list.
*/



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=50945&edit=1

Reply via email to