mirror of
https://github.com/php/php-src.git
synced 2026-03-29 03:32:20 +02:00
* The array "subject" of a function gets called $array. * Further parameters should be self-descriptive if used as a named parameter, and a full word, not an abbreviation. * If there is a "bunch more arrays" variadic, it gets called $arrays (because that's what was already there). * A few functions have a variadic "a bunch more arrays, and then a callable", and were already called $rest. I left those as is and died a little inside. * Any callable provided to an array function that acts on the array is called $callback. (Nearly all were already, I just fixed the one or two outliers.) * array_multisort() is beyond help so I ran screaming.
69 lines
1.1 KiB
PHP
69 lines
1.1 KiB
PHP
--TEST--
|
|
ReflectionParameter class - canBePassedByValue() method.
|
|
--FILE--
|
|
<?php
|
|
|
|
function aux($fun) {
|
|
|
|
$func = new ReflectionFunction($fun);
|
|
$parameters = $func->getParameters();
|
|
foreach($parameters as $parameter) {
|
|
echo "Name: ", $parameter->getName(), "\n";
|
|
echo "Is passed by reference: ", $parameter->isPassedByReference()?"yes":"no", "\n";
|
|
echo "Can be passed by value: ", $parameter->canBePassedByValue()?"yes":"no", "\n";
|
|
echo "\n";
|
|
}
|
|
|
|
}
|
|
|
|
echo "=> array_multisort:\n\n";
|
|
|
|
aux('array_multisort');
|
|
|
|
|
|
echo "=> sort:\n\n";
|
|
|
|
aux('sort');
|
|
|
|
echo "=> user function:\n\n";
|
|
|
|
function ufunc(&$array1, $array2) {}
|
|
|
|
aux('ufunc');
|
|
|
|
echo "Done.\n";
|
|
|
|
?>
|
|
--EXPECT--
|
|
=> array_multisort:
|
|
|
|
Name: array1
|
|
Is passed by reference: yes
|
|
Can be passed by value: yes
|
|
|
|
Name: rest
|
|
Is passed by reference: yes
|
|
Can be passed by value: yes
|
|
|
|
=> sort:
|
|
|
|
Name: array
|
|
Is passed by reference: yes
|
|
Can be passed by value: no
|
|
|
|
Name: flags
|
|
Is passed by reference: no
|
|
Can be passed by value: yes
|
|
|
|
=> user function:
|
|
|
|
Name: array1
|
|
Is passed by reference: yes
|
|
Can be passed by value: no
|
|
|
|
Name: array2
|
|
Is passed by reference: no
|
|
Can be passed by value: yes
|
|
|
|
Done.
|