From b7008a59b8d605c0fbcde590133eab37a9d8ea5e Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Tue, 22 Sep 2020 08:23:37 +0200 Subject: [PATCH 1/5] Remove support for async extension --- .travis.yml | 8 ++------ CHANGELOG.md | 4 ++-- composer.json | 3 ++- src/Client.php | 8 -------- tests/AsyncTest.php | 37 ------------------------------------- 5 files changed, 6 insertions(+), 54 deletions(-) delete mode 100644 tests/AsyncTest.php diff --git a/.travis.yml b/.travis.yml index 8b584a9..25f354a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,10 @@ cache: - $HOME/.composer/cache php: - - 7.1 - 7.2 - 7.3 + - 7.4 + - 8.0 env: global: @@ -26,14 +27,9 @@ matrix: env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci" - php: 7.2 env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" - - php: 7.3 - env: USE_ASYNC=true before_install: - travis_retry composer self-update - - if [[ "$USE_ASYNC" = true ]]; then git clone https://github.com/concurrent-php/ext-async.git /tmp/async; fi - - if [[ "$USE_ASYNC" = true ]]; then cd /tmp/async && phpize && ./configure && sudo make install; fi - - if [[ "$USE_ASYNC" = true ]]; then echo "extension = async.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini && php -m && cd $TRAVIS_BUILD_DIR; fi install: - travis_retry composer update ${COMPOSER_FLAGS} --prefer-source --no-interaction --ignore-platform-reqs diff --git a/CHANGELOG.md b/CHANGELOG.md index f92a44d..b4ec355 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## 2.0.0 (unreleased) +## 2.0.0 * Remove response and stream factory, use direct implementation of nyholm/psr7 * Async support with ext-async extension: see https://github.com/concurrent-php/ext-async @@ -20,7 +20,7 @@ * `ConnectionException` * `InvalidRequestException` * `SSLConnectionException` - + ## 1.2.0 * Dropped PHP 5.4 support diff --git a/composer.json b/composer.json index 6a7dbdd..eece4a0 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "php-http/client-common": "^2.0" }, "provide": { - "php-http/client-implementation": "1.0" + "php-http/client-implementation": "1.0", + "psr/http-client": "1.0" }, "autoload": { "psr-4": { diff --git a/src/Client.php b/src/Client.php index 9c5a3d6..188026c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -34,8 +34,6 @@ class Client implements HttpClient 'ssl_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, ]; - private $hasAsync; - /** * Constructor. * @@ -52,8 +50,6 @@ class Client implements HttpClient */ public function __construct($config1 = [], $config2 = null, array $config = []) { - $this->hasAsync = PHP_VERSION_ID >= 70300 && \extension_loaded('async'); - if (\is_array($config1)) { $this->config = $this->configure($config1); @@ -191,10 +187,6 @@ private function determineRemoteFromRequest(RequestInterface $request) $endpoint = $request->getHeaderLine('Host'); } - if ($this->hasAsync) { - return sprintf('async-tcp://%s', $endpoint); - } - return sprintf('tcp://%s', $endpoint); } } diff --git a/tests/AsyncTest.php b/tests/AsyncTest.php deleted file mode 100644 index 58f62d8..0000000 --- a/tests/AsyncTest.php +++ /dev/null @@ -1,37 +0,0 @@ -markTestSkipped('Test need async extension'); - } - - $client = new Client(); - $request = new Request('GET', 'https://httpbin.org/delay/1'); - - $timeStart = microtime(true); - $task1 = Task::async(function () use ($request, $client) { - return $client->sendRequest($request); - }); - $task2 = Task::async(function () use ($request, $client) { - return $client->sendRequest($request); - }); - - [$response1, $response2] = Task::await(all([$task1, $task2])); - $timeTaken = microtime(true) - $timeStart; - - self::assertLessThan(2, $timeTaken); - self::assertEquals(200, $response1->getStatusCode()); - self::assertEquals(200, $response2->getStatusCode()); - } -} From 1e3b3b9dab3f430207c13cec5eb1901df3b56af9 Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Tue, 22 Sep 2020 08:25:39 +0200 Subject: [PATCH 2/5] Fix cs --- src/Client.php | 1 - tests/SocketClientFeatureTest.php | 2 +- tests/SocketHttpAdapterTest.php | 2 +- tests/SocketHttpClientTest.php | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Client.php b/src/Client.php index 188026c..9480549 100644 --- a/src/Client.php +++ b/src/Client.php @@ -167,7 +167,6 @@ protected function configure(array $config = []) /** * Return remote socket from the request. * - * * @throws InvalidRequestException When no remote can be determined from the request * * @return string diff --git a/tests/SocketClientFeatureTest.php b/tests/SocketClientFeatureTest.php index aa614c4..e6e698b 100644 --- a/tests/SocketClientFeatureTest.php +++ b/tests/SocketClientFeatureTest.php @@ -2,8 +2,8 @@ namespace Http\Client\Socket\Tests; -use Http\Client\Tests\HttpFeatureTest; use Http\Client\Socket\Client as SocketHttpClient; +use Http\Client\Tests\HttpFeatureTest; use Psr\Http\Client\ClientInterface; class SocketClientFeatureTest extends HttpFeatureTest diff --git a/tests/SocketHttpAdapterTest.php b/tests/SocketHttpAdapterTest.php index 7aa785b..f95b28e 100644 --- a/tests/SocketHttpAdapterTest.php +++ b/tests/SocketHttpAdapterTest.php @@ -2,8 +2,8 @@ namespace Http\Client\Socket\Tests; -use Http\Client\Tests\HttpClientTest; use Http\Client\Socket\Client as SocketHttpClient; +use Http\Client\Tests\HttpClientTest; use Psr\Http\Client\ClientInterface; class SocketHttpAdapterTest extends HttpClientTest diff --git a/tests/SocketHttpClientTest.php b/tests/SocketHttpClientTest.php index cfec8ce..cca4fd6 100644 --- a/tests/SocketHttpClientTest.php +++ b/tests/SocketHttpClientTest.php @@ -3,8 +3,8 @@ namespace Http\Client\Socket\Tests; use Http\Client\Common\HttpMethodsClient; -use Http\Message\MessageFactory\GuzzleMessageFactory; use Http\Client\Socket\Client as SocketHttpClient; +use Http\Message\MessageFactory\GuzzleMessageFactory; class SocketHttpClientTest extends BaseTestCase { From 3c76d7b4d454a0b3a6b454fc831f41a7ea1eea5a Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Tue, 22 Sep 2020 08:28:02 +0200 Subject: [PATCH 3/5] Remove php 7.1 for coverage --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 25f354a..c447f5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ branches: matrix: fast_finish: true include: - - php: 7.1 + - php: 7.2 env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci" - php: 7.2 env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" From e27facb5ac65aab27aa202e59b0cf448dbf05d9c Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Tue, 22 Sep 2020 08:30:26 +0200 Subject: [PATCH 4/5] Remove async package --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index eece4a0..178985f 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,6 @@ "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0 || ^5.0" }, "require-dev": { - "concurrent-php/async-api": "dev-master", "friendsofphp/php-cs-fixer": "^2.2", "php-http/client-integration-tests": "dev-master", "php-http/message": "^1.0", From d730acdc248f981c2d3c7c8854f5cda4d31bd1cc Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Tue, 22 Sep 2020 08:36:10 +0200 Subject: [PATCH 5/5] Remove feature test and 8.0 php version --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c447f5c..deadd3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ php: - 7.2 - 7.3 - 7.4 - - 8.0 env: global: @@ -40,7 +39,6 @@ before_script: script: - cd ./tests/server/ssl && ./generate.sh && pwd && ls -la && cd ../../../ - $TEST_COMMAND - - ./vendor/bin/phpunit tests/SocketClientFeatureTest.php --printer Http\\Client\\Tests\\FeatureTestListener || echo "" after_success: - if [[ "$COVERAGE" = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi