<?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); // Expected new Foo(...$args);
You have javascript disabled. You will not be able to edit any code.