From 97e6ae1272981d4885ddbe463012107be5e8f802 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 14 Dec 2021 08:46:12 +0800 Subject: [PATCH] wip Signed-off-by: Mior Muhammad Zaki --- phpstan-baseline.neon | 15 --------------- src/Concerns/Cash.php | 13 +++++++------ src/Concerns/Tax.php | 14 +++++++------- src/MYR.php | 4 ++-- 4 files changed, 16 insertions(+), 30 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 15394da..139597f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,17 +1,2 @@ -parameters: - ignoreErrors: - - - message: "#^Method Duit\\\\MYR\\:\\:getClosestAcceptedCashAmount\\(\\) should return int but returns float\\|int\\.$#" - count: 1 - path: src/MYR.php - - - message: "#^Parameter \\#1 \\$amount of class Money\\\\Money constructor expects int\\|\\(string&numeric\\), int\\|string given\\.$#" - count: 1 - path: src/MYR.php - - - - message: "#^Parameter \\#1 \\$number of static method Money\\\\Number\\:\\:fromString\\(\\) expects string, int\\|string given\\.$#" - count: 1 - path: src/MYR.php diff --git a/src/Concerns/Cash.php b/src/Concerns/Cash.php index efb4e0e..a1ef264 100644 --- a/src/Concerns/Cash.php +++ b/src/Concerns/Cash.php @@ -9,8 +9,8 @@ trait Cash { /** * Get formatted amount. - * - * @return numeric-string + * + * @return numeric-string|non-empty-string */ public function amount(): string { @@ -19,8 +19,8 @@ public function amount(): string /** * Get formatted cash. - * - * @return numeric-string + * + * @return numeric-string|non-empty-string */ public function cashAmount(): string { @@ -31,7 +31,7 @@ public function cashAmount(): string /** * Get amount for cash. - * + * * @return numeric-string */ public function getCashAmount(): string @@ -48,7 +48,8 @@ public function getCashAmount(): string */ protected function getClosestAcceptedCashAmount($amount): int { - $value = Number::fromString($amount)->getIntegerPart(); + /** @var int $value */ + $value = Number::fromString((string) $amount)->getIntegerPart(); $cent = $amount % 5; if ($cent <= 2) { diff --git a/src/Concerns/Tax.php b/src/Concerns/Tax.php index 25494ec..7cf7a70 100644 --- a/src/Concerns/Tax.php +++ b/src/Concerns/Tax.php @@ -59,8 +59,8 @@ public static function withoutTax($amount) /** * Get formatted amount with GST. - * - * @return numeric-string + * + * @return numeric-string|non-empty-string */ public function amountWithTax(): string { @@ -71,8 +71,8 @@ public function amountWithTax(): string /** * Get formatted cash with GST. - * - * @return numeric-string + * + * @return numeric-string|non-empty-string */ public function cashAmountWithTax(): string { @@ -115,7 +115,7 @@ final public function hasTax(): bool /** * Get GST amount. - * + * * @return numeric-string */ public function getTaxAmount(): string @@ -129,7 +129,7 @@ public function getTaxAmount(): string /** * Returns the value represented by this object with Tax. - * + * * @return numeric-string */ public function getAmountWithTax(): string @@ -143,7 +143,7 @@ public function getAmountWithTax(): string /** * Get amount for cash with Tax. - * + * * @return numeric-string */ public function getCashAmountWithTax(): string diff --git a/src/MYR.php b/src/MYR.php index 7224bdf..b34c9e1 100644 --- a/src/MYR.php +++ b/src/MYR.php @@ -78,7 +78,7 @@ public static function parse($value) /** * Returns the value represented by this object. - * + * * @return numeric-string */ public function getAmount(): string @@ -157,7 +157,7 @@ public function __call(string $method, array $parameters) /** * Build money object. * - * @param int|string $amount + * @param int|numeric-string $amount */ protected static function asMoney($amount): Money {