Skip to content

Commit 742e5c6

Browse files
committed
Minor documentation fixes
1 parent 7bc0172 commit 742e5c6

7 files changed

Lines changed: 27 additions & 26 deletions

File tree

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Here is an async HTTP server built with just the event loop.
3232
$loop = React\EventLoop\Factory::create();
3333

3434
$server = stream_socket_server('tcp://127.0.0.1:8080');
35-
stream_set_blocking($server, 0);
35+
stream_set_blocking($server, false);
3636

3737
$loop->addReadStream($server, function ($server) use ($loop) {
3838
$conn = stream_socket_accept($server);
@@ -97,7 +97,7 @@ $loop->run();
9797
## Factory
9898

9999
The `Factory` class exists as a convenient way to pick the best available
100-
[loop implementation)(#loop-implementation).
100+
[loop implementation](#loop-implementations).
101101

102102
The `create(): LoopInterface` method can be used to create a new loop
103103
instance:
@@ -170,14 +170,14 @@ If you want to access any variables within your callback function, you
170170
can bind arbitrary data to a callback closure like this:
171171

172172
```php
173-
function hello(LoopInterface $loop, $name)
173+
function hello($name, LoopInterface $loop)
174174
{
175175
$loop->addTimer(1.0, function () use ($name) {
176176
echo "hello $name\n";
177177
});
178178
}
179179

180-
hello('Tester');
180+
hello('Tester', $loop);
181181
```
182182

183183
The execution order of timers scheduled to execute at the same time is
@@ -218,7 +218,7 @@ If you want to limit the number of executions, you can bind
218218
arbitrary data to a callback closure like this:
219219

220220
```php
221-
function hello(LoopInterface $loop, $name)
221+
function hello($name, LoopInterface $loop)
222222
{
223223
$n = 3;
224224
$loop->addPeriodicTimer(1.0, function ($timer) use ($name, $loop, &$n) {
@@ -231,7 +231,7 @@ function hello(LoopInterface $loop, $name)
231231
});
232232
}
233233

234-
hello('Tester');
234+
hello('Tester', $loop);
235235
```
236236

237237
The execution order of timers scheduled to execute at the same time is
@@ -245,11 +245,12 @@ cancel a pending timer.
245245
See also [`addPeriodicTimer()`](#addperiodictimer) and [example #2](examples).
246246

247247
You can use the [`isTimerActive()`](#istimeractive) method to check if
248-
this timer is still "active". After a timer is successfully canceled,
248+
this timer is still "active". After a timer is successfully cancelled,
249249
it is no longer considered "active".
250250

251251
Calling this method on a timer instance that has not been added to this
252-
loop instance or on a timer
252+
loop instance or on a timer that is not "active" (or has already been
253+
cancelled) has no effect.
253254

254255
### isTimerActive()
255256

@@ -258,7 +259,7 @@ check if a given timer is active.
258259

259260
A timer is considered "active" if it has been added to this loop instance
260261
via [`addTimer()`](#addtimer) or [`addPeriodicTimer()`](#addperiodictimer)
261-
and has not been canceled via [`cancelTimer()`](#canceltimer) and is not
262+
and has not been cancelled via [`cancelTimer()`](#canceltimer) and is not
262263
a non-periodic timer that has already been triggered after its interval.
263264

264265
### futureTick()
@@ -280,14 +281,14 @@ If you want to access any variables within your callback function, you
280281
can bind arbitrary data to a callback closure like this:
281282

282283
```php
283-
function hello(LoopInterface $loop, $name)
284+
function hello($name, LoopInterface $loop)
284285
{
285286
$loop->futureTick(function () use ($name) {
286287
echo "hello $name\n";
287288
});
288289
}
289290

290-
hello('Tester');
291+
hello('Tester', $loop);
291292
```
292293

293294
Unlike timers, tick callbacks are guaranteed to be executed in the order

src/ExtEventLoop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function ($signal) {
4242
$this->signals->call($signal);
4343
// Ensure there are two copies of the callable around until it has been executed.
4444
// For more information see: https://bugs.php.net/bug.php?id=62452
45-
// Only an issue for PHP 5, this hack can be removed once PHP 5 suppose has been dropped.
45+
// Only an issue for PHP 5, this hack can be removed once PHP 5 support has been dropped.
4646
$g = $f;
4747
$f = $g;
4848
});

src/LibEvLoop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function ($signal) {
3939
$this->signals->call($signal);
4040
// Ensure there are two copies of the callable around until it has been executed.
4141
// For more information see: https://bugs.php.net/bug.php?id=62452
42-
// Only an issue for PHP 5, this hack can be removed once PHP 5 suppose has been dropped.
42+
// Only an issue for PHP 5, this hack can be removed once PHP 5 support has been dropped.
4343
$g = $f;
4444
$f = $g;
4545
}, $signal);

src/LibEventLoop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function ($signal) {
4343
$this->signals->call($signal);
4444
// Ensure there are two copies of the callable around until it has been executed.
4545
// For more information see: https://bugs.php.net/bug.php?id=62452
46-
// Only an issue for PHP 5, this hack can be removed once PHP 5 suppose has been dropped.
46+
// Only an issue for PHP 5, this hack can be removed once PHP 5 support has been dropped.
4747
$g = $f;
4848
$f = $g;
4949
});

src/LoopInterface.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ public function removeWriteStream($stream);
152152
* can bind arbitrary data to a callback closure like this:
153153
*
154154
* ```php
155-
* function hello(LoopInterface $loop, $name)
155+
* function hello($name, LoopInterface $loop)
156156
* {
157157
* $loop->addTimer(1.0, function () use ($name) {
158158
* echo "hello $name\n";
159159
* });
160160
* }
161161
*
162-
* hello('Tester');
162+
* hello('Tester', $loop);
163163
* ```
164164
*
165165
* The execution order of timers scheduled to execute at the same time is
@@ -205,7 +205,7 @@ public function addTimer($interval, callable $callback);
205205
* arbitrary data to a callback closure like this:
206206
*
207207
* ```php
208-
* function hello(LoopInterface $loop, $name)
208+
* function hello($name, LoopInterface $loop)
209209
* {
210210
* $n = 3;
211211
* $loop->addPeriodicTimer(1.0, function ($timer) use ($name, $loop, &$n) {
@@ -218,7 +218,7 @@ public function addTimer($interval, callable $callback);
218218
* });
219219
* }
220220
*
221-
* hello('Tester');
221+
* hello('Tester', $loop);
222222
* ```
223223
*
224224
* The execution order of timers scheduled to execute at the same time is
@@ -237,12 +237,12 @@ public function addPeriodicTimer($interval, callable $callback);
237237
* See also [`addPeriodicTimer()`](#addperiodictimer) and [example #2](examples).
238238
*
239239
* You can use the [`isTimerActive()`](#istimeractive) method to check if
240-
* this timer is still "active". After a timer is successfully canceled,
240+
* this timer is still "active". After a timer is successfully cancelled,
241241
* it is no longer considered "active".
242242
*
243243
* Calling this method on a timer instance that has not been added to this
244244
* loop instance or on a timer that is not "active" (or has already been
245-
* canceled) has no effect.
245+
* cancelled) has no effect.
246246
*
247247
* @param TimerInterface $timer The timer to cancel.
248248
*
@@ -255,7 +255,7 @@ public function cancelTimer(TimerInterface $timer);
255255
*
256256
* A timer is considered "active" if it has been added to this loop instance
257257
* via [`addTimer()`](#addtimer) or [`addPeriodicTimer()`](#addperiodictimer)
258-
* and has not been canceled via [`cancelTimer()`](#canceltimer) and is not
258+
* and has not been cancelled via [`cancelTimer()`](#canceltimer) and is not
259259
* a non-periodic timer that has already been triggered after its interval.
260260
*
261261
* @param TimerInterface $timer The timer to check.
@@ -281,14 +281,14 @@ public function isTimerActive(TimerInterface $timer);
281281
* can bind arbitrary data to a callback closure like this:
282282
*
283283
* ```php
284-
* function hello(LoopInterface $loop, $name)
284+
* function hello($name, LoopInterface $loop)
285285
* {
286286
* $loop->futureTick(function () use ($name) {
287287
* echo "hello $name\n";
288288
* });
289289
* }
290290
*
291-
* hello('Tester');
291+
* hello('Tester', $loop);
292292
* ```
293293
*
294294
* Unlike timers, tick callbacks are guaranteed to be executed in the order

src/StreamSelectLoop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function ($signal) {
3737
$this->signals->call($signal);
3838
// Ensure there are two copies of the callable around until it has been executed.
3939
// For more information see: https://bugs.php.net/bug.php?id=62452
40-
// Only an issue for PHP 5, this hack can be removed once PHP 5 suppose has been dropped.
40+
// Only an issue for PHP 5, this hack can be removed once PHP 5 support has been dropped.
4141
$g = $f;
4242
$f = $g;
4343
});

tests/AbstractLoopTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function testAddReadStreamReceivesDataFromStreamReference()
7272
}
7373

7474
/**
75-
* Telper for above test. This happens in another helper method to verify
76-
* the loop keep track of assigned stream resources (refcount).
75+
* Helper for above test. This happens in another helper method to verify
76+
* the loop keeps track of assigned stream resources (refcount).
7777
*/
7878
private function subAddReadStreamReceivesDataFromStreamReference()
7979
{

0 commit comments

Comments
 (0)