Skip to content

Commit

Permalink
Add native types to public API
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonFrings committed Jul 8, 2024
1 parent f2fb5a2 commit a695ad1
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 79 deletions.
24 changes: 12 additions & 12 deletions src/ExtEvLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct()
$this->signals = new SignalsHandler();
}

public function addReadStream($stream, $listener)
public function addReadStream($stream, callable $listener): void
{
$key = (int)$stream;

Expand All @@ -97,7 +97,7 @@ private function getStreamListenerClosure($stream, $listener)
};
}

public function addWriteStream($stream, $listener)
public function addWriteStream($stream, callable $listener): void
{
$key = (int)$stream;

Expand All @@ -110,7 +110,7 @@ public function addWriteStream($stream, $listener)
$this->writeStreams[$key] = $event;
}

public function removeReadStream($stream)
public function removeReadStream($stream): void
{
$key = (int)$stream;

Expand All @@ -122,7 +122,7 @@ public function removeReadStream($stream)
unset($this->readStreams[$key]);
}

public function removeWriteStream($stream)
public function removeWriteStream($stream): void
{
$key = (int)$stream;

Expand All @@ -134,7 +134,7 @@ public function removeWriteStream($stream)
unset($this->writeStreams[$key]);
}

public function addTimer($interval, $callback)
public function addTimer(float $interval, callable $callback): TimerInterface
{
$timer = new Timer($interval, $callback, false);

Expand All @@ -152,7 +152,7 @@ public function addTimer($interval, $callback)
return $timer;
}

public function addPeriodicTimer($interval, $callback)
public function addPeriodicTimer(float $interval, callable $callback): TimerInterface
{
$timer = new Timer($interval, $callback, true);

Expand All @@ -166,7 +166,7 @@ public function addPeriodicTimer($interval, $callback)
return $timer;
}

public function cancelTimer(TimerInterface $timer)
public function cancelTimer(TimerInterface $timer): void
{
if (!isset($this->timers[$timer])) {
return;
Expand All @@ -177,12 +177,12 @@ public function cancelTimer(TimerInterface $timer)
$this->timers->detach($timer);
}

public function futureTick($listener)
public function futureTick(callable $listener): void
{
$this->futureTickQueue->add($listener);
}

public function run()
public function run(): void
{
$this->running = true;

Expand All @@ -207,7 +207,7 @@ public function run()
}
}

public function stop()
public function stop(): void
{
$this->running = false;
}
Expand All @@ -228,7 +228,7 @@ public function __destruct()
}
}

public function addSignal($signal, $listener)
public function addSignal(int $signal, callable $listener): void
{
$this->signals->add($signal, $listener);

Expand All @@ -239,7 +239,7 @@ public function addSignal($signal, $listener)
}
}

public function removeSignal($signal, $listener)
public function removeSignal(int $signal, callable $listener): void
{
$this->signals->remove($signal, $listener);

Expand Down
24 changes: 12 additions & 12 deletions src/ExtEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __destruct()
$this->writeEvents = [];
}

public function addReadStream($stream, $listener)
public function addReadStream($stream, callable $listener): void
{
$key = (int) $stream;
if (isset($this->readListeners[$key])) {
Expand All @@ -88,7 +88,7 @@ public function addReadStream($stream, $listener)
$this->readRefs[$key] = $stream;
}

public function addWriteStream($stream, $listener)
public function addWriteStream($stream, callable $listener): void
{
$key = (int) $stream;
if (isset($this->writeListeners[$key])) {
Expand All @@ -105,7 +105,7 @@ public function addWriteStream($stream, $listener)
$this->writeRefs[$key] = $stream;
}

public function removeReadStream($stream)
public function removeReadStream($stream): void
{
$key = (int) $stream;

Expand All @@ -119,7 +119,7 @@ public function removeReadStream($stream)
}
}

public function removeWriteStream($stream)
public function removeWriteStream($stream): void
{
$key = (int) $stream;

Expand All @@ -133,7 +133,7 @@ public function removeWriteStream($stream)
}
}

public function addTimer($interval, $callback)
public function addTimer(float $interval, callable $callback): TimerInterface
{
$timer = new Timer($interval, $callback, false);

Expand All @@ -142,7 +142,7 @@ public function addTimer($interval, $callback)
return $timer;
}

public function addPeriodicTimer($interval, $callback)
public function addPeriodicTimer(float $interval, callable $callback): TimerInterface
{
$timer = new Timer($interval, $callback, true);

Expand All @@ -151,20 +151,20 @@ public function addPeriodicTimer($interval, $callback)
return $timer;
}

public function cancelTimer(TimerInterface $timer)
public function cancelTimer(TimerInterface $timer): void
{
if ($this->timerEvents->contains($timer)) {
$this->timerEvents[$timer]->free();
$this->timerEvents->detach($timer);
}
}

public function futureTick($listener)
public function futureTick(callable $listener): void
{
$this->futureTickQueue->add($listener);
}

public function addSignal($signal, $listener)
public function addSignal(int $signal, callable $listener): void
{
$this->signals->add($signal, $listener);

Expand All @@ -174,7 +174,7 @@ public function addSignal($signal, $listener)
}
}

public function removeSignal($signal, $listener)
public function removeSignal(int $signal, callable $listener): void
{
$this->signals->remove($signal, $listener);

Expand All @@ -184,7 +184,7 @@ public function removeSignal($signal, $listener)
}
}

public function run()
public function run(): void
{
$this->running = true;

Expand All @@ -202,7 +202,7 @@ public function run()
}
}

public function stop()
public function stop(): void
{
$this->running = false;
}
Expand Down
24 changes: 12 additions & 12 deletions src/ExtUvLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function getUvLoop()
/**
* {@inheritdoc}
*/
public function addReadStream($stream, $listener)
public function addReadStream($stream, callable $listener): void
{
if (isset($this->readStreams[(int) $stream])) {
return;
Expand All @@ -71,7 +71,7 @@ public function addReadStream($stream, $listener)
/**
* {@inheritdoc}
*/
public function addWriteStream($stream, $listener)
public function addWriteStream($stream, callable $listener): void
{
if (isset($this->writeStreams[(int) $stream])) {
return;
Expand All @@ -84,7 +84,7 @@ public function addWriteStream($stream, $listener)
/**
* {@inheritdoc}
*/
public function removeReadStream($stream)
public function removeReadStream($stream): void
{
if (!isset($this->streamEvents[(int) $stream])) {
return;
Expand All @@ -97,7 +97,7 @@ public function removeReadStream($stream)
/**
* {@inheritdoc}
*/
public function removeWriteStream($stream)
public function removeWriteStream($stream): void
{
if (!isset($this->streamEvents[(int) $stream])) {
return;
Expand All @@ -110,7 +110,7 @@ public function removeWriteStream($stream)
/**
* {@inheritdoc}
*/
public function addTimer($interval, $callback)
public function addTimer(float $interval, callable $callback): TimerInterface
{
$timer = new Timer($interval, $callback, false);

Expand All @@ -137,7 +137,7 @@ public function addTimer($interval, $callback)
/**
* {@inheritdoc}
*/
public function addPeriodicTimer($interval, $callback)
public function addPeriodicTimer(float $interval, callable $callback): TimerInterface
{
$timer = new Timer($interval, $callback, true);

Expand All @@ -161,7 +161,7 @@ public function addPeriodicTimer($interval, $callback)
/**
* {@inheritdoc}
*/
public function cancelTimer(TimerInterface $timer)
public function cancelTimer(TimerInterface $timer): void
{
if (isset($this->timers[$timer])) {
@\uv_timer_stop($this->timers[$timer]);
Expand All @@ -172,12 +172,12 @@ public function cancelTimer(TimerInterface $timer)
/**
* {@inheritdoc}
*/
public function futureTick($listener)
public function futureTick(callable $listener): void
{
$this->futureTickQueue->add($listener);
}

public function addSignal($signal, $listener)
public function addSignal(int $signal, callable $listener): void
{
$this->signals->add($signal, $listener);

Expand All @@ -189,7 +189,7 @@ public function addSignal($signal, $listener)
}
}

public function removeSignal($signal, $listener)
public function removeSignal(int $signal, callable $listener): void
{
$this->signals->remove($signal, $listener);

Expand All @@ -202,7 +202,7 @@ public function removeSignal($signal, $listener)
/**
* {@inheritdoc}
*/
public function run()
public function run(): void
{
$this->running = true;

Expand Down Expand Up @@ -233,7 +233,7 @@ public function run()
/**
* {@inheritdoc}
*/
public function stop()
public function stop(): void
{
$this->running = false;
}
Expand Down
Loading

0 comments on commit a695ad1

Please sign in to comment.