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

 ID:                 50945
 Comment by:         + at ni-po dot com
 Reported by:        robert at binalan dot com
 Summary:            [PATCH] func_get_args(offset=0)
 Status:             Open
 Type:               Feature/Change Request
 Package:            Feature/Change Request
 Operating System:   FreeBSD
 PHP Version:        5.2.12
 Block user comment: N

 New Comment:

@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 ;)


Previous Comments:
------------------------------------------------------------------------
[2010-03-06 12:50:28] ka...@php.net

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 http://bugs.php.net/bug.php?id=50945&edit=1

Reply via email to