-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Description
Description
The following code:
<?php
declare(strict_types=1);
$arr = ["1"];
$filtered = array_filter($arr, function (int $i) {
var_dump(["func_get_args" => func_get_args()]);
return true;
});
var_dump($arr);
Resulted in this output:
array(1) {
["func_get_args"]=>
array(1) {
[0]=>
int(1)
}
}
array(1) {
[0]=>
string(1) "1"
}
But I expected this output instead:
Fatal error: Uncaught TypeError: {closure}(): Argument #1 ($i) must be of type int, string given in /in/Gf4Pq:5
Stack trace:
#0 [internal function]: {closure}('1')
#1 /in/Gf4Pq(5): array_filter(Array, Object(Closure))
#2 {main}
thrown in /in/Gf4Pq on line 5
Process exited with code 255.
PHP Version
PHP 8.2.9
Operating System
No response