Skip to content

Commit 1cf5df8

Browse files
committed
Merge remote-tracking branch 'github/pr/13'
From DaveRandom:fix/docblocks.
2 parents 8d12457 + a496c63 commit 1cf5df8

5 files changed

Lines changed: 97 additions & 17 deletions

File tree

src/ExtEventLoop.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ private function scheduleTimer(TimerInterface $timer)
236236
/**
237237
* Create a new ext-event Event object, or update the existing one.
238238
*
239-
* @param stream $stream
240-
* @param integer $flag Event::READ or Event::WRITE
239+
* @param resource $stream
240+
* @param integer $flag Event::READ or Event::WRITE
241241
*/
242242
private function subscribeStreamEvent($stream, $flag)
243243
{
@@ -263,8 +263,8 @@ private function subscribeStreamEvent($stream, $flag)
263263
* Update the ext-event Event object for this stream to stop listening to
264264
* the given event type, or remove it entirely if it's no longer needed.
265265
*
266-
* @param stream $stream
267-
* @param integer $flag Event::READ or Event::WRITE
266+
* @param resource $stream
267+
* @param integer $flag Event::READ or Event::WRITE
268268
*/
269269
private function unsubscribeStreamEvent($stream, $flag)
270270
{

src/LibEventLoop.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ private function scheduleTimer(TimerInterface $timer)
237237
/**
238238
* Create a new ext-libevent event resource, or update the existing one.
239239
*
240-
* @param stream $stream
241-
* @param integer $flag EV_READ or EV_WRITE
240+
* @param resource $stream
241+
* @param integer $flag EV_READ or EV_WRITE
242242
*/
243243
private function subscribeStreamEvent($stream, $flag)
244244
{
@@ -267,8 +267,8 @@ private function subscribeStreamEvent($stream, $flag)
267267
* Update the ext-libevent event resource for this stream to stop listening to
268268
* the given event type, or remove it entirely if it's no longer needed.
269269
*
270-
* @param stream $stream
271-
* @param integer $flag EV_READ or EV_WRITE
270+
* @param resource $stream
271+
* @param integer $flag EV_READ or EV_WRITE
272272
*/
273273
private function unsubscribeStreamEvent($stream, $flag)
274274
{

src/LoopInterface.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,37 @@ interface LoopInterface
99
/**
1010
* Register a listener to be notified when a stream is ready to read.
1111
*
12-
* @param stream $stream The PHP stream resource to check.
12+
* @param resource $stream The PHP stream resource to check.
1313
* @param callable $listener Invoked when the stream is ready.
1414
*/
1515
public function addReadStream($stream, callable $listener);
1616

1717
/**
1818
* Register a listener to be notified when a stream is ready to write.
1919
*
20-
* @param stream $stream The PHP stream resource to check.
20+
* @param resource $stream The PHP stream resource to check.
2121
* @param callable $listener Invoked when the stream is ready.
2222
*/
2323
public function addWriteStream($stream, callable $listener);
2424

2525
/**
2626
* Remove the read event listener for the given stream.
2727
*
28-
* @param stream $stream The PHP stream resource.
28+
* @param resource $stream The PHP stream resource.
2929
*/
3030
public function removeReadStream($stream);
3131

3232
/**
3333
* Remove the write event listener for the given stream.
3434
*
35-
* @param stream $stream The PHP stream resource.
35+
* @param resource $stream The PHP stream resource.
3636
*/
3737
public function removeWriteStream($stream);
3838

3939
/**
4040
* Remove all listeners for the given stream.
4141
*
42-
* @param stream $stream The PHP stream resource.
42+
* @param resource $stream The PHP stream resource.
4343
*/
4444
public function removeStream($stream);
4545

@@ -49,8 +49,8 @@ public function removeStream($stream);
4949
* The execution order of timers scheduled to execute at the same time is
5050
* not guaranteed.
5151
*
52-
* @param numeric $interval The number of seconds to wait before execution.
53-
* @param callable $callback The callback to invoke.
52+
* @param int|float $interval The number of seconds to wait before execution.
53+
* @param callable $callback The callback to invoke.
5454
*
5555
* @return TimerInterface
5656
*/
@@ -62,8 +62,8 @@ public function addTimer($interval, callable $callback);
6262
* The execution order of timers scheduled to execute at the same time is
6363
* not guaranteed.
6464
*
65-
* @param numeric $interval The number of seconds to wait before execution.
66-
* @param callable $callback The callback to invoke.
65+
* @param int|float $interval The number of seconds to wait before execution.
66+
* @param callable $callback The callback to invoke.
6767
*
6868
* @return TimerInterface
6969
*/

src/Timer/Timer.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ class Timer implements TimerInterface
1414
protected $periodic;
1515
protected $data;
1616

17+
/**
18+
* Constructor initializes the fields of the Timer
19+
*
20+
* @param LoopInterface $loop The loop with which this timer is associated
21+
* @param float $interval The interval after which this timer will execute, in seconds
22+
* @param callable $callback The callback that will be executed when this timer elapses
23+
* @param bool $periodic Whether the time is periodic
24+
* @param mixed $data Arbitrary data associated with timer
25+
*/
1726
public function __construct(LoopInterface $loop, $interval, callable $callback, $periodic = false, $data = null)
1827
{
1928
if ($interval < self::MIN_INTERVAL) {
@@ -27,41 +36,65 @@ public function __construct(LoopInterface $loop, $interval, callable $callback,
2736
$this->data = null;
2837
}
2938

39+
/**
40+
* {@inheritdoc}
41+
*/
3042
public function getLoop()
3143
{
3244
return $this->loop;
3345
}
3446

47+
/**
48+
* {@inheritdoc}
49+
*/
3550
public function getInterval()
3651
{
3752
return $this->interval;
3853
}
3954

55+
/**
56+
* {@inheritdoc}
57+
*/
4058
public function getCallback()
4159
{
4260
return $this->callback;
4361
}
4462

63+
/**
64+
* {@inheritdoc}
65+
*/
4566
public function setData($data)
4667
{
4768
$this->data = $data;
4869
}
4970

71+
/**
72+
* {@inheritdoc}
73+
*/
5074
public function getData()
5175
{
5276
return $this->data;
5377
}
5478

79+
/**
80+
* {@inheritdoc}
81+
*/
5582
public function isPeriodic()
5683
{
5784
return $this->periodic;
5885
}
5986

87+
/**
88+
* {@inheritdoc}
89+
*/
6090
public function isActive()
6191
{
6292
return $this->loop->isTimerActive($this);
6393
}
6494

95+
/**
96+
* {@inheritdoc}
97+
*/
6598
public function cancel()
6699
{
67100
$this->loop->cancelTimer($this);

src/Timer/TimerInterface.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,61 @@
22

33
namespace React\EventLoop\Timer;
44

5+
use React\EventLoop\LoopInterface;
6+
57
interface TimerInterface
68
{
9+
/**
10+
* Get the loop with which this timer is associated
11+
12+
* @return LoopInterface
13+
*/
714
public function getLoop();
15+
16+
/**
17+
* Get the interval after which this timer will execute, in seconds
18+
*
19+
* @return float
20+
*/
821
public function getInterval();
22+
23+
/**
24+
* Get the callback that will be executed when this timer elapses
25+
*
26+
* @return callable
27+
*/
928
public function getCallback();
29+
30+
/**
31+
* Set arbitrary data associated with timer
32+
*
33+
* @param mixed $data
34+
*/
1035
public function setData($data);
36+
37+
/**
38+
* Get arbitrary data associated with timer
39+
*
40+
* @return mixed
41+
*/
1142
public function getData();
43+
44+
/**
45+
* Determine whether the time is periodic
46+
*
47+
* @return bool
48+
*/
1249
public function isPeriodic();
50+
51+
/**
52+
* Determine whether the time is active
53+
*
54+
* @return bool
55+
*/
1356
public function isActive();
57+
58+
/**
59+
* Cancel this timer
60+
*/
1461
public function cancel();
1562
}

0 commit comments

Comments
 (0)