From 6483a64b86a0927ea36a4fdebf9026f8a14d68e7 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Fri, 23 Dec 2016 11:02:58 +0100 Subject: [PATCH] Add Loop::getHandle Previously we advised to use Loop::get()->getHandle(), because it's a method only required by very few components, namely the filesystem libraries, which need the underlying handle to operate. We argued that we get a smaller autocomplete list that way. I think consistency is more important. --- src/Loop.php | 13 +++++++++++++ src/Loop/Driver.php | 3 --- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Loop.php b/src/Loop.php index 8c4fb1a..ab58af5 100644 --- a/src/Loop.php +++ b/src/Loop.php @@ -422,6 +422,19 @@ public static function info() return $driver->info(); } + /** + * Get the underlying loop handle. + * + * Example: the `uv_loop` resource for `libuv` or the `EvLoop` object for `libev` or `null` for a native driver. + * + * @return null|object|resource The loop handle the event loop operates on. `null` if there is none. + */ + public static function getHandle() + { + $driver = self::$driver ?: self::get(); + return $driver->getHandle(); + } + /** * Disable construction as this is a static class. */ diff --git a/src/Loop/Driver.php b/src/Loop/Driver.php index 5aa41e1..2dd6127 100644 --- a/src/Loop/Driver.php +++ b/src/Loop/Driver.php @@ -277,9 +277,6 @@ abstract public function info(); * * Example: the `uv_loop` resource for `libuv` or the `EvLoop` object for `libev` or `null` for a native driver. * - * Note: This function is *not* exposed in the `Loop` class. Users shall access it directly on the respective loop - * instance. - * * @return null|object|resource The loop handle the event loop operates on. `null` if there is none. */ abstract public function getHandle();