I'll add a little more.
> I would like to state my opinion on this matter, making it clear that I am of the opinion that
> "GMP class should be final."
>
> First of all, to meet the requirements that are the basis of this discussion, it is not
> actually necessary to expose the calculation logic; it is enough to simply specify the class of
> result.
>
> A practical approach to get around this issue is to tell php what class the result should be.
>
> For example, could prepare a method like resultClass(string $num1Class, string
> $num2Class, string $calcType): string|false
, and return the class name of the result based on
> the class names of the two objects to be calculated and the calculation type, such as addition or
> subtraction.
>
> PHP calls this method as a "hook" when it finishes a calculation and returns the
> result to determine the class of the return value.
>
> But I don't like this because it's a "hacky" way of doing things with
> zend.. Also, I am concerned about the cost of doing this for every calculation.
>
> The reason I'm putting together what I consider to be a bad method is because it's
> possible that you or someone else will take my idea, add a twist that I haven't thought of, and
> come up with a way to make it all work.
>
> Regards,
>
> Saki
This method is actually not as simple as it may seem. The problem of commutativity still exists as
to which to prioritize when calculating between different classes.
And if the child class has its own properties that must be specified in the constructor, you need to
figure out how to store them.
Regards,
Saki