@@ -65,7 +65,7 @@ function blockingExample()
6565 $request2 = $browser->get('http://www.google.co.uk/');
6666
6767 // keep the loop running (i.e. block) until the first response arrives
68- $fasterResponse = Block\awaitAny(array($request1, $request2), $loop);
68+ $fasterResponse = Clue\React\ Block\awaitAny(array($request1, $request2), $loop);
6969
7070 return $fasterResponse->getBody();
7171}
@@ -76,18 +76,26 @@ function blockingExample()
7676This lightweight library consists only of a few simple functions.
7777All functions reside under the ` Clue\React\Block ` namespace.
7878
79- The below examples assume you use an import statement similar to this:
79+ The below examples refer to all functions with their fully-qualified names like this:
8080
8181``` php
82- use Clue\React\Block;
82+ Clue\React\Block\await(…);
83+ ```
8384
84- Block\await(…);
85+ As of PHP 5.6+ you can also import each required function into your code like this:
86+
87+ ``` php
88+ use function Clue\React\Block\await;
89+
90+ await(…);
8591```
8692
87- Alternatively, you can also refer to them with their fully-qualified name :
93+ Alternatively, you can also use an import statement similar to this :
8894
8995``` php
90- \Clue\React\Block\await(…);
96+ use Clue\React\Block;
97+
98+ Block\await(…);
9199```
92100
93101### EventLoop
@@ -106,7 +114,7 @@ The `sleep($seconds, LoopInterface $loop): void` function can be used to
106114wait/sleep for ` $time ` seconds.
107115
108116``` php
109- Block\sleep(1.5, $loop);
117+ Clue\React\ Block\sleep(1.5, $loop);
110118```
111119
112120This function will only return after the given ` $time ` has elapsed. In the
@@ -125,7 +133,7 @@ The `await(PromiseInterface $promise, LoopInterface $loop, ?float $timeout = nul
125133block waiting for the given ` $promise ` to be fulfilled.
126134
127135``` php
128- $result = Block\await($promise, $loop, $timeout);
136+ $result = Clue\React\ Block\await($promise, $loop, $timeout);
129137```
130138
131139This function will only return after the given ` $promise ` has settled, i.e.
@@ -141,7 +149,7 @@ will throw an `UnexpectedValueException` instead.
141149
142150``` php
143151try {
144- $result = Block\await($promise, $loop);
152+ $result = Clue\React\ Block\await($promise, $loop);
145153 // promise successfully fulfilled with $result
146154 echo 'Result: ' . $result;
147155} catch (Exception $exception) {
@@ -171,7 +179,7 @@ $promises = array(
171179 $promise2
172180);
173181
174- $firstResult = Block\awaitAny($promises, $loop, $timeout);
182+ $firstResult = Clue\React\ Block\awaitAny($promises, $loop, $timeout);
175183
176184echo 'First result: ' . $firstResult;
177185```
@@ -208,7 +216,7 @@ $promises = array(
208216 $promise2
209217);
210218
211- $allResults = Block\awaitAll($promises, $loop, $timeout);
219+ $allResults = Clue\React\ Block\awaitAll($promises, $loop, $timeout);
212220
213221echo 'First promise resolved with: ' . $allResults[0];
214222```
0 commit comments