Re: [PHP-DEV] Limit write access to object function parameters

2023-05-06 Thread Lokrain
Hey there, Looking at how to achieve “readonly input object” now a few things come in my mind: * Write a readonly class in first place, assuming it’s not a class from a package you cannot or don’t want to update * Clone the object * Use a new immutable DTO for data transfer * Use stateless “se

[PHP-DEV] Limit write access to object function parameters

2023-05-06 Thread Olle Härstedt
Heyo internalitos, I was thinking of having the possibility to use `readonly` (or any other keyword) to make a function argument behave as if it was a readonly object. class Point { public int $x; public int $y; } function doThing(readonly Point $p) { $p->x =