3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); class Foo { public $bool; public $int; public function __construct( bool $bool, int $int ) { $this->bool = $bool; $this->int = $int; } } $args = ['bar', '10']; $reflection = new \ReflectionClass(Foo::class); $constructor = $reflection->getConstructor(); $instance = $reflection->newInstance(...$args); var_dump($instance);

preferences:
22.07 ms | 475 KiB | 4 Q