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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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)

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 13:01:30 2024 UTC