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/s3/GuzzleHttp/Promise/TaskQueue.php +9 -6 1.0.31.4.1 View file →
@@ -1,6 +1,7 @@
1 1 <?php
2 2
3 +declare (strict_types=1);
3 4 namespace Dudlewebs\WPMCS\s3\GuzzleHttp\Promise;
4 5
5 6 /**
6 7 * A task queue that executes tasks in a FIFO order.
@@ -9,17 +10,19 @@
9 10 * maintains a constant stack size. You can use the task queue asynchronously
10 11 * by calling the `run()` function of the global task queue in an event loop.
11 12 *
12 13 * GuzzleHttp\Promise\Utils::queue()->run();
14 + *
15 + * @final
13 16 */
14 17 class TaskQueue implements TaskQueueInterface
15 18 {
16 19 private $enableShutdown = \true;
17 20 private $queue = [];
18 - public function __construct($withShutdown = \true)
21 + public function __construct(bool $withShutdown = \true)
19 22 {
20 23 if ($withShutdown) {
21 - \register_shutdown_function(function () {
24 + \register_shutdown_function(function () : void {
22 25 if ($this->enableShutdown) {
23 26 // Only run the tasks if an E_ERROR didn't occur.
24 27 $err = \error_get_last();
25 28 if (!$err || $err['type'] ^ \E_ERROR) {
@@ -28,17 +31,17 @@
28 31 }
29 32 });
30 33 }
31 34 }
32 - public function isEmpty()
35 + public function isEmpty() : bool
33 36 {
34 37 return !$this->queue;
35 38 }
36 - public function add(callable $task)
39 + public function add(callable $task) : void
37 40 {
38 41 $this->queue[] = $task;
39 42 }
40 - public function run()
43 + public function run() : void
41 44 {
42 45 while ($task = \array_shift($this->queue)) {
43 46 /** @var callable $task */
44 47 $task();
@@ -54,9 +57,9 @@
54 57 * or manually using the run() method) or wait on each outstanding promise.
55 58 *
56 59 * Note: This shutdown will occur before any destructors are triggered.
57 60 */
58 - public function disableShutdown()
61 + public function disableShutdown() : void
59 62 {
60 63 $this->enableShutdown = \false;
61 64 }
62 65 }