Aggiornato Composer
This commit is contained in:
16
vendor/guzzlehttp/promises/src/TaskQueue.php
vendored
16
vendor/guzzlehttp/promises/src/TaskQueue.php
vendored
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user