diff options
Diffstat (limited to 'vendor/guzzlehttp/promises/src/TaskQueue.php')
-rw-r--r-- | vendor/guzzlehttp/promises/src/TaskQueue.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/vendor/guzzlehttp/promises/src/TaskQueue.php b/vendor/guzzlehttp/promises/src/TaskQueue.php index f0fba2c..503e0b2 100644 --- a/vendor/guzzlehttp/promises/src/TaskQueue.php +++ b/vendor/guzzlehttp/promises/src/TaskQueue.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace GuzzleHttp\Promise; /** @@ -10,16 +12,18 @@ namespace GuzzleHttp\Promise; * by calling the `run()` function of the global task queue in an event loop. * * GuzzleHttp\Promise\Utils::queue()->run(); + * + * @final */ class TaskQueue implements TaskQueueInterface { private $enableShutdown = true; private $queue = []; - public function __construct($withShutdown = true) + public function __construct(bool $withShutdown = true) { if ($withShutdown) { - register_shutdown_function(function () { + register_shutdown_function(function (): void { if ($this->enableShutdown) { // Only run the tasks if an E_ERROR didn't occur. $err = error_get_last(); @@ -31,17 +35,17 @@ class TaskQueue implements TaskQueueInterface } } - public function isEmpty() + public function isEmpty(): bool { return !$this->queue; } - public function add(callable $task) + public function add(callable $task): void { $this->queue[] = $task; } - public function run() + public function run(): void { while ($task = array_shift($this->queue)) { /** @var callable $task */ @@ -60,7 +64,7 @@ class TaskQueue implements TaskQueueInterface * * Note: This shutdown will occur before any destructors are triggered. */ - public function disableShutdown() + public function disableShutdown(): void { $this->enableShutdown = false; } |