On 24 March 2026 14:06:53 GMT, "Michał Marcin Brzuchalski"
<[email protected]> wrote:
>So while I understand the motivation behind the RFC, I think this moves
>readonly further toward special-case behavior, when it would be better to
>keep it strict and predictable.
I agree with Ilija and Michal here. I can see why this might seem useful, but
the detailed rules feel very complicated, weakening the value of "readonly".
I think it also weakens the premise of CPP, which was to merge *three* pieces
of code: the property declaration, the parameter declaration, and the
assignment.
Perhaps what's actually needed is a variant that only merges the *assignment*
with the property declaration? That would then cover the case mentioned in the
RFC with a change in type, as well as the "readonly" case:
```
class Config {
public function __construct(
?string $cacheDir = null,
) {
public readonly string $this->cacheDir = $cacheDir ??
sys_get_temp_dir() . '/app_cache';
}
}
```
I'm not sure I love it, but it feels more consistent with the intention of both
CPP and readonly.
Regards,
Rowan Tommins
[IMSoP]