Skip to content

Commit

Permalink
Minor documentation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Dec 1, 2017
1 parent 7bc0172 commit 742e5c6
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Here is an async HTTP server built with just the event loop.
$loop = React\EventLoop\Factory::create();

$server = stream_socket_server('tcp://127.0.0.1:8080');
stream_set_blocking($server, 0);
stream_set_blocking($server, false);

$loop->addReadStream($server, function ($server) use ($loop) {
$conn = stream_socket_accept($server);
Expand Down Expand Up @@ -97,7 +97,7 @@ $loop->run();
## Factory

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

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

```php
function hello(LoopInterface $loop, $name)
function hello($name, LoopInterface $loop)
{
$loop->addTimer(1.0, function () use ($name) {
echo "hello $name\n";
});
}

hello('Tester');
hello('Tester', $loop);
```

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

```php
function hello(LoopInterface $loop, $name)
function hello($name, LoopInterface $loop)
{
$n = 3;
$loop->addPeriodicTimer(1.0, function ($timer) use ($name, $loop, &$n) {
Expand All @@ -231,7 +231,7 @@ function hello(LoopInterface $loop, $name)
});
}

hello('Tester');
hello('Tester', $loop);
```

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

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

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

### isTimerActive()

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

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

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

```php
function hello(LoopInterface $loop, $name)
function hello($name, LoopInterface $loop)
{
$loop->futureTick(function () use ($name) {
echo "hello $name\n";
});
}

hello('Tester');
hello('Tester', $loop);
```

Unlike timers, tick callbacks are guaranteed to be executed in the order
Expand Down
2 changes: 1 addition & 1 deletion src/ExtEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function ($signal) {
$this->signals->call($signal);
// Ensure there are two copies of the callable around until it has been executed.
// For more information see: https://bugs.php.net/bug.php?id=62452
// Only an issue for PHP 5, this hack can be removed once PHP 5 suppose has been dropped.
// Only an issue for PHP 5, this hack can be removed once PHP 5 support has been dropped.
$g = $f;
$f = $g;
});
Expand Down
2 changes: 1 addition & 1 deletion src/LibEvLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function ($signal) {
$this->signals->call($signal);
// Ensure there are two copies of the callable around until it has been executed.
// For more information see: https://bugs.php.net/bug.php?id=62452
// Only an issue for PHP 5, this hack can be removed once PHP 5 suppose has been dropped.
// Only an issue for PHP 5, this hack can be removed once PHP 5 support has been dropped.
$g = $f;
$f = $g;
}, $signal);
Expand Down
2 changes: 1 addition & 1 deletion src/LibEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function ($signal) {
$this->signals->call($signal);
// Ensure there are two copies of the callable around until it has been executed.
// For more information see: https://bugs.php.net/bug.php?id=62452
// Only an issue for PHP 5, this hack can be removed once PHP 5 suppose has been dropped.
// Only an issue for PHP 5, this hack can be removed once PHP 5 support has been dropped.
$g = $f;
$f = $g;
});
Expand Down
18 changes: 9 additions & 9 deletions src/LoopInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ public function removeWriteStream($stream);
* can bind arbitrary data to a callback closure like this:
*
* ```php
* function hello(LoopInterface $loop, $name)
* function hello($name, LoopInterface $loop)
* {
* $loop->addTimer(1.0, function () use ($name) {
* echo "hello $name\n";
* });
* }
*
* hello('Tester');
* hello('Tester', $loop);
* ```
*
* The execution order of timers scheduled to execute at the same time is
Expand Down Expand Up @@ -205,7 +205,7 @@ public function addTimer($interval, callable $callback);
* arbitrary data to a callback closure like this:
*
* ```php
* function hello(LoopInterface $loop, $name)
* function hello($name, LoopInterface $loop)
* {
* $n = 3;
* $loop->addPeriodicTimer(1.0, function ($timer) use ($name, $loop, &$n) {
Expand All @@ -218,7 +218,7 @@ public function addTimer($interval, callable $callback);
* });
* }
*
* hello('Tester');
* hello('Tester', $loop);
* ```
*
* The execution order of timers scheduled to execute at the same time is
Expand All @@ -237,12 +237,12 @@ public function addPeriodicTimer($interval, callable $callback);
* See also [`addPeriodicTimer()`](#addperiodictimer) and [example #2](examples).
*
* You can use the [`isTimerActive()`](#istimeractive) method to check if
* this timer is still "active". After a timer is successfully canceled,
* this timer is still "active". After a timer is successfully cancelled,
* it is no longer considered "active".
*
* Calling this method on a timer instance that has not been added to this
* loop instance or on a timer that is not "active" (or has already been
* canceled) has no effect.
* cancelled) has no effect.
*
* @param TimerInterface $timer The timer to cancel.
*
Expand All @@ -255,7 +255,7 @@ public function cancelTimer(TimerInterface $timer);
*
* A timer is considered "active" if it has been added to this loop instance
* via [`addTimer()`](#addtimer) or [`addPeriodicTimer()`](#addperiodictimer)
* and has not been canceled via [`cancelTimer()`](#canceltimer) and is not
* and has not been cancelled via [`cancelTimer()`](#canceltimer) and is not
* a non-periodic timer that has already been triggered after its interval.
*
* @param TimerInterface $timer The timer to check.
Expand All @@ -281,14 +281,14 @@ public function isTimerActive(TimerInterface $timer);
* can bind arbitrary data to a callback closure like this:
*
* ```php
* function hello(LoopInterface $loop, $name)
* function hello($name, LoopInterface $loop)
* {
* $loop->futureTick(function () use ($name) {
* echo "hello $name\n";
* });
* }
*
* hello('Tester');
* hello('Tester', $loop);
* ```
*
* Unlike timers, tick callbacks are guaranteed to be executed in the order
Expand Down
2 changes: 1 addition & 1 deletion src/StreamSelectLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function ($signal) {
$this->signals->call($signal);
// Ensure there are two copies of the callable around until it has been executed.
// For more information see: https://bugs.php.net/bug.php?id=62452
// Only an issue for PHP 5, this hack can be removed once PHP 5 suppose has been dropped.
// Only an issue for PHP 5, this hack can be removed once PHP 5 support has been dropped.
$g = $f;
$f = $g;
});
Expand Down
4 changes: 2 additions & 2 deletions tests/AbstractLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public function testAddReadStreamReceivesDataFromStreamReference()
}

/**
* Telper for above test. This happens in another helper method to verify
* the loop keep track of assigned stream resources (refcount).
* Helper for above test. This happens in another helper method to verify
* the loop keeps track of assigned stream resources (refcount).
*/
private function subAddReadStreamReceivesDataFromStreamReference()
{
Expand Down

0 comments on commit 742e5c6

Please sign in to comment.