<?php final readonly class TestObject { public function __construct(public int $number) { echo "Constructor called\n"; } public function getLucky(): void { echo "Your lucky number: $this->number\n"; } } $lazy = new ReflectionClass(TestObject::class)->newLazyGhost(function (TestObject $object) { $object->__construct(42); }); echo "Object created\n"; $lazy->getLucky();
You have javascript disabled. You will not be able to edit any code.