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