Skip to content

Commit f5011bc

Browse files
authored
Laravel 12 support (#28)
* Laravel 12 support * bump larastan * phpstan fixes * remove pest() * update larastan dependency name
1 parent b642e32 commit f5011bc

File tree

7 files changed

+14
-18
lines changed

7 files changed

+14
-18
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
laravel: [10, 11]
19+
laravel: [10, 11, 12]
2020

2121
steps:
2222
- uses: actions/checkout@v2

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
},
2626
"require": {
2727
"php": "^8.2",
28-
"illuminate/support": "^10.0|^11.0",
28+
"illuminate/support": "^10.0|^11.0|^12.0",
2929
"archtechx/helpers": "^0.3.2"
3030
},
3131
"require-dev": {
32-
"orchestra/testbench": "^8.0|^9.0",
33-
"pestphp/pest": "^2.0",
34-
"phpstan/phpstan": "^1.9.8",
35-
"pestphp/pest-plugin-laravel": "^2.0",
36-
"nunomaduro/larastan": "^2.4"
32+
"orchestra/testbench": "^8.0|^9.0|^10.0",
33+
"pestphp/pest": "^2.0|^3.7",
34+
"phpstan/phpstan": "^1.9.8|^2.1",
35+
"pestphp/pest-plugin-laravel": "^2.0|^3.1",
36+
"larastan/larastan": "^2.4|^3.0"
3737
},
3838
"extra": {
3939
"laravel": {

phpstan.neon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
includes:
2-
- ./vendor/nunomaduro/larastan/extension.neon
2+
- ./vendor/larastan/larastan/extension.neon
33

44
parameters:
55
paths:
@@ -23,3 +23,4 @@ parameters:
2323
paths:
2424
- src/Currency.php
2525
- identifier: missingType.iterableValue
26+
- identifier: unset.possiblyHookedProperty

src/PriceFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function resolve(string $formatted, Currency $currency, array $ove
4444
$formatted = ltrim($formatted, $currency->prefix());
4545
$formatted = rtrim($formatted, $currency->suffix());
4646

47-
$removeNonDigits = preg_replace('/[^\d' . preg_quote($currency->decimalSeparator()) . ']/', '', $formatted);
47+
$removeNonDigits = preg_replace('/[^\d' . preg_quote($currency->decimalSeparator(), '/') . ']/', '', $formatted);
4848

4949
if (! is_string($removeNonDigits)) {
5050
throw new Exception('The formatted string could not be resolved to a valid number.');

tests/Pest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,3 @@
44
use Pest\TestSuite;
55

66
uses(ArchTech\Money\Tests\TestCase::class)->in('Pest');
7-
8-
function pest(): TestCase
9-
{
10-
return TestSuite::getInstance()->test;
11-
}

tests/Pest/CurrencyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
use ArchTech\Money\Tests\Currencies\CZK;
66

77
test("a currency is invalid if it doesn't have a name", function () {
8-
pest()->expectException(InvalidCurrencyException::class);
8+
$this->expectException(InvalidCurrencyException::class);
99

1010
new Currency(rate: 2.0, code: 'CZK');
1111
});
1212

1313
test("a currency is invalid if it doesn't have a code", function () {
14-
pest()->expectException(InvalidCurrencyException::class);
14+
$this->expectException(InvalidCurrencyException::class);
1515

1616
new Currency(rate: 2.0, name: 'Czech Crown');
1717
});

tests/Pest/MoneyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,15 @@
170170

171171
currencies()->remove(USD::class);
172172

173-
pest()->expectException(CannotExtractCurrencyException::class);
173+
$this->expectException(CannotExtractCurrencyException::class);
174174
Money::fromFormatted($formatted);
175175
});
176176

177177
test('an exception is thrown if multiple currencies are using the same prefix and suffix', function () {
178178
currencies()->add(['code' => 'USD2', 'name' => 'USD2', 'prefix' => '$']);
179179
$money = money(1000);
180180

181-
pest()->expectException(CannotExtractCurrencyException::class);
181+
$this->expectException(CannotExtractCurrencyException::class);
182182
Money::fromFormatted($money->formatted());
183183
});
184184

0 commit comments

Comments
 (0)