From 415dfc413b65a5a42b0648d36e3e57a52522e4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 4 Mar 2024 08:49:37 +0100 Subject: [PATCH 1/4] Drop support for PHP < .8.0 + Add support for PHP 8.2, and 8.3 --- .github/workflows/ci.yml | 8 +++----- CHANGELOG.md | 4 ++++ composer.json | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b0943f..f2ecf66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,10 +2,8 @@ name: CI on: push: - branches: [master] + branches: [main] pull_request: - schedule: - - cron: "0 0 * * MON" jobs: php-cs-fixer: @@ -38,11 +36,11 @@ jobs: strategy: fail-fast: false matrix: - php-version: ["7.4", "8.0", "8.1"] + php-version: ["8.2", "8.3"] composer-flags: [""] name: [""] include: - - php-version: 7.4 + - php-version: 8.1 composer-flags: "--prefer-lowest" name: "(prefer lowest dependencies)" diff --git a/CHANGELOG.md b/CHANGELOG.md index 46e504f..45b4faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 5.2.0 (not released yet) +* Drop support for PHP < .8.0 +* Add support for PHP 8.2, and 8.3 +* Drop support for Symfony < 5.4, and 6.0, 6.1, 6.2, and 6.3 + ## 5.1.0 (2023-12-21) * Add support for Support symfony/http-client 7.x diff --git a/composer.json b/composer.json index e0d3f44..bfe8495 100644 --- a/composer.json +++ b/composer.json @@ -11,12 +11,12 @@ } ], "require": { - "php": ">=7.4", + "php": ">=8.1", "psr/log": "^1|^2|^3", - "symfony/http-client": "^5.1|^6.0|^7.0" + "symfony/http-client": "^5.4|^6.4|^7.0" }, "require-dev": { - "symfony/phpunit-bridge": "^5.0" + "symfony/phpunit-bridge": "^6.0|^7.0" }, "autoload": { "psr-4": { From 4a80390330f0de0389c4fed7b451774c548f68d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 4 Mar 2024 08:52:46 +0100 Subject: [PATCH 2/4] fixed cs --- .php-cs-fixer.php | 2 +- src/Client.php | 4 ++-- src/ClientInterface.php | 2 +- src/Helper/LockHandler.php | 2 +- src/Helper/MultiLockHandler.php | 3 +-- src/Helper/MultiSemaphore.php | 3 +-- src/Services/Agent.php | 2 +- src/Services/Catalog.php | 2 +- src/Services/Health.php | 2 +- src/Services/KV.php | 2 +- src/Services/Session.php | 2 +- src/Services/TXN.php | 2 +- tests/Helper/MultiSemaphoreTest.php | 3 +-- 13 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 91e3632..deccd98 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -10,7 +10,7 @@ return (new PhpCsFixer\Config()) ->setRiskyAllowed(true) ->setRules([ - '@PHP74Migration' => true, + '@PHP81Migration' => true, '@PhpCsFixer' => true, '@Symfony' => true, '@Symfony:risky' => true, diff --git a/src/Client.php b/src/Client.php index effafff..e10d1d5 100644 --- a/src/Client.php +++ b/src/Client.php @@ -16,7 +16,7 @@ final class Client implements ClientInterface private HttpClientInterface $client; private LoggerInterface $logger; - public function __construct(array $options = [], LoggerInterface $logger = null, HttpClientInterface $client = null) + public function __construct(array $options = [], ?LoggerInterface $logger = null, ?HttpClientInterface $client = null) { if (!$client) { $options['base_uri'] = DsnResolver::resolve($options); @@ -27,7 +27,7 @@ public function __construct(array $options = [], LoggerInterface $logger = null, $this->logger = $logger ?? new NullLogger(); } - public function get(string $url = null, array $options = []): ConsulResponse + public function get(?string $url = null, array $options = []): ConsulResponse { return $this->doRequest('GET', $url, $options); } diff --git a/src/ClientInterface.php b/src/ClientInterface.php index a6f0021..a57b536 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -4,7 +4,7 @@ interface ClientInterface { - public function get(string $url = null, array $options = []): ConsulResponse; + public function get(?string $url = null, array $options = []): ConsulResponse; public function head(string $url, array $options = []): ConsulResponse; diff --git a/src/Helper/LockHandler.php b/src/Helper/LockHandler.php index 13134d3..18a7851 100644 --- a/src/Helper/LockHandler.php +++ b/src/Helper/LockHandler.php @@ -14,7 +14,7 @@ final class LockHandler private $sessionId; - public function __construct($key, $value = null, Session $session = null, KV $kv = null) + public function __construct($key, $value = null, ?Session $session = null, ?KV $kv = null) { $this->key = $key; $this->value = $value; diff --git a/src/Helper/MultiLockHandler.php b/src/Helper/MultiLockHandler.php index c095dba..b2fbe2c 100644 --- a/src/Helper/MultiLockHandler.php +++ b/src/Helper/MultiLockHandler.php @@ -4,7 +4,6 @@ use Consul\Services\KV; use Consul\Services\Session; -use Exception; class MultiLockHandler { @@ -45,7 +44,7 @@ public function lock(): bool $lockedResources[] = $resource; } - } catch (Exception $e) { + } catch (\Exception $e) { $result = false; } finally { if (!$result) { diff --git a/src/Helper/MultiSemaphore.php b/src/Helper/MultiSemaphore.php index a158352..683714f 100644 --- a/src/Helper/MultiSemaphore.php +++ b/src/Helper/MultiSemaphore.php @@ -5,7 +5,6 @@ use Consul\Helper\MultiSemaphore\Resource; use Consul\Services\KV; use Consul\Services\Session; -use RuntimeException; class MultiSemaphore { @@ -34,7 +33,7 @@ public function getResources(): array public function acquire(): bool { if (null !== $this->sessionId) { - throw new RuntimeException('Resources are acquired already'); + throw new \RuntimeException('Resources are acquired already'); } // Start a session diff --git a/src/Services/Agent.php b/src/Services/Agent.php index b716dfd..82178f6 100644 --- a/src/Services/Agent.php +++ b/src/Services/Agent.php @@ -11,7 +11,7 @@ final class Agent { private ClientInterface $client; - public function __construct(ClientInterface $client = null) + public function __construct(?ClientInterface $client = null) { $this->client = $client ?: new Client(); } diff --git a/src/Services/Catalog.php b/src/Services/Catalog.php index 964b78d..f6c0117 100644 --- a/src/Services/Catalog.php +++ b/src/Services/Catalog.php @@ -11,7 +11,7 @@ final class Catalog { private ClientInterface $client; - public function __construct(ClientInterface $client = null) + public function __construct(?ClientInterface $client = null) { $this->client = $client ?: new Client(); } diff --git a/src/Services/Health.php b/src/Services/Health.php index 0e5c416..1be72af 100644 --- a/src/Services/Health.php +++ b/src/Services/Health.php @@ -11,7 +11,7 @@ final class Health { private ClientInterface $client; - public function __construct(ClientInterface $client = null) + public function __construct(?ClientInterface $client = null) { $this->client = $client ?: new Client(); } diff --git a/src/Services/KV.php b/src/Services/KV.php index 8e89d72..230050d 100644 --- a/src/Services/KV.php +++ b/src/Services/KV.php @@ -11,7 +11,7 @@ final class KV { private ClientInterface $client; - public function __construct(ClientInterface $client = null) + public function __construct(?ClientInterface $client = null) { $this->client = $client ?: new Client(); } diff --git a/src/Services/Session.php b/src/Services/Session.php index 093ba81..27eb6cb 100644 --- a/src/Services/Session.php +++ b/src/Services/Session.php @@ -11,7 +11,7 @@ final class Session { private ClientInterface $client; - public function __construct(ClientInterface $client = null) + public function __construct(?ClientInterface $client = null) { $this->client = $client ?: new Client(); } diff --git a/src/Services/TXN.php b/src/Services/TXN.php index 833c327..9a013c8 100644 --- a/src/Services/TXN.php +++ b/src/Services/TXN.php @@ -11,7 +11,7 @@ final class TXN { private ClientInterface $client; - public function __construct(ClientInterface $client = null) + public function __construct(?ClientInterface $client = null) { $this->client = $client ?: new Client(); } diff --git a/tests/Helper/MultiSemaphoreTest.php b/tests/Helper/MultiSemaphoreTest.php index a0323a0..77768b3 100644 --- a/tests/Helper/MultiSemaphoreTest.php +++ b/tests/Helper/MultiSemaphoreTest.php @@ -7,7 +7,6 @@ use Consul\Services\KV; use Consul\Services\Session; use PHPUnit\Framework\TestCase; -use RuntimeException; class MultiSemaphoreTest extends TestCase { @@ -92,7 +91,7 @@ public function testRenew(): void public function testExceptionAcquireAcquired(): void { - $this->expectExceptionObject(new RuntimeException('Resources are acquired already')); + $this->expectExceptionObject(new \RuntimeException('Resources are acquired already')); $resources = [ new Resource('resource11', 7, 7), From c0e13bdb761d8ad324cadc940215a3190dc252cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 4 Mar 2024 08:54:52 +0100 Subject: [PATCH 3/4] Specify a consul version in GHA --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2ecf66..acc1bc6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: services: service-name-1: - image: consul + image: consul:1.15 ports: - 8500:8500 From 0d2b76412b6f9ea1d249d3bbf431c0a6792e6e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 4 Mar 2024 08:59:24 +0100 Subject: [PATCH 4/4] Prepare v5.2.0 release --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45b4faa..a120724 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # CHANGELOG -## 5.2.0 (not released yet) +## 5.3.0 (not released yet) + +## 5.2.0 (2024-03-04) * Drop support for PHP < .8.0 * Add support for PHP 8.2, and 8.3