diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..48cae7b --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,5 @@ +# Code Owners settings +# See: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners + +# As soon as a PR is added or a project is published, these teams will be invited for review. +* @Rebilly/php diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 9ed7f6e..cbea659 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -25,6 +25,7 @@ jobs: with: php-version: ${{ matrix.php-version }} extensions: ${{ env.PHP_EXTENSIONS }} + tools: composer:v1 - name: Get Composer Cache Directory id: composer-cache @@ -77,6 +78,7 @@ jobs: with: php-version: ${{ matrix.php-version }} extensions: ${{ env.PHP_EXTENSIONS }} + tools: composer:v1 - name: Get Composer Cache Directory id: composer-cache diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ac1595..474d483 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,12 +16,18 @@ Security - in case of vulnerabilities. ## [Unreleased] +## 1.1.2 (2021-04-19) + +### Changed + ++ Fix `Money::fromString` phpdoc and improve type validation of arguments. + ## 1.1.0 (2020-02-21) ### Changed -+ Migrated CI from **Travis CI** to **GitHub Actions**. -+ Upgraded minimum PHP version to v7.3. ++ Migrated CI from **Travis CI** to **GitHub Actions**. ++ Upgraded minimum PHP version to v7.3. ### Added diff --git a/src/Money.php b/src/Money.php index 9fde506..ecf9b10 100644 --- a/src/Money.php +++ b/src/Money.php @@ -62,7 +62,7 @@ public function __construct(int $amount, Currency $currency) * number of fractional digits then the value will be rounded to the * currency's number of fractional digits. * - * @param string $value + * @param float|int|string $value * @param Currency|string $currency * * @throws InvalidArgumentException @@ -71,11 +71,11 @@ public function __construct(int $amount, Currency $currency) */ public static function fromString($value, $currency): self { - if (!is_scalar($value) && !is_callable([$value, '__toString'])) { + if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { throw new InvalidArgumentException('$value must be a string'); } - if (!is_scalar($currency) && !is_callable([$currency, '__toString'])) { + if (!is_string($currency) && !(is_object($currency) && method_exists($currency, '__toString'))) { throw new InvalidArgumentException('$currency must be a string'); } diff --git a/tests/MoneyTest.php b/tests/MoneyTest.php index e13ce51..2e2905e 100644 --- a/tests/MoneyTest.php +++ b/tests/MoneyTest.php @@ -27,6 +27,7 @@ public function testCannotBeConstructedUsingInvalidValueArgument(): void public function testCannotBeConstructedUsingInvalidCurrencyArgument(): void { $this->expectException(InvalidArgumentException::class); + /** @noinspection PhpParamsInspection */ Money::fromString(0, new stdClass()); }