[php-src] Issue #12055: array_filter ignores strict_types

From: Date: Sat, 26 Aug 2023 13:56:34 +0000
Subject: [php-src] Issue #12055: array_filter ignores strict_types
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245250@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12055 Author: divinity76 ### Description The following code: ```php <?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_

« previous php.bugs (#245250) next »