From cea99911ecb082bb53f1307a428cdb155be8f2f1 Mon Sep 17 00:00:00 2001 From: Marcus Olsson Date: Wed, 11 Dec 2024 13:50:29 +0100 Subject: [PATCH 1/3] Fix implicitly nullable parameters --- src/Certificate.php | 2 +- src/Client.php | 8 ++++---- src/Exceptions/InvalidUuidException.php | 2 +- src/Exceptions/ValidationException.php | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Certificate.php b/src/Certificate.php index ba7144a..b140919 100644 --- a/src/Certificate.php +++ b/src/Certificate.php @@ -28,7 +28,7 @@ public function __construct( ?string $passphrase = null, bool|string $rootPath = true, ?string $signingPath = null, - string $signingPassphrase = null + ?string $signingPassphrase = null ) { $this->client = $clientPath; $this->passphrase = $passphrase; diff --git a/src/Client.php b/src/Client.php index 9cabde9..79827c9 100644 --- a/src/Client.php +++ b/src/Client.php @@ -36,17 +36,17 @@ class Client protected ClientInterface $client; public function __construct( - Certificate $certificate = null, + ?Certificate $certificate = null, string $endpoint = self::PRODUCTION_ENDPOINT, - ClientInterface $client = null + ?ClientInterface $client = null ) { $this->setup($certificate, $endpoint, $client); } public function setup( - Certificate $certificate = null, + ?Certificate $certificate = null, string $endpoint = self::PRODUCTION_ENDPOINT, - ClientInterface $client = null + ?ClientInterface $client = null ): void { if ($certificate) { diff --git a/src/Exceptions/InvalidUuidException.php b/src/Exceptions/InvalidUuidException.php index 97e6c33..c64728d 100644 --- a/src/Exceptions/InvalidUuidException.php +++ b/src/Exceptions/InvalidUuidException.php @@ -4,7 +4,7 @@ class InvalidUuidException extends \InvalidArgumentException { - public function __construct(string $message = null, int $code = 0) + public function __construct(?string $message = null, int $code = 0) { if (!$message) { throw new $this('Invalid UUID ' . get_class($this), $code); diff --git a/src/Exceptions/ValidationException.php b/src/Exceptions/ValidationException.php index a36903b..cb095ec 100644 --- a/src/Exceptions/ValidationException.php +++ b/src/Exceptions/ValidationException.php @@ -6,6 +6,7 @@ use Olssonm\Swish\Error; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; +use Throwable; class ValidationException extends RequestException { @@ -22,8 +23,8 @@ class ValidationException extends RequestException public function __construct( string $message, RequestInterface $request, - ResponseInterface $response = null, - \Throwable $previous = null, + ?ResponseInterface $response = null, + ?Throwable $previous = null, array $handlerContext = [] ) { From 16bb48fd5774d0cd4a26e207f14924a1dff1c1fd Mon Sep 17 00:00:00 2001 From: Marcus Olsson Date: Wed, 11 Dec 2024 13:51:49 +0100 Subject: [PATCH 2/3] Fix offset-issue in some IDEs --- src/Providers/SwishServiceProvider.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Providers/SwishServiceProvider.php b/src/Providers/SwishServiceProvider.php index 4bd2709..1c9795f 100644 --- a/src/Providers/SwishServiceProvider.php +++ b/src/Providers/SwishServiceProvider.php @@ -18,21 +18,24 @@ public function register(): void $this->mergeConfigFrom($source, 'swish'); $this->app->singleton('swish', function (Container $app): Client { + $config = $app->get('config'); $certificate = new Certificate( - clientPath: $app['config']['swish.certificates.client'], - passphrase: $app['config']['swish.certificates.password'], - rootPath: $app['config']['swish.certificates.root'], - signingPath: $app['config']['swish.certificates.signing'], - signingPassphrase: $app['config']['swish.certificates.signing_password'], + clientPath: $config['swish.certificates.client'], + passphrase: $config['swish.certificates.password'], + rootPath: $config['swish.certificates.root'], + signingPath: $config['swish.certificates.signing'], + signingPassphrase: $config['swish.certificates.signing_password'], ); - return new Client($certificate, $app['config']['swish.endpoint']); + return new Client($certificate, $config['swish.endpoint']); }); $this->app->alias('swish', Client::class); } - /** @codeCoverageIgnore */ + /** + * @return array + */ public function provides(): array { return ['swish']; From 7a895d30ef844fea8fc97e48bb23379826bb7dfb Mon Sep 17 00:00:00 2001 From: Marcus Olsson Date: Wed, 11 Dec 2024 13:52:05 +0100 Subject: [PATCH 3/3] Add PHP 8.4 to test strategy, cleanup --- .github/workflows/test.yaml | 3 ++- phpunit.xml.bak | 16 ---------------- 2 files changed, 2 insertions(+), 17 deletions(-) delete mode 100644 phpunit.xml.bak diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8edef45..7389d1b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,7 @@ jobs: strategy: matrix: php: - - "8.3" + - "8.4" steps: - name: "Checkout" @@ -42,6 +42,7 @@ jobs: php: - 8.2 - 8.3 + - 8.4 dependency-version: [prefer-stable] exclude: - os: ubuntu-20.04 diff --git a/phpunit.xml.bak b/phpunit.xml.bak deleted file mode 100644 index 2eb2416..0000000 --- a/phpunit.xml.bak +++ /dev/null @@ -1,16 +0,0 @@ - - - - - ./tests/ - - - - - ./src - - - - - -