[php-src] Issue #19257: array_walk with printf callback bypasses TypeError for non-string format
| From: | sanmai | Date: | Sun, 27 Jul 2025 06:27:50 +0000 |
| Subject: | [php-src] Issue #19257: array_walk with printf callback bypasses TypeError for non-string format | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250504@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/19257
Author: sanmai
### Description
The following code:
```php
<?php declare(strict_types=1);
$input = [1, 2, 3];
array_walk($input, printf(...));
```
Resulted in this output:
```
123
```
But I expected this output instead:
```
Fatal error: Uncaught TypeError: printf(): Argument #1 ($format) must be of type string, int given
```
By comparison, this code throws as expected:
```php
<?php declare(strict_types=1);
$input = [1, 2, 3];
foreach ($input as $k => $i) {
printf($i, $k);
}
```
### PHP Version
```plain
PHP 8.4.10 (cli) (built: Jul 3 2025 12:35:27) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.10, Copyright (c) Zend Technologies
with Zend OPcache v8.4.10, Copyright (c), by Zend Technologies
with Xdebug v3.4.2, Copyright (c) 2002-2025, by Derick Rethans
```
### Operating System
_No response_