Cloning Readonly Classes in PHP 8.2

preview_player
Показать описание
Readonly classes can never have their data changed, even not when cloning them. This video explores patterns to deal with this problem.

Рекомендации по теме
Комментарии
Автор

Just ran across a similar problem and I simply love your approach, it is indeed, at least to me, the best solution at this time

brunoggdev
Автор

TBH the problem is you are not using DatePeriod to produce the expected date range. No cloning or manual date modification needed.

You should use DatePeriod for creating set of dates for a common interval.

tagKnife
Автор

Looks like a nightmare for an IDE dev :)
_IMO, like magic method, we should not use it. Or can an IDE follow this through?_

CottonInDerTube
Автор

Sow actually you creating a non read only class. Cause it is mutable. You lose all intelisense...🙄why do you need a read only ckass than???

janvanlooveren