Doc #80736 [Opn]: array_uintersect parameters difference

From: Date: Fri, 12 Feb 2021 15:53:38 +0000
Subject: Doc #80736 [Opn]: array_uintersect parameters difference
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18541@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80736&edit=1 ID: 80736 User updated by: jurigag at gmail dot com Reported by: jurigag at gmail dot com Summary: array_uintersect parameters difference Status: Open Type: Documentation Problem Package: Arrays related Operating System: Ubuntu 18.04 PHP Version: 8.0.2 Block user comment: N Private report: N New Comment: Yea, but this callable is missing in the parameters. Previous Comments: ------------------------------------------------------------------------ [2021-02-12 15:51:28] requinix@php.net The documented signature is array_uintersect ( array $array , array ...$arrays , callable $value_compare_func ) : array but that isn't actually possible to do: a varargs parameter must be the last one in the list. Reflection is now returning to you the "actual" signature of the method, as one might implement manually in userland, where the first argument is an array and the rest is dynamic. array_uintersect ( array $array , mixed ...$rest ) : array This isn't just for array_uintersect but being applied across the board to most/all built-in functions. ------------------------------------------------------------------------ [2021-02-12 09:53:44] jurigag at gmail dot com Description: ------------ When using PHP8 ReflectionFunction::getNumberOfParameters() for array_uintersect returns 2 and also they look like this: array(2) { [0]=> object(ReflectionParameter)#2 (1) { ["name"]=> string(5) "array" } [1]=> object(ReflectionParameter)#3 (1) { ["name"]=> string(4) "rest" } } But for PHP7 it was looking like this: array(3) { [0]=> object(ReflectionParameter)#2 (1) { ["name"]=> string(4) "arr1" } [1]=> object(ReflectionParameter)#3 (1) { ["name"]=> string(4) "arr2" } [2]=> object(ReflectionParameter)#4 (1) { ["name"]=> string(26) "callback_data_compare_func" } } Change itself isn't documented on docs, not sure why it was changed, but also when executing this function it works as it was previously. Test script: --------------- <?php $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red"); print_r(array_uintersect($array1, $array2, "strcasecmp")); $reflection = new ReflectionFunction('array_uintersect'); var_dump($reflection->getNumberOfParameters()); var_dump($reflection->getNumberOfRequiredParameters()); var_dump($reflection->getParameters()); Expected result: ---------------- Array ( [a] => green [b] => brown [0] => red ) int(3) int(3) array(3) { [0]=> object(ReflectionParameter)#2 (1) { ["name"]=> string(4) "arr1" } [1]=> object(ReflectionParameter)#3 (1) { ["name"]=> string(4) "arr2" } [2]=> object(ReflectionParameter)#4 (1) { ["name"]=> string(26) "callback_data_compare_func" } } Actual result: -------------- Array ( [a] => green [b] => brown [0] => red ) int(2) int(1) array(2) { [0]=> object(ReflectionParameter)#2 (1) { ["name"]=> string(5) "array" } [1]=> object(ReflectionParameter)#3 (1) { ["name"]=> string(4) "rest" } } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80736&edit=1

« previous php.doc.bugs (#18541) next »