← All changes
|
vendor_prefixed/guzzlehttp/guzzle/src/HandlerStack.php
+12
-4
27.7
→
trunk
View file →
| @@ -160,14 +160,22 @@ | ||
| 160 | 160 | */ |
| 161 | 161 | public function remove($remove) : void |
| 162 | 162 | { |
| 163 | 163 | if (!\is_string($remove) && !\is_callable($remove)) { |
| 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__); | |
| 164 | + \YoastSEO_Vendor\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 | - $idx = \is_callable($remove) ? 0 : 1; | |
| 168 | - $this->stack = \array_values(\array_filter($this->stack, static function ($tuple) use($idx, $remove) { | |
| 169 | - return $tuple[$idx] !== $remove; | |
| 167 | + if (\is_string($remove)) { | |
| 168 | + $count = \count($this->stack); | |
| 169 | + $this->stack = \array_values(\array_filter($this->stack, static function ($tuple) use($remove) { | |
| 170 | + return $tuple[1] !== $remove; | |
| 171 | + })); | |
| 172 | + if ($count !== \count($this->stack) || !\is_callable($remove)) { | |
| 173 | + return; | |
| 174 | + } | |
| 175 | + } | |
| 176 | + $this->stack = \array_values(\array_filter($this->stack, static function ($tuple) use($remove) { | |
| 177 | + return $tuple[0] !== $remove; | |
| 170 | 178 | })); |
| 171 | 179 | } |
| 172 | 180 | /** |
| 173 | 181 | * Compose the middleware and handler into a single callable function. |