1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Files
archived-php-src/ext/standard/tests/array/bug74345.phpt
Larry Garfield 96f2f3174b Update array parameter names for named parameters
* 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.
2020-09-14 14:56:49 +00:00

47 lines
979 B
PHP

--TEST--
Bug #74345: Call trampoline leaked if callback not invoked
--FILE--
<?php
class Test {
public function __call($name, $args) {
echo "__call()\n";
}
}
$name = "foo" . ($x = "bar");
$cb = [new Test, $name];
array_map($cb, []);
array_map($cb, [], []);
try {
array_map($cb, null);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
array_map($cb, null, null);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
array_filter([], $cb);
array_reduce([], $cb);
$array = [];
array_walk($array, $cb);
array_walk_recursive($array, $cb);
usort($array, $cb);
try {
preg_replace_callback('/./', $cb, new stdClass);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
===DONE===
--EXPECT--
array_map(): Argument #2 ($array) must be of type array, null given
array_map(): Argument #2 ($array) must be of type array, null given
preg_replace_callback(): Argument #3 ($subject) must be of type array|string, stdClass given
===DONE===