From 4a32ce51ecf0a8652866c9fcfdef131619ead421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Tue, 11 Mar 2025 13:07:31 +0100 Subject: [PATCH 1/5] Laravel 12 support --- .github/workflows/ci.yml | 2 +- composer.json | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2148426..32f10b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - laravel: [10, 11] + laravel: [10, 11, 12] steps: - uses: actions/checkout@v2 diff --git a/composer.json b/composer.json index fff9205..8350a9f 100644 --- a/composer.json +++ b/composer.json @@ -25,14 +25,14 @@ }, "require": { "php": "^8.2", - "illuminate/support": "^10.0|^11.0", + "illuminate/support": "^10.0|^11.0|^12.0", "archtechx/helpers": "^0.3.2" }, "require-dev": { - "orchestra/testbench": "^8.0|^9.0", - "pestphp/pest": "^2.0", - "phpstan/phpstan": "^1.9.8", - "pestphp/pest-plugin-laravel": "^2.0", + "orchestra/testbench": "^8.0|^9.0|^10.0", + "pestphp/pest": "^2.0|^3.7", + "phpstan/phpstan": "^1.9.8|^2.1", + "pestphp/pest-plugin-laravel": "^2.0|^3.1", "nunomaduro/larastan": "^2.4" }, "extra": { From 1ee60cb22db092028153346090b8a3beff0805a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Tue, 11 Mar 2025 13:14:16 +0100 Subject: [PATCH 2/5] bump larastan --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8350a9f..6e535f5 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "pestphp/pest": "^2.0|^3.7", "phpstan/phpstan": "^1.9.8|^2.1", "pestphp/pest-plugin-laravel": "^2.0|^3.1", - "nunomaduro/larastan": "^2.4" + "nunomaduro/larastan": "^2.4|^3.0" }, "extra": { "laravel": { From e30211058a108fd6ccc5937dc17e32e6fe5dc70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Tue, 11 Mar 2025 17:26:54 +0100 Subject: [PATCH 3/5] phpstan fixes --- phpstan.neon | 1 + src/PriceFormatter.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 2d7efab..be84088 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -23,3 +23,4 @@ parameters: paths: - src/Currency.php - identifier: missingType.iterableValue + - identifier: unset.possiblyHookedProperty diff --git a/src/PriceFormatter.php b/src/PriceFormatter.php index 67f0a19..cb2963c 100644 --- a/src/PriceFormatter.php +++ b/src/PriceFormatter.php @@ -44,7 +44,7 @@ public static function resolve(string $formatted, Currency $currency, array $ove $formatted = ltrim($formatted, $currency->prefix()); $formatted = rtrim($formatted, $currency->suffix()); - $removeNonDigits = preg_replace('/[^\d' . preg_quote($currency->decimalSeparator()) . ']/', '', $formatted); + $removeNonDigits = preg_replace('/[^\d' . preg_quote($currency->decimalSeparator(), '/') . ']/', '', $formatted); if (! is_string($removeNonDigits)) { throw new Exception('The formatted string could not be resolved to a valid number.'); From 578c5c48bae7362cfab6880314ea352da54595b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Tue, 11 Mar 2025 17:31:46 +0100 Subject: [PATCH 4/5] remove pest() --- tests/Pest.php | 5 ----- tests/Pest/CurrencyTest.php | 4 ++-- tests/Pest/MoneyTest.php | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/Pest.php b/tests/Pest.php index 46ef170..9a6a482 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -4,8 +4,3 @@ use Pest\TestSuite; uses(ArchTech\Money\Tests\TestCase::class)->in('Pest'); - -function pest(): TestCase -{ - return TestSuite::getInstance()->test; -} diff --git a/tests/Pest/CurrencyTest.php b/tests/Pest/CurrencyTest.php index 4d917bd..1fbea1e 100644 --- a/tests/Pest/CurrencyTest.php +++ b/tests/Pest/CurrencyTest.php @@ -5,13 +5,13 @@ use ArchTech\Money\Tests\Currencies\CZK; test("a currency is invalid if it doesn't have a name", function () { - pest()->expectException(InvalidCurrencyException::class); + $this->expectException(InvalidCurrencyException::class); new Currency(rate: 2.0, code: 'CZK'); }); test("a currency is invalid if it doesn't have a code", function () { - pest()->expectException(InvalidCurrencyException::class); + $this->expectException(InvalidCurrencyException::class); new Currency(rate: 2.0, name: 'Czech Crown'); }); diff --git a/tests/Pest/MoneyTest.php b/tests/Pest/MoneyTest.php index f895818..4749196 100644 --- a/tests/Pest/MoneyTest.php +++ b/tests/Pest/MoneyTest.php @@ -170,7 +170,7 @@ currencies()->remove(USD::class); - pest()->expectException(CannotExtractCurrencyException::class); + $this->expectException(CannotExtractCurrencyException::class); Money::fromFormatted($formatted); }); @@ -178,7 +178,7 @@ currencies()->add(['code' => 'USD2', 'name' => 'USD2', 'prefix' => '$']); $money = money(1000); - pest()->expectException(CannotExtractCurrencyException::class); + $this->expectException(CannotExtractCurrencyException::class); Money::fromFormatted($money->formatted()); }); From 2d4b587b56606c983bff2ab94ec398b7a4251172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Tue, 11 Mar 2025 17:37:23 +0100 Subject: [PATCH 5/5] update larastan dependency name --- composer.json | 2 +- phpstan.neon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 6e535f5..dd0e60d 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "pestphp/pest": "^2.0|^3.7", "phpstan/phpstan": "^1.9.8|^2.1", "pestphp/pest-plugin-laravel": "^2.0|^3.1", - "nunomaduro/larastan": "^2.4|^3.0" + "larastan/larastan": "^2.4|^3.0" }, "extra": { "laravel": { diff --git a/phpstan.neon b/phpstan.neon index be84088..a21938c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ includes: - - ./vendor/nunomaduro/larastan/extension.neon + - ./vendor/larastan/larastan/extension.neon parameters: paths: