[php-src] Issue #8414: `ReflectionClass::newInstance` and `ReflectionClass::newInstanceArgs` are not strict

From: Date: Thu, 21 Apr 2022 09:58:34 +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-241107@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8414 Author: roxblnfk ### Description The following code: ```php <?php declare(strict_types=1); class Foo { public function __construct( public bool $bool, public int $int, ) {} } $args = ['bar', '10']; $reflection = new \ReflectionClass(Foo::class); $constructor = $reflection->getConstructor(); $instance = $reflection->newInstance(...$args); var_dump($instance); ``` Resulted in this output: ``` object(Foo)#3 (2) { ["bool"]=> bool(true) ["int"]=> int(10) } ``` But I expected this output instead: ``` TypeError: Foo::__construct(): Argument #1 ($bool) must be of type bool, string given ``` Sandbox: https://3v4l.org/KtY24 ### PHP Version 8.0, 8.1 ### Operating System _No response_

« previous php.bugs (#241107) next »