← All changes
|
includes/sdk/google/guzzlehttp/promises/src/TaskQueue.php
+8
-8
1.2.12
→
1.4.2
View file →
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | declare (strict_types=1); |
| 4 | -namespace Dudlewebs\WPMCS\GuzzleHttp\Promise; | |
| 4 | +namespace Dudlewebs\WPMCS\GCP\GuzzleHttp\Promise; | |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * A task queue that executes tasks in a FIFO order. |
| 8 | 8 | * |
| @@ -20,12 +20,12 @@ | ||
| 20 | 20 | private $queue = []; |
| 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 | - $err = error_get_last(); | |
| 27 | + $err = \error_get_last(); | |
| 28 | 28 | if (!$err || $err['type'] ^ \E_ERROR) { |
| 29 | 29 | $this->run(); |
| 30 | 30 | } |
| 31 | 31 | } |
| @@ -31,19 +31,19 @@ | ||
| 31 | 31 | } |
| 32 | 32 | }); |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | - public function isEmpty(): bool | |
| 35 | + public function isEmpty() : bool | |
| 36 | 36 | { |
| 37 | 37 | return !$this->queue; |
| 38 | 38 | } |
| 39 | - public function add(callable $task): void | |
| 39 | + public function add(callable $task) : void | |
| 40 | 40 | { |
| 41 | 41 | $this->queue[] = $task; |
| 42 | 42 | } |
| 43 | - public function run(): void | |
| 43 | + public function run() : void | |
| 44 | 44 | { |
| 45 | - while ($task = array_shift($this->queue)) { | |
| 45 | + while ($task = \array_shift($this->queue)) { | |
| 46 | 46 | /** @var callable $task */ |
| 47 | 47 | $task(); |
| 48 | 48 | } |
| 49 | 49 | } |
| @@ -57,9 +57,9 @@ | ||
| 57 | 57 | * or manually using the run() method) or wait on each outstanding promise. |
| 58 | 58 | * |
| 59 | 59 | * Note: This shutdown will occur before any destructors are triggered. |
| 60 | 60 | */ |
| 61 | - public function disableShutdown(): void | |
| 61 | + public function disableShutdown() : void | |
| 62 | 62 | { |
| 63 | 63 | $this->enableShutdown = \false; |
| 64 | 64 | } |
| 65 | 65 | } |