Skip to content

Commit

Permalink
Fix line lengths, resolves #76 (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik authored and bwoebi committed Jul 15, 2016
1 parent e089d8e commit 8f38808
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 34 deletions.
35 changes: 19 additions & 16 deletions src/Loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ final class Loop
/**
* Set the factory to be used to create a default drivers.
*
* Setting a factory is only allowed as long as no loop is currently running.
* Passing null will reset the default driver and remove the factory.
* Setting a factory is only allowed as long as no loop is currently running. Passing null will reset the default
* driver and remove the factory.
*
* The factory will be invoked if none is passed to Loop::execute. A default driver will be created to support
* synchronous waits in traditional applications.
*
* @param DriverFactory|null $factory
* @param DriverFactory|null $factory New factory to replace the previous one.
*/
public static function setFactory(DriverFactory $factory = null)
{
Expand All @@ -42,13 +42,15 @@ public static function setFactory(DriverFactory $factory = null)
}

self::$factory = $factory;
self::$driver = null; // reset it here, it will be actually instantiated inside execute() or get()

// reset it here, it will be actually instantiated inside execute() or get()
self::$driver = null;
}

/**
* Execute a callback within the scope of an event loop driver.
*
* @param callable $callback The callback to execute
* @param callable $callback The callback to execute.
* @param Driver $driver The event loop driver. If null a new one is created from the set factory.
*
* @return void
Expand All @@ -72,7 +74,7 @@ public static function execute(callable $callback, Driver $driver = null)
/**
* Create a new driver if a factory is present, otherwise throw.
*
* @throws \LogicException if no factory is set or no driver returned from factory
* @throws \LogicException If no factory is set or no driver returned from factory.
*/
private static function createDriver()
{
Expand Down Expand Up @@ -100,6 +102,7 @@ public static function get()
if (self::$driver) {
return self::$driver;
}

return self::$driver = self::createDriver();
}

Expand Down Expand Up @@ -232,7 +235,7 @@ public static function enable($watcherId)
*
* @return void
*
* @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
* @throws InvalidWatcherException If the watcher identifier is invalid.
*/
public static function disable($watcherId)
{
Expand All @@ -241,8 +244,8 @@ public static function disable($watcherId)
}

/**
* Cancel a watcher. This will detatch the event loop from all resources that are associated to the watcher. After this
* operation the watcher is permanently invalid.
* Cancel a watcher. This will detatch the event loop from all resources that are associated to the watcher. After
* this operation the watcher is permanently invalid.
*
* @param string $watcherId The watcher identifier.
*
Expand All @@ -264,7 +267,7 @@ public static function cancel($watcherId)
*
* @return void
*
* @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
* @throws InvalidWatcherException If the watcher identifier is invalid.
*/
public static function reference($watcherId)
{
Expand All @@ -282,7 +285,7 @@ public static function reference($watcherId)
*
* @return void
*
* @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
* @throws InvalidWatcherException If the watcher identifier is invalid.
*/
public static function unreference($watcherId)
{
Expand Down Expand Up @@ -328,7 +331,8 @@ public static function fetchState($key)
*
* Subsequent calls to this method will overwrite the previous handler.
*
* @param callable(\Throwable|\Exception $error)|null $callback The callback to execute; null will clear the current handler.
* @param callable(\Throwable|\Exception $error)|null $callback The callback to execute; null will clear the current
* handler.
*
* @return void
*/
Expand All @@ -341,8 +345,7 @@ public static function setErrorHandler(callable $callback = null)
/**
* Retrieve an associative array of information about the event loop driver.
*
* The returned array MUST contain the following data describing the driver's
* currently registered watchers:
* The returned array MUST contain the following data describing the driver's currently registered watchers:
*
* [
* "defer" => ["enabled" => int, "disabled" => int],
Expand All @@ -354,8 +357,8 @@ public static function setErrorHandler(callable $callback = null)
* "watchers" => ["referenced" => int, "unreferenced" => int],
* ];
*
* Implementations MAY optionally add more information in the array but
* at minimum the above key => value format MUST always be provided.
* Implementations MAY optionally add more information in the array but at minimum the above key => value format
* MUST always be provided.
*
* @return array
*/
Expand Down
32 changes: 16 additions & 16 deletions src/Loop/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,21 @@ public function onWritable($stream, callable $callback, $data = null);
*
* @return string An unique identifier that can be used to cancel, enable or disable the watcher.
*
* @throws UnsupportedFeatureException Thrown if signal handling is not supported.
* @throws UnsupportedFeatureException If signal handling is not supported.
*/
public function onSignal($signo, callable $callback, $data = null);

/**
* Enable a watcher.
*
*
* Watchers (enabling or new watchers) MUST immediately be marked as enabled, but only be activated (i.e. callbacks
* can be called) right before the next tick. Callbacks of watchers MUST not be called in the tick they were enabled.
*
* @param string $watcherId The watcher identifier.
*
* @return void
*
* @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
* @throws InvalidWatcherException If the watcher identifier is invalid.
*/
public function enable($watcherId);

Expand All @@ -131,14 +131,14 @@ public function enable($watcherId);
*
* @return void
*
* @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
* @throws InvalidWatcherException If the watcher identifier is invalid.
*/
public function disable($watcherId);

/**
* Cancel a watcher. This will detatch the event loop from all resources that are associated to the watcher. After this
* operation the watcher is permanently invalid. Calling this function MUST never fail, even when passed an invalid
* watcher.
* Cancel a watcher. This will detatch the event loop from all resources that are associated to the watcher. After
* this operation the watcher is permanently invalid. Calling this function MUST never fail, even when passed an
* invalid watcher.
*
* @param string $watcherId The watcher identifier.
*
Expand All @@ -156,7 +156,7 @@ public function cancel($watcherId);
*
* @return void
*
* @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
* @throws InvalidWatcherException If the watcher identifier is invalid.
*/
public function reference($watcherId);

Expand All @@ -170,10 +170,10 @@ public function reference($watcherId);
*
* @return void
*
* @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
* @throws InvalidWatcherException If the watcher identifier is invalid.
*/
public function unreference($watcherId);

/**
* Stores information in the loop bound registry. This can be used to store loop bound information. Stored
* information is package private. Packages MUST NOT retrieve the stored state of other packages.
Expand All @@ -193,7 +193,7 @@ public function storeState($key, $value);
*
* Therefore packages SHOULD use the following prefix to keys: `vendor.package.`
*
* @param string $key namespaced storage key
* @param string $key Namespaced storage key.
*
* @return mixed previously stored value or null if it doesn't exist
*/
Expand All @@ -214,8 +214,7 @@ public function setErrorHandler(callable $callback = null);
/**
* Retrieve an associative array of information about the event loop driver.
*
* The returned array MUST contain the following data describing the driver's
* currently registered watchers:
* The returned array MUST contain the following data describing the driver's currently registered watchers:
*
* [
* "defer" => ["enabled" => int, "disabled" => int],
Expand All @@ -227,8 +226,8 @@ public function setErrorHandler(callable $callback = null);
* "watchers" => ["referenced" => int, "unreferenced" => int],
* ];
*
* Implementations MAY optionally add more information in the array but
* at minimum the above key => value format MUST always be provided.
* Implementations MAY optionally add more information in the array but at minimum the above key => value format
* MUST always be provided.
*
* @return array
*/
Expand All @@ -239,7 +238,8 @@ 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.
* 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.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Loop/InvalidWatcherException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Interop\Async\Loop;

/**
* MUST be thrown if any operation (except cancel()) is attempted with an invalid watcher identifier.
* [Invalid watcher identifier: any identifier not yet emitted by the driver or cancelled by the user]
* MUST be thrown if any operation (except cancel()) is attempted with an invalid watcher identifier. An invalid watcher
* identifier is any identifier that is not yet emitted by the driver or cancelled by the user.
*/
class InvalidWatcherException extends \LogicException
{
Expand Down

0 comments on commit 8f38808

Please sign in to comment.