PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
← All changes | includes/sdk/google/guzzlehttp/guzzle/src/HandlerStack.php +18 -18 1.2.9 → 1.4.1 View file →
@@ -1,11 +1,11 @@
1 1 <?php
2 2
3 -namespace Dudlewebs\WPMCS\GuzzleHttp;
3 +namespace Dudlewebs\WPMCS\GCP\GuzzleHttp;
4 4
5 -use Dudlewebs\WPMCS\GuzzleHttp\Promise\PromiseInterface;
6 -use Dudlewebs\WPMCS\Psr\Http\Message\RequestInterface;
7 -use Dudlewebs\WPMCS\Psr\Http\Message\ResponseInterface;
5 +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Promise\PromiseInterface;
6 +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\RequestInterface;
7 +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\ResponseInterface;
8 8 /**
9 9 * Creates a composed Guzzle handler function by stacking middlewares on top of
10 10 * an HTTP handler function.
11 11 *
@@ -39,9 +39,9 @@
39 39 * @param (callable(RequestInterface, array): PromiseInterface)|null $handler HTTP handler function to use with the stack. If no
40 40 * handler is provided, the best handler for your
41 41 * system will be utilized.
42 42 */
43 - public static function create(?callable $handler = null): self
43 + public static function create(?callable $handler = null) : self
44 44 {
45 45 $stack = new self($handler ?: Utils::chooseHandler());
46 46 $stack->push(Middleware::httpErrors(), 'http_errors');
47 47 $stack->push(Middleware::redirect(), 'allow_redirects');
@@ -96,9 +96,9 @@
96 96 *
97 97 * @param callable(RequestInterface, array): PromiseInterface $handler Accepts a request and array of options and
98 98 * returns a Promise.
99 99 */
100 - public function setHandler(callable $handler): void
100 + public function setHandler(callable $handler) : void
101 101 {
102 102 $this->handler = $handler;
103 103 $this->cached = null;
104 104 }
@@ -104,9 +104,9 @@
104 104 }
105 105 /**
106 106 * Returns true if the builder has a handler.
107 107 */
108 - public function hasHandler(): bool
108 + public function hasHandler() : bool
109 109 {
110 110 return $this->handler !== null;
111 111 }
112 112 /**
@@ -114,9 +114,9 @@
114 114 *
115 115 * @param callable(callable): callable $middleware Middleware function
116 116 * @param string $name Name to register for this middleware.
117 117 */
118 - public function unshift(callable $middleware, ?string $name = null): void
118 + public function unshift(callable $middleware, ?string $name = null) : void
119 119 {
120 120 \array_unshift($this->stack, [$middleware, $name]);
121 121 $this->cached = null;
122 122 }
@@ -125,9 +125,9 @@
125 125 *
126 126 * @param callable(callable): callable $middleware Middleware function
127 127 * @param string $name Name to register for this middleware.
128 128 */
129 - public function push(callable $middleware, string $name = ''): void
129 + public function push(callable $middleware, string $name = '') : void
130 130 {
131 131 $this->stack[] = [$middleware, $name];
132 132 $this->cached = null;
133 133 }
@@ -137,9 +137,9 @@
137 137 * @param string $findName Middleware to find
138 138 * @param callable(callable): callable $middleware Middleware function
139 139 * @param string $withName Name to register for this middleware.
140 140 */
141 - public function before(string $findName, callable $middleware, string $withName = ''): void
141 + public function before(string $findName, callable $middleware, string $withName = '') : void
142 142 {
143 143 $this->splice($findName, $withName, $middleware, \true);
144 144 }
145 145 /**
@@ -148,9 +148,9 @@
148 148 * @param string $findName Middleware to find
149 149 * @param callable(callable): callable $middleware Middleware function
150 150 * @param string $withName Name to register for this middleware.
151 151 */
152 - public function after(string $findName, callable $middleware, string $withName = ''): void
152 + public function after(string $findName, callable $middleware, string $withName = '') : void
153 153 {
154 154 $this->splice($findName, $withName, $middleware, \false);
155 155 }
156 156 /**
@@ -157,16 +157,16 @@
157 157 * Remove a middleware by instance or name from the stack.
158 158 *
159 159 * @param callable|string $remove Middleware to remove by instance or name.
160 160 */
161 - public function remove($remove): void
161 + public function remove($remove) : void
162 162 {
163 - if (!is_string($remove) && !is_callable($remove)) {
163 + if (!\is_string($remove) && !\is_callable($remove)) {
164 164 trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a callable or string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
165 165 }
166 166 $this->cached = null;
167 167 $idx = \is_callable($remove) ? 0 : 1;
168 - $this->stack = \array_values(\array_filter($this->stack, static function ($tuple) use ($idx, $remove) {
168 + $this->stack = \array_values(\array_filter($this->stack, static function ($tuple) use($idx, $remove) {
169 169 return $tuple[$idx] !== $remove;
170 170 }));
171 171 }
172 172 /**
@@ -173,9 +173,9 @@
173 173 * Compose the middleware and handler into a single callable function.
174 174 *
175 175 * @return callable(RequestInterface, array): PromiseInterface
176 176 */
177 - public function resolve(): callable
177 + public function resolve() : callable
178 178 {
179 179 if ($this->cached === null) {
180 180 if (($prev = $this->handler) === null) {
181 181 throw new \LogicException('No handler has been specified');
@@ -187,9 +187,9 @@
187 187 $this->cached = $prev;
188 188 }
189 189 return $this->cached;
190 190 }
191 - private function findByName(string $name): int
191 + private function findByName(string $name) : int
192 192 {
193 193 foreach ($this->stack as $k => $v) {
194 194 if ($v[1] === $name) {
195 195 return $k;
@@ -199,9 +199,9 @@
199 199 }
200 200 /**
201 201 * Splices a function into the middleware list at a specific position.
202 202 */
203 - private function splice(string $findName, string $withName, callable $middleware, bool $before): void
203 + private function splice(string $findName, string $withName, callable $middleware, bool $before) : void
204 204 {
205 205 $this->cached = null;
206 206 $idx = $this->findByName($findName);
207 207 $tuple = [$middleware, $withName];
@@ -223,9 +223,9 @@
223 223 * Provides a debug string for a given callable.
224 224 *
225 225 * @param callable|string $fn Function to write as a string.
226 226 */
227 - private function debugCallable($fn): string
227 + private function debugCallable($fn) : string
228 228 {
229 229 if (\is_string($fn)) {
230 230 return "callable({$fn})";
231 231 }