aeon-php/calendar

Different naming for mutation methods

christian-kolb opened this issue · 5 comments

Describe the bug
There is a different naming scheme when it comes to mutations of DateTime and Day.

For Day the methods are named plus* and minus* (for example plusDays($days) or minusDays($days)).
For DateTime the methods are named add* and sub* (for example addDays($days) or subDays($days)).

Expected behavior

I would expect that the naming follows the same schema so that both are ether using plus/minus or add/sub.

Additional context

I'm not sure if that's a bug or whether there is a specific reason. I looked through the documentation but couldn't find an explanation why the naming schemes are different and how I would know when to use which naming.

Is there a specific reason or just due to growth of the library and nobody noticed it until now? 🙂

UPDATE: I've also looked into Time and it only has add/sub without any shortcut methods. So I guess Day is the outlier.

@christian-kolb good catch!
As far as I remember this was even on my todo list before 1.0 release but I somehow lost it :( It's definitely an effect of evolution, not design.
It should not be that hard to add new add* and sub* methods to Day and mark all plys*, minus* as deprecated so we can remove them in 2.0.
Would you mind opening PR with those changes?

@norberttech Of course, I'll create that tomorrow.
Can you take over the part of the documentation? I don't know whether that's somehow generated through the code or whether that's outside of it.

@norberttech Just to make sure, I would add the logic to the new add* and sub* methods and pipe the plus* and minus* ones through to those. Because they are the ones to use, so they should have no overhead. Does this work for you?

correct 👍

@norberttech I just realized that it's not the only outlier. At least Month also has the same problem. I'm going through the whole codebase and searching for where else we've got the naming.