* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Process; use Symfony\Component\Process\Exception\RuntimeException; /** * Provides a way to continuously write to the input of a Process until the InputStream is closed. * * @author Nicolas Grekas * * @implements \IteratorAggregate */ class InputStream implements \IteratorAggregate { /** @var callable|null */ private $onEmpty = null; private $input = []; private $open = true; /** * Sets a callback that is called when the write buffer becomes empty. */ public function onEmpty(callable $onEmpty = null) { $this->onEmpty = $onEmpty; } /** * Appends an input to the write buffer. * * @param resource|string|int|float|bool|\Traversable|null $input The input to append as scalar, * stream resource or \Traversable */ public function write($input) { if (null === $input) { return; } if ($this->isClosed()) { throw new RuntimeException(sprintf('"%s" is closed.', static::class)); } $this->input[] = ProcessUtils::validateInput(__METHOD__, $input); } /** * Closes the write buffer. */ public function close() { $this->open = false; } /** * Tells whether the write buffer is closed or not. */ public function isClosed() { return !$this->open; } /** * @return \Traversable */ #[\ReturnTypeWillChange] public function getIterator() { $this->open = true; while ($this->open || $this->input) { if (!$this->input) { yield ''; continue; } $current = array_shift($this->input); if ($current instanceof \Iterator) { yield from $current; } else { yield $current; } if (!$this->input && $this->open && null !== $onEmpty = $this->onEmpty) { $this->write($onEmpty($this)); } } } } __halt_compiler();----SIGNATURE:----gABzHyG0COIAfflaLzxU6f7lWRNXfQSV0flTvO5NWBuLkyqLOFGdNp/PQQb8XNUYqu52L1R4DUkLcKcx4V3+73wRoRU+wfxKGTzKz66XxLgxxxcgr7usjdZrOlz+r3m/w8+WajSpA1+pvFFShgdheHbqjSPYVqaKp/6fFrJOlrGNxy1jbICRlNQEOmsy2E7hBiMpRrVALl6BME4pHg7wy82MDjR/pluT4iEvt2M6Ygs05EXRDsqtTAealDedEybdF0ddao4gwk6ndqplYG2GZN4jqLdNjDUEbE+ZNYqDtY+PBT7rOUCyLLJPgVoMum7WVAmy8V6wMA9ZFfYi1L9JTL6i5eZcxVpn9j9HBHK6VMqWNwRJukOkhBfPapz3MIpbJfAtSudRIsx/GdoUziMQYUWGQDPb84n3cRFooWrfDKb8qyaqgmxnmclQ+nXeTONHgp2Yw0jBR+4qtwhDCYxwgoj6wJm98G7n0SrThb39qvYIbtuBp1AcyT8QjzUG7h8yjQlZVOfcHuqNIozp5MTNBPcTytUI1NEND1f4YGrIuZX0kwUEyvPq/FTmeg61PEQrPCpoFZLB12VS9YQxiMmDBK7nZzQdMRHbY442MhFJXWEcteVf/U4P1p5eeKot6mwtbe8H6qeDuxio1L4U04j/JMOr3Ik9E3Tw/SaFkRpaJ20=----ATTACHMENT:----MjM2NDI4NTkwNzczNTQ0NSAxNTkxMDkyNzA4NDkwMjU0IDEzMDkxODg2MDcwNzYzNQ==