Skip to content

Commit

Permalink
Add Loop::getHandle
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kelunik committed Dec 23, 2016
1 parent 21683ee commit ba719fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/Loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,19 @@ public static function getInfo()
return $driver->getInfo();
}

/**
* 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.
*/
Expand Down
3 changes: 0 additions & 3 deletions src/Loop/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,6 @@ abstract public function getInfo();
*
* 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();
Expand Down

0 comments on commit ba719fa

Please sign in to comment.