Description
The following code:
<?php
declare(strict_types=1); // unfortunately strict types can not be declared on 3v4l.org
$array = [1, 1.2, '1.2.3'];
// var_dump(array_filter($array, function (string $value) { return is_string($value); })); // will not filter
// var_dump(array_map(fn (string $value) => $value, $array)); // all returned values are strings
array_walk($array, fn (string &$value) => $value);
var_dump($array);
Resulted in this output:
array(3) {
[0]=>
string(1) "1"
[1]=>
string(3) "1.2"
[2]=>
string(5) "1.2.3"
}
But I expected this output instead:
PHP Fatal error: Uncaught TypeError: {closure}(): Argument #1 ($a) must be of type string, int given, .....
(as is thrown when call_user_func is used with a closure with a wrong argument type)
PHP Version
PHP 8.3.6
Operating System
No response