[PHP-BUG] Bug #74351 [NEW]: Wrong reflection on variadic array functions

[email protected] ("fabien dot villepinte at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
From:             fabien dot villepinte at gmail dot com
Operating system: 
PHP version:      Irrelevant
Package:          Reflection related
Bug Type:         Bug
Bug description:Wrong reflection on variadic array functions

Description:
------------
The following functions are variadic but ReflectionFunction::isVariadic
and ReflectionParameter::isVariadic return false :
array_diff_uassoc
array_diff_ukey
array_intersect_uassoc
array_intersect_ukey
array_udiff
array_udiff_assoc
array_udiff_uassoc
array_uintersect
array_uintersect_assoc
array_uintersect_uassoc

The test script looks more complicated than necessary because I wanted
to highlight the differencies with HHVM (see : https://3v4l.org/clKBH ).

Test script:
---------------
<?php

$functions = [
    'array_diff_uassoc',
    'array_diff_ukey',
    'array_intersect_uassoc',
    'array_intersect_ukey',
    'array_udiff',
    'array_udiff_assoc',
    'array_udiff_uassoc',
    'array_uintersect',
    'array_uintersect_assoc',
    'array_uintersect_uassoc',
];

foreach ($functions as $func) {
    $reflFunc = new ReflectionFunction($func);
    $nbParams = $reflFunc->getNumberOfParameters();
    $nbRequiredParams = $reflFunc->getNumberOfRequiredParameters();
    printf("$func ($nbParams params, $nbRequiredParams required) %s
VARIADIC", $reflFunc->isVariadic() ? "IS" : "IS NOT");
    foreach ($reflFunc->getParameters() as $i => $param) {
        if ($param->isVariadic()) {
            printf(" - PARAM #%d%s IS VARIADIC", $i + 1,
$param->isOptional() ? " (Opt.)" : "");
        }
    }
    echo PHP_EOL;
}

Expected result:
----------------
array_diff_uassoc (3 params, 3 required) IS VARIADIC - PARAM #2 IS
VARIADIC
array_diff_ukey (3 params, 3 required) IS VARIADIC - PARAM #2 IS
VARIADIC
array_intersect_uassoc (3 params, 3 required) IS VARIADIC - PARAM #2 IS
VARIADIC
array_intersect_ukey (3 params, 3 required) IS VARIADIC - PARAM #2 IS
VARIADIC
array_udiff (3 params, 3 required) IS VARIADIC - PARAM #2 IS VARIADIC
array_udiff_assoc (3 params, 3 required) IS VARIADIC - PARAM #2 IS
VARIADIC
array_udiff_uassoc (4 params, 4 required) IS VARIADIC - PARAM #2 IS
VARIADIC
array_uintersect (3 params, 3 required) IS VARIADIC - PARAM #2 IS
VARIADIC
array_uintersect_assoc (3 params, 3 required) IS VARIADIC - PARAM #2 IS
VARIADIC
array_uintersect_uassoc (4 params, 4 required) IS VARIADIC - PARAM #2 IS
VARIADIC

Actual result:
--------------
array_diff_uassoc (3 params, 3 required) IS NOT VARIADIC
array_diff_ukey (3 params, 3 required) IS NOT VARIADIC
array_intersect_uassoc (3 params, 3 required) IS NOT VARIADIC
array_intersect_ukey (3 params, 3 required) IS NOT VARIADIC
array_udiff (3 params, 3 required) IS NOT VARIADIC
array_udiff_assoc (3 params, 3 required) IS NOT VARIADIC
array_udiff_uassoc (4 params, 4 required) IS NOT VARIADIC
array_uintersect (3 params, 3 required) IS NOT VARIADIC
array_uintersect_assoc (3 params, 3 required) IS NOT VARIADIC
array_uintersect_uassoc (4 params, 4 required) IS NOT VARIADIC

-- 
Edit bug report at https://bugs.php.net/bug.php?id=74351&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=74351&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=74351&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=74351&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=74351&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=74351&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=74351&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=74351&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=74351&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=74351&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=74351&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=74351&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=74351&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=74351&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74351&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=74351&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=74351&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=74351&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74351&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=74351&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=74351&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.