[php-src] Issue #8414: `ReflectionClass::newInstance` and `ReflectionClass::newInstanceArgs` are not strict
| From: | iluuu1994 | Date: | Thu, 21 Apr 2022 10:22:37 +0000 |
| Subject: | [php-src] Issue #8414: `ReflectionClass::newInstance` and `ReflectionClass::newInstanceArgs` are not strict | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241111@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8414
Comment Author: iluuu1994
https://3v4l.org/r7atB
This has been like this since
strict_types are supported. The constructor is called
from the internal newInstance method which does not have strict_types
enabled. Similarly, something like array_map will invoke the closure without
strict_types and thus do type coercion.
https://3v4l.org/isV9d
```php
declare(strict_types=1);
array_map(function (string $i) {
var_dump($i);
}, [1, 2, 3]);
```
> string(1) "1"
> string(1) "2"
> string(1) "3"
I think it's not completely unreasonable to expect strict_types to be applied to
internal functions but it would also be a large BC break.