From e360c730904e48581447d8fe11da9148c97c20e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Fri, 10 Nov 2017 19:23:57 +0100 Subject: [PATCH 1/2] Documentation for Factory --- README.md | 17 +++++++++++++++++ src/Factory.php | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/README.md b/README.md index 9795f2f9..03a93a12 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,23 @@ $loop->run(); purposes. 3. The loop is run with a single `$loop->run()` call at the end of the program. +## Factory + +The `Factory` class exists as a convenient way to pick the best available +[loop implementation)(#loop-implementation). + +The `create(): LoopInterface` method can be used to create a new loop +instance: + +```php +$loop = React\EventLoop\Factory::create(); +``` + +This method always returns an instance implementing `LoopInterface`, +the actual loop implementation is an implementation detail. + +This method should usually only be called once at the beginning of the program. + ## Loop implementations In addition to the interface there are the following implementations provided: diff --git a/src/Factory.php b/src/Factory.php index 271c2654..7c87180c 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -2,8 +2,25 @@ namespace React\EventLoop; +/** + * The `Factory` class exists as a convenient way to pick the best available loop implementation. + */ class Factory { + /** + * Creates a new loop instance + * + * ```php + * $loop = React\EventLoop\Factory::create(); + * ``` + * + * This method always returns an instance implementing `LoopInterface`, + * the actual loop implementation is an implementation detail. + * + * This method should usually only be called once at the beginning of the program. + * + * @return LoopInterface + */ public static function create() { // @codeCoverageIgnoreStart From f4e932250aec05207db7b24e1986aef54942edf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Fri, 10 Nov 2017 19:34:30 +0100 Subject: [PATCH 2/2] Remove unneeded "{@inheritdoc}" annotation --- src/ExtEventLoop.php | 39 --------------------------------------- src/LibEvLoop.php | 39 --------------------------------------- src/LibEventLoop.php | 40 ---------------------------------------- src/StreamSelectLoop.php | 39 --------------------------------------- src/Timer/Timer.php | 9 --------- 5 files changed, 166 deletions(-) diff --git a/src/ExtEventLoop.php b/src/ExtEventLoop.php index f192025e..b1cb3e74 100644 --- a/src/ExtEventLoop.php +++ b/src/ExtEventLoop.php @@ -59,9 +59,6 @@ function ($signal) { $this->createStreamCallback(); } - /** - * {@inheritdoc} - */ public function addReadStream($stream, callable $listener) { $key = (int) $stream; @@ -72,9 +69,6 @@ public function addReadStream($stream, callable $listener) } } - /** - * {@inheritdoc} - */ public function addWriteStream($stream, callable $listener) { $key = (int) $stream; @@ -85,9 +79,6 @@ public function addWriteStream($stream, callable $listener) } } - /** - * {@inheritdoc} - */ public function removeReadStream($stream) { $key = (int) $stream; @@ -98,9 +89,6 @@ public function removeReadStream($stream) } } - /** - * {@inheritdoc} - */ public function removeWriteStream($stream) { $key = (int) $stream; @@ -127,9 +115,6 @@ private function removeStream($stream) } } - /** - * {@inheritdoc} - */ public function addTimer($interval, callable $callback) { $timer = new Timer($interval, $callback, false); @@ -139,9 +124,6 @@ public function addTimer($interval, callable $callback) return $timer; } - /** - * {@inheritdoc} - */ public function addPeriodicTimer($interval, callable $callback) { $timer = new Timer($interval, $callback, true); @@ -151,9 +133,6 @@ public function addPeriodicTimer($interval, callable $callback) return $timer; } - /** - * {@inheritdoc} - */ public function cancelTimer(TimerInterface $timer) { if ($this->isTimerActive($timer)) { @@ -162,41 +141,26 @@ public function cancelTimer(TimerInterface $timer) } } - /** - * {@inheritdoc} - */ public function isTimerActive(TimerInterface $timer) { return $this->timerEvents->contains($timer); } - /** - * {@inheritdoc} - */ public function futureTick(callable $listener) { $this->futureTickQueue->add($listener); } - /** - * {@inheritdoc} - */ public function addSignal($signal, callable $listener) { $this->signals->add($signal, $listener); } - /** - * {@inheritdoc} - */ public function removeSignal($signal, callable $listener) { $this->signals->remove($signal, $listener); } - /** - * {@inheritdoc} - */ public function run() { $this->running = true; @@ -215,9 +179,6 @@ public function run() } } - /** - * {@inheritdoc} - */ public function stop() { $this->running = false; diff --git a/src/LibEvLoop.php b/src/LibEvLoop.php index 7c9b57be..638d9fa9 100644 --- a/src/LibEvLoop.php +++ b/src/LibEvLoop.php @@ -54,9 +54,6 @@ function ($signal) { ); } - /** - * {@inheritdoc} - */ public function addReadStream($stream, callable $listener) { if (isset($this->readEvents[(int) $stream])) { @@ -73,9 +70,6 @@ public function addReadStream($stream, callable $listener) $this->readEvents[(int) $stream] = $event; } - /** - * {@inheritdoc} - */ public function addWriteStream($stream, callable $listener) { if (isset($this->writeEvents[(int) $stream])) { @@ -92,9 +86,6 @@ public function addWriteStream($stream, callable $listener) $this->writeEvents[(int) $stream] = $event; } - /** - * {@inheritdoc} - */ public function removeReadStream($stream) { $key = (int) $stream; @@ -105,9 +96,6 @@ public function removeReadStream($stream) } } - /** - * {@inheritdoc} - */ public function removeWriteStream($stream) { $key = (int) $stream; @@ -118,9 +106,6 @@ public function removeWriteStream($stream) } } - /** - * {@inheritdoc} - */ public function addTimer($interval, callable $callback) { $timer = new Timer( $interval, $callback, false); @@ -140,9 +125,6 @@ public function addTimer($interval, callable $callback) return $timer; } - /** - * {@inheritdoc} - */ public function addPeriodicTimer($interval, callable $callback) { $timer = new Timer($interval, $callback, true); @@ -158,9 +140,6 @@ public function addPeriodicTimer($interval, callable $callback) return $timer; } - /** - * {@inheritdoc} - */ public function cancelTimer(TimerInterface $timer) { if (isset($this->timerEvents[$timer])) { @@ -169,41 +148,26 @@ public function cancelTimer(TimerInterface $timer) } } - /** - * {@inheritdoc} - */ public function isTimerActive(TimerInterface $timer) { return $this->timerEvents->contains($timer); } - /** - * {@inheritdoc} - */ public function futureTick(callable $listener) { $this->futureTickQueue->add($listener); } - /** - * {@inheritdoc} - */ public function addSignal($signal, callable $listener) { $this->signals->add($signal, $listener); } - /** - * {@inheritdoc} - */ public function removeSignal($signal, callable $listener) { $this->signals->remove($signal, $listener); } - /** - * {@inheritdoc} - */ public function run() { $this->running = true; @@ -222,9 +186,6 @@ public function run() } } - /** - * {@inheritdoc} - */ public function stop() { $this->running = false; diff --git a/src/LibEventLoop.php b/src/LibEventLoop.php index fa35fa43..3b49e2e2 100644 --- a/src/LibEventLoop.php +++ b/src/LibEventLoop.php @@ -4,7 +4,6 @@ use Event; use EventBase; -use React\EventLoop\Signal\Pcntl; use React\EventLoop\Tick\FutureTickQueue; use React\EventLoop\Timer\Timer; use React\EventLoop\Timer\TimerInterface; @@ -64,9 +63,6 @@ function ($signal) { $this->createStreamCallback(); } - /** - * {@inheritdoc} - */ public function addReadStream($stream, callable $listener) { $key = (int) $stream; @@ -77,9 +73,6 @@ public function addReadStream($stream, callable $listener) } } - /** - * {@inheritdoc} - */ public function addWriteStream($stream, callable $listener) { $key = (int) $stream; @@ -90,9 +83,6 @@ public function addWriteStream($stream, callable $listener) } } - /** - * {@inheritdoc} - */ public function removeReadStream($stream) { $key = (int) $stream; @@ -103,9 +93,6 @@ public function removeReadStream($stream) } } - /** - * {@inheritdoc} - */ public function removeWriteStream($stream) { $key = (int) $stream; @@ -135,9 +122,6 @@ private function removeStream($stream) } } - /** - * {@inheritdoc} - */ public function addTimer($interval, callable $callback) { $timer = new Timer($interval, $callback, false); @@ -147,9 +131,6 @@ public function addTimer($interval, callable $callback) return $timer; } - /** - * {@inheritdoc} - */ public function addPeriodicTimer($interval, callable $callback) { $timer = new Timer($interval, $callback, true); @@ -159,9 +140,6 @@ public function addPeriodicTimer($interval, callable $callback) return $timer; } - /** - * {@inheritdoc} - */ public function cancelTimer(TimerInterface $timer) { if ($this->isTimerActive($timer)) { @@ -174,41 +152,26 @@ public function cancelTimer(TimerInterface $timer) } } - /** - * {@inheritdoc} - */ public function isTimerActive(TimerInterface $timer) { return $this->timerEvents->contains($timer); } - /** - * {@inheritdoc} - */ public function futureTick(callable $listener) { $this->futureTickQueue->add($listener); } - /** - * {@inheritdoc} - */ public function addSignal($signal, callable $listener) { $this->signals->add($signal, $listener); } - /** - * {@inheritdoc} - */ public function removeSignal($signal, callable $listener) { $this->signals->remove($signal, $listener); } - /** - * {@inheritdoc} - */ public function run() { $this->running = true; @@ -227,9 +190,6 @@ public function run() } } - /** - * {@inheritdoc} - */ public function stop() { $this->running = false; diff --git a/src/StreamSelectLoop.php b/src/StreamSelectLoop.php index 1d151829..4273f24e 100644 --- a/src/StreamSelectLoop.php +++ b/src/StreamSelectLoop.php @@ -50,9 +50,6 @@ function ($signal) { ); } - /** - * {@inheritdoc} - */ public function addReadStream($stream, callable $listener) { $key = (int) $stream; @@ -63,9 +60,6 @@ public function addReadStream($stream, callable $listener) } } - /** - * {@inheritdoc} - */ public function addWriteStream($stream, callable $listener) { $key = (int) $stream; @@ -76,9 +70,6 @@ public function addWriteStream($stream, callable $listener) } } - /** - * {@inheritdoc} - */ public function removeReadStream($stream) { $key = (int) $stream; @@ -89,9 +80,6 @@ public function removeReadStream($stream) ); } - /** - * {@inheritdoc} - */ public function removeWriteStream($stream) { $key = (int) $stream; @@ -102,9 +90,6 @@ public function removeWriteStream($stream) ); } - /** - * {@inheritdoc} - */ public function addTimer($interval, callable $callback) { $timer = new Timer($interval, $callback, false); @@ -114,9 +99,6 @@ public function addTimer($interval, callable $callback) return $timer; } - /** - * {@inheritdoc} - */ public function addPeriodicTimer($interval, callable $callback) { $timer = new Timer($interval, $callback, true); @@ -126,33 +108,21 @@ public function addPeriodicTimer($interval, callable $callback) return $timer; } - /** - * {@inheritdoc} - */ public function cancelTimer(TimerInterface $timer) { $this->timers->cancel($timer); } - /** - * {@inheritdoc} - */ public function isTimerActive(TimerInterface $timer) { return $this->timers->contains($timer); } - /** - * {@inheritdoc} - */ public function futureTick(callable $listener) { $this->futureTickQueue->add($listener); } - /** - * {@inheritdoc} - */ public function addSignal($signal, callable $listener) { if ($this->pcntl === false) { @@ -162,17 +132,11 @@ public function addSignal($signal, callable $listener) $this->signals->add($signal, $listener); } - /** - * {@inheritdoc} - */ public function removeSignal($signal, callable $listener) { $this->signals->remove($signal, $listener); } - /** - * {@inheritdoc} - */ public function run() { $this->running = true; @@ -212,9 +176,6 @@ public function run() } } - /** - * {@inheritdoc} - */ public function stop() { $this->running = false; diff --git a/src/Timer/Timer.php b/src/Timer/Timer.php index 433f5be2..8a8926c6 100644 --- a/src/Timer/Timer.php +++ b/src/Timer/Timer.php @@ -36,25 +36,16 @@ public function __construct($interval, callable $callback, $periodic = false) $this->periodic = (bool) $periodic; } - /** - * {@inheritdoc} - */ public function getInterval() { return $this->interval; } - /** - * {@inheritdoc} - */ public function getCallback() { return $this->callback; } - /** - * {@inheritdoc} - */ public function isPeriodic() { return $this->periodic; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy