briannesbitt / Carbon

A simple PHP API extension for DateTime.
https://carbon.nesbot.com/
MIT License
16.58k stars 1.28k forks source link

Remove copy() & Make all arithmetic immutable. #3058

Closed kpconnell closed 4 months ago

kpconnell commented 4 months ago

Having the arithmetic operations modify the underlying object rather than just return the result is completely non intuitive and different than 99% of the libraries in PHP.

Please remove copy() and change all date arithmetic methods to simply return the result without modifying the class instance.

kylekatarnls commented 4 months ago

Use CarbonImmutable instead, please read the first chapter of the doc carbon.nesbot.com/docs/ it's inherited directly from PHP having DateTime and DateTimeImmutable, and also please next time open issue following the given template.

Thanks,