Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk committed Nov 22, 2024
1 parent 3f63526 commit 6c272be
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 20 deletions.
5 changes: 2 additions & 3 deletions resources/generate-money-factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ trait MoneyFactory
* $fiveDollar = Money::USD(500);
* </code>
*
* @param array $arguments
* @psalm-param non-empty-string $method
* @psalm-param array{numeric-string|int} $arguments
* @param non-empty-string $method
* @param array{numeric-string|int} $arguments
*
* @throws InvalidArgumentException If amount is not integer(ish).
*
Expand Down
4 changes: 2 additions & 2 deletions resources/generate-teller-factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ trait TellerFactory
* $teller = Teller::USD();
* </code>
*
* @param non-empty-string $method
* @param array{0?: Money::ROUND_*} $arguments
* @param non-empty-string $method
* @param array{0?: Money::ROUND_*} $arguments
*/
public static function __callStatic(string $method, array $arguments): Teller
{
Expand Down
1 change: 1 addition & 0 deletions src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function convert(Money $money, Currency $counterCurrency, int $roundingMo

/**
* @param Money::ROUND_* $roundingMode
*
* @return array{0: Money, 1: CurrencyPair}
*/
public function convertAndReturnWithCurrencyPair(Money $money, Currency $counterCurrency, int $roundingMode = Money::ROUND_HALF_UP): array
Expand Down
3 changes: 2 additions & 1 deletion src/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ final class Currency implements JsonSerializable
private string $code;

/**
* @phpstan-pure
* @phpstan-param non-empty-string $code
*
* @phpstan-pure
*/
public function __construct(string $code)
{
Expand Down
8 changes: 6 additions & 2 deletions src/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ final class Money implements JsonSerializable
/**
* @param int|string $amount Amount, expressed in the smallest units of $currency (eg cents)
* @phpstan-param int|numeric-string $amount
* @phpstan-pure
*
* @throws InvalidArgumentException If amount is not integer(ish).
*
* @phpstan-pure
*/
public function __construct(int|string $amount, private readonly Currency $currency)
{
Expand Down Expand Up @@ -264,6 +266,7 @@ public function multiply(int|string $multiplier, int $roundingMode = self::ROUND
*
* @phpstan-param int|numeric-string $divisor
* @phpstan-param self::ROUND_* $roundingMode
*
* @phpstan-pure
*/
public function divide(int|string $divisor, int $roundingMode = self::ROUND_HALF_UP): Money
Expand Down Expand Up @@ -391,9 +394,10 @@ public function ratioOf(Money $money): string
/**
* @phpstan-param numeric-string $amount
* @phpstan-param self::ROUND_* $roundingMode
* @phpstan-pure
*
* @phpstan-return numeric-string
*
* @phpstan-pure
*/
private function round(string $amount, int $roundingMode): string
{
Expand Down
5 changes: 2 additions & 3 deletions src/MoneyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,8 @@ trait MoneyFactory
* $fiveDollar = Money::USD(500);
* </code>
*
* @param array $arguments
* @psalm-param non-empty-string $method
* @psalm-param array{numeric-string|int} $arguments
* @param non-empty-string $method
* @param array{numeric-string|int} $arguments
*
* @throws InvalidArgumentException If amount is not integer(ish).
*
Expand Down
16 changes: 10 additions & 6 deletions src/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ public function isCloserToNext(): bool
}

/**
* @phpstan-pure
* @phpstan-return numeric-string
*
* @phpstan-pure
*/
public function __toString(): string
{
Expand All @@ -143,26 +144,29 @@ public function isNegative(): bool
}

/**
* @phpstan-pure
* @phpstan-return numeric-string
*
* @phpstan-pure
*/
public function getIntegerPart(): string
{
return $this->integerPart;
}

/**
* @phpstan-pure
* @phpstan-return numeric-string|''
*
* @phpstan-pure
*/
public function getFractionalPart(): string
{
return $this->fractionalPart;
}

/**
* @phpstan-pure
* @phpstan-return numeric-string
*
* @phpstan-pure
*/
public function getIntegerRoundingMultiplier(): string
{
Expand Down Expand Up @@ -214,7 +218,6 @@ public function base10(int $number): self
* @phpstan-return numeric-string
*
* @phpstan-pure
*
*/
private static function parseIntegerPart(string $number): string
{
Expand Down Expand Up @@ -291,14 +294,15 @@ public static function roundMoneyValue(string $moneyValue, int $targetDigits, in

if ($shouldRound && $moneyValue[$valueLength - $havingDigits + $targetDigits] >= 5) {
$position = $valueLength - $havingDigits + $targetDigits;
$addend = 1;
$addend = 1;

while ($position > 0) {
// @phpstan-ignore possiblyImpure.methodCall (no idea what it thinks this)
$newValue = (string) ((int) $moneyValue[$position - 1] + $addend);

if ($newValue >= 10) {
$moneyValue[$position - 1] = $newValue[1];

$addend = $newValue[0];
--$position;
if ($position === 0) {
Expand Down
1 change: 0 additions & 1 deletion src/PHPUnit/Comparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* \SebastianBergmann\Comparator\Factory::getInstance()->register(new \Money\PHPUnit\Comparator());
*
* @internal do not use within your sources: this comparator is only to be used within the test suite of this library
*
*/
final class Comparator extends \SebastianBergmann\Comparator\Comparator
{
Expand Down
4 changes: 2 additions & 2 deletions src/TellerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ trait TellerFactory
* $teller = Teller::USD();
* </code>
*
* @param non-empty-string $method
* @param array{0?: Money::ROUND_*} $arguments
* @param non-empty-string $method
* @param array{0?: Money::ROUND_*} $arguments
*/
public static function __callStatic(string $method, array $arguments): Teller
{
Expand Down

0 comments on commit 6c272be

Please sign in to comment.