@@ -351,7 +351,7 @@ event loop implementation first or they will throw a `BadMethodCallException` on
351
351
A ` stream_select() ` based event loop.
352
352
353
353
This uses the [ ` stream_select() ` ] ( https://www.php.net/manual/en/function.stream-select.php )
354
- function and is the only implementation which works out of the box with PHP.
354
+ function and is the only implementation that works out of the box with PHP.
355
355
356
356
This event loop works out of the box on PHP 5.3 through PHP 7+ and HHVM.
357
357
This means that no installation is required and this library works on all
@@ -468,7 +468,7 @@ run the event loop until there are no more tasks to perform.
468
468
469
469
For many applications, this method is the only directly visible
470
470
invocation on the event loop.
471
- As a rule of thumb, it is usally recommended to attach everything to the
471
+ As a rule of thumb, it is usually recommended to attach everything to the
472
472
same loop instance and then run the loop once at the bottom end of the
473
473
application.
474
474
@@ -486,7 +486,7 @@ run it will result in the application exiting without actually waiting
486
486
for any of the attached listeners.
487
487
488
488
This method MUST NOT be called while the loop is already running.
489
- This method MAY be called more than once after it has explicity been
489
+ This method MAY be called more than once after it has explicitly been
490
490
[ ` stop() ` ped] ( #stop ) or after it automatically stopped because it
491
491
previously did no longer have anything to do.
492
492
@@ -515,18 +515,21 @@ on a loop instance that has already been stopped has no effect.
515
515
The ` addTimer(float $interval, callable $callback): TimerInterface ` method can be used to
516
516
enqueue a callback to be invoked once after the given interval.
517
517
518
- The timer callback function MUST be able to accept a single parameter,
519
- the timer instance as also returned by this method or you MAY use a
520
- function which has no parameters at all.
518
+ The second parameter MUST be a timer callback function that accepts
519
+ the timer instance as its only parameter.
520
+ If you don't use the timer instance inside your timer callback function
521
+ you MAY use a function which has no parameters at all.
521
522
522
523
The timer callback function MUST NOT throw an ` Exception ` .
523
524
The return value of the timer callback function will be ignored and has
524
525
no effect, so for performance reasons you're recommended to not return
525
526
any excessive data structures.
526
527
528
+ This method returns a timer instance. The same timer instance will also be
529
+ passed into the timer callback function as described above.
530
+ You can invoke [ ` cancelTimer ` ] ( #canceltimer ) to cancel a pending timer.
527
531
Unlike [ ` addPeriodicTimer() ` ] ( #addperiodictimer ) , this method will ensure
528
532
the callback will be invoked only once after the given interval.
529
- You can invoke [ ` cancelTimer ` ] ( #canceltimer ) to cancel a pending timer.
530
533
531
534
``` php
532
535
$loop->addTimer(0.8, function () {
@@ -581,15 +584,18 @@ See also [event loop implementations](#loop-implementations) for more details.
581
584
The ` addPeriodicTimer(float $interval, callable $callback): TimerInterface ` method can be used to
582
585
enqueue a callback to be invoked repeatedly after the given interval.
583
586
584
- The timer callback function MUST be able to accept a single parameter,
585
- the timer instance as also returned by this method or you MAY use a
586
- function which has no parameters at all.
587
+ The second parameter MUST be a timer callback function that accepts
588
+ the timer instance as its only parameter.
589
+ If you don't use the timer instance inside your timer callback function
590
+ you MAY use a function which has no parameters at all.
587
591
588
592
The timer callback function MUST NOT throw an ` Exception ` .
589
593
The return value of the timer callback function will be ignored and has
590
594
no effect, so for performance reasons you're recommended to not return
591
595
any excessive data structures.
592
596
597
+ This method returns a timer instance. The same timer instance will also be
598
+ passed into the timer callback function as described above.
593
599
Unlike [ ` addTimer() ` ] ( #addtimer ) , this method will ensure the callback
594
600
will be invoked infinitely after the given interval or until you invoke
595
601
[ ` cancelTimer ` ] ( #canceltimer ) .
@@ -720,9 +726,10 @@ register a listener to be notified when a signal has been caught by this process
720
726
This is useful to catch user interrupt signals or shutdown signals from
721
727
tools like ` supervisor ` or ` systemd ` .
722
728
723
- The listener callback function MUST be able to accept a single parameter,
724
- the signal added by this method or you MAY use a function which
725
- has no parameters at all.
729
+ The second parameter MUST be a listener callback function that accepts
730
+ the signal as its only parameter.
731
+ If you don't use the signal inside your listener callback function
732
+ you MAY use a function which has no parameters at all.
726
733
727
734
The listener callback function MUST NOT throw an ` Exception ` .
728
735
The return value of the listener callback function will be ignored and has
@@ -737,14 +744,14 @@ $loop->addSignal(SIGINT, function (int $signal) {
737
744
738
745
See also [ example #4 ] ( examples ) .
739
746
740
- Signaling is only available on Unix-like platform , Windows isn't
747
+ Signaling is only available on Unix-like platforms , Windows isn't
741
748
supported due to operating system limitations.
742
749
This method may throw a ` BadMethodCallException ` if signals aren't
743
750
supported on this platform, for example when required extensions are
744
751
missing.
745
752
746
753
** Note: A listener can only be added once to the same signal, any
747
- attempts to add it more then once will be ignored.**
754
+ attempts to add it more than once will be ignored.**
748
755
749
756
#### removeSignal()
750
757
@@ -775,9 +782,10 @@ react to this event with a single listener and then dispatch from this
775
782
listener. This method MAY throw an ` Exception ` if the given resource type
776
783
is not supported by this loop implementation.
777
784
778
- The listener callback function MUST be able to accept a single parameter,
779
- the stream resource added by this method or you MAY use a function which
780
- has no parameters at all.
785
+ The second parameter MUST be a listener callback function that accepts
786
+ the stream resource as its only parameter.
787
+ If you don't use the stream resource inside your listener callback function
788
+ you MAY use a function which has no parameters at all.
781
789
782
790
The listener callback function MUST NOT throw an ` Exception ` .
783
791
The return value of the listener callback function will be ignored and has
@@ -827,9 +835,10 @@ react to this event with a single listener and then dispatch from this
827
835
listener. This method MAY throw an ` Exception ` if the given resource type
828
836
is not supported by this loop implementation.
829
837
830
- The listener callback function MUST be able to accept a single parameter,
831
- the stream resource added by this method or you MAY use a function which
832
- has no parameters at all.
838
+ The second parameter MUST be a listener callback function that accepts
839
+ the stream resource as its only parameter.
840
+ If you don't use the stream resource inside your listener callback function
841
+ you MAY use a function which has no parameters at all.
833
842
834
843
The listener callback function MUST NOT throw an ` Exception ` .
835
844
The return value of the listener callback function will be ignored and has
@@ -871,7 +880,7 @@ to remove a stream that was never added or is invalid has no effect.
871
880
872
881
## Install
873
882
874
- The recommended way to install this library is [ through Composer] ( https://getcomposer.org ) .
883
+ The recommended way to install this library is [ through Composer] ( https://getcomposer.org/ ) .
875
884
[ New to Composer?] ( https://getcomposer.org/doc/00-intro.md )
876
885
877
886
This project follows [ SemVer] ( https://semver.org/ ) .
@@ -894,7 +903,7 @@ See also [event loop implementations](#loop-implementations) for more details.
894
903
## Tests
895
904
896
905
To run the test suite, you first need to clone this repo and then install all
897
- dependencies [ through Composer] ( https://getcomposer.org ) :
906
+ dependencies [ through Composer] ( https://getcomposer.org/ ) :
898
907
899
908
``` bash
900
909
$ composer install
@@ -903,7 +912,7 @@ $ composer install
903
912
To run the test suite, go to the project root and run:
904
913
905
914
``` bash
906
- $ php vendor/bin/phpunit
915
+ $ vendor/bin/phpunit
907
916
```
908
917
909
918
## License
0 commit comments