Skip to content

Commit

Permalink
Merge pull request #99 from ariaieboy/psalm
Browse files Browse the repository at this point in the history
fix psalm errors
  • Loading branch information
denisdulici authored Mar 29, 2024
2 parents c6710ee + ae58ada commit 11d61be
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
coverage: none

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
Expand Down
3 changes: 1 addition & 2 deletions src/Casts/CurrencyCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
use UnexpectedValueException;

/**
* @template TGet
* @template TSet
* @template-implements CastsAttributes<Currency,Currency>
*/
class CurrencyCast implements CastsAttributes
{
Expand Down
3 changes: 1 addition & 2 deletions src/Casts/MoneyCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
use UnexpectedValueException;

/**
* @template TGet
* @template TSet
* @template-implements CastsAttributes<Money,Money>
*/
class MoneyCast implements CastsAttributes
{
Expand Down
1 change: 1 addition & 0 deletions src/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
* @method static Currency ZAR()
* @method static Currency ZMW()
* @method static Currency ZWL()
* @template-implements Arrayable<string,array>
*/
class Currency implements Arrayable, Castable, Jsonable, JsonSerializable, Renderable
{
Expand Down
6 changes: 4 additions & 2 deletions src/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Support\Arr;
use Illuminate\Support\Traits\Macroable;
use InvalidArgumentException;
use JsonSerializable;
Expand Down Expand Up @@ -183,6 +184,7 @@
* @method static Money ZAR(mixed $amount, bool $convert = false)
* @method static Money ZMW(mixed $amount, bool $convert = false)
* @method static Money ZWL(mixed $amount, bool $convert = false)
* @template-implements Arrayable<string,int|float|Currency>
*/
class Money implements Arrayable, Castable, Jsonable, JsonSerializable, Renderable
{
Expand Down Expand Up @@ -606,7 +608,7 @@ public function formatForHumans(?string $locale = null, ?Closure $callback = nul
$prefix = $this->currency->getPrefix();
$suffix = $this->currency->getSuffix();

$formatter = new \NumberFormatter($locale ?: static::getLocale(), \NumberFormatter::PADDING_POSITION);
$formatter = new \NumberFormatter(is_null($locale) ? static::getLocale():$locale, \NumberFormatter::PADDING_POSITION);

$formatter->setSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL, $this->currency->getDecimalMark());
$formatter->setSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, $this->currency->getThousandsSeparator());
Expand All @@ -632,7 +634,7 @@ public function formatLocale(?string $locale = null, ?Closure $callback = null):
}
// @codeCoverageIgnoreEnd

$formatter = new \NumberFormatter($locale ?: static::getLocale(), \NumberFormatter::CURRENCY);
$formatter = new \NumberFormatter(is_null($locale) ? static::getLocale():$locale, \NumberFormatter::CURRENCY);

$formatter->setSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL, $this->currency->getDecimalMark());
$formatter->setSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, $this->currency->getThousandsSeparator());
Expand Down
3 changes: 3 additions & 0 deletions src/Rules/CurrencyRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Akaunting\Money\Currency;
use Illuminate\Contracts\Validation\Rule;

/**
* @psalm-suppress DeprecatedInterface
*/
class CurrencyRule implements Rule
{
public function passes($attribute, $value): bool
Expand Down

0 comments on commit 11d61be

Please sign in to comment.