[php-src] Issue #11316: (s)printf strict_types coercion instead of error

From: Date: Thu, 25 May 2023 11:32:39 +0000
Subject: [php-src] Issue #11316: (s)printf strict_types coercion instead of error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244528@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11316
Author: kkmuffme

### Description

The following code:

```php
<?php
declare(strict_types=1);

printf( '%d', 'hello' );

echo PHP_EOL;

printf( '%s', 15 );

echo PHP_EOL;

printf( '%d', 1.23 );
```

Resulted in this output:
```
0
15
1
```

But I expected this output instead:
A TypeError since the type was coerced in all three cases.

When strict_types is NOT used, the last one should give an error like (as of PHP 8.1.0)
>Deprecated: Implicit conversion from float 1.23 to int loses precision

Like it does in other cases when a float is passed to an int param.


### PHP Version

7.0.0 until master (8.2 currently)

### Operating System

_No response_


Thread (1 message)

  • kkmuffme
« previous php.bugs (#244528) next »