Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../vendor/guzzleht.../promises/src
File: FulfilledPromise.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace GuzzleHttp\Promise;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* A promise that has been fulfilled.
[5] Fix | Delete
*
[6] Fix | Delete
* Thenning off of this promise will invoke the onFulfilled callback
[7] Fix | Delete
* immediately and ignore other callbacks.
[8] Fix | Delete
*/
[9] Fix | Delete
class FulfilledPromise implements PromiseInterface
[10] Fix | Delete
{
[11] Fix | Delete
private $value;
[12] Fix | Delete
[13] Fix | Delete
public function __construct($value)
[14] Fix | Delete
{
[15] Fix | Delete
if (is_object($value) && method_exists($value, 'then')) {
[16] Fix | Delete
throw new \InvalidArgumentException(
[17] Fix | Delete
'You cannot create a FulfilledPromise with a promise.'
[18] Fix | Delete
);
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
$this->value = $value;
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
public function then(
[25] Fix | Delete
callable $onFulfilled = null,
[26] Fix | Delete
callable $onRejected = null
[27] Fix | Delete
) {
[28] Fix | Delete
// Return itself if there is no onFulfilled function.
[29] Fix | Delete
if (!$onFulfilled) {
[30] Fix | Delete
return $this;
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
$queue = Utils::queue();
[34] Fix | Delete
$p = new Promise([$queue, 'run']);
[35] Fix | Delete
$value = $this->value;
[36] Fix | Delete
$queue->add(static function () use ($p, $value, $onFulfilled) {
[37] Fix | Delete
if (Is::pending($p)) {
[38] Fix | Delete
try {
[39] Fix | Delete
$p->resolve($onFulfilled($value));
[40] Fix | Delete
} catch (\Throwable $e) {
[41] Fix | Delete
$p->reject($e);
[42] Fix | Delete
} catch (\Exception $e) {
[43] Fix | Delete
$p->reject($e);
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
});
[47] Fix | Delete
[48] Fix | Delete
return $p;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
public function otherwise(callable $onRejected)
[52] Fix | Delete
{
[53] Fix | Delete
return $this->then(null, $onRejected);
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
public function wait($unwrap = true, $defaultDelivery = null)
[57] Fix | Delete
{
[58] Fix | Delete
return $unwrap ? $this->value : null;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
public function getState()
[62] Fix | Delete
{
[63] Fix | Delete
return self::FULFILLED;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
public function resolve($value)
[67] Fix | Delete
{
[68] Fix | Delete
if ($value !== $this->value) {
[69] Fix | Delete
throw new \LogicException("Cannot resolve a fulfilled promise");
[70] Fix | Delete
}
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
public function reject($reason)
[74] Fix | Delete
{
[75] Fix | Delete
throw new \LogicException("Cannot reject a fulfilled promise");
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
public function cancel()
[79] Fix | Delete
{
[80] Fix | Delete
// pass
[81] Fix | Delete
}
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function