-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deal with integer limits #115
Conversation
In the next few days I will write something on the design decisions I made. This will help reviewing the PR (I guess). |
Sounds good. Merry Christmas 😄 |
While creating this PR, I had the following things in mind.
Things I came across into when creating this PR.
Please let me know whether you need more clarification. |
No need for the
Is there a reason for that? Does it make sense to allow the user to change the priority order we define?
Soes it mean strings are allowed from the public API as well? I am not a big fan of the idea, because it requires more validation logic than necessary.
If we have an interface then this assumption is moved to the fact that the interface must be implemented by all calculators.
Is this a problem? With don't need decimal precision. |
|
||
/** | ||
* Class BcMathCalculator | ||
* @package Money\Calculator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add yourself as an author (if you are OK with that) and remove the rest from here.
Nice PR @frederikbosch. I added some comments, mostly related CS thing, but there are some design questions as well. |
@sagikazarmark Thanks for the comments, fixed most of the issues you brought up. Regarding your questions.
|
/** | ||
* @param Calculator[] $calculators | ||
*/ | ||
public static function registerCalculators(array $calculators) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having a singular method would be better. I would also add a check whether the class exists at all and implements our Calculator interface. Also, why default? It could be just calculators IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, a new calculator should be added to the beggining of the list to make sure custom calculators are checked first.
But is it necessary to be a public detail? IMO we can do it internally, but from a public API point of view, accepting integers is fine. |
@sagikazarmark No, that is whole point of no integer limits, right? Big integer (bigger than php's max int) can only be expressed in string, not in integers. |
Ok, rebased. Make sure to checkout your nextrelease branch as a new local branch. |
@sagikazarmark Thanks! Will see if I can finish the PR today. |
I think the PR should be ready. Added documentation to the |
@@ -0,0 +1,95 @@ | |||
<?php | |||
namespace Money; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why this is necessary, but OK, I will add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency.
Looks good to me. I added a few more CS related things, can you please correct those? The rest can be automatically fixed by CS fixer. |
Fixed things, except for the docblock. You sure you want to remove |
For now, yes. I am aware of the inheritdoc recommended usage, but it is a common pattern to use it for all kinds of docblocks. IDEs recognize it, even if phpDocumentor says otherwise. There is demand for complete docblock inheritance, and phpDocumentor is working on it for some years now. |
OK, removed the |
Cool, thanks. Ready for merge then? |
I would say so :) |
Deal with integer limits, closes #111
Thanks @frederikbosch |
Great! Thanks @sagikazarmark for reviewing! Maybe we can create an alpha release? I would be happy with some sort of tag. #111 can also be closed. |
#111 should automatically be closed. Tagging sounds good, but we should first rebase/merge into master. |
I would just rename branches in such cases ;) But I do not if that has any negative side-effects. |
Solves #111.
Probably has quite some impact on the library. Review carefully. Rather see some more comments on the design decisions than on some PSR-2 compliance. The latter will be solved - if there is any compliance oversights - when there is agreement on the design.
Hard aspect of this PR was rounding in GMP and BC Math libraries. Had a look at some other libraries for this to implement.