Hi

Am 2026-03-31 15:23, schrieb Jakub Zelenka:
There is actually no internal API for hooks so it would require using
object handlers (which is from the user space point of view just __get). It means no stubs declaration either. We also don't have an internal policy where to use hooks and where methods. So there are still lots of blockers
to start using it in core.

While I agree with the conclusion that using hooks internally is complicated and there is no real policy there, Valentin was actually making a good point: We could use regular `readonly` properties for those cases where we're just exposing a “constructor parameter”. Specifically:

- Context::getBackend() -> public readonly Backend $backend;
- Watcher::getHandle() -> public readonly Handle $handle;

Potentially Watcher::$data could also be a regular (non-readonly) property, or does `modifyData()` contain additional logic that is not just “store the value somewhere”?

There is precedent for this kind of regular `readonly` property referring to an input object in ext/random with Randomizer::$engine: https://github.com/php/php-src/blob/32c1931f18109655bc074dd5cda3248b838de636/ext/random/random.stub.php#L139

Best regards
Tim Düsterhus

Reply via email to