mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
96f2f3174b
* 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.
40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
--TEST--
|
|
Test array_walk_recursive() function : usage variations - buit-in function as callback
|
|
--FILE--
|
|
<?php
|
|
/*
|
|
* Passing different buit-in functionns as callback function
|
|
* pow function
|
|
* min function
|
|
* echo language construct
|
|
*/
|
|
|
|
echo "*** Testing array_walk_recursive() : built-in function as callback ***\n";
|
|
|
|
$input = array(array(2 => 1, 65), array(98, 100), array(6 => -4));
|
|
|
|
echo "-- With 'pow' built-in function --\n";
|
|
var_dump( array_walk_recursive($input, 'pow'));
|
|
|
|
echo "-- With 'min' built-in function --\n";
|
|
var_dump( array_walk_recursive($input, "min"));
|
|
|
|
echo "-- With 'echo' language construct --\n";
|
|
try {
|
|
var_dump( array_walk_recursive($input, "echo"));
|
|
} catch (TypeError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
echo "Done"
|
|
?>
|
|
--EXPECT--
|
|
*** Testing array_walk_recursive() : built-in function as callback ***
|
|
-- With 'pow' built-in function --
|
|
bool(true)
|
|
-- With 'min' built-in function --
|
|
bool(true)
|
|
-- With 'echo' language construct --
|
|
array_walk_recursive(): Argument #2 ($callback) must be a valid callback, function "echo" not found or invalid function name
|
|
Done
|