#40694 [NEW]: __call() does not allow passing args by reference

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #40694 [NEW]: __call() does not allow passing args by reference

    From: [email]andrei@php.net[/email]
    Operating system:
    PHP version: 5CVS-2007-03-02 (CVS)
    PHP Bug Type: Scripting Engine problem
    Bug description: __call() does not allow passing args by reference

    Description:
    ------------
    __call() method does not allow specifying the arguments array by
    reference. Essentially this means that there is no way to return modified
    arguments when using overloading.

    Reproduce code:
    ---------------
    class Foo {
    function __call($method, &$args)
    {
    print $args[0]."\n";
    $args[0] = 5;
    print $args[0]."\n";
    return true;
    }
    }

    $v = 'str';

    $o = new Foo();
    $o->test($v);

    var_dump($v);


    Expected result:
    ----------------
    str
    5
    int(5)


    Actual result:
    --------------
    str
    5
    string(3) "str"


    --
    Edit bug report at [url]http://bugs.php.net/?id=40694&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40694&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40694&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40694&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40694&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=40694&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=40694&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40694&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=40694&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=40694&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=40694&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=40694&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=40694&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=40694&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40694&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=40694&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=40694&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40694&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=40694&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40694&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40694&r=mysqlcfg[/url]
    andrei@php.net Guest

  2. Similar Questions and Discussions

    1. Passing Variables by Reference
      I have a webservice that accepts some variables by reference and after the service is called, all the passed variables are 'undefined' Thanks for...
    2. #25831 [Ver->WFx]: overload/__call breaks method Pass by reference
      ID: 25831 Updated by: moriyoshi@php.net Reported By: viking at dslnorthwest dot net -Status: Verified +Status:...
    3. #25831 [Ver]: overload/__call breaks method Pass by reference
      ID: 25831 Updated by: alan_k@php.net Reported By: viking at dslnorthwest dot net Status: Verified Bug Type: ...
    4. #25831 [Opn->Ver]: overload/__call breaks method Pass by reference
      ID: 25831 Updated by: alan_k@php.net -Summary: Pass by reference doesn't work with subclasses of DB_DataObject...
    5. passing row types by reference
      Hallo, I´m working with the new informix funcionality that allow use structure data like rows an list rows. I would like to know how I can...
  3. #2

    Default #40694 [Opn->Ver]: __call() does not allow passing args by reference

    ID: 40694
    Updated by: [email]pollita@php.net[/email]
    Reported By: [email]andrei@php.net[/email]
    -Status: Open
    +Status: Verified
    Bug Type: Scripting Engine problem
    PHP Version: 5CVS-2007-03-02 (CVS)
    New Comment:

    Summary from IRC:

    This should be fixable by selectively populating arg_info in
    zend_std_get_method() with a structure that turns on the pass rest by
    ref flag. That'll tell the macros in zend_vm_def.h to send the
    arguments by reference. From there, you might need to modify
    zend_std_call_user_call() a little bit where it's building the args
    array... (Havn't looked close enough to be sure)

    While addressing this, you should look at the return value as well,
    again this should be a minor matter of checking the __call
    implementation and flipping the return type in zend_std_get_method()...


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-02 17:27:59] [email]andrei@php.net[/email]

    Description:
    ------------
    __call() method does not allow specifying the arguments array by
    reference. Essentially this means that there is no way to return
    modified arguments when using overloading.

    Reproduce code:
    ---------------
    class Foo {
    function __call($method, &$args)
    {
    print $args[0]."\n";
    $args[0] = 5;
    print $args[0]."\n";
    return true;
    }
    }

    $v = 'str';

    $o = new Foo();
    $o->test($v);

    var_dump($v);


    Expected result:
    ----------------
    str
    5
    int(5)


    Actual result:
    --------------
    str
    5
    string(3) "str"



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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40694&edit=1[/url]
    pollita@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139