You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
useMoney\Currency;
useCknow\Money\Money;
$revenueA = newMoney(123, newCurrency('EUR'));
$revenueB = newMoney(123, newCurrency('EUR'));
$revenueTotal = $revenueA->add($revenueB);
$type = get_class($revenueTotal);
echo"The type of the calculation result is: $type";
This will return "The type of the calculation result is: Cknow\Money\Money" - while a good editor which supports @mixin will show that it should be a Money\Money - which in turn may lead to confused developers and wrongly using Money::convert to get the correct type for function arguments, resulting in runtime typing errors while one does not expect them.
For example:
The text was updated successfully, but these errors were encountered:
Maybe a good solution would be to add the PHPDoc manually to the Money class - or discuss with Money\Money that it should return self|static instead of Money and extend their class directly instead of, sorry to say this, abusing the magic methods
I noticed (don't know when this was done), but due the combination of
@mixin \Money\Money
atlaravel-money/src/Money.php
Lines 11 to 13 in d37ceea
convertResult
atlaravel-money/src/Money.php
Line 81 in d37ceea
__call
the typing of the methods is wrong.For example:
This will return "The type of the calculation result is: Cknow\Money\Money" - while a good editor which supports
@mixin
will show that it should be aMoney\Money
- which in turn may lead to confused developers and wrongly usingMoney::convert
to get the correct type for function arguments, resulting in runtime typing errors while one does not expect them.For example:
The text was updated successfully, but these errors were encountered: