php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74745 Incorrect ReflectionFunction information for array_multisort
Submitted: 2017-06-11 20:10 UTC Modified: 2017-06-11 20:18 UTC
From: tandre at themeetgroup dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tandre at themeetgroup dot com
New email:
PHP Version: OS:

 

 [2017-06-11 20:10 UTC] 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


Patches

array_multisort.patch (last revision 2017-06-11 20:11 UTC by tandre at themeetgroup dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-11 20:18 UTC] tandre at themeetgroup dot com
-Status: Open +Status: Closed
 [2017-06-11 20:18 UTC] tandre at themeetgroup dot com
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 &$... ]]] )
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 15:01:36 2025 UTC