Bug #74745 [Opn->Csd]: Incorrect ReflectionFunction information for array_multisort
| From: | tandre at themeetgroup dot com | Date: | Sun, 11 Jun 2017 20:18:45 +0000 |
| Subject: | Bug #74745 [Opn->Csd]: Incorrect ReflectionFunction information for array_multisort | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209485@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74745&edit=1
ID: 74745
User updated by: tandre at themeetgroup dot com
Reported by: tandre at themeetgroup dot com
Summary: Incorrect ReflectionFunction information for
array_multisort
-Status: Open
+Status: Closed
Type: Bug
Package: Arrays related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
I misread the documentation. This issue is incorrect, the parameters are really sorted
bool array_multisort ( array &$array1 [, mixed $array1_sort_order = SORT_ASC [, mixed
$array1_sort_flags = SORT_REGULAR [, mixed $... ]]] )
could possibly be changed to the below to make it less confusing, but that's unrelated
bool array_multisort ( array &$array1 [, mixed &$array1_sort_order = SORT_ASC [, mixed
&$array1_sort_flags = SORT_REGULAR [, mixed &$... ]]] )
Previous Comments:
------------------------------------------------------------------------
[2017-06-11 20:10:46] tandre at themeetgroup dot com
Description:
------------
ReflectionFunction incorrectly states that $sort_order and $array1_sort_flags are passed by
reference, not by value.
This doesn't make sense, and is inconsistent with the documentation at https://secure.php.net/array_multisort
See https://3v4l.org/sZcuu
Test script:
---------------
<?php
$functionName = 'array_multisort';
printf("Params of %s:\n", $functionName);
foreach ((new ReflectionFunction($functionName))->getParameters() as $param) {
printf("Param \$%s: isPassedByReference=%s, isOptional=%s, isVariadic=%s\n",
$param->getName(),
var_export($param->isPassedByReference(), true),
var_export($param->isOptional(), true),
var_export($param->isVariadic(), true));
}
Expected result:
----------------
... otherwise unchanged
Param $sort_order: isPassedByReference=false, isOptional=true, isVariadic=false
Param $sort_flags: isPassedByReference=false, isOptional=true, isVariadic=false
... otherwise unchanged
Actual result:
--------------
Params of array_multisort:
Param $arr1: isPassedByReference=true, isOptional=false, isVariadic=false
Param $sort_order: isPassedByReference=true, isOptional=true, isVariadic=false
Param $sort_flags: isPassedByReference=true, isOptional=true, isVariadic=false
Param $arr2: isPassedByReference=true, isOptional=true, isVariadic=true
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74745&edit=1