From fafa71f41bf6de9a4015a074d3c0de0267ee8f88 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Thu, 30 Sep 2021 09:16:42 +0200 Subject: [PATCH 1/2] Improve documentation --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d6c9d31..f697bfd 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,10 @@ Once [installed](#install), you can use the following code to access an HTTP webserver and send a large number of HTTP GET requests: ```php +get($url); }); foreach ($urls as $url) { - $q($url)->then(function (ResponseInterface $response) use ($url) { + $q($url)->then(function (Psr\Http\Message\ResponseInterface $response) use ($url) { echo $url . ': ' . $response->getBody()->getSize() . ' bytes' . PHP_EOL; }); } @@ -473,7 +477,7 @@ for more details. ## Install -The recommended way to install this library is [through Composer](https://getcomposer.org). +The recommended way to install this library is [through Composer](https://getcomposer.org/). [New to Composer?](https://getcomposer.org/doc/00-intro.md) This project follows [SemVer](https://semver.org/). @@ -487,12 +491,12 @@ See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. This project aims to run on any platform and thus does not require any PHP extensions and supports running on legacy PHP 5.3 through current PHP 8+. -It's *highly recommended to use PHP 7+* for this project. +It's highly recommended to use the latest supported PHP version for this project. ## Tests To run the test suite, you first need to clone this repo and then install all -dependencies [through Composer](https://getcomposer.org): +dependencies [through Composer](https://getcomposer.org/): ```bash $ composer install @@ -501,7 +505,7 @@ $ composer install To run the test suite, go to the project root and run: ```bash -$ php vendor/bin/phpunit +$ vendor/bin/phpunit ``` ## License From 1ce1147f31ab1aea15303ba5800ddcffa2429960 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Thu, 30 Sep 2021 09:18:07 +0200 Subject: [PATCH 2/2] Use full namespaces in examples --- composer.json | 2 +- examples/01-http.php | 11 +++-------- examples/02-http-all.php | 11 +++-------- examples/03-http-any.php | 11 +++-------- examples/11-http-blocking.php | 13 +++++-------- 5 files changed, 15 insertions(+), 33 deletions(-) diff --git a/composer.json b/composer.json index ada8f27..d6e7793 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,6 @@ "clue/block-react": "^1.0", "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", "react/event-loop": "^1.2", - "react/http": "^1.4" + "react/http": "^1.5" } } diff --git a/examples/01-http.php b/examples/01-http.php index d57388c..0248fd7 100644 --- a/examples/01-http.php +++ b/examples/01-http.php @@ -1,10 +1,5 @@ get($url); }); foreach ($urls as $url) { $queue($url)->then( - function (ResponseInterface $response) use ($url) { + function (Psr\Http\Message\ResponseInterface $response) use ($url) { echo $url . ' has ' . $response->getBody()->getSize() . ' bytes' . PHP_EOL; }, function (Exception $e) use ($url) { diff --git a/examples/02-http-all.php b/examples/02-http-all.php index cb3bb54..3eaf0bd 100644 --- a/examples/02-http-all.php +++ b/examples/02-http-all.php @@ -1,10 +1,5 @@ get($url); }); $promise->then( function ($responses) { - /* @var $responses ResponseInterface[] */ + /* @var $responses Psr\Http\Message\ResponseInterface[] */ echo 'All URLs succeeded!' . PHP_EOL; foreach ($responses as $url => $response) { echo $url . ' has ' . $response->getBody()->getSize() . ' bytes' . PHP_EOL; diff --git a/examples/03-http-any.php b/examples/03-http-any.php index 417f644..9f96e8c 100644 --- a/examples/03-http-any.php +++ b/examples/03-http-any.php @@ -1,10 +1,5 @@ get($url)->then( - function (ResponseInterface $response) use ($url) { + function (Psr\Http\Message\ResponseInterface $response) use ($url) { // return only the URL for the first successful response return $url; } diff --git a/examples/11-http-blocking.php b/examples/11-http-blocking.php index 6ba2dee..d176db7 100644 --- a/examples/11-http-blocking.php +++ b/examples/11-http-blocking.php @@ -1,10 +1,7 @@ get($url)->then( - function (ResponseInterface $response) { + function (Psr\Http\Message\ResponseInterface $response) { // return only the body for successful responses return $response->getBody(); }, @@ -36,7 +33,7 @@ function (Exception $e) { ); }); - return Block\await($promise, $loop); + return Block\await($promise, Loop::get()); } $responses = download($urls);