From a6bbe530e7ce200d9d244d323256cd05a4e04480 Mon Sep 17 00:00:00 2001 From: Christopher Gammie Date: Sun, 25 May 2025 16:55:17 +0100 Subject: [PATCH 1/2] feat!: upgrade to Laravel 11 and 12 --- .github/workflows/tests.yml | 8 ++-- .gitignore | 2 +- CHANGELOG.md | 7 +++ README.md | 2 + composer.json | 26 +++++----- phpunit.xml | 47 +++++++++---------- src/Connect/AuthorizeUrl.php | 2 +- src/Connect/Authorizer.php | 6 +-- tests/lib/Integration/Connect/OAuthTest.php | 10 ++-- .../Integration/Console/StripeQueryTest.php | 26 ++-------- tests/lib/Integration/TestCase.php | 2 +- tests/lib/Unit/Connect/AuthorizeUrlTest.php | 29 +++--------- 12 files changed, 71 insertions(+), 96 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 895d784..23ea67c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,12 +14,12 @@ jobs: strategy: fail-fast: true matrix: - php: [8.1, 8.2] - laravel: [10] + php: [8.2, 8.3, 8.4] + laravel: [11, 12] steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -34,7 +34,7 @@ jobs: run: composer require "laravel/framework:^${{ matrix.laravel }}" --no-update - name: Install dependencies - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 5 max_attempts: 5 diff --git a/.gitignore b/.gitignore index 525642d..c42f4b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /vendor/ /composer.lock -.phpunit.result.cache +.phpunit.cache/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 2205594..3d7830b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. This projec ## Unreleased +### Changed + +- Minimum PHP version is now 8.2, previously was 8.1. +- Upgraded to Laravel 11 and 12, dropping support for Laravel 10. + +## [0.7.1] - 2024-09-01 + ### Removed - Removed checking the prefix of account and charge ids, as Stripe does not consider changing these as diff --git a/README.md b/README.md index 742e3af..e616502 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,8 @@ developed against as guide. You may find the package works with older versions o | Laravel | Stripe PHP | Stripe API | Laravel-Stripe | Cashier | |:--------|:-----------|:---------------|:---------------|:----------------------------| +| `12.x` | `^16.2` | `>=2020-03-02` | `0.8.x` | `^15.6` | +| `11.x` | `^16.2` | `>=2020-03-02` | `0.8.x` | `^15.6` | | `10.x` | `^7.52` | `>=2020-03-02` | `0.7.x` | `^14.8` | | `9.x` | `^7.52` | `>=2020-03-02` | `0.6.x` | `^12.3` | | `8.x` | `^7.52` | `>=2020-03-02` | `0.5.x\|0.6.x` | `^12.3` | diff --git a/composer.json b/composer.json index 4d9634c..8c43d1c 100644 --- a/composer.json +++ b/composer.json @@ -12,23 +12,23 @@ "minimum-stability": "stable", "prefer-stable": true, "require": { - "php": "^8.1", + "php": "^8.2", "ext-json": "*", - "illuminate/console": "^10.0", - "illuminate/contracts": "^10.0", - "illuminate/database": "^10.0", - "illuminate/http": "^10.0", - "illuminate/queue": "^10.0", - "illuminate/routing": "^10.0", - "illuminate/support": "^10.0", + "illuminate/console": "^11.0|^12.0", + "illuminate/contracts": "^11.0|^12.0", + "illuminate/database": "^11.0|^12.0", + "illuminate/http": "^11.0|^12.0", + "illuminate/queue": "^11.0|^12.0", + "illuminate/routing": "^11.0|^12.0", + "illuminate/support": "^11.0|^12.0", "psr/log": "^3.0", - "stripe/stripe-php": "^7.52" + "stripe/stripe-php": "^16.2" }, "require-dev": { - "laravel/cashier": "^14.8", - "laravel/legacy-factories": "^1.0", - "orchestra/testbench": "^8.0", - "phpunit/phpunit": "^9.5" + "laravel/cashier": "^15.6", + "laravel/legacy-factories": "^1.4", + "orchestra/testbench": "^9.14|^10.0", + "phpunit/phpunit": "^11.5" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index 8638057..e775997 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,35 +1,34 @@ - - - src/ - - - - - ./tests/lib/Unit/ - - - ./tests/lib/Integration/ - - - - - - + + + ./tests/lib/Unit/ + + + ./tests/lib/Integration/ + + + + + + + + + src/ + + diff --git a/src/Connect/AuthorizeUrl.php b/src/Connect/AuthorizeUrl.php index 12d2e91..62a474c 100644 --- a/src/Connect/AuthorizeUrl.php +++ b/src/Connect/AuthorizeUrl.php @@ -80,7 +80,7 @@ public static function scopes() * @param string $state * @param array|null $options */ - public function __construct($state, array $options = null) + public function __construct(string $state, ?array $options = null) { $this->state = $state; $this->options = $options ?: []; diff --git a/src/Connect/Authorizer.php b/src/Connect/Authorizer.php index 46e7c6d..fd61ca9 100644 --- a/src/Connect/Authorizer.php +++ b/src/Connect/Authorizer.php @@ -62,7 +62,7 @@ public function __construct(Client $client, StateProviderInterface $state) * @return AuthorizeUrl * @see https://stripe.com/docs/connect/standard-accounts#integrating-oauth */ - public function authorizeUrl(array $options = null) + public function authorizeUrl(?array $options = null) { if (!$state = $this->state->get()) { throw new RuntimeException('State parameter cannot be empty.'); @@ -79,7 +79,7 @@ public function authorizeUrl(array $options = null) * @return StripeObject * @see https://stripe.com/docs/connect/standard-accounts#token-request */ - public function authorize($code, array $options = null) + public function authorize(string $code, ?array $options = null) { $params = [ self::CODE => $code, @@ -102,7 +102,7 @@ public function refresh() * @return StripeObject * @see https://stripe.com/docs/connect/standard-accounts#revoked-access */ - public function deauthorize($accountId, array $options = null) + public function deauthorize(string $accountId, ?array $options = null) { $params = [ self::STRIPE_USER_ID => $accountId, diff --git a/tests/lib/Integration/Connect/OAuthTest.php b/tests/lib/Integration/Connect/OAuthTest.php index 201a31d..3668d5d 100644 --- a/tests/lib/Integration/Connect/OAuthTest.php +++ b/tests/lib/Integration/Connect/OAuthTest.php @@ -28,6 +28,7 @@ use Illuminate\Foundation\Auth\User; use Illuminate\Support\Facades\Queue; use Illuminate\Support\Facades\Route; +use PHPUnit\Framework\Attributes\DataProvider; class OAuthTest extends TestCase { @@ -208,10 +209,7 @@ public function testForbidden() Queue::assertNotPushed(FetchUserCredentials::class); } - /** - * @return array - */ - public function invalidProvider() + public static function invalidProvider(): array { return [ 'state' => ['state'], @@ -227,9 +225,9 @@ public function invalidProvider() * we expect it to send. But it is good to handle the scenario just in case. * * @param string $missing - * @dataProvider invalidProvider */ - public function testInvalid($missing) + #[DataProvider('invalidProvider')] + public function testInvalid(string $missing): void { $params = collect([ 'state' => 'session_token', diff --git a/tests/lib/Integration/Console/StripeQueryTest.php b/tests/lib/Integration/Console/StripeQueryTest.php index 5b2d420..cef026e 100644 --- a/tests/lib/Integration/Console/StripeQueryTest.php +++ b/tests/lib/Integration/Console/StripeQueryTest.php @@ -20,18 +20,14 @@ use CloudCreativity\LaravelStripe\Facades\Stripe; use CloudCreativity\LaravelStripe\Models\StripeAccount; use CloudCreativity\LaravelStripe\Tests\Integration\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use Stripe\Balance; use Stripe\Charge; use Stripe\Collection; class StripeQueryTest extends TestCase { - - /** - * @param string $fqn - * @param string $resource - * @dataProvider classProvider - */ + #[DataProvider('classProvider')] public function testAll(string $fqn, string $resource): void { Stripe::fake(new Collection()); @@ -65,11 +61,7 @@ public function testAllSingular(): void }); } - /** - * @param string $fqn - * @param string $resource - * @dataProvider classProvider - */ + #[DataProvider('classProvider')] public function testAllConnect(string $fqn, string $resource): void { /** @var StripeAccount $account */ @@ -95,11 +87,7 @@ public function testAllConnect(string $fqn, string $resource): void }); } - /** - * @param string $fqn - * @param string $resource - * @dataProvider classProvider - */ + #[DataProvider('classProvider')] public function testRetrieveAndExpand(string $fqn, string $resource): void { Stripe::fake(new $fqn($id = 'foo_bazbat')); @@ -147,11 +135,7 @@ public function testRetrieveSingular(): void }); } - /** - * @param $fqn - * @param $resource - * @dataProvider classProvider - */ + #[DataProvider('classProvider')] public function testRetrieveConnect($fqn, $resource) { /** @var StripeAccount $account */ diff --git a/tests/lib/Integration/TestCase.php b/tests/lib/Integration/TestCase.php index 79a77c1..1cd03d8 100644 --- a/tests/lib/Integration/TestCase.php +++ b/tests/lib/Integration/TestCase.php @@ -68,7 +68,7 @@ protected function tearDown(): void * * @return array */ - public function classProvider(): array + public static function classProvider(): array { return [ 'accounts' => [\Stripe\Account::class, 'accounts'], diff --git a/tests/lib/Unit/Connect/AuthorizeUrlTest.php b/tests/lib/Unit/Connect/AuthorizeUrlTest.php index dda7f63..5fff7aa 100644 --- a/tests/lib/Unit/Connect/AuthorizeUrlTest.php +++ b/tests/lib/Unit/Connect/AuthorizeUrlTest.php @@ -18,6 +18,7 @@ namespace CloudCreativity\LaravelStripe\Tests\Unit\Connect; use CloudCreativity\LaravelStripe\Connect\AuthorizeUrl; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Stripe\Stripe; use Stripe\Util\Util; @@ -52,7 +53,7 @@ protected function tearDown(): void /** * @return array */ - public function valueProvider() + public static function valueProvider(): array { return [ 'read_only' => [ @@ -93,13 +94,8 @@ public function valueProvider() ]; } - /** - * @param array $expected - * @param string $method - * @param mixed|null $value - * @dataProvider valueProvider - */ - public function testStandard(array $expected, $method, $value = null) + #[DataProvider('valueProvider')] + public function testStandard(array $expected, string $method, mixed $value = null): void { $args = !is_null($value) ? [$value] : []; $result = call_user_func_array([$this->url, $method], $args); @@ -108,13 +104,8 @@ public function testStandard(array $expected, $method, $value = null) $this->assertUrl('https://connect.stripe.com/oauth/authorize', $expected, "{$method}"); } - /** - * @param array $expected - * @param string $method - * @param mixed|null $value - * @dataProvider valueProvider - */ - public function testExpress(array $expected, $method, $value = null) + #[DataProvider('valueProvider')] + public function testExpress(array $expected, string $method, mixed $value = null): void { $this->assertSame($this->url, $this->url->express(), 'express is fluent'); @@ -125,13 +116,7 @@ public function testExpress(array $expected, $method, $value = null) $this->assertUrl('https://connect.stripe.com/express/oauth/authorize', $expected, "{$method}"); } - /** - * @param string $uri - * @param array $params - * @param string $message - * @return void - */ - private function assertUrl($uri, array $params, $message = '') + private function assertUrl(string $uri, array $params, string $message = ''): void { $params = array_replace([ 'state' => 'state_secret', From 13f61617f5f5b3880d45c62c93b0a5c464c20821 Mon Sep 17 00:00:00 2001 From: Christopher Gammie Date: Sun, 25 May 2025 16:55:54 +0100 Subject: [PATCH 2/2] refactor!: remove deprecated constants --- src/Assert.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Assert.php b/src/Assert.php index b5638fc..7657af5 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -22,11 +22,6 @@ class Assert { - /** @deprecated */ - const ACCOUNT_ID_PREFIX = 'acct_'; - /** @deprecated */ - const CHARGE_ID_PREFIX = 'ch_'; - /** * @param string $expected * the expected prefix.