php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #16464 func_get_arg(), func_get_args() should be reference proof
Submitted: 2002-04-06 13:32 UTC Modified: 2003-01-18 14:48 UTC
From: fbeyer at clickhand dot de Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.1.2 OS: All
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fbeyer at clickhand dot de
New email:
PHP Version: OS:

 

 [2002-04-06 13:32 UTC] fbeyer at clickhand dot de
The function func_get_arg() and func_get_args() should support being called to return references:

function do_something()
{
    $args = func_get_args();

    for ($i=0; $i<count($args); $i++) {
        do_something_with($args[$i]);
    }
}

$ref = new Object();
do_something(&$ref, "String", 0, 1.5);

This function could register a dynamic number of variables to the session (references for the Object!!!), create an array or simple call another function with exactly the same arguments.

I think it should be no problem for func_get_arg[s]() to save references passed to the function. Like

function x($arg1, $arg2)
{
    $args = array(&$arg1, &$arg2);
}

saves $arg1 and $args by reference if they are passed by reference or by value if they are passed by value.

Thank you, looking forward to the new object model in Zend 2!!!

Ferdinand Beyer
<fbeyer@clickhand.de>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-06 13:38 UTC] fbeyer at clickhand dot de
Think of a factory function that creates an object of various classes by calling that object's constructor with the same arguments. If a constructor needs a reference (perhaps to another object), this is not possible if you want to write clean code without tricks like hard-code arguments with default values.
 [2003-01-18 14:48 UTC] moriyoshi@php.net
This request is virtually the same as bug #6427.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC