Skip to content

Commit

Permalink
Corrected a few type-hints (#8)
Browse files Browse the repository at this point in the history
* Correct return type-hint in Real::toInteger

* Correct return type-hint for Integer::toReal

```
ERROR: InvalidMethodCall - php/Foo/Bar/Baz.php:63:57 - Cannot call method on float variable  (see https://psalm.dev/091)
            $this->chargeAmount->getAmount()->toReal()->toNative(),
```

* Correct construtor type-hint in Money clas

```
ERROR: InvalidArgument - php/Foo/Bar/Baz.php:564:38 - Argument 1 of ValueObjects\Money\Money::__construct expects int, ValueObjects\Number\Integer provided (see https://psalm.dev/004)
            $lowestMoney = new Money(new Integer((int)$lowestPrice), new Currency($this->catalog->getCurrencyCode()));
```
  • Loading branch information
addiks committed Mar 3, 2021
1 parent 4b35857 commit 61f10ee
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Money/Money.php
Expand Up @@ -38,7 +38,7 @@ class Money implements ValueObjectInterface
/**
* Returns a Money object.
*
* @param int $amount Amount expressed in the smallest units of $currency (e.g. cents)
* @param Integer $amount Amount expressed in the smallest units of $currency (e.g. cents)
* @param Currency $currency Currency of the money object
*/
public function __construct(Integer $amount, Currency $currency)
Expand Down
2 changes: 1 addition & 1 deletion src/Number/Integer.php
Expand Up @@ -69,7 +69,7 @@ public function toNative(): int
/**
* Returns a Real with the value of the Integer.
*
* @return float
* @return Real
*/
public function toReal(): Real
{
Expand Down
2 changes: 1 addition & 1 deletion src/Number/Real.php
Expand Up @@ -111,7 +111,7 @@ public function sameValueAs(ValueObjectInterface $real): bool
*
* @param RoundingMode $roundingMode Rounding mode of the conversion. Defaults to RoundingMode::HALF_UP.
*
* @return int
* @return Integer
*/
public function toInteger(RoundingMode $roundingMode = null): Integer
{
Expand Down

0 comments on commit 61f10ee

Please sign in to comment.