Skip to content

Commit 70e2174

Browse files
committed
Use full namespaces in examples
1 parent fafa71f commit 70e2174

File tree

4 files changed

+12
-31
lines changed

4 files changed

+12
-31
lines changed

examples/01-http.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?php
22

3-
use Clue\React\Mq\Queue;
4-
use Psr\Http\Message\ResponseInterface;
5-
use React\EventLoop\Factory;
6-
use React\Http\Browser;
7-
83
require __DIR__ . '/../vendor/autoload.php';
94

105
// list of all URLs you want to download
@@ -17,17 +12,17 @@
1712
'http://www.google.com/',
1813
);
1914

20-
$browser = new Browser();
15+
$browser = new React\Http\Browser();
2116

2217
// each job should use the browser to GET a certain URL
2318
// limit number of concurrent jobs here to avoid using excessive network resources
24-
$queue = new Queue(3, null, function ($url) use ($browser) {
19+
$queue = new Clue\React\Mq\Queue(3, null, function ($url) use ($browser) {
2520
return $browser->get($url);
2621
});
2722

2823
foreach ($urls as $url) {
2924
$queue($url)->then(
30-
function (ResponseInterface $response) use ($url) {
25+
function (Psr\Http\Message\ResponseInterface $response) use ($url) {
3126
echo $url . ' has ' . $response->getBody()->getSize() . ' bytes' . PHP_EOL;
3227
},
3328
function (Exception $e) use ($url) {

examples/02-http-all.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?php
22

3-
use Clue\React\Mq\Queue;
4-
use Psr\Http\Message\ResponseInterface;
5-
use React\EventLoop\Factory;
6-
use React\Http\Browser;
7-
83
require __DIR__ . '/../vendor/autoload.php';
94

105
// list of all URLs you want to download
@@ -17,17 +12,17 @@
1712
//'http://httpbin.org/delay/2',
1813
);
1914

20-
$browser = new Browser();
15+
$browser = new React\Http\Browser();
2116

2217
// each job should use the browser to GET a certain URL
2318
// limit number of concurrent jobs here to avoid using excessive network resources
24-
$promise = Queue::all(3, array_combine($urls, $urls), function ($url) use ($browser) {
19+
$promise = Clue\React\Mq\Queue::all(3, array_combine($urls, $urls), function ($url) use ($browser) {
2520
return $browser->get($url);
2621
});
2722

2823
$promise->then(
2924
function ($responses) {
30-
/* @var $responses ResponseInterface[] */
25+
/* @var $responses Psr\Http\Message\ResponseInterface[] */
3126
echo 'All URLs succeeded!' . PHP_EOL;
3227
foreach ($responses as $url => $response) {
3328
echo $url . ' has ' . $response->getBody()->getSize() . ' bytes' . PHP_EOL;

examples/03-http-any.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?php
22

3-
use Clue\React\Mq\Queue;
4-
use Psr\Http\Message\ResponseInterface;
5-
use React\EventLoop\Factory;
6-
use React\Http\Browser;
7-
83
require __DIR__ . '/../vendor/autoload.php';
94

105
// list of all URLs you want to try
@@ -18,13 +13,13 @@
1813
'http://www.google.com/invalid',
1914
);
2015

21-
$browser = new Browser();
16+
$browser = new React\Http\Browser();
2217

2318
// each job should use the browser to GET a certain URL
2419
// limit number of concurrent jobs here to avoid using excessive network resources
25-
$promise = Queue::any(2, $urls, function ($url) use ($browser) {
20+
$promise = Clue\React\Mq\Queue::any(2, $urls, function ($url) use ($browser) {
2621
return $browser->get($url)->then(
27-
function (ResponseInterface $response) use ($url) {
22+
function (Psr\Http\Message\ResponseInterface $response) use ($url) {
2823
// return only the URL for the first successful response
2924
return $url;
3025
}

examples/11-http-blocking.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<?php
22

33
use Clue\React\Block;
4-
use Clue\React\Mq\Queue;
5-
use Psr\Http\Message\ResponseInterface;
6-
use React\EventLoop\Factory;
7-
use React\Http\Browser;
84

95
require __DIR__ . '/../vendor/autoload.php';
106

@@ -20,12 +16,12 @@
2016

2117
function download(array $urls)
2218
{
23-
$browser = new Browser();
19+
$browser = new React\Http\Browser();
2420

2521
$urls = array_combine($urls, $urls);
26-
$promise = Queue::all(3, $urls, function ($url) use ($browser) {
22+
$promise = Clue\React\Mq\Queue::all(3, $urls, function ($url) use ($browser) {
2723
return $browser->get($url)->then(
28-
function (ResponseInterface $response) {
24+
function (Psr\Http\Message\ResponseInterface $response) {
2925
// return only the body for successful responses
3026
return $response->getBody();
3127
},

0 commit comments

Comments
 (0)