diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b0943f..acc1bc6 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,17 +36,17 @@ 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)" services: service-name-1: - image: consul + image: consul:1.15 ports: - 8500:8500 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/CHANGELOG.md b/CHANGELOG.md index 46e504f..a120724 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # 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 +* Drop support for Symfony < 5.4, and 6.0, 6.1, 6.2, and 6.3 ## 5.1.0 (2023-12-21) 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": { 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),