8.4 lazy objects, applied to a service whose constructor opens a connection and which fires on 3% of requests.
$reflector = new ReflectionClass(SupplierClient::class);
$client = $reflector->newLazyProxy(
fn (SupplierClient $proxy) => new SupplierClient($config, $psr18),
);
// the constructor runs on first property or method
// access. until then it is an object of the right type
// with nothing behind it.
This replaces a hand-written proxy class that existed only to defer construction, which is the case the feature is for. It is worth knowing what triggers initialisation — any property read, any method call, and instanceof deliberately does not — because a debugger inspecting the object initialises it and hides the very behaviour you are debugging.