@@ -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
9999The ` Factory ` class exists as a convenient way to pick the best available
100- [ loop implementation) (#loop-implementation ).
100+ [ loop implementation] ( #loop-implementations ) .
101101
102102The ` create(): LoopInterface ` method can be used to create a new loop
103103instance:
@@ -170,14 +170,14 @@ If you want to access any variables within your callback function, you
170170can 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
183183The 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
218218arbitrary 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
237237The execution order of timers scheduled to execute at the same time is
@@ -245,11 +245,12 @@ cancel a pending timer.
245245See also [ ` addPeriodicTimer() ` ] ( #addperiodictimer ) and [ example #2 ] ( examples ) .
246246
247247You 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 ,
249249it is no longer considered "active".
250250
251251Calling 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
259260A timer is considered "active" if it has been added to this loop instance
260261via [ ` 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
262263a 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
280281can 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
293294Unlike timers, tick callbacks are guaranteed to be executed in the order
@@ -312,8 +313,10 @@ See also [example #3](examples).
312313### addSignal()
313314
314315The ` addSignal(int $signal, callable $listener): void ` method can be used to
315- be notified about OS signals. This is useful to catch user interrupt signals or
316- shutdown signals from tools like ` supervisor ` or ` systemd ` .
316+ register a listener to be notified when a signal has been caught by this process.
317+
318+ This is useful to catch user interrupt signals or shutdown signals from
319+ tools like ` supervisor ` or ` systemd ` .
317320
318321The listener callback function MUST be able to accept a single parameter,
319322the signal added by this method or you MAY use a function which
@@ -325,32 +328,32 @@ no effect, so for performance reasons you're recommended to not return
325328any excessive data structures.
326329
327330``` php
328- $listener = function (int $signal) {
329- echo 'Caught user iterrupt signal', PHP_EOL;
330- };
331- $loop->addSignal(SIGINT, $listener);
331+ $loop->addSignal(SIGINT, function (int $signal) {
332+ echo 'Caught user interrupt signal' . PHP_EOL;
333+ });
332334```
333335
334336See also [ example #4 ] ( examples ) .
335337
336- ** Note: A listener can only be added once to the same signal, any attempts to add it
337- more then once will be ignored.**
338+ Signaling is only available on Unix-like platform, Windows isn't
339+ supported due to operating system limitations.
340+ This method may throw a ` BadMethodCallException ` if signals aren't
341+ supported on this platform, for example when required extensions are
342+ missing.
338343
339- ** Note: Signaling is only available on Unix-like platform, Windows isn't supported due
340- to limitations from underlying signal handlers .**
344+ ** Note: A listener can only be added once to the same signal, any
345+ attempts to add it more then once will be ignored .**
341346
342347### removeSignal()
343348
344- The ` removeSignal(int $signal, callable $listener): void ` removes a previously added
345- signal listener.
346-
347- Any attempts to remove listeners that aren't registerred will be ignored.
349+ The ` removeSignal(int $signal, callable $listener): void ` method can be used to
350+ remove a previously added signal listener.
348351
349352``` php
350353$loop->removeSignal(SIGINT, $listener);
351354```
352355
353- See also [ example # 4 ] ( examples ) .
356+ Any attempts to remove listeners that aren't registered will be ignored .
354357
355358### addReadStream()
356359
0 commit comments