From e244c7a34d3297d4dfac18bffc5eec8b12ee91ab Mon Sep 17 00:00:00 2001 From: gaalferov Date: Thu, 23 Jan 2025 15:45:39 +0100 Subject: [PATCH 1/7] * use psr/http-factory instead php-http/message-factory * remove vimeo/psalm from dev block --- .github/workflows/ci-phpunit.yml | 6 +++++- .github/workflows/ci-psalm.yaml | 6 ++++++ composer.json | 7 +++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-phpunit.yml b/.github/workflows/ci-phpunit.yml index dec4fc1..f05922b 100644 --- a/.github/workflows/ci-phpunit.yml +++ b/.github/workflows/ci-phpunit.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest ] - php-version: [ '8.0','8.1','8.2','8.3' ] + php-version: [ '8.0','8.1','8.2','8.3','8.4' ] steps: - name: Checkout @@ -64,6 +64,8 @@ jobs: php-version: '8.2' - symfony: '7' php-version: '8.3' + - symfony: '7' + php-version: '8.4' steps: - name: Checkout @@ -98,6 +100,8 @@ jobs: php-version: '8.2' - laravel: '11' php-version: '8.3' + - laravel: '11' + php-version: '8.4' steps: - name: Checkout diff --git a/.github/workflows/ci-psalm.yaml b/.github/workflows/ci-psalm.yaml index e3faa58..3a5cf4a 100644 --- a/.github/workflows/ci-psalm.yaml +++ b/.github/workflows/ci-psalm.yaml @@ -45,5 +45,11 @@ jobs: - name: Install Composer dependencies run: composer install --prefer-dist --no-progress + - name: Install Psalm + run: composer require --dev vimeo/psalm --no-update + - name: Run Psalm analyze run: vendor/bin/psalm + + - name: Remove Psalm + run: composer remove vimeo/psalm --dev --no-update diff --git a/composer.json b/composer.json index 42192a0..85a2a4b 100644 --- a/composer.json +++ b/composer.json @@ -13,16 +13,15 @@ "php-http/client-common": "^2.0", "php-http/httplug": "^2.0", "php-http/discovery": "^1.0", - "php-http/message-factory": "^1.0", "symfony/mime": "^6.0|^7.0", - "egulias/email-validator": "^2.1.10|^3.1|^4" + "egulias/email-validator": "^2.1.10|^3.1|^4", + "psr/http-factory": "^1.1" }, "require-dev": { "symfony/http-client": "^6.0|^7.0", "symfony/mailer": "^6.0|^7.0", "phpunit/phpunit": "^9", - "nyholm/psr7": "^1.5", - "vimeo/psalm": "^5.0" + "nyholm/psr7": "^1.5" }, "suggest": { "nyholm/psr7": "PSR-7 message implementation", From 2f96d820c1baee3e3ad0a61736ebfd498d06b3c3 Mon Sep 17 00:00:00 2001 From: gaalferov Date: Thu, 23 Jan 2025 16:06:12 +0100 Subject: [PATCH 2/7] fix nullable type deprecations in PHP 8.4 --- .github/workflows/ci-phpunit.yml | 4 ++-- .github/workflows/ci-psalm.yaml | 4 ++-- phpunit.xml.dist | 2 +- src/Api/AbstractApi.php | 2 +- src/Api/Sandbox/Attachment.php | 2 +- src/Bridge/Transport/MailtrapApiTransport.php | 4 ++-- src/HttpClient/HttpClientBuilder.php | 6 +++--- src/MailtrapClient.php | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci-phpunit.yml b/.github/workflows/ci-phpunit.yml index f05922b..e2d2b0e 100644 --- a/.github/workflows/ci-phpunit.yml +++ b/.github/workflows/ci-phpunit.yml @@ -55,7 +55,7 @@ jobs: run: composer test symfony: - name: Symfony ${{ matrix.symfony }} LTS + name: Symfony ${{ matrix.symfony }} LTS and PHP ${{ matrix.php-version }} runs-on: ubuntu-latest strategy: matrix: @@ -89,7 +89,7 @@ jobs: run: composer test laravel: - name: Laravel ${{ matrix.laravel }} LTS + name: Laravel ${{ matrix.laravel }} LTS and PHP ${{ matrix.php-version }} runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/ci-psalm.yaml b/.github/workflows/ci-psalm.yaml index 3a5cf4a..b24a4c0 100644 --- a/.github/workflows/ci-psalm.yaml +++ b/.github/workflows/ci-psalm.yaml @@ -46,10 +46,10 @@ jobs: run: composer install --prefer-dist --no-progress - name: Install Psalm - run: composer require --dev vimeo/psalm --no-update + run: composer require --dev vimeo/psalm:^5.0 - name: Run Psalm analyze run: vendor/bin/psalm - name: Remove Psalm - run: composer remove vimeo/psalm --dev --no-update + run: composer remove vimeo/psalm --dev diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3a58bdb..854c641 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -17,7 +17,7 @@ verbose="true" > - + diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index 98842aa..893c1a7 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -117,7 +117,7 @@ protected function handleResponse(ResponseInterface $response): ResponseInterfac * * @return string */ - private function jsonEncode(mixed $value, int $flags = null, int $maxDepth = 512): string + private function jsonEncode(mixed $value, ?int $flags = null, int $maxDepth = 512): string { $flags ??= \JSON_HEX_TAG | \JSON_HEX_APOS | \JSON_HEX_AMP | \JSON_HEX_QUOT | \JSON_PRESERVE_ZERO_FRACTION; diff --git a/src/Api/Sandbox/Attachment.php b/src/Api/Sandbox/Attachment.php index 7297413..574dcf7 100644 --- a/src/Api/Sandbox/Attachment.php +++ b/src/Api/Sandbox/Attachment.php @@ -31,7 +31,7 @@ public function __construct( */ public function getMessageAttachments( int $messageId, - string $attachmentType = null + ?string $attachmentType = null ): ResponseInterface { $parameters = []; if (!empty($attachmentType)) { diff --git a/src/Bridge/Transport/MailtrapApiTransport.php b/src/Bridge/Transport/MailtrapApiTransport.php index eb1d76e..5e40019 100644 --- a/src/Bridge/Transport/MailtrapApiTransport.php +++ b/src/Bridge/Transport/MailtrapApiTransport.php @@ -26,8 +26,8 @@ class MailtrapApiTransport extends AbstractTransport public function __construct( private EmailsSendApiInterface $emailsSendApiLayer, private Config $config, - EventDispatcherInterface $dispatcher = null, - LoggerInterface $logger = null + ?EventDispatcherInterface $dispatcher = null, + ?LoggerInterface $logger = null ) { parent::__construct($dispatcher, $logger); } diff --git a/src/HttpClient/HttpClientBuilder.php b/src/HttpClient/HttpClientBuilder.php index 7538a4b..4a5a2c4 100644 --- a/src/HttpClient/HttpClientBuilder.php +++ b/src/HttpClient/HttpClientBuilder.php @@ -27,9 +27,9 @@ class HttpClientBuilder implements HttpClientBuilderInterface public function __construct( private string $apiToken, - ClientInterface $httpClient = null, - RequestFactoryInterface $requestFactory = null, - StreamFactoryInterface $streamFactory = null + ?ClientInterface $httpClient = null, + ?RequestFactoryInterface $requestFactory = null, + ?StreamFactoryInterface $streamFactory = null ) { $this->httpClient = $httpClient ?? Psr18ClientDiscovery::find(); $this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory(); diff --git a/src/MailtrapClient.php b/src/MailtrapClient.php index 3274da4..e2f70a0 100644 --- a/src/MailtrapClient.php +++ b/src/MailtrapClient.php @@ -35,7 +35,7 @@ public static function initSendingEmails( string $apiKey, bool $isBulk = false, bool $isSandbox = false, - int $inboxId = null, + ?int $inboxId = null, ): EmailsSendApiInterface { $client = new self(new Config($apiKey)); From 040378a885a183ca373f05e8aa69bd0ea3586353 Mon Sep 17 00:00:00 2001 From: gaalferov Date: Thu, 23 Jan 2025 16:08:53 +0100 Subject: [PATCH 3/7] fix psalm config --- .github/workflows/ci-psalm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-psalm.yaml b/.github/workflows/ci-psalm.yaml index b24a4c0..6aa9f67 100644 --- a/.github/workflows/ci-psalm.yaml +++ b/.github/workflows/ci-psalm.yaml @@ -46,7 +46,7 @@ jobs: run: composer install --prefer-dist --no-progress - name: Install Psalm - run: composer require --dev vimeo/psalm:^5.0 + run: composer require --dev vimeo/psalm - name: Run Psalm analyze run: vendor/bin/psalm From b1f8314ae011ce707106c089f0f7885466ade28c Mon Sep 17 00:00:00 2001 From: gaalferov Date: Thu, 23 Jan 2025 16:12:46 +0100 Subject: [PATCH 4/7] fix psalm config [2] --- .github/workflows/ci-psalm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-psalm.yaml b/.github/workflows/ci-psalm.yaml index 6aa9f67..539a289 100644 --- a/.github/workflows/ci-psalm.yaml +++ b/.github/workflows/ci-psalm.yaml @@ -46,7 +46,7 @@ jobs: run: composer install --prefer-dist --no-progress - name: Install Psalm - run: composer require --dev vimeo/psalm + run: composer require --dev vimeo/psalm:^5 - name: Run Psalm analyze run: vendor/bin/psalm From b0b232cde4aea77ccc17bf11ea6ec8935b052aba Mon Sep 17 00:00:00 2001 From: gaalferov Date: Thu, 23 Jan 2025 16:19:03 +0100 Subject: [PATCH 5/7] remove psalm --- .github/workflows/ci-psalm.yaml | 55 --------------------------------- psalm.xml | 20 ------------ 2 files changed, 75 deletions(-) delete mode 100644 .github/workflows/ci-psalm.yaml delete mode 100644 psalm.xml diff --git a/.github/workflows/ci-psalm.yaml b/.github/workflows/ci-psalm.yaml deleted file mode 100644 index 539a289..0000000 --- a/.github/workflows/ci-psalm.yaml +++ /dev/null @@ -1,55 +0,0 @@ -name: Psalm Analyze - -on: - push: - branches: [ main ] - pull_request: - branches: - - 'release/**' - - 'feature/**' - - 'main' - -jobs: - psalm-analyze: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-latest ] - php-versions: [ '8.0','8.1','8.2','8.3' ] - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - id: setup-php - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - extensions: mbstring, intl, curl - - - name: Print PHP version - run: echo ${{ steps.setup-php.outputs.php-version }} - - - name: Get composer cache directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer - - - name: Install Composer dependencies - run: composer install --prefer-dist --no-progress - - - name: Install Psalm - run: composer require --dev vimeo/psalm:^5 - - - name: Run Psalm analyze - run: vendor/bin/psalm - - - name: Remove Psalm - run: composer remove vimeo/psalm --dev diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index 0cc97c2..0000000 --- a/psalm.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - From a77879e7620486ba22249c632843ccc71e04423a Mon Sep 17 00:00:00 2001 From: gaalferov Date: Thu, 23 Jan 2025 16:22:12 +0100 Subject: [PATCH 6/7] remove psalm from README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 11a77fa..756ace1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ Official Mailtrap PHP client =============== ![GitHub Actions](https://github.com/railsware/mailtrap-php/actions/workflows/ci-phpunit.yml/badge.svg) -![GitHub Actions](https://github.com/railsware/mailtrap-php/actions/workflows/ci-psalm.yaml/badge.svg) [![PHP version support](https://img.shields.io/packagist/dependency-v/railsware/mailtrap-php/php?style=flat)](https://packagist.org/packages/railsware/mailtrap-php) [![Latest Version on Packagist](https://img.shields.io/packagist/v/railsware/mailtrap-php.svg?style=flat)](https://packagist.org/packages/railsware/mailtrap-php) From 69d25720f8bfa826a99e56472bf2144c0d2d37ee Mon Sep 17 00:00:00 2001 From: gaalferov Date: Thu, 23 Jan 2025 16:34:58 +0100 Subject: [PATCH 7/7] bump a version in CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a0f6b5..07be92b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [2.1.0] - 2025-01-28 + +- Use psr/http-factory instead of php-http/message-factory +- Remove a Psalm library from dependencies which can break installation on PHP 8.4 + ## [2.0.4] - 2025-01-22 - Add name prefix into custom EmailHeaders to avoid conflicts with reserved names Symfony\Component\Mime\Header\Headers::HEADER_CLASS_MAP