aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/event
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-10 14:18:18 +0100
committerMario <mario@mariovavti.com>2019-11-10 14:18:18 +0100
commite1b923ab7d9070631b9bcf24fe1c42678f827169 (patch)
tree402fc0be56a0000701d969697ba1f271a66b8413 /vendor/sabre/event
parentbed9876d68ac72a27f3c05fa3ed5c4ccad39b72e (diff)
parent580c3f4ffe9608d2beb56d418c68b3b112420e76 (diff)
downloadvolse-hubzilla-e1b923ab7d9070631b9bcf24fe1c42678f827169.tar.gz
volse-hubzilla-e1b923ab7d9070631b9bcf24fe1c42678f827169.tar.bz2
volse-hubzilla-e1b923ab7d9070631b9bcf24fe1c42678f827169.zip
Merge branch 'cherry-pick-6685381f' into 'dev'
another bulk of composer updates See merge request hubzilla/core!1781
Diffstat (limited to 'vendor/sabre/event')
-rw-r--r--vendor/sabre/event/.gitattributes2
-rw-r--r--vendor/sabre/event/.travis.yml11
-rw-r--r--vendor/sabre/event/CHANGELOG.md44
-rw-r--r--vendor/sabre/event/LICENSE2
-rw-r--r--vendor/sabre/event/README.md11
-rw-r--r--vendor/sabre/event/_config.yml1
-rw-r--r--vendor/sabre/event/composer.json11
-rw-r--r--vendor/sabre/event/lib/Emitter.php18
-rw-r--r--vendor/sabre/event/lib/EmitterInterface.php (renamed from vendor/sabre/event/lib/EventEmitterInterface.php)35
-rw-r--r--vendor/sabre/event/lib/EmitterTrait.php (renamed from vendor/sabre/event/lib/EventEmitterTrait.php)62
-rw-r--r--vendor/sabre/event/lib/EventEmitter.php13
-rw-r--r--vendor/sabre/event/lib/Loop/Loop.php40
-rw-r--r--vendor/sabre/event/lib/Loop/functions.php29
-rw-r--r--vendor/sabre/event/lib/Promise.php67
-rw-r--r--vendor/sabre/event/lib/Promise/functions.php26
-rw-r--r--vendor/sabre/event/lib/PromiseAlreadyResolvedException.php4
-rw-r--r--vendor/sabre/event/lib/Version.php6
-rw-r--r--vendor/sabre/event/lib/WildcardEmitter.php37
-rw-r--r--vendor/sabre/event/lib/WildcardEmitterTrait.php264
-rw-r--r--vendor/sabre/event/lib/coroutine.php53
20 files changed, 499 insertions, 237 deletions
diff --git a/vendor/sabre/event/.gitattributes b/vendor/sabre/event/.gitattributes
new file mode 100644
index 000000000..0fdd4b01c
--- /dev/null
+++ b/vendor/sabre/event/.gitattributes
@@ -0,0 +1,2 @@
+/examples export-ignore
+/tests export-ignore
diff --git a/vendor/sabre/event/.travis.yml b/vendor/sabre/event/.travis.yml
index b6719f591..020488b79 100644
--- a/vendor/sabre/event/.travis.yml
+++ b/vendor/sabre/event/.travis.yml
@@ -1,13 +1,8 @@
language: php
php:
- - 5.5
- - 5.6
- - 7
- - hhvm
-
-matrix:
- allow_failures:
- - php: hhvm
+ - 7.0
+ - 7.1
+ - 7.2
env:
matrix:
diff --git a/vendor/sabre/event/CHANGELOG.md b/vendor/sabre/event/CHANGELOG.md
index 9d6d7cfaa..5b1fb2e68 100644
--- a/vendor/sabre/event/CHANGELOG.md
+++ b/vendor/sabre/event/CHANGELOG.md
@@ -1,5 +1,49 @@
ChangeLog
=========
+5.0.3 (2018-05-03)
+------------------
+
+* Dropped remaining hhvm leftovers.
+* #55: Fixed typo in WildcardEmitterTrait (@SamMousa)
+* #54: export-ignore examples & tests in distribution (@staabm)
+
+5.0.2 (2017-04-29)
+------------------
+
+* #50: Fixed Promise\all to resolve immediately for empty arrays (@MadHed)
+* #48, #49: Performance optimisations for EmitterTrait and WildcardEmitterTrait (@lunixyacht).
+
+5.0.1 (2016-10-29)
+------------------
+
+* #45: Fixed `Emitter` class to use the correct interface. (@felixfbecker).
+
+
+5.0.0 (2016-10-23)
+------------------
+
+* #42: The `coroutine` function now supports `return` in the passed generator
+ function. This allows you to more generally return a value. This is a BC
+ break as this is a feature that was only made possible with PHP 7, and
+ before the coroutine function would only ever return the last thing that
+ was yielded. If you depended on that feature, replace your last `yield` with
+ a `return`.
+
+
+4.0.0 (2016-09-19)
+------------------
+
+* sabre/event now requires PHP 7. If you need PHP 5.5 support, just keep
+ using 3.0.0.
+* PHP 7 type hints are now used everywhere. We're also using strict_types.
+* Support for a new `WildcardEmitter` which allows you to listen for events
+ using the `*` wildcard.
+* Removed deprecated functions `Promise::error` and `Promise::all`. Instead,
+ use `Promise::otherwise` and `Promise\all()`.
+* `EventEmitter`, `EventEmitterTrait` and `EventEmitterInterface` are now just
+ called `Emitter`, `EmitterTrait`, and `EmitterInterface`.
+* When rejecting Promises, it's now _required_ to use an `Exception` or
+ `Throwable`. This makes the typical case simpler and reduces special cases.
3.0.0 (2015-11-05)
------------------
diff --git a/vendor/sabre/event/LICENSE b/vendor/sabre/event/LICENSE
index 9a495cef0..962a49267 100644
--- a/vendor/sabre/event/LICENSE
+++ b/vendor/sabre/event/LICENSE
@@ -1,4 +1,4 @@
-Copyright (C) 2013-2015 fruux GmbH (https://fruux.com/)
+Copyright (C) 2013-2016 fruux GmbH (https://fruux.com/)
All rights reserved.
diff --git a/vendor/sabre/event/README.md b/vendor/sabre/event/README.md
index 364906fd4..9e2bdd042 100644
--- a/vendor/sabre/event/README.md
+++ b/vendor/sabre/event/README.md
@@ -17,7 +17,7 @@ Installation
Make sure you have [composer][3] installed, and then run:
- composer require sabre/event "~3.0.0"
+ composer require sabre/event "^3.0"
This package requires PHP 5.5. The 2.0 branch is still maintained as well, and
supports PHP 5.4.
@@ -27,10 +27,11 @@ Build status
| branch | status |
| ------ | ------ |
-| master | [![Build Status](https://travis-ci.org/fruux/sabre-event.svg?branch=master)](https://travis-ci.org/fruux/sabre-event) |
-| 2.0 | [![Build Status](https://travis-ci.org/fruux/sabre-event.svg?branch=2.0)](https://travis-ci.org/fruux/sabre-event) |
-| 1.0 | [![Build Status](https://travis-ci.org/fruux/sabre-event.svg?branch=1.0)](https://travis-ci.org/fruux/sabre-event) |
-| php53 | [![Build Status](https://travis-ci.org/fruux/sabre-event.svg?branch=php53)](https://travis-ci.org/fruux/sabre-event) |
+| master | [![Build Status](https://travis-ci.org/sabre-io/event.svg?branch=master)](https://travis-ci.org/sabre-io/event) |
+| 3.0 | [![Build Status](https://travis-ci.org/sabre-io/event.svg?branch=2.0)](https://travis-ci.org/sabre-io/event) |
+| 2.0 | [![Build Status](https://travis-ci.org/sabre-io/event.svg?branch=2.0)](https://travis-ci.org/sabre-io/event) |
+| 1.0 | [![Build Status](https://travis-ci.org/sabre-io/event.svg?branch=1.0)](https://travis-ci.org/sabre-io/event) |
+| php53 | [![Build Status](https://travis-ci.org/sabre-io/event.svg?branch=php53)](https://travis-ci.org/sabre-io/event) |
Questions?
diff --git a/vendor/sabre/event/_config.yml b/vendor/sabre/event/_config.yml
new file mode 100644
index 000000000..c4192631f
--- /dev/null
+++ b/vendor/sabre/event/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-cayman \ No newline at end of file
diff --git a/vendor/sabre/event/composer.json b/vendor/sabre/event/composer.json
index 9a11b01aa..d7a13c5ca 100644
--- a/vendor/sabre/event/composer.json
+++ b/vendor/sabre/event/composer.json
@@ -8,12 +8,15 @@
"Hooks",
"Plugin",
"Signal",
- "Async"
+ "Async",
+ "EventLoop",
+ "Reactor",
+ "Coroutine"
],
"homepage": "http://sabre.io/event/",
"license": "BSD-3-Clause",
"require": {
- "php": ">=5.5"
+ "php": ">=7.0"
},
"authors": [
{
@@ -38,8 +41,8 @@
]
},
"require-dev": {
- "sabre/cs": "~0.0.4",
- "phpunit/phpunit" : "*"
+ "sabre/cs": "~1.0.0",
+ "phpunit/phpunit" : ">=6"
},
"config" : {
"bin-dir" : "bin/"
diff --git a/vendor/sabre/event/lib/Emitter.php b/vendor/sabre/event/lib/Emitter.php
new file mode 100644
index 000000000..ab5e8c90e
--- /dev/null
+++ b/vendor/sabre/event/lib/Emitter.php
@@ -0,0 +1,18 @@
+<?php declare (strict_types=1);
+
+namespace Sabre\Event;
+
+/**
+ * Emitter object.
+ *
+ * Instantiate this class, or subclass it for easily creating event emitters.
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class Emitter implements EmitterInterface {
+
+ use EmitterTrait;
+
+}
diff --git a/vendor/sabre/event/lib/EventEmitterInterface.php b/vendor/sabre/event/lib/EmitterInterface.php
index 0e2be2cef..a7e4b6132 100644
--- a/vendor/sabre/event/lib/EventEmitterInterface.php
+++ b/vendor/sabre/event/lib/EmitterInterface.php
@@ -1,4 +1,4 @@
-<?php
+<?php declare (strict_types=1);
namespace Sabre\Event;
@@ -8,31 +8,25 @@ namespace Sabre\Event;
* Anything that accepts listeners and emits events should implement this
* interface.
*
- * @copyright Copyright (C) 2013-2015 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface EventEmitterInterface {
+interface EmitterInterface {
/**
* Subscribe to an event.
*
- * @param string $eventName
- * @param callable $callBack
- * @param int $priority
* @return void
*/
- function on($eventName, callable $callBack, $priority = 100);
+ function on(string $eventName, callable $callBack, int $priority = 100);
/**
* Subscribe to an event exactly once.
*
- * @param string $eventName
- * @param callable $callBack
- * @param int $priority
* @return void
*/
- function once($eventName, callable $callBack, $priority = 100);
+ function once(string $eventName, callable $callBack, int $priority = 100);
/**
* Emits an event.
@@ -54,13 +48,8 @@ interface EventEmitterInterface {
*
* Lastly, if there are 5 event handlers for an event. The continueCallback
* will be called at most 4 times.
- *
- * @param string $eventName
- * @param array $arguments
- * @param callback $continueCallBack
- * @return bool
*/
- function emit($eventName, array $arguments = [], callable $continueCallBack = null);
+ function emit(string $eventName, array $arguments = [], callable $continueCallBack = null) : bool;
/**
* Returns the list of listeners for an event.
@@ -68,22 +57,17 @@ interface EventEmitterInterface {
* The list is returned as an array, and the list of events are sorted by
* their priority.
*
- * @param string $eventName
* @return callable[]
*/
- function listeners($eventName);
+ function listeners(string $eventName) : array;
/**
* Removes a specific listener from an event.
*
* If the listener could not be found, this method will return false. If it
* was removed it will return true.
- *
- * @param string $eventName
- * @param callable $listener
- * @return bool
*/
- function removeListener($eventName, callable $listener);
+ function removeListener(string $eventName, callable $listener) : bool;
/**
* Removes all listeners.
@@ -92,9 +76,8 @@ interface EventEmitterInterface {
* removed. If it is not specified, every listener for every event is
* removed.
*
- * @param string $eventName
* @return void
*/
- function removeAllListeners($eventName = null);
+ function removeAllListeners(string $eventName = null);
}
diff --git a/vendor/sabre/event/lib/EventEmitterTrait.php b/vendor/sabre/event/lib/EmitterTrait.php
index 257629fae..dafae362f 100644
--- a/vendor/sabre/event/lib/EventEmitterTrait.php
+++ b/vendor/sabre/event/lib/EmitterTrait.php
@@ -1,4 +1,4 @@
-<?php
+<?php declare (strict_types=1);
namespace Sabre\Event;
@@ -11,28 +11,19 @@ namespace Sabre\Event;
* Using the trait + interface allows you to add EventEmitter capabilities
* without having to change your base-class.
*
- * @copyright Copyright (C) 2013-2015 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-trait EventEmitterTrait {
+trait EmitterTrait {
- /**
- * The list of listeners
- *
- * @var array
- */
- protected $listeners = [];
/**
* Subscribe to an event.
*
- * @param string $eventName
- * @param callable $callBack
- * @param int $priority
* @return void
*/
- function on($eventName, callable $callBack, $priority = 100) {
+ function on(string $eventName, callable $callBack, int $priority = 100) {
if (!isset($this->listeners[$eventName])) {
$this->listeners[$eventName] = [
@@ -51,18 +42,15 @@ trait EventEmitterTrait {
/**
* Subscribe to an event exactly once.
*
- * @param string $eventName
- * @param callable $callBack
- * @param int $priority
* @return void
*/
- function once($eventName, callable $callBack, $priority = 100) {
+ function once(string $eventName, callable $callBack, int $priority = 100) {
$wrapper = null;
$wrapper = function() use ($eventName, $callBack, &$wrapper) {
$this->removeListener($eventName, $wrapper);
- return call_user_func_array($callBack, func_get_args());
+ return \call_user_func_array($callBack, \func_get_args());
};
@@ -90,19 +78,14 @@ trait EventEmitterTrait {
*
* Lastly, if there are 5 event handlers for an event. The continueCallback
* will be called at most 4 times.
- *
- * @param string $eventName
- * @param array $arguments
- * @param callback $continueCallBack
- * @return bool
*/
- function emit($eventName, array $arguments = [], callable $continueCallBack = null) {
+ function emit(string $eventName, array $arguments = [], callable $continueCallBack = null) : bool {
- if (is_null($continueCallBack)) {
+ if (\is_null($continueCallBack)) {
foreach ($this->listeners($eventName) as $listener) {
- $result = call_user_func_array($listener, $arguments);
+ $result = \call_user_func_array($listener, $arguments);
if ($result === false) {
return false;
}
@@ -111,12 +94,12 @@ trait EventEmitterTrait {
} else {
$listeners = $this->listeners($eventName);
- $counter = count($listeners);
+ $counter = \count($listeners);
foreach ($listeners as $listener) {
$counter--;
- $result = call_user_func_array($listener, $arguments);
+ $result = \call_user_func_array($listener, $arguments);
if ($result === false) {
return false;
}
@@ -139,10 +122,9 @@ trait EventEmitterTrait {
* The list is returned as an array, and the list of events are sorted by
* their priority.
*
- * @param string $eventName
* @return callable[]
*/
- function listeners($eventName) {
+ function listeners(string $eventName) : array {
if (!isset($this->listeners[$eventName])) {
return [];
@@ -152,7 +134,7 @@ trait EventEmitterTrait {
if (!$this->listeners[$eventName][0]) {
// Sorting
- array_multisort($this->listeners[$eventName][1], SORT_NUMERIC, $this->listeners[$eventName][2]);
+ \array_multisort($this->listeners[$eventName][1], SORT_NUMERIC, $this->listeners[$eventName][2]);
// Marking the listeners as sorted
$this->listeners[$eventName][0] = true;
@@ -167,12 +149,8 @@ trait EventEmitterTrait {
*
* If the listener could not be found, this method will return false. If it
* was removed it will return true.
- *
- * @param string $eventName
- * @param callable $listener
- * @return bool
*/
- function removeListener($eventName, callable $listener) {
+ function removeListener(string $eventName, callable $listener) : bool {
if (!isset($this->listeners[$eventName])) {
return false;
@@ -195,12 +173,11 @@ trait EventEmitterTrait {
* removed. If it is not specified, every listener for every event is
* removed.
*
- * @param string $eventName
* @return void
*/
- function removeAllListeners($eventName = null) {
+ function removeAllListeners(string $eventName = null) {
- if (!is_null($eventName)) {
+ if (!\is_null($eventName)) {
unset($this->listeners[$eventName]);
} else {
$this->listeners = [];
@@ -208,4 +185,11 @@ trait EventEmitterTrait {
}
+ /**
+ * The list of listeners
+ *
+ * @var array
+ */
+ protected $listeners = [];
+
}
diff --git a/vendor/sabre/event/lib/EventEmitter.php b/vendor/sabre/event/lib/EventEmitter.php
index 1bb1c3cf9..cae6ac2a6 100644
--- a/vendor/sabre/event/lib/EventEmitter.php
+++ b/vendor/sabre/event/lib/EventEmitter.php
@@ -1,18 +1,19 @@
-<?php
+<?php declare (strict_types=1);
namespace Sabre\Event;
/**
- * EventEmitter object.
+ * This is the old name for the Emitter class.
*
- * Instantiate this class, or subclass it for easily creating event emitters.
+ * Instead of of using EventEmitter, please use Emitter. They are identical
+ * otherwise.
*
- * @copyright Copyright (C) 2013-2015 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class EventEmitter implements EventEmitterInterface {
+class EventEmitter implements EmitterInterface {
- use EventEmitterTrait;
+ use EmitterTrait;
}
diff --git a/vendor/sabre/event/lib/Loop/Loop.php b/vendor/sabre/event/lib/Loop/Loop.php
index 86ee7c8b0..301fe8920 100644
--- a/vendor/sabre/event/lib/Loop/Loop.php
+++ b/vendor/sabre/event/lib/Loop/Loop.php
@@ -1,4 +1,4 @@
-<?php
+<?php declare (strict_types=1);
namespace Sabre\Event\Loop;
@@ -11,7 +11,7 @@ namespace Sabre\Event\Loop;
* * setInterval for repeating functions
* * stream events using stream_select
*
- * @copyright Copyright (C) 2007-2015 fruux GmbH. (https://fruux.com/)
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -20,11 +20,9 @@ class Loop {
/**
* Executes a function after x seconds.
*
- * @param callable $cb
- * @param float $timeout timeout in seconds
* @return void
*/
- function setTimeout(callable $cb, $timeout) {
+ function setTimeout(callable $cb, float $timeout) {
$triggerTime = microtime(true) + ($timeout);
@@ -63,12 +61,8 @@ class Loop {
*
* The value this function returns can be used to stop the interval with
* clearInterval.
- *
- * @param callable $cb
- * @param float $timeout
- * @return array
*/
- function setInterval(callable $cb, $timeout) {
+ function setInterval(callable $cb, float $timeout) : array {
$keepGoing = true;
$f = null;
@@ -92,12 +86,11 @@ class Loop {
}
/**
- * Stops a running internval.
+ * Stops a running interval.
*
- * @param array $intervalId
* @return void
*/
- function clearInterval($intervalId) {
+ function clearInterval(array $intervalId) {
$intervalId[1] = false;
@@ -106,7 +99,6 @@ class Loop {
/**
* Runs a function immediately at the next iteration of the loop.
*
- * @param callable $cb
* @return void
*/
function nextTick(callable $cb) {
@@ -126,7 +118,6 @@ class Loop {
* prevent the eventloop from never stopping.
*
* @param resource $stream
- * @param callable $cb
* @return void
*/
function addReadStream($stream, callable $cb) {
@@ -146,7 +137,6 @@ class Loop {
* prevent the eventloop from never stopping.
*
* @param resource $stream
- * @param callable $cb
* @return void
*/
function addWriteStream($stream, callable $cb) {
@@ -219,11 +209,8 @@ class Loop {
*
* This function will return true if there are _any_ events left in the
* loop after the tick.
- *
- * @param bool $block
- * @return bool
*/
- function tick($block = false) {
+ function tick(bool $block = false) : bool {
$this->runNextTicks();
$nextTimeout = $this->runTimers();
@@ -284,7 +271,7 @@ class Loop {
*
* If there's no more pending timers, this function returns null.
*
- * @return float
+ * @return float|null
*/
protected function runTimers() {
@@ -295,7 +282,7 @@ class Loop {
// Add the last timer back to the array.
if ($timer) {
$this->timers[] = $timer;
- return $timer[0] - microtime(true);
+ return max(0, $timer[0] - microtime(true));
}
}
@@ -303,7 +290,10 @@ class Loop {
/**
* Runs all pending stream events.
*
- * @param float $timeout
+ * If $timeout is 0, it will return immediately. If $timeout is null, it
+ * will wait indefinitely.
+ *
+ * @param float|null timeout
*/
protected function runStreams($timeout) {
@@ -312,7 +302,7 @@ class Loop {
$read = $this->readStreams;
$write = $this->writeStreams;
$except = null;
- if (stream_select($read, $write, $except, null, $timeout)) {
+ if (stream_select($read, $write, $except, ($timeout === null) ? null : 0, $timeout ? (int)($timeout * 1000000) : 0)) {
// See PHP Bug https://bugs.php.net/bug.php?id=62452
// Fixed in PHP7
@@ -328,7 +318,7 @@ class Loop {
}
} elseif ($this->running && ($this->nextTick || $this->timers)) {
- usleep($timeout !== null ? $timeout * 1000000 : 200000);
+ usleep($timeout !== null ? intval($timeout * 1000000) : 200000);
}
}
diff --git a/vendor/sabre/event/lib/Loop/functions.php b/vendor/sabre/event/lib/Loop/functions.php
index 56c5bc8c7..b5884b2b6 100644
--- a/vendor/sabre/event/lib/Loop/functions.php
+++ b/vendor/sabre/event/lib/Loop/functions.php
@@ -1,15 +1,13 @@
-<?php
+<?php declare (strict_types=1);
namespace Sabre\Event\Loop;
/**
* Executes a function after x seconds.
*
- * @param callable $cb
- * @param float $timeout timeout in seconds
* @return void
*/
-function setTimeout(callable $cb, $timeout) {
+function setTimeout(callable $cb, float $timeout) {
instance()->setTimeout($cb, $timeout);
@@ -20,24 +18,19 @@ function setTimeout(callable $cb, $timeout) {
*
* The value this function returns can be used to stop the interval with
* clearInterval.
- *
- * @param callable $cb
- * @param float $timeout
- * @return array
*/
-function setInterval(callable $cb, $timeout) {
+function setInterval(callable $cb, float $timeout) : array {
return instance()->setInterval($cb, $timeout);
}
/**
- * Stops a running internval.
+ * Stops a running interval.
*
- * @param array $intervalId
* @return void
*/
-function clearInterval($intervalId) {
+function clearInterval(array $intervalId) {
instance()->clearInterval($intervalId);
@@ -46,7 +39,6 @@ function clearInterval($intervalId) {
/**
* Runs a function immediately at the next iteration of the loop.
*
- * @param callable $cb
* @return void
*/
function nextTick(callable $cb) {
@@ -66,7 +58,6 @@ function nextTick(callable $cb) {
* prevent the eventloop from never stopping.
*
* @param resource $stream
- * @param callable $cb
* @return void
*/
function addReadStream($stream, callable $cb) {
@@ -85,7 +76,6 @@ function addReadStream($stream, callable $cb) {
* prevent the eventloop from never stopping.
*
* @param resource $stream
- * @param callable $cb
* @return void
*/
function addWriteStream($stream, callable $cb) {
@@ -144,11 +134,8 @@ function run() {
*
* This function will return true if there are _any_ events left in the
* loop after the tick.
- *
- * @param bool $block
- * @return bool
*/
-function tick($block = false) {
+function tick(bool $block = false) : bool {
return instance()->tick($block);
@@ -167,10 +154,8 @@ function stop() {
/**
* Retrieves or sets the global Loop object.
- *
- * @param Loop $newLoop
*/
-function instance(Loop $newLoop = null) {
+function instance(Loop $newLoop = null) : Loop {
static $loop;
if ($newLoop) {
diff --git a/vendor/sabre/event/lib/Promise.php b/vendor/sabre/event/lib/Promise.php
index 1c874c1bd..1d04bd4d4 100644
--- a/vendor/sabre/event/lib/Promise.php
+++ b/vendor/sabre/event/lib/Promise.php
@@ -1,8 +1,9 @@
-<?php
+<?php declare (strict_types=1);
namespace Sabre\Event;
use Exception;
+use Throwable;
/**
* An implementation of the Promise pattern.
@@ -16,7 +17,7 @@ use Exception;
*
* To get a callback when the operation has finished, use the `then` method.
*
- * @copyright Copyright (C) 2013-2015 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -52,8 +53,6 @@ class Promise {
*
* Each are callbacks that map to $this->fulfill and $this->reject.
* Using the executor is optional.
- *
- * @param callable $executor
*/
function __construct(callable $executor = null) {
@@ -84,12 +83,8 @@ class Promise {
*
* If either of the callbacks throw an exception, the returned promise will
* be rejected and the exception will be passed back.
- *
- * @param callable $onFulfilled
- * @param callable $onRejected
- * @return Promise
*/
- function then(callable $onFulfilled = null, callable $onRejected = null) {
+ function then(callable $onFulfilled = null, callable $onRejected = null) : Promise {
// This new subPromise will be returned from this function, and will
// be fulfilled with the result of the onFulfilled or onRejected event
@@ -122,11 +117,8 @@ class Promise {
*
* Its usage is identical to then(). However, the otherwise() function is
* preferred.
- *
- * @param callable $onRejected
- * @return Promise
*/
- function otherwise(callable $onRejected) {
+ function otherwise(callable $onRejected) : Promise {
return $this->then(null, $onRejected);
@@ -152,13 +144,9 @@ class Promise {
/**
* Marks this promise as rejected, and set it's rejection reason.
*
- * While it's possible to use any PHP value as the reason, it's highly
- * recommended to use an Exception for this.
- *
- * @param mixed $reason
* @return void
*/
- function reject($reason = null) {
+ function reject(Throwable $reason) {
if ($this->state !== self::PENDING) {
throw new PromiseAlreadyResolvedException('This promise is already resolved, and you\'re not allowed to resolve a promise more than once');
}
@@ -181,7 +169,6 @@ class Promise {
* one. In PHP it might be useful to call this on the last promise in a
* chain.
*
- * @throws Exception
* @return mixed
*/
function wait() {
@@ -205,15 +192,7 @@ class Promise {
} else {
// If we got here, it means that the asynchronous operation
// errored. Therefore we need to throw an exception.
- $reason = $this->value;
- if ($reason instanceof Exception) {
- throw $reason;
- } elseif (is_scalar($reason)) {
- throw new Exception($reason);
- } else {
- $type = is_object($reason) ? get_class($reason) : gettype($reason);
- throw new Exception('Promise was rejected with reason of type: ' . $type);
- }
+ throw $this->value;
}
@@ -272,7 +251,7 @@ class Promise {
// immediately fulfill the chained promise.
$subPromise->fulfill($result);
}
- } catch (Exception $e) {
+ } catch (Throwable $e) {
// If the event handler threw an exception, we need to make sure that
// the chained promise is rejected as well.
$subPromise->reject($e);
@@ -287,34 +266,4 @@ class Promise {
});
}
- /**
- * Alias for 'otherwise'.
- *
- * This function is now deprecated and will be removed in a future version.
- *
- * @param callable $onRejected
- * @deprecated
- * @return Promise
- */
- function error(callable $onRejected) {
-
- return $this->otherwise($onRejected);
-
- }
-
- /**
- * Deprecated.
- *
- * Please use Sabre\Event\Promise::all
- *
- * @param Promise[] $promises
- * @deprecated
- * @return Promise
- */
- static function all(array $promises) {
-
- return Promise\all($promises);
-
- }
-
}
diff --git a/vendor/sabre/event/lib/Promise/functions.php b/vendor/sabre/event/lib/Promise/functions.php
index 3604b8aaa..275492cbc 100644
--- a/vendor/sabre/event/lib/Promise/functions.php
+++ b/vendor/sabre/event/lib/Promise/functions.php
@@ -1,14 +1,15 @@
-<?php
+<?php declare (strict_types=1);
namespace Sabre\Event\Promise;
use Sabre\Event\Promise;
+use Throwable;
/**
* This file contains a set of functions that are useful for dealing with the
* Promise object.
*
- * @copyright Copyright (C) 2013-2015 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -27,12 +28,16 @@ use Sabre\Event\Promise;
* fail with the first Promise that fails, and its reason.
*
* @param Promise[] $promises
- * @return Promise
*/
-function all(array $promises) {
+function all(array $promises) : Promise {
return new Promise(function($success, $fail) use ($promises) {
+ if (empty($promises)) {
+ $success([]);
+ return;
+ }
+
$successCount = 0;
$completeResult = [];
@@ -47,7 +52,7 @@ function all(array $promises) {
}
return $result;
}
- )->error(
+ )->otherwise(
function($reason) use ($fail) {
$fail($reason);
}
@@ -66,9 +71,8 @@ function all(array $promises) {
* that first promise.
*
* @param Promise[] $promises
- * @return Promise
*/
-function race(array $promises) {
+function race(array $promises) : Promise {
return new Promise(function($success, $fail) use ($promises) {
@@ -106,9 +110,8 @@ function race(array $promises) {
* promise and eventually get the same state as the followed promise.
*
* @param mixed $value
- * @return Promise
*/
-function resolve($value) {
+function resolve($value) : Promise {
if ($value instanceof Promise) {
return $value->then();
@@ -122,11 +125,8 @@ function resolve($value) {
/**
* Returns a Promise that will reject with the given reason.
- *
- * @param mixed $reason
- * @return Promise
*/
-function reject($reason) {
+function reject(Throwable $reason) : Promise {
$promise = new Promise();
$promise->reject($reason);
diff --git a/vendor/sabre/event/lib/PromiseAlreadyResolvedException.php b/vendor/sabre/event/lib/PromiseAlreadyResolvedException.php
index 86a6c5b3f..534a3d494 100644
--- a/vendor/sabre/event/lib/PromiseAlreadyResolvedException.php
+++ b/vendor/sabre/event/lib/PromiseAlreadyResolvedException.php
@@ -1,4 +1,4 @@
-<?php
+<?php declare (strict_types=1);
namespace Sabre\Event;
@@ -6,7 +6,7 @@ namespace Sabre\Event;
* This exception is thrown when the user tried to reject or fulfill a promise,
* after either of these actions were already performed.
*
- * @copyright Copyright (C) 2013-2015 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
diff --git a/vendor/sabre/event/lib/Version.php b/vendor/sabre/event/lib/Version.php
index 5de22193f..9aee4b3ab 100644
--- a/vendor/sabre/event/lib/Version.php
+++ b/vendor/sabre/event/lib/Version.php
@@ -1,11 +1,11 @@
-<?php
+<?php declare (strict_types=1);
namespace Sabre\Event;
/**
* This class contains the version number for this package.
*
- * @copyright Copyright (C) 2013-2015 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -14,6 +14,6 @@ class Version {
/**
* Full version number
*/
- const VERSION = '3.0.0';
+ const VERSION = '5.0.3';
}
diff --git a/vendor/sabre/event/lib/WildcardEmitter.php b/vendor/sabre/event/lib/WildcardEmitter.php
new file mode 100644
index 000000000..2ef15fe83
--- /dev/null
+++ b/vendor/sabre/event/lib/WildcardEmitter.php
@@ -0,0 +1,37 @@
+<?php declare (strict_types=1);
+
+namespace Sabre\Event;
+
+/**
+ * This class is an EventEmitter with support for wildcard event handlers.
+ *
+ * What this means is that you can emit events like this:
+ *
+ * emit('change:firstName')
+ *
+ * and listen to this event like this:
+ *
+ * on('change:*')
+ *
+ * A few notes:
+ *
+ * - Wildcards only work at the end of an event name.
+ * - Currently you can only use 1 wildcard.
+ * - Using ":" as a separator is optional, but it's highly recommended to use
+ * some kind of separator.
+ *
+ * The WilcardEmitter is a bit slower than the regular Emitter. If you code
+ * must be very high performance, it might be better to try to use the other
+ * emitter. For must usage the difference is negligible though.
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class WildcardEmitter implements EmitterInterface {
+
+ use WildcardEmitterTrait;
+
+
+
+}
diff --git a/vendor/sabre/event/lib/WildcardEmitterTrait.php b/vendor/sabre/event/lib/WildcardEmitterTrait.php
new file mode 100644
index 000000000..7d8d62c26
--- /dev/null
+++ b/vendor/sabre/event/lib/WildcardEmitterTrait.php
@@ -0,0 +1,264 @@
+<?php declare (strict_types=1);
+
+namespace Sabre\Event;
+
+/**
+ * Wildcard Emitter Trait
+ *
+ * This trait provides the implementation for WildCardEmitter
+ * Refer to that class for the full documentation about this
+ * trait.
+ *
+ * Normally you can just instantiate that class, but if you want to add
+ * emitter functionality to existing classes, using the trait might be a
+ * better way to do this.
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+trait WildcardEmitterTrait {
+
+ /**
+ * Subscribe to an event.
+ *
+ * @return void
+ */
+ function on(string $eventName, callable $callBack, int $priority = 100) {
+
+ // If it ends with a wildcard, we use the wildcardListeners array
+ if ($eventName[\strlen($eventName) - 1] === '*') {
+ $eventName = \substr($eventName, 0, -1);
+ $listeners = & $this->wildcardListeners;
+ } else {
+ $listeners = & $this->listeners;
+ }
+
+ // Always fully reset the listener index. This is fairly sane for most
+ // applications, because there's a clear "event registering" and "event
+ // emitting" phase, but can be slow if there's a lot adding and removing
+ // of listeners during emitting of events.
+ $this->listenerIndex = [];
+
+ if (!isset($listeners[$eventName])) {
+ $listeners[$eventName] = [];
+ }
+ $listeners[$eventName][] = [$priority, $callBack];
+
+ }
+
+ /**
+ * Subscribe to an event exactly once.
+ *
+ * @return void
+ */
+ function once(string $eventName, callable $callBack, int $priority = 100) {
+
+ $wrapper = null;
+ $wrapper = function() use ($eventName, $callBack, &$wrapper) {
+
+ $this->removeListener($eventName, $wrapper);
+ return \call_user_func_array($callBack, \func_get_args());
+
+ };
+
+ $this->on($eventName, $wrapper, $priority);
+
+ }
+
+ /**
+ * Emits an event.
+ *
+ * This method will return true if 0 or more listeners were succesfully
+ * handled. false is returned if one of the events broke the event chain.
+ *
+ * If the continueCallBack is specified, this callback will be called every
+ * time before the next event handler is called.
+ *
+ * If the continueCallback returns false, event propagation stops. This
+ * allows you to use the eventEmitter as a means for listeners to implement
+ * functionality in your application, and break the event loop as soon as
+ * some condition is fulfilled.
+ *
+ * Note that returning false from an event subscriber breaks propagation
+ * and returns false, but if the continue-callback stops propagation, this
+ * is still considered a 'successful' operation and returns true.
+ *
+ * Lastly, if there are 5 event handlers for an event. The continueCallback
+ * will be called at most 4 times.
+ */
+ function emit(string $eventName, array $arguments = [], callable $continueCallBack = null) : bool {
+
+ if (\is_null($continueCallBack)) {
+
+ foreach ($this->listeners($eventName) as $listener) {
+
+ $result = \call_user_func_array($listener, $arguments);
+ if ($result === false) {
+ return false;
+ }
+ }
+
+ } else {
+
+ $listeners = $this->listeners($eventName);
+ $counter = \count($listeners);
+
+ foreach ($listeners as $listener) {
+
+ $counter--;
+ $result = \call_user_func_array($listener, $arguments);
+ if ($result === false) {
+ return false;
+ }
+
+ if ($counter > 0) {
+ if (!$continueCallBack()) break;
+ }
+
+ }
+
+ }
+
+ return true;
+
+
+ }
+
+ /**
+ * Returns the list of listeners for an event.
+ *
+ * The list is returned as an array, and the list of events are sorted by
+ * their priority.
+ *
+ * @return callable[]
+ */
+ function listeners(string $eventName) : array {
+
+ if (!\array_key_exists($eventName, $this->listenerIndex)) {
+
+ // Create a new index.
+ $listeners = [];
+ $listenersPriority = [];
+ if (isset($this->listeners[$eventName])) foreach ($this->listeners[$eventName] as $listener) {
+
+ $listenersPriority[] = $listener[0];
+ $listeners[] = $listener[1];
+
+ }
+
+ foreach ($this->wildcardListeners as $wcEvent => $wcListeners) {
+
+ // Wildcard match
+ if (\substr($eventName, 0, \strlen($wcEvent)) === $wcEvent) {
+
+ foreach ($wcListeners as $listener) {
+
+ $listenersPriority[] = $listener[0];
+ $listeners[] = $listener[1];
+
+ }
+
+ }
+
+ }
+
+ // Sorting by priority
+ \array_multisort($listenersPriority, SORT_NUMERIC, $listeners);
+
+ // Creating index
+ $this->listenerIndex[$eventName] = $listeners;
+
+ }
+
+ return $this->listenerIndex[$eventName];
+
+ }
+
+ /**
+ * Removes a specific listener from an event.
+ *
+ * If the listener could not be found, this method will return false. If it
+ * was removed it will return true.
+ */
+ function removeListener(string $eventName, callable $listener) : bool {
+
+ // If it ends with a wildcard, we use the wildcardListeners array
+ if ($eventName[\strlen($eventName) - 1] === '*') {
+ $eventName = \substr($eventName, 0, -1);
+ $listeners = & $this->wildcardListeners;
+ } else {
+ $listeners = & $this->listeners;
+ }
+
+ if (!isset($listeners[$eventName])) {
+ return false;
+ }
+
+ foreach ($listeners[$eventName] as $index => $check) {
+
+ if ($check[1] === $listener) {
+
+ // Remove listener
+ unset($listeners[$eventName][$index]);
+ // Reset index
+ $this->listenerIndex = [];
+ return true;
+
+ }
+
+ }
+
+ return false;
+
+ }
+
+ /**
+ * Removes all listeners.
+ *
+ * If the eventName argument is specified, all listeners for that event are
+ * removed. If it is not specified, every listener for every event is
+ * removed.
+ *
+ * @return void
+ */
+ function removeAllListeners(string $eventName = null) {
+
+ if (\is_null($eventName)) {
+ $this->listeners = [];
+ $this->wildcardListeners = [];
+
+ } else {
+
+ if ($eventName[\strlen($eventName) - 1] === '*') {
+ // Wildcard event
+ unset($this->wildcardListeners[\substr($eventName, 0, -1)]);
+ } else {
+ unset($this->listeners[$eventName]);
+ }
+
+ }
+
+ // Reset index
+ $this->listenerIndex = [];
+
+ }
+
+ /**
+ * The list of listeners
+ */
+ protected $listeners = [];
+
+ /**
+ * The list of "wildcard listeners".
+ */
+ protected $wildcardListeners = [];
+
+ /**
+ * An index of listeners for a specific event name. This helps speeding
+ * up emitting events after all listeners have been set.
+ *
+ * If the list of listeners changes though, the index clears.
+ */
+ protected $listenerIndex = [];
+}
diff --git a/vendor/sabre/event/lib/coroutine.php b/vendor/sabre/event/lib/coroutine.php
index 19c0ba8a7..750e8ab52 100644
--- a/vendor/sabre/event/lib/coroutine.php
+++ b/vendor/sabre/event/lib/coroutine.php
@@ -1,9 +1,9 @@
-<?php
+<?php declare (strict_types=1);
namespace Sabre\Event;
use Generator;
-use Exception;
+use Throwable;
/**
* Turn asynchronous promise-based code into something that looks synchronous
@@ -34,17 +34,18 @@ use Exception;
* yield $httpClient->request('GET', '/foo');
* yield $httpClient->request('DELETE', /foo');
* yield $httpClient->request('PUT', '/foo');
- * } catch(\Exception $reason) {
+ * } catch(\Throwable $reason) {
* echo "Failed because: $reason\n";
* }
*
* });
*
- * @copyright Copyright (C) 2013-2015 fruux GmbH. All rights reserved.
+ * @return \Sabre\Event\Promise
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-function coroutine(callable $gen) {
+function coroutine(callable $gen) : Promise {
$generator = $gen();
if (!$generator instanceof Generator) {
@@ -54,8 +55,6 @@ function coroutine(callable $gen) {
// This is the value we're returning.
$promise = new Promise();
- $lastYieldResult = null;
-
/**
* So tempted to use the mythical y-combinator here, but it's not needed in
* PHP.
@@ -68,22 +67,14 @@ function coroutine(callable $gen) {
if ($yieldedValue instanceof Promise) {
$yieldedValue->then(
function($value) use ($generator, &$advanceGenerator, &$lastYieldResult) {
- $lastYieldResult = $value;
$generator->send($value);
$advanceGenerator();
},
- function($reason) use ($generator, $advanceGenerator) {
- if ($reason instanceof Exception) {
- $generator->throw($reason);
- } elseif (is_scalar($reason)) {
- $generator->throw(new Exception($reason));
- } else {
- $type = is_object($reason) ? get_class($reason) : gettype($reason);
- $generator->throw(new Exception('Promise was rejected with reason of type: ' . $type));
- }
+ function(Throwable $reason) use ($generator, $advanceGenerator) {
+ $generator->throw($reason);
$advanceGenerator();
}
- )->error(function($reason) use ($promise) {
+ )->otherwise(function(Throwable $reason) use ($promise) {
// This error handler would be called, if something in the
// generator throws an exception, and it's not caught
// locally.
@@ -94,24 +85,38 @@ function coroutine(callable $gen) {
break;
} else {
// If the value was not a promise, we'll just let it pass through.
- $lastYieldResult = $yieldedValue;
$generator->send($yieldedValue);
}
}
// If the generator is at the end, and we didn't run into an exception,
- // we can fullfill the promise with the last thing that was yielded to
- // us.
- if (!$generator->valid() && $promise->state === Promise::PENDING) {
- $promise->fulfill($lastYieldResult);
+ // We're grabbing the "return" value and fulfilling our top-level
+ // promise with its value.
+ if (!$generator->valid() && $promise->state === Promise::PENDING) {
+ $returnValue = $generator->getReturn();
+
+ // The return value is a promise.
+ if ($returnValue instanceof Promise) {
+ $returnValue->then(function($value) use ($promise) {
+ $promise->fulfill($value);
+ }, function(Throwable $reason) {
+ $promise->reject($reason);
+ });
+ } else {
+
+ $promise->fulfill($returnValue);
+
+ }
+
+
}
};
try {
$advanceGenerator();
- } catch (Exception $e) {
+ } catch (Throwable $e) {
$promise->reject($e);
}