Completed
Pull Request — master (#407)
by
unknown
02:40
created
lib/Vendor/GuzzleHttp/functions.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  */
16 16
 function describe_type($input) : string
17 17
 {
18
-    return Utils::describeType($input);
18
+	return Utils::describeType($input);
19 19
 }
20 20
 /**
21 21
  * Parses an array of header lines into an associative array of headers.
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  */
28 28
 function headers_from_lines(iterable $lines) : array
29 29
 {
30
-    return Utils::headersFromLines($lines);
30
+	return Utils::headersFromLines($lines);
31 31
 }
32 32
 /**
33 33
  * Returns a debug stream based on the provided variable.
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
  */
41 41
 function debug_resource($value = null)
42 42
 {
43
-    return Utils::debugResource($value);
43
+	return Utils::debugResource($value);
44 44
 }
45 45
 /**
46 46
  * Chooses and creates a default handler to use based on the environment.
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function choose_handler() : callable
57 57
 {
58
-    return Utils::chooseHandler();
58
+	return Utils::chooseHandler();
59 59
 }
60 60
 /**
61 61
  * Get the default User-Agent string to use with Guzzle.
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
  */
65 65
 function default_user_agent() : string
66 66
 {
67
-    return Utils::defaultUserAgent();
67
+	return Utils::defaultUserAgent();
68 68
 }
69 69
 /**
70 70
  * Returns the default cacert bundle for the current system.
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
  */
84 84
 function default_ca_bundle() : string
85 85
 {
86
-    return Utils::defaultCaBundle();
86
+	return Utils::defaultCaBundle();
87 87
 }
88 88
 /**
89 89
  * Creates an associative array of lowercase header names to the actual
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
  */
94 94
 function normalize_header_keys(array $headers) : array
95 95
 {
96
-    return Utils::normalizeHeaderKeys($headers);
96
+	return Utils::normalizeHeaderKeys($headers);
97 97
 }
98 98
 /**
99 99
  * Returns true if the provided host matches any of the no proxy areas.
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
  */
119 119
 function is_host_in_noproxy(string $host, array $noProxyArray) : bool
120 120
 {
121
-    return Utils::isHostInNoProxy($host, $noProxyArray);
121
+	return Utils::isHostInNoProxy($host, $noProxyArray);
122 122
 }
123 123
 /**
124 124
  * Wrapper for json_decode that throws when an error occurs.
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
  */
139 139
 function json_decode(string $json, bool $assoc = \false, int $depth = 512, int $options = 0)
140 140
 {
141
-    return Utils::jsonDecode($json, $assoc, $depth, $options);
141
+	return Utils::jsonDecode($json, $assoc, $depth, $options);
142 142
 }
143 143
 /**
144 144
  * Wrapper for JSON encoding that throws when an error occurs.
@@ -154,5 +154,5 @@  discard block
 block discarded – undo
154 154
  */
155 155
 function json_encode($value, int $options = 0, int $depth = 512) : string
156 156
 {
157
-    return Utils::jsonEncode($value, $options, $depth);
157
+	return Utils::jsonEncode($value, $options, $depth);
158 158
 }
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Promise/TaskQueueInterface.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -5,17 +5,17 @@
 block discarded – undo
5 5
 
6 6
 interface TaskQueueInterface
7 7
 {
8
-    /**
9
-     * Returns true if the queue is empty.
10
-     */
11
-    public function isEmpty() : bool;
12
-    /**
13
-     * Adds a task to the queue that will be executed the next time run is
14
-     * called.
15
-     */
16
-    public function add(callable $task) : void;
17
-    /**
18
-     * Execute all of the pending task in the queue.
19
-     */
20
-    public function run() : void;
8
+	/**
9
+	 * Returns true if the queue is empty.
10
+	 */
11
+	public function isEmpty() : bool;
12
+	/**
13
+	 * Adds a task to the queue that will be executed the next time run is
14
+	 * called.
15
+	 */
16
+	public function add(callable $task) : void;
17
+	/**
18
+	 * Execute all of the pending task in the queue.
19
+	 */
20
+	public function run() : void;
21 21
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Promise;
5 5
 
6 6
 interface TaskQueueInterface
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,7 @@
 block discarded – undo
3 3
 declare (strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Promise;
5 5
 
6
-interface TaskQueueInterface
7
-{
6
+interface TaskQueueInterface {
8 7
     /**
9 8
      * Returns true if the queue is empty.
10 9
      */
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Promise/RejectionException.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Promise;
5 5
 
6 6
 /**
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
         $this->reason = $reason;
22 22
         $message = 'The promise was rejected';
23 23
         if ($description) {
24
-            $message .= ' with reason: ' . $description;
24
+            $message .= ' with reason: '.$description;
25 25
         } elseif (\is_string($reason) || \is_object($reason) && \method_exists($reason, '__toString')) {
26
-            $message .= ' with reason: ' . $this->reason;
26
+            $message .= ' with reason: '.$this->reason;
27 27
         } elseif ($reason instanceof \JsonSerializable) {
28
-            $message .= ' with reason: ' . \json_encode($this->reason, \JSON_PRETTY_PRINT);
28
+            $message .= ' with reason: '.\json_encode($this->reason, \JSON_PRETTY_PRINT);
29 29
         }
30 30
         parent::__construct($message);
31 31
     }
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -10,32 +10,32 @@
 block discarded – undo
10 10
  */
11 11
 class RejectionException extends \RuntimeException
12 12
 {
13
-    /** @var mixed Rejection reason. */
14
-    private $reason;
15
-    /**
16
-     * @param mixed       $reason      Rejection reason.
17
-     * @param string|null $description Optional description.
18
-     */
19
-    public function __construct($reason, ?string $description = null)
20
-    {
21
-        $this->reason = $reason;
22
-        $message = 'The promise was rejected';
23
-        if ($description) {
24
-            $message .= ' with reason: ' . $description;
25
-        } elseif (\is_string($reason) || \is_object($reason) && \method_exists($reason, '__toString')) {
26
-            $message .= ' with reason: ' . $this->reason;
27
-        } elseif ($reason instanceof \JsonSerializable) {
28
-            $message .= ' with reason: ' . \json_encode($this->reason, \JSON_PRETTY_PRINT);
29
-        }
30
-        parent::__construct($message);
31
-    }
32
-    /**
33
-     * Returns the rejection reason.
34
-     *
35
-     * @return mixed
36
-     */
37
-    public function getReason()
38
-    {
39
-        return $this->reason;
40
-    }
13
+	/** @var mixed Rejection reason. */
14
+	private $reason;
15
+	/**
16
+	 * @param mixed       $reason      Rejection reason.
17
+	 * @param string|null $description Optional description.
18
+	 */
19
+	public function __construct($reason, ?string $description = null)
20
+	{
21
+		$this->reason = $reason;
22
+		$message = 'The promise was rejected';
23
+		if ($description) {
24
+			$message .= ' with reason: ' . $description;
25
+		} elseif (\is_string($reason) || \is_object($reason) && \method_exists($reason, '__toString')) {
26
+			$message .= ' with reason: ' . $this->reason;
27
+		} elseif ($reason instanceof \JsonSerializable) {
28
+			$message .= ' with reason: ' . \json_encode($this->reason, \JSON_PRETTY_PRINT);
29
+		}
30
+		parent::__construct($message);
31
+	}
32
+	/**
33
+	 * Returns the rejection reason.
34
+	 *
35
+	 * @return mixed
36
+	 */
37
+	public function getReason()
38
+	{
39
+		return $this->reason;
40
+	}
41 41
 }
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Promise/TaskQueue.php 3 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -16,50 +16,50 @@
 block discarded – undo
16 16
  */
17 17
 class TaskQueue implements TaskQueueInterface
18 18
 {
19
-    private $enableShutdown = \true;
20
-    private $queue = [];
21
-    public function __construct(bool $withShutdown = \true)
22
-    {
23
-        if ($withShutdown) {
24
-            \register_shutdown_function(function () : void {
25
-                if ($this->enableShutdown) {
26
-                    // Only run the tasks if an E_ERROR didn't occur.
27
-                    $err = \error_get_last();
28
-                    if (!$err || $err['type'] ^ \E_ERROR) {
29
-                        $this->run();
30
-                    }
31
-                }
32
-            });
33
-        }
34
-    }
35
-    public function isEmpty() : bool
36
-    {
37
-        return !$this->queue;
38
-    }
39
-    public function add(callable $task) : void
40
-    {
41
-        $this->queue[] = $task;
42
-    }
43
-    public function run() : void
44
-    {
45
-        while ($task = \array_shift($this->queue)) {
46
-            /** @var callable $task */
47
-            $task();
48
-        }
49
-    }
50
-    /**
51
-     * The task queue will be run and exhausted by default when the process
52
-     * exits IFF the exit is not the result of a PHP E_ERROR error.
53
-     *
54
-     * You can disable running the automatic shutdown of the queue by calling
55
-     * this function. If you disable the task queue shutdown process, then you
56
-     * MUST either run the task queue (as a result of running your event loop
57
-     * or manually using the run() method) or wait on each outstanding promise.
58
-     *
59
-     * Note: This shutdown will occur before any destructors are triggered.
60
-     */
61
-    public function disableShutdown() : void
62
-    {
63
-        $this->enableShutdown = \false;
64
-    }
19
+	private $enableShutdown = \true;
20
+	private $queue = [];
21
+	public function __construct(bool $withShutdown = \true)
22
+	{
23
+		if ($withShutdown) {
24
+			\register_shutdown_function(function () : void {
25
+				if ($this->enableShutdown) {
26
+					// Only run the tasks if an E_ERROR didn't occur.
27
+					$err = \error_get_last();
28
+					if (!$err || $err['type'] ^ \E_ERROR) {
29
+						$this->run();
30
+					}
31
+				}
32
+			});
33
+		}
34
+	}
35
+	public function isEmpty() : bool
36
+	{
37
+		return !$this->queue;
38
+	}
39
+	public function add(callable $task) : void
40
+	{
41
+		$this->queue[] = $task;
42
+	}
43
+	public function run() : void
44
+	{
45
+		while ($task = \array_shift($this->queue)) {
46
+			/** @var callable $task */
47
+			$task();
48
+		}
49
+	}
50
+	/**
51
+	 * The task queue will be run and exhausted by default when the process
52
+	 * exits IFF the exit is not the result of a PHP E_ERROR error.
53
+	 *
54
+	 * You can disable running the automatic shutdown of the queue by calling
55
+	 * this function. If you disable the task queue shutdown process, then you
56
+	 * MUST either run the task queue (as a result of running your event loop
57
+	 * or manually using the run() method) or wait on each outstanding promise.
58
+	 *
59
+	 * Note: This shutdown will occur before any destructors are triggered.
60
+	 */
61
+	public function disableShutdown() : void
62
+	{
63
+		$this->enableShutdown = \false;
64
+	}
65 65
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Promise;
5 5
 
6 6
 /**
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     public function __construct(bool $withShutdown = \true)
22 22
     {
23 23
         if ($withShutdown) {
24
-            \register_shutdown_function(function () : void {
24
+            \register_shutdown_function(function() : void {
25 25
                 if ($this->enableShutdown) {
26 26
                     // Only run the tasks if an E_ERROR didn't occur.
27 27
                     $err = \error_get_last();
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,7 @@
 block discarded – undo
14 14
  *
15 15
  * @final
16 16
  */
17
-class TaskQueue implements TaskQueueInterface
18
-{
17
+class TaskQueue implements TaskQueueInterface {
19 18
     private $enableShutdown = \true;
20 19
     private $queue = [];
21 20
     public function __construct(bool $withShutdown = \true)
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Promise/FulfilledPromise.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Promise;
5 5
 
6 6
 /**
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $queue = Utils::queue();
34 34
         $p = new Promise([$queue, 'run']);
35 35
         $value = $this->value;
36
-        $queue->add(static function () use($p, $value, $onFulfilled) : void {
36
+        $queue->add(static function() use($p, $value, $onFulfilled) : void {
37 37
             if (Is::pending($p)) {
38 38
                 try {
39 39
                     $p->resolve($onFulfilled($value));
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@
 block discarded – undo
11 11
  *
12 12
  * @final
13 13
  */
14
-class FulfilledPromise implements PromiseInterface
15
-{
14
+class FulfilledPromise implements PromiseInterface {
16 15
     private $value;
17 16
     /**
18 17
      * @param mixed $value
Please login to merge, or discard this patch.
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -13,61 +13,61 @@
 block discarded – undo
13 13
  */
14 14
 class FulfilledPromise implements PromiseInterface
15 15
 {
16
-    private $value;
17
-    /**
18
-     * @param mixed $value
19
-     */
20
-    public function __construct($value)
21
-    {
22
-        if (\is_object($value) && \method_exists($value, 'then')) {
23
-            throw new \InvalidArgumentException('You cannot create a FulfilledPromise with a promise.');
24
-        }
25
-        $this->value = $value;
26
-    }
27
-    public function then(?callable $onFulfilled = null, ?callable $onRejected = null) : PromiseInterface
28
-    {
29
-        // Return itself if there is no onFulfilled function.
30
-        if (!$onFulfilled) {
31
-            return $this;
32
-        }
33
-        $queue = Utils::queue();
34
-        $p = new Promise([$queue, 'run']);
35
-        $value = $this->value;
36
-        $queue->add(static function () use($p, $value, $onFulfilled) : void {
37
-            if (Is::pending($p)) {
38
-                try {
39
-                    $p->resolve($onFulfilled($value));
40
-                } catch (\Throwable $e) {
41
-                    $p->reject($e);
42
-                }
43
-            }
44
-        });
45
-        return $p;
46
-    }
47
-    public function otherwise(callable $onRejected) : PromiseInterface
48
-    {
49
-        return $this->then(null, $onRejected);
50
-    }
51
-    public function wait(bool $unwrap = \true)
52
-    {
53
-        return $unwrap ? $this->value : null;
54
-    }
55
-    public function getState() : string
56
-    {
57
-        return self::FULFILLED;
58
-    }
59
-    public function resolve($value) : void
60
-    {
61
-        if ($value !== $this->value) {
62
-            throw new \LogicException('Cannot resolve a fulfilled promise');
63
-        }
64
-    }
65
-    public function reject($reason) : void
66
-    {
67
-        throw new \LogicException('Cannot reject a fulfilled promise');
68
-    }
69
-    public function cancel() : void
70
-    {
71
-        // pass
72
-    }
16
+	private $value;
17
+	/**
18
+	 * @param mixed $value
19
+	 */
20
+	public function __construct($value)
21
+	{
22
+		if (\is_object($value) && \method_exists($value, 'then')) {
23
+			throw new \InvalidArgumentException('You cannot create a FulfilledPromise with a promise.');
24
+		}
25
+		$this->value = $value;
26
+	}
27
+	public function then(?callable $onFulfilled = null, ?callable $onRejected = null) : PromiseInterface
28
+	{
29
+		// Return itself if there is no onFulfilled function.
30
+		if (!$onFulfilled) {
31
+			return $this;
32
+		}
33
+		$queue = Utils::queue();
34
+		$p = new Promise([$queue, 'run']);
35
+		$value = $this->value;
36
+		$queue->add(static function () use($p, $value, $onFulfilled) : void {
37
+			if (Is::pending($p)) {
38
+				try {
39
+					$p->resolve($onFulfilled($value));
40
+				} catch (\Throwable $e) {
41
+					$p->reject($e);
42
+				}
43
+			}
44
+		});
45
+		return $p;
46
+	}
47
+	public function otherwise(callable $onRejected) : PromiseInterface
48
+	{
49
+		return $this->then(null, $onRejected);
50
+	}
51
+	public function wait(bool $unwrap = \true)
52
+	{
53
+		return $unwrap ? $this->value : null;
54
+	}
55
+	public function getState() : string
56
+	{
57
+		return self::FULFILLED;
58
+	}
59
+	public function resolve($value) : void
60
+	{
61
+		if ($value !== $this->value) {
62
+			throw new \LogicException('Cannot resolve a fulfilled promise');
63
+		}
64
+	}
65
+	public function reject($reason) : void
66
+	{
67
+		throw new \LogicException('Cannot reject a fulfilled promise');
68
+	}
69
+	public function cancel() : void
70
+	{
71
+		// pass
72
+	}
73 73
 }
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Promise/EachPromise.php 3 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -11,186 +11,186 @@
 block discarded – undo
11 11
  */
12 12
 class EachPromise implements PromisorInterface
13 13
 {
14
-    private $pending = [];
15
-    private $nextPendingIndex = 0;
16
-    /** @var \Iterator|null */
17
-    private $iterable;
18
-    /** @var callable|int|null */
19
-    private $concurrency;
20
-    /** @var callable|null */
21
-    private $onFulfilled;
22
-    /** @var callable|null */
23
-    private $onRejected;
24
-    /** @var Promise|null */
25
-    private $aggregate;
26
-    /** @var bool|null */
27
-    private $mutex;
28
-    /**
29
-     * Configuration hash can include the following key value pairs:
30
-     *
31
-     * - fulfilled: (callable) Invoked when a promise fulfills. The function
32
-     *   is invoked with three arguments: the fulfillment value, the index
33
-     *   position from the iterable list of the promise, and the aggregate
34
-     *   promise that manages all of the promises. The aggregate promise may
35
-     *   be resolved from within the callback to short-circuit the promise.
36
-     * - rejected: (callable) Invoked when a promise is rejected. The
37
-     *   function is invoked with three arguments: the rejection reason, the
38
-     *   index position from the iterable list of the promise, and the
39
-     *   aggregate promise that manages all of the promises. The aggregate
40
-     *   promise may be resolved from within the callback to short-circuit
41
-     *   the promise.
42
-     * - concurrency: (integer) Pass this configuration option to limit the
43
-     *   allowed number of outstanding concurrently executing promises,
44
-     *   creating a capped pool of promises. There is no limit by default.
45
-     *
46
-     * @param mixed $iterable Promises or values to iterate.
47
-     * @param array $config   Configuration options
48
-     */
49
-    public function __construct($iterable, array $config = [])
50
-    {
51
-        $this->iterable = Create::iterFor($iterable);
52
-        if (isset($config['concurrency'])) {
53
-            $this->concurrency = $config['concurrency'];
54
-        }
55
-        if (isset($config['fulfilled'])) {
56
-            $this->onFulfilled = $config['fulfilled'];
57
-        }
58
-        if (isset($config['rejected'])) {
59
-            $this->onRejected = $config['rejected'];
60
-        }
61
-    }
62
-    /** @psalm-suppress InvalidNullableReturnType */
63
-    public function promise() : PromiseInterface
64
-    {
65
-        if ($this->aggregate) {
66
-            return $this->aggregate;
67
-        }
68
-        try {
69
-            $this->createPromise();
70
-            /** @psalm-assert Promise $this->aggregate */
71
-            $this->iterable->rewind();
72
-            $this->refillPending();
73
-        } catch (\Throwable $e) {
74
-            $this->aggregate->reject($e);
75
-        }
76
-        /**
77
-         * @psalm-suppress NullableReturnStatement
78
-         */
79
-        return $this->aggregate;
80
-    }
81
-    private function createPromise() : void
82
-    {
83
-        $this->mutex = \false;
84
-        $this->aggregate = new Promise(function () : void {
85
-            if ($this->checkIfFinished()) {
86
-                return;
87
-            }
88
-            \reset($this->pending);
89
-            // Consume a potentially fluctuating list of promises while
90
-            // ensuring that indexes are maintained (precluding array_shift).
91
-            while ($promise = \current($this->pending)) {
92
-                \next($this->pending);
93
-                $promise->wait();
94
-                if (Is::settled($this->aggregate)) {
95
-                    return;
96
-                }
97
-            }
98
-        });
99
-        // Clear the references when the promise is resolved.
100
-        $clearFn = function () : void {
101
-            $this->iterable = $this->concurrency = $this->pending = null;
102
-            $this->onFulfilled = $this->onRejected = null;
103
-            $this->nextPendingIndex = 0;
104
-        };
105
-        $this->aggregate->then($clearFn, $clearFn);
106
-    }
107
-    private function refillPending() : void
108
-    {
109
-        if (!$this->concurrency) {
110
-            // Add all pending promises.
111
-            while ($this->addPending() && $this->advanceIterator()) {
112
-            }
113
-            return;
114
-        }
115
-        // Add only up to N pending promises.
116
-        $concurrency = \is_callable($this->concurrency) ? ($this->concurrency)(\count($this->pending)) : $this->concurrency;
117
-        $concurrency = \max($concurrency - \count($this->pending), 0);
118
-        // Concurrency may be set to 0 to disallow new promises.
119
-        if (!$concurrency) {
120
-            return;
121
-        }
122
-        // Add the first pending promise.
123
-        $this->addPending();
124
-        // Note this is special handling for concurrency=1 so that we do
125
-        // not advance the iterator after adding the first promise. This
126
-        // helps work around issues with generators that might not have the
127
-        // next value to yield until promise callbacks are called.
128
-        while (--$concurrency && $this->advanceIterator() && $this->addPending()) {
129
-        }
130
-    }
131
-    private function addPending() : bool
132
-    {
133
-        if (!$this->iterable || !$this->iterable->valid()) {
134
-            return \false;
135
-        }
136
-        $promise = Create::promiseFor($this->iterable->current());
137
-        $key = $this->iterable->key();
138
-        // Iterable keys may not be unique, so we use a counter to
139
-        // guarantee uniqueness
140
-        $idx = $this->nextPendingIndex++;
141
-        $this->pending[$idx] = $promise->then(function ($value) use($idx, $key) : void {
142
-            if ($this->onFulfilled) {
143
-                ($this->onFulfilled)($value, $key, $this->aggregate);
144
-            }
145
-            $this->step($idx);
146
-        }, function ($reason) use($idx, $key) : void {
147
-            if ($this->onRejected) {
148
-                ($this->onRejected)($reason, $key, $this->aggregate);
149
-            }
150
-            $this->step($idx);
151
-        });
152
-        return \true;
153
-    }
154
-    private function advanceIterator() : bool
155
-    {
156
-        // Place a lock on the iterator so that we ensure to not recurse,
157
-        // preventing fatal generator errors.
158
-        if ($this->mutex) {
159
-            return \false;
160
-        }
161
-        $this->mutex = \true;
162
-        try {
163
-            $this->iterable->next();
164
-            $this->mutex = \false;
165
-            return \true;
166
-        } catch (\Throwable $e) {
167
-            $this->aggregate->reject($e);
168
-            $this->mutex = \false;
169
-            return \false;
170
-        }
171
-    }
172
-    private function step(int $idx) : void
173
-    {
174
-        // If the promise was already resolved, then ignore this step.
175
-        if (Is::settled($this->aggregate)) {
176
-            return;
177
-        }
178
-        unset($this->pending[$idx]);
179
-        // Only refill pending promises if we are not locked, preventing the
180
-        // EachPromise to recursively invoke the provided iterator, which
181
-        // cause a fatal error: "Cannot resume an already running generator"
182
-        if ($this->advanceIterator() && !$this->checkIfFinished()) {
183
-            // Add more pending promises if possible.
184
-            $this->refillPending();
185
-        }
186
-    }
187
-    private function checkIfFinished() : bool
188
-    {
189
-        if (!$this->pending && !$this->iterable->valid()) {
190
-            // Resolve the promise if there's nothing left to do.
191
-            $this->aggregate->resolve(null);
192
-            return \true;
193
-        }
194
-        return \false;
195
-    }
14
+	private $pending = [];
15
+	private $nextPendingIndex = 0;
16
+	/** @var \Iterator|null */
17
+	private $iterable;
18
+	/** @var callable|int|null */
19
+	private $concurrency;
20
+	/** @var callable|null */
21
+	private $onFulfilled;
22
+	/** @var callable|null */
23
+	private $onRejected;
24
+	/** @var Promise|null */
25
+	private $aggregate;
26
+	/** @var bool|null */
27
+	private $mutex;
28
+	/**
29
+	 * Configuration hash can include the following key value pairs:
30
+	 *
31
+	 * - fulfilled: (callable) Invoked when a promise fulfills. The function
32
+	 *   is invoked with three arguments: the fulfillment value, the index
33
+	 *   position from the iterable list of the promise, and the aggregate
34
+	 *   promise that manages all of the promises. The aggregate promise may
35
+	 *   be resolved from within the callback to short-circuit the promise.
36
+	 * - rejected: (callable) Invoked when a promise is rejected. The
37
+	 *   function is invoked with three arguments: the rejection reason, the
38
+	 *   index position from the iterable list of the promise, and the
39
+	 *   aggregate promise that manages all of the promises. The aggregate
40
+	 *   promise may be resolved from within the callback to short-circuit
41
+	 *   the promise.
42
+	 * - concurrency: (integer) Pass this configuration option to limit the
43
+	 *   allowed number of outstanding concurrently executing promises,
44
+	 *   creating a capped pool of promises. There is no limit by default.
45
+	 *
46
+	 * @param mixed $iterable Promises or values to iterate.
47
+	 * @param array $config   Configuration options
48
+	 */
49
+	public function __construct($iterable, array $config = [])
50
+	{
51
+		$this->iterable = Create::iterFor($iterable);
52
+		if (isset($config['concurrency'])) {
53
+			$this->concurrency = $config['concurrency'];
54
+		}
55
+		if (isset($config['fulfilled'])) {
56
+			$this->onFulfilled = $config['fulfilled'];
57
+		}
58
+		if (isset($config['rejected'])) {
59
+			$this->onRejected = $config['rejected'];
60
+		}
61
+	}
62
+	/** @psalm-suppress InvalidNullableReturnType */
63
+	public function promise() : PromiseInterface
64
+	{
65
+		if ($this->aggregate) {
66
+			return $this->aggregate;
67
+		}
68
+		try {
69
+			$this->createPromise();
70
+			/** @psalm-assert Promise $this->aggregate */
71
+			$this->iterable->rewind();
72
+			$this->refillPending();
73
+		} catch (\Throwable $e) {
74
+			$this->aggregate->reject($e);
75
+		}
76
+		/**
77
+		 * @psalm-suppress NullableReturnStatement
78
+		 */
79
+		return $this->aggregate;
80
+	}
81
+	private function createPromise() : void
82
+	{
83
+		$this->mutex = \false;
84
+		$this->aggregate = new Promise(function () : void {
85
+			if ($this->checkIfFinished()) {
86
+				return;
87
+			}
88
+			\reset($this->pending);
89
+			// Consume a potentially fluctuating list of promises while
90
+			// ensuring that indexes are maintained (precluding array_shift).
91
+			while ($promise = \current($this->pending)) {
92
+				\next($this->pending);
93
+				$promise->wait();
94
+				if (Is::settled($this->aggregate)) {
95
+					return;
96
+				}
97
+			}
98
+		});
99
+		// Clear the references when the promise is resolved.
100
+		$clearFn = function () : void {
101
+			$this->iterable = $this->concurrency = $this->pending = null;
102
+			$this->onFulfilled = $this->onRejected = null;
103
+			$this->nextPendingIndex = 0;
104
+		};
105
+		$this->aggregate->then($clearFn, $clearFn);
106
+	}
107
+	private function refillPending() : void
108
+	{
109
+		if (!$this->concurrency) {
110
+			// Add all pending promises.
111
+			while ($this->addPending() && $this->advanceIterator()) {
112
+			}
113
+			return;
114
+		}
115
+		// Add only up to N pending promises.
116
+		$concurrency = \is_callable($this->concurrency) ? ($this->concurrency)(\count($this->pending)) : $this->concurrency;
117
+		$concurrency = \max($concurrency - \count($this->pending), 0);
118
+		// Concurrency may be set to 0 to disallow new promises.
119
+		if (!$concurrency) {
120
+			return;
121
+		}
122
+		// Add the first pending promise.
123
+		$this->addPending();
124
+		// Note this is special handling for concurrency=1 so that we do
125
+		// not advance the iterator after adding the first promise. This
126
+		// helps work around issues with generators that might not have the
127
+		// next value to yield until promise callbacks are called.
128
+		while (--$concurrency && $this->advanceIterator() && $this->addPending()) {
129
+		}
130
+	}
131
+	private function addPending() : bool
132
+	{
133
+		if (!$this->iterable || !$this->iterable->valid()) {
134
+			return \false;
135
+		}
136
+		$promise = Create::promiseFor($this->iterable->current());
137
+		$key = $this->iterable->key();
138
+		// Iterable keys may not be unique, so we use a counter to
139
+		// guarantee uniqueness
140
+		$idx = $this->nextPendingIndex++;
141
+		$this->pending[$idx] = $promise->then(function ($value) use($idx, $key) : void {
142
+			if ($this->onFulfilled) {
143
+				($this->onFulfilled)($value, $key, $this->aggregate);
144
+			}
145
+			$this->step($idx);
146
+		}, function ($reason) use($idx, $key) : void {
147
+			if ($this->onRejected) {
148
+				($this->onRejected)($reason, $key, $this->aggregate);
149
+			}
150
+			$this->step($idx);
151
+		});
152
+		return \true;
153
+	}
154
+	private function advanceIterator() : bool
155
+	{
156
+		// Place a lock on the iterator so that we ensure to not recurse,
157
+		// preventing fatal generator errors.
158
+		if ($this->mutex) {
159
+			return \false;
160
+		}
161
+		$this->mutex = \true;
162
+		try {
163
+			$this->iterable->next();
164
+			$this->mutex = \false;
165
+			return \true;
166
+		} catch (\Throwable $e) {
167
+			$this->aggregate->reject($e);
168
+			$this->mutex = \false;
169
+			return \false;
170
+		}
171
+	}
172
+	private function step(int $idx) : void
173
+	{
174
+		// If the promise was already resolved, then ignore this step.
175
+		if (Is::settled($this->aggregate)) {
176
+			return;
177
+		}
178
+		unset($this->pending[$idx]);
179
+		// Only refill pending promises if we are not locked, preventing the
180
+		// EachPromise to recursively invoke the provided iterator, which
181
+		// cause a fatal error: "Cannot resume an already running generator"
182
+		if ($this->advanceIterator() && !$this->checkIfFinished()) {
183
+			// Add more pending promises if possible.
184
+			$this->refillPending();
185
+		}
186
+	}
187
+	private function checkIfFinished() : bool
188
+	{
189
+		if (!$this->pending && !$this->iterable->valid()) {
190
+			// Resolve the promise if there's nothing left to do.
191
+			$this->aggregate->resolve(null);
192
+			return \true;
193
+		}
194
+		return \false;
195
+	}
196 196
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Promise;
5 5
 
6 6
 /**
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     private function createPromise() : void
82 82
     {
83 83
         $this->mutex = \false;
84
-        $this->aggregate = new Promise(function () : void {
84
+        $this->aggregate = new Promise(function() : void {
85 85
             if ($this->checkIfFinished()) {
86 86
                 return;
87 87
             }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             }
98 98
         });
99 99
         // Clear the references when the promise is resolved.
100
-        $clearFn = function () : void {
100
+        $clearFn = function() : void {
101 101
             $this->iterable = $this->concurrency = $this->pending = null;
102 102
             $this->onFulfilled = $this->onRejected = null;
103 103
             $this->nextPendingIndex = 0;
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
         // Iterable keys may not be unique, so we use a counter to
139 139
         // guarantee uniqueness
140 140
         $idx = $this->nextPendingIndex++;
141
-        $this->pending[$idx] = $promise->then(function ($value) use($idx, $key) : void {
141
+        $this->pending[$idx] = $promise->then(function($value) use($idx, $key) : void {
142 142
             if ($this->onFulfilled) {
143 143
                 ($this->onFulfilled)($value, $key, $this->aggregate);
144 144
             }
145 145
             $this->step($idx);
146
-        }, function ($reason) use($idx, $key) : void {
146
+        }, function($reason) use($idx, $key) : void {
147 147
             if ($this->onRejected) {
148 148
                 ($this->onRejected)($reason, $key, $this->aggregate);
149 149
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@
 block discarded – undo
9 9
  *
10 10
  * @final
11 11
  */
12
-class EachPromise implements PromisorInterface
13
-{
12
+class EachPromise implements PromisorInterface {
14 13
     private $pending = [];
15 14
     private $nextPendingIndex = 0;
16 15
     /** @var \Iterator|null */
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Promise/Is.php 3 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -5,32 +5,32 @@
 block discarded – undo
5 5
 
6 6
 final class Is
7 7
 {
8
-    /**
9
-     * Returns true if a promise is pending.
10
-     */
11
-    public static function pending(PromiseInterface $promise) : bool
12
-    {
13
-        return $promise->getState() === PromiseInterface::PENDING;
14
-    }
15
-    /**
16
-     * Returns true if a promise is fulfilled or rejected.
17
-     */
18
-    public static function settled(PromiseInterface $promise) : bool
19
-    {
20
-        return $promise->getState() !== PromiseInterface::PENDING;
21
-    }
22
-    /**
23
-     * Returns true if a promise is fulfilled.
24
-     */
25
-    public static function fulfilled(PromiseInterface $promise) : bool
26
-    {
27
-        return $promise->getState() === PromiseInterface::FULFILLED;
28
-    }
29
-    /**
30
-     * Returns true if a promise is rejected.
31
-     */
32
-    public static function rejected(PromiseInterface $promise) : bool
33
-    {
34
-        return $promise->getState() === PromiseInterface::REJECTED;
35
-    }
8
+	/**
9
+	 * Returns true if a promise is pending.
10
+	 */
11
+	public static function pending(PromiseInterface $promise) : bool
12
+	{
13
+		return $promise->getState() === PromiseInterface::PENDING;
14
+	}
15
+	/**
16
+	 * Returns true if a promise is fulfilled or rejected.
17
+	 */
18
+	public static function settled(PromiseInterface $promise) : bool
19
+	{
20
+		return $promise->getState() !== PromiseInterface::PENDING;
21
+	}
22
+	/**
23
+	 * Returns true if a promise is fulfilled.
24
+	 */
25
+	public static function fulfilled(PromiseInterface $promise) : bool
26
+	{
27
+		return $promise->getState() === PromiseInterface::FULFILLED;
28
+	}
29
+	/**
30
+	 * Returns true if a promise is rejected.
31
+	 */
32
+	public static function rejected(PromiseInterface $promise) : bool
33
+	{
34
+		return $promise->getState() === PromiseInterface::REJECTED;
35
+	}
36 36
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Promise;
5 5
 
6 6
 final class Is
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,7 @@
 block discarded – undo
3 3
 declare (strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Promise;
5 5
 
6
-final class Is
7
-{
6
+final class Is {
8 7
     /**
9 8
      * Returns true if a promise is pending.
10 9
      */
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Promise/RejectedPromise.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Promise;
5 5
 
6 6
 /**
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $queue = Utils::queue();
34 34
         $reason = $this->reason;
35 35
         $p = new Promise([$queue, 'run']);
36
-        $queue->add(static function () use($p, $reason, $onRejected) : void {
36
+        $queue->add(static function() use($p, $reason, $onRejected) : void {
37 37
             if (Is::pending($p)) {
38 38
                 try {
39 39
                     // Return a resolved promise if onRejected does not throw.
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@
 block discarded – undo
11 11
  *
12 12
  * @final
13 13
  */
14
-class RejectedPromise implements PromiseInterface
15
-{
14
+class RejectedPromise implements PromiseInterface {
16 15
     private $reason;
17 16
     /**
18 17
      * @param mixed $reason
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -13,66 +13,66 @@
 block discarded – undo
13 13
  */
14 14
 class RejectedPromise implements PromiseInterface
15 15
 {
16
-    private $reason;
17
-    /**
18
-     * @param mixed $reason
19
-     */
20
-    public function __construct($reason)
21
-    {
22
-        if (\is_object($reason) && \method_exists($reason, 'then')) {
23
-            throw new \InvalidArgumentException('You cannot create a RejectedPromise with a promise.');
24
-        }
25
-        $this->reason = $reason;
26
-    }
27
-    public function then(?callable $onFulfilled = null, ?callable $onRejected = null) : PromiseInterface
28
-    {
29
-        // If there's no onRejected callback then just return self.
30
-        if (!$onRejected) {
31
-            return $this;
32
-        }
33
-        $queue = Utils::queue();
34
-        $reason = $this->reason;
35
-        $p = new Promise([$queue, 'run']);
36
-        $queue->add(static function () use($p, $reason, $onRejected) : void {
37
-            if (Is::pending($p)) {
38
-                try {
39
-                    // Return a resolved promise if onRejected does not throw.
40
-                    $p->resolve($onRejected($reason));
41
-                } catch (\Throwable $e) {
42
-                    // onRejected threw, so return a rejected promise.
43
-                    $p->reject($e);
44
-                }
45
-            }
46
-        });
47
-        return $p;
48
-    }
49
-    public function otherwise(callable $onRejected) : PromiseInterface
50
-    {
51
-        return $this->then(null, $onRejected);
52
-    }
53
-    public function wait(bool $unwrap = \true)
54
-    {
55
-        if ($unwrap) {
56
-            throw Create::exceptionFor($this->reason);
57
-        }
58
-        return null;
59
-    }
60
-    public function getState() : string
61
-    {
62
-        return self::REJECTED;
63
-    }
64
-    public function resolve($value) : void
65
-    {
66
-        throw new \LogicException('Cannot resolve a rejected promise');
67
-    }
68
-    public function reject($reason) : void
69
-    {
70
-        if ($reason !== $this->reason) {
71
-            throw new \LogicException('Cannot reject a rejected promise');
72
-        }
73
-    }
74
-    public function cancel() : void
75
-    {
76
-        // pass
77
-    }
16
+	private $reason;
17
+	/**
18
+	 * @param mixed $reason
19
+	 */
20
+	public function __construct($reason)
21
+	{
22
+		if (\is_object($reason) && \method_exists($reason, 'then')) {
23
+			throw new \InvalidArgumentException('You cannot create a RejectedPromise with a promise.');
24
+		}
25
+		$this->reason = $reason;
26
+	}
27
+	public function then(?callable $onFulfilled = null, ?callable $onRejected = null) : PromiseInterface
28
+	{
29
+		// If there's no onRejected callback then just return self.
30
+		if (!$onRejected) {
31
+			return $this;
32
+		}
33
+		$queue = Utils::queue();
34
+		$reason = $this->reason;
35
+		$p = new Promise([$queue, 'run']);
36
+		$queue->add(static function () use($p, $reason, $onRejected) : void {
37
+			if (Is::pending($p)) {
38
+				try {
39
+					// Return a resolved promise if onRejected does not throw.
40
+					$p->resolve($onRejected($reason));
41
+				} catch (\Throwable $e) {
42
+					// onRejected threw, so return a rejected promise.
43
+					$p->reject($e);
44
+				}
45
+			}
46
+		});
47
+		return $p;
48
+	}
49
+	public function otherwise(callable $onRejected) : PromiseInterface
50
+	{
51
+		return $this->then(null, $onRejected);
52
+	}
53
+	public function wait(bool $unwrap = \true)
54
+	{
55
+		if ($unwrap) {
56
+			throw Create::exceptionFor($this->reason);
57
+		}
58
+		return null;
59
+	}
60
+	public function getState() : string
61
+	{
62
+		return self::REJECTED;
63
+	}
64
+	public function resolve($value) : void
65
+	{
66
+		throw new \LogicException('Cannot resolve a rejected promise');
67
+	}
68
+	public function reject($reason) : void
69
+	{
70
+		if ($reason !== $this->reason) {
71
+			throw new \LogicException('Cannot reject a rejected promise');
72
+		}
73
+	}
74
+	public function cancel() : void
75
+	{
76
+		// pass
77
+	}
78 78
 }
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Promise/Create.php 3 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -5,64 +5,64 @@
 block discarded – undo
5 5
 
6 6
 final class Create
7 7
 {
8
-    /**
9
-     * Creates a promise for a value if the value is not a promise.
10
-     *
11
-     * @param mixed $value Promise or value.
12
-     */
13
-    public static function promiseFor($value) : PromiseInterface
14
-    {
15
-        if ($value instanceof PromiseInterface) {
16
-            return $value;
17
-        }
18
-        // Return a Guzzle promise that shadows the given promise.
19
-        if (\is_object($value) && \method_exists($value, 'then')) {
20
-            $wfn = \method_exists($value, 'wait') ? [$value, 'wait'] : null;
21
-            $cfn = \method_exists($value, 'cancel') ? [$value, 'cancel'] : null;
22
-            $promise = new Promise($wfn, $cfn);
23
-            $value->then([$promise, 'resolve'], [$promise, 'reject']);
24
-            return $promise;
25
-        }
26
-        return new FulfilledPromise($value);
27
-    }
28
-    /**
29
-     * Creates a rejected promise for a reason if the reason is not a promise.
30
-     * If the provided reason is a promise, then it is returned as-is.
31
-     *
32
-     * @param mixed $reason Promise or reason.
33
-     */
34
-    public static function rejectionFor($reason) : PromiseInterface
35
-    {
36
-        if ($reason instanceof PromiseInterface) {
37
-            return $reason;
38
-        }
39
-        return new RejectedPromise($reason);
40
-    }
41
-    /**
42
-     * Create an exception for a rejected promise value.
43
-     *
44
-     * @param mixed $reason
45
-     */
46
-    public static function exceptionFor($reason) : \Throwable
47
-    {
48
-        if ($reason instanceof \Throwable) {
49
-            return $reason;
50
-        }
51
-        return new RejectionException($reason);
52
-    }
53
-    /**
54
-     * Returns an iterator for the given value.
55
-     *
56
-     * @param mixed $value
57
-     */
58
-    public static function iterFor($value) : \Iterator
59
-    {
60
-        if ($value instanceof \Iterator) {
61
-            return $value;
62
-        }
63
-        if (\is_array($value)) {
64
-            return new \ArrayIterator($value);
65
-        }
66
-        return new \ArrayIterator([$value]);
67
-    }
8
+	/**
9
+	 * Creates a promise for a value if the value is not a promise.
10
+	 *
11
+	 * @param mixed $value Promise or value.
12
+	 */
13
+	public static function promiseFor($value) : PromiseInterface
14
+	{
15
+		if ($value instanceof PromiseInterface) {
16
+			return $value;
17
+		}
18
+		// Return a Guzzle promise that shadows the given promise.
19
+		if (\is_object($value) && \method_exists($value, 'then')) {
20
+			$wfn = \method_exists($value, 'wait') ? [$value, 'wait'] : null;
21
+			$cfn = \method_exists($value, 'cancel') ? [$value, 'cancel'] : null;
22
+			$promise = new Promise($wfn, $cfn);
23
+			$value->then([$promise, 'resolve'], [$promise, 'reject']);
24
+			return $promise;
25
+		}
26
+		return new FulfilledPromise($value);
27
+	}
28
+	/**
29
+	 * Creates a rejected promise for a reason if the reason is not a promise.
30
+	 * If the provided reason is a promise, then it is returned as-is.
31
+	 *
32
+	 * @param mixed $reason Promise or reason.
33
+	 */
34
+	public static function rejectionFor($reason) : PromiseInterface
35
+	{
36
+		if ($reason instanceof PromiseInterface) {
37
+			return $reason;
38
+		}
39
+		return new RejectedPromise($reason);
40
+	}
41
+	/**
42
+	 * Create an exception for a rejected promise value.
43
+	 *
44
+	 * @param mixed $reason
45
+	 */
46
+	public static function exceptionFor($reason) : \Throwable
47
+	{
48
+		if ($reason instanceof \Throwable) {
49
+			return $reason;
50
+		}
51
+		return new RejectionException($reason);
52
+	}
53
+	/**
54
+	 * Returns an iterator for the given value.
55
+	 *
56
+	 * @param mixed $value
57
+	 */
58
+	public static function iterFor($value) : \Iterator
59
+	{
60
+		if ($value instanceof \Iterator) {
61
+			return $value;
62
+		}
63
+		if (\is_array($value)) {
64
+			return new \ArrayIterator($value);
65
+		}
66
+		return new \ArrayIterator([$value]);
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Promise;
5 5
 
6 6
 final class Create
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,7 @@
 block discarded – undo
3 3
 declare (strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Promise;
5 5
 
6
-final class Create
7
-{
6
+final class Create {
8 7
     /**
9 8
      * Creates a promise for a value if the value is not a promise.
10 9
      *
Please login to merge, or discard this patch.