Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../vendor/symfony/process
File: InputStream.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/*
[2] Fix | Delete
* This file is part of the Symfony package.
[3] Fix | Delete
*
[4] Fix | Delete
* (c) Fabien Potencier <fabien@symfony.com>
[5] Fix | Delete
*
[6] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[7] Fix | Delete
* file that was distributed with this source code.
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
namespace Symfony\Component\Process;
[11] Fix | Delete
[12] Fix | Delete
use Symfony\Component\Process\Exception\RuntimeException;
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Provides a way to continuously write to the input of a Process until the InputStream is closed.
[16] Fix | Delete
*
[17] Fix | Delete
* @author Nicolas Grekas <p@tchwork.com>
[18] Fix | Delete
*/
[19] Fix | Delete
class InputStream implements \IteratorAggregate
[20] Fix | Delete
{
[21] Fix | Delete
/** @var callable|null */
[22] Fix | Delete
private $onEmpty = null;
[23] Fix | Delete
private $input = [];
[24] Fix | Delete
private $open = true;
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Sets a callback that is called when the write buffer becomes empty.
[28] Fix | Delete
*/
[29] Fix | Delete
public function onEmpty(callable $onEmpty = null)
[30] Fix | Delete
{
[31] Fix | Delete
$this->onEmpty = $onEmpty;
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Appends an input to the write buffer.
[36] Fix | Delete
*
[37] Fix | Delete
* @param resource|string|int|float|bool|\Traversable|null $input The input to append as scalar,
[38] Fix | Delete
* stream resource or \Traversable
[39] Fix | Delete
*/
[40] Fix | Delete
public function write($input)
[41] Fix | Delete
{
[42] Fix | Delete
if (null === $input) {
[43] Fix | Delete
return;
[44] Fix | Delete
}
[45] Fix | Delete
if ($this->isClosed()) {
[46] Fix | Delete
throw new RuntimeException(sprintf('"%s" is closed.', static::class));
[47] Fix | Delete
}
[48] Fix | Delete
$this->input[] = ProcessUtils::validateInput(__METHOD__, $input);
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Closes the write buffer.
[53] Fix | Delete
*/
[54] Fix | Delete
public function close()
[55] Fix | Delete
{
[56] Fix | Delete
$this->open = false;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Tells whether the write buffer is closed or not.
[61] Fix | Delete
*/
[62] Fix | Delete
public function isClosed()
[63] Fix | Delete
{
[64] Fix | Delete
return !$this->open;
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
public function getIterator()
[68] Fix | Delete
{
[69] Fix | Delete
$this->open = true;
[70] Fix | Delete
[71] Fix | Delete
while ($this->open || $this->input) {
[72] Fix | Delete
if (!$this->input) {
[73] Fix | Delete
yield '';
[74] Fix | Delete
continue;
[75] Fix | Delete
}
[76] Fix | Delete
$current = array_shift($this->input);
[77] Fix | Delete
[78] Fix | Delete
if ($current instanceof \Iterator) {
[79] Fix | Delete
foreach ($current as $cur) {
[80] Fix | Delete
yield $cur;
[81] Fix | Delete
}
[82] Fix | Delete
} else {
[83] Fix | Delete
yield $current;
[84] Fix | Delete
}
[85] Fix | Delete
if (!$this->input && $this->open && null !== $onEmpty = $this->onEmpty) {
[86] Fix | Delete
$this->write($onEmpty($this));
[87] Fix | Delete
}
[88] Fix | Delete
}
[89] Fix | Delete
}
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function