Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for PHP < .8.0 + Add support for PHP 8.2, and 8.3 #64

Merged
merged 4 commits into from Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Expand Up @@ -2,10 +2,8 @@ name: CI

on:
push:
branches: [master]
branches: [main]
pull_request:
schedule:
- cron: "0 0 * * MON"

jobs:
php-cs-fixer:
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Expand Up @@ -10,7 +10,7 @@
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PHP74Migration' => true,
'@PHP81Migration' => true,
'@PhpCsFixer' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
Expand Down
8 changes: 7 additions & 1 deletion 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)

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ClientInterface.php
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Helper/LockHandler.php
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/Helper/MultiLockHandler.php
Expand Up @@ -4,7 +4,6 @@

use Consul\Services\KV;
use Consul\Services\Session;
use Exception;

class MultiLockHandler
{
Expand Down Expand Up @@ -45,7 +44,7 @@ public function lock(): bool

$lockedResources[] = $resource;
}
} catch (Exception $e) {
} catch (\Exception $e) {
$result = false;
} finally {
if (!$result) {
Expand Down
3 changes: 1 addition & 2 deletions src/Helper/MultiSemaphore.php
Expand Up @@ -5,7 +5,6 @@
use Consul\Helper\MultiSemaphore\Resource;
use Consul\Services\KV;
use Consul\Services\Session;
use RuntimeException;

class MultiSemaphore
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Agent.php
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Catalog.php
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Health.php
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/KV.php
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Session.php
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/TXN.php
Expand Up @@ -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();
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Helper/MultiSemaphoreTest.php
Expand Up @@ -7,7 +7,6 @@
use Consul\Services\KV;
use Consul\Services\Session;
use PHPUnit\Framework\TestCase;
use RuntimeException;

class MultiSemaphoreTest extends TestCase
{
Expand Down Expand Up @@ -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),
Expand Down