From:             csaba at alum dot mit dot edu
Operating system: Win XP Pro
PHP version:      5CVS-2005-02-19 (dev)
PHP Bug Type:     COM related
Bug description:  Can't call to function with paramArray in arg list definition

Description:
------------
If I try to make a call to a function where the function has a paramArray
(a VB construct) in the definition, the call fails with (if the param
array gets at least one argument).

For the unfamiliar, a paramArray in VB is an array (of variants) which
consists of all the remaining arguments to the procedure.  As such, it
must be the last declared parameter in the Function declaration.

Csaba Gabor from Vienna


Reproduce code:
---------------
Here is the PHP test code (menu.php):
<?php
    $oTool = new COM("Menu.Tool");
    $result = $oTool->ArgCount ("junk", 5, 13);
    print $result;
?>


Here is the code for the Menu.OCX file:
Public Function ArgCount(Arg1, ParamArray paArgRest())
    'counts the number of arguments passed, excluding Arg1
    ArgCount = UBound(paArgRest) + 1 - LBound(paArgRest)
End Function

Notes:
This was built using VB5CCE (the free (while available) VB, Control
Creation Edition)
I have named my control Tool
I have named the Project Menu
I made the OCX into Menu.ocx
In the (VB5CCE) project I went to Project => Menu Properties => Component
tab and set No Compatibility
After I made Menu.OCX, from the directory Menu.ocx resides in, I did:
regsvr32 Menu.ocx


Here is the corresponding VBScript test file (menu.vbs) that works:
Set oTool = CreateObject("Menu.Tool")
result = oTool.ArgCount("junk", 5, 13)
MsgBox result

Expected result:
----------------
I expect to see a 2 printed or displayed (since there are two arguments
after "junk")

Actual result:
--------------
menu.vbs produces the expected 2.

menu.php file fails with:
Cannot pass parameter 2 by reference in C:\Testing\ParamArray\menu.php on
line 3

If the paramArray gets no elements
    $result = $oTool->ArgCount ("junk");
then I get the expected 0

I've inserted a
    com_print_typeinfo($oTool) and received (there was other code in
menu.ocx):
        /* DISPID=1610809344 */
        /* VT_VARIANT [12] */
        function ArgCount(
                /* VT_PTR [26] [in][out] --> VT_VARIANT [12]  */ &$Arg1,
                /* VT_PTR [26] [in][out] --> ? [27]  */ &$paArgRest
                )
        {
        }

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

Reply via email to