diff --git a/.github/workflows/Build-Test.yml b/.github/workflows/Build-Test.yml
index eb6545b..3c8d40e 100644
--- a/.github/workflows/Build-Test.yml
+++ b/.github/workflows/Build-Test.yml
@@ -14,11 +14,11 @@ jobs:
strategy:
fail-fast: false
matrix:
- operating-system: [ubuntu-20.04]
- php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
+ operating-system: [ubuntu-22.04]
+ php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
include:
- - operating-system: ubuntu-16.04
- php-versions: '7.1'
+ - operating-system: ubuntu-20.04
+ php-versions: '7.4'
COMPOSER_FLAGS: '--prefer-stable --prefer-lowest'
PHPUNIT_FLAGS: '--coverage-clover build/coverage.xml'
@@ -31,7 +31,7 @@ jobs:
steps:
# Checks out a copy of your repository on the ubuntu machine
- name: Checkout code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup PHP Action
uses: shivammathur/setup-php@v2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 29183b4..caef53e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## 2.3.3 - 2024-10-31
+
+### Added
+
+- Added support for PHP 8.4
+
+## 2.3.2 - 2024-03-03
+
+### Fixed
+
+- Fixed running the tests with Guzzle PSR-7 and PSR-17 implementations.
+
+## 2.3.1 - 2023-11-03
+
+### Added
+
+- Allow installation with Symfony 7.
+
## 2.3.0 - 2023-04-28
### Added
diff --git a/README.md b/README.md
index c9d6b5c..71ab2ea 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
[](https://github.com/php-http/curl-client/releases)
[](LICENSE)
-[](https://github.com/php-http/curl-client/actions?query=workflow%3ATests)
+[](https://github.com/php-http/curl-client/actions/workflows/Build-Test.yml)
[](https://packagist.org/packages/php-http/curl-client)
The cURL client use the cURL PHP extension which must be activated in your `php.ini`.
diff --git a/composer.json b/composer.json
index 78b4a46..cb1d971 100644
--- a/composer.json
+++ b/composer.json
@@ -15,20 +15,21 @@
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
- "php": "^7.1 || ^8.0",
+ "php": "^7.4 || ^8.0",
"ext-curl": "*",
"php-http/discovery": "^1.6",
"php-http/httplug": "^2.0",
"php-http/message": "^1.2",
"psr/http-client": "^1.0",
"psr/http-factory-implementation": "^1.0",
- "symfony/options-resolver": "^3.4 || ^4.0 || ^5.0 || ^6.0"
+ "symfony/options-resolver": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"require-dev": {
- "guzzlehttp/psr7": "^1.0",
+ "guzzlehttp/psr7": "^2.0",
"php-http/client-integration-tests": "^3.0",
"phpunit/phpunit": "^7.5 || ^9.4",
- "laminas/laminas-diactoros": "^2.0"
+ "laminas/laminas-diactoros": "^2.0 || ^3.0",
+ "php-http/message-factory": "^1.1"
},
"autoload": {
"psr-4": {
@@ -48,5 +49,10 @@
"scripts": {
"test": "vendor/bin/phpunit",
"test-ci": "vendor/bin/phpunit --coverage-clover build/coverage.xml"
+ },
+ "config": {
+ "allow-plugins": {
+ "php-http/discovery": false
+ }
}
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 3f3b615..1df4f8a 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -14,9 +14,6 @@
tests
-
- tests/Functional/HttpAsyncClientGuzzleTest.php
- tests/Functional/HttpClientGuzzleTest.php
@@ -25,9 +22,6 @@
tests/Functional
-
- tests/Functional/HttpAsyncClientGuzzleTest.php
- tests/Functional/HttpClientGuzzleTest.php
diff --git a/src/Client.php b/src/Client.php
index 739fdc2..d3fd6bd 100644
--- a/src/Client.php
+++ b/src/Client.php
@@ -77,8 +77,8 @@ class Client implements HttpClient, HttpAsyncClient
* @since 2.0 Accepts PSR-17 factories instead of HTTPlug ones.
*/
public function __construct(
- ResponseFactoryInterface $responseFactory = null,
- StreamFactoryInterface $streamFactory = null,
+ ?ResponseFactoryInterface $responseFactory = null,
+ ?StreamFactoryInterface $streamFactory = null,
array $options = []
) {
$this->responseFactory = $responseFactory ?: Psr17FactoryDiscovery::findResponseFactory();
diff --git a/src/CurlPromise.php b/src/CurlPromise.php
index f04ccf6..d69494c 100644
--- a/src/CurlPromise.php
+++ b/src/CurlPromise.php
@@ -51,15 +51,15 @@ public function __construct(PromiseCore $core, MultiRunner $runner)
* If you do not care about one of the cases, you can set the corresponding callable to null
* The callback will be called when the response or exception arrived and never more than once.
*
- * @param callable $onFulfilled Called when a response will be available
- * @param callable $onRejected Called when an error happens.
+ * @param callable|null $onFulfilled Called when a response will be available
+ * @param callable|null $onRejected Called when an error happens.
*
* You must always return the Response in the interface or throw an Exception
*
* @return Promise Always returns a new promise which is resolved with value of the executed
* callback (onFulfilled / onRejected)
*/
- public function then(callable $onFulfilled = null, callable $onRejected = null)
+ public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
{
if ($onFulfilled) {
$this->core->addOnFulfilled($onFulfilled);
diff --git a/src/MultiRunner.php b/src/MultiRunner.php
index 7a2c50c..13f43a9 100644
--- a/src/MultiRunner.php
+++ b/src/MultiRunner.php
@@ -81,7 +81,7 @@ public function remove(PromiseCore $core): void
*
* @param PromiseCore|null $targetCore
*/
- public function wait(PromiseCore $targetCore = null): void
+ public function wait(?PromiseCore $targetCore = null): void
{
do {
$status = curl_multi_exec($this->multiHandle, $active);
diff --git a/tests/Functional/HttpAsyncClientGuzzleTest.php b/tests/Functional/HttpAsyncClientGuzzleTest.php
index f1d2808..2f6c47f 100644
--- a/tests/Functional/HttpAsyncClientGuzzleTest.php
+++ b/tests/Functional/HttpAsyncClientGuzzleTest.php
@@ -4,10 +4,9 @@
namespace Http\Client\Curl\Tests\Functional;
+use GuzzleHttp\Psr7\HttpFactory;
use Http\Client\Curl\Client;
use Http\Client\HttpAsyncClient;
-use Http\Message\MessageFactory\GuzzleMessageFactory;
-use Http\Message\StreamFactory\GuzzleStreamFactory;
/**
* @covers \Http\Client\Curl\Client
@@ -19,6 +18,6 @@ class HttpAsyncClientGuzzleTest extends HttpAsyncClientTestCase
*/
protected function createHttpAsyncClient(): HttpAsyncClient
{
- return new Client(new GuzzleMessageFactory(), new GuzzleStreamFactory());
+ return new Client(new HttpFactory(), new HttpFactory());
}
}
diff --git a/tests/Functional/HttpClientGuzzleTest.php b/tests/Functional/HttpClientGuzzleTest.php
index 9cbe9da..d7cf853 100644
--- a/tests/Functional/HttpClientGuzzleTest.php
+++ b/tests/Functional/HttpClientGuzzleTest.php
@@ -4,11 +4,10 @@
namespace Http\Client\Curl\Tests\Functional;
+use GuzzleHttp\Psr7\HttpFactory;
use GuzzleHttp\Psr7\Stream;
use Http\Client\Curl\Client;
-use Http\Client\HttpClient;
-use Http\Message\MessageFactory\GuzzleMessageFactory;
-use Http\Message\StreamFactory\GuzzleStreamFactory;
+use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\StreamInterface;
/**
@@ -19,9 +18,9 @@ class HttpClientGuzzleTest extends HttpClientTestCase
/**
* {@inheritdoc}
*/
- protected function createHttpAdapter(): HttpClient
+ protected function createHttpAdapter(): ClientInterface
{
- return new Client(new GuzzleMessageFactory(), new GuzzleStreamFactory());
+ return new Client(new HttpFactory(), new HttpFactory());
}
/**
diff --git a/tests/Unit/ClientTest.php b/tests/Unit/ClientTest.php
index f198930..55d3e89 100644
--- a/tests/Unit/ClientTest.php
+++ b/tests/Unit/ClientTest.php
@@ -4,6 +4,7 @@
namespace Http\Client\Curl\Tests\Unit;
+use GuzzleHttp\Psr7\Utils;
use Http\Client\Curl\Client;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseFactoryInterface;
@@ -83,14 +84,13 @@ public function testRewindLargeStream(): void
}
$length = strlen($content);
- $body = \GuzzleHttp\Psr7\stream_for($content);
+ $body = Utils::streamFor($content);
$body->seek(40);
$request = new Request('http://foo.com', 'POST', $body);
$options = $bodyOptions->invoke($client, $request, []);
- static::assertTrue(
- false !== strstr($options[CURLOPT_READFUNCTION](null, null, $length), 'abcdef'),
- 'Steam was not rewinded'
+ static::assertNotFalse(
+ strpos($options[CURLOPT_READFUNCTION](null, null, $length), 'abcdef'), 'Steam was not rewinded'
);
}
@@ -101,7 +101,7 @@ public function testRewindStream(): void
$bodyOptions = new \ReflectionMethod(Client::class, 'addRequestBodyOptions');
$bodyOptions->setAccessible(true);
- $body = \GuzzleHttp\Psr7\stream_for('abcdef');
+ $body = Utils::streamFor('abcdef');
$body->seek(3);
$request = new Request('http://foo.com', 'POST', $body);
$options = $bodyOptions->invoke($client, $request, []);