* * 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:----fKinkQPWZj9+uJby8eSrA5UULPE2IEbL21ahZi9huhNp8abrrFdbr4lgULAxzeGZY6Tpl0SC6hKyCLgofRQoLvmu19giPAkAsGmRqNDXbjeH/6skI3vwsnP/j5IIQdoQ86v7RdatzMe31CH4f8HoYOqxz0mXZ0t1ZSDZbGcKfJSKy9JMJdSL3wzhZbQ7FRSL9+QjNqn7aIvyY/WlVoHJfSGpRkvrXCN64JA4qfgRPyyljY8bOkz7XAALViP3/FJdofEgKkHOnyVL2QPPeSlRptLaWmsl+0sRh1h9d23z7uBBAKsR4uGXUoTCDhVaRjildBgPlHg+yCuypXsAXD0CnwKxu5MZG7RzkTVxEgJV2nBIXfJIIQzphI+cAKaUvXENbQaU8J62vYaMwrB076sqTCLDmNOCASY7Y9/cbSUG6UHUjA/S34zWQOsRDR/ZzlHkavho/F3vaaS5f3l9hTIlXckZkmPv2gpV5TM8idQC+S0+xqHw3f/VhnHYQdtpShRSsM8AFDs0Z5igsVUF/Zs1Ao/tZ2/H3R8Agk9UrT0DHtrL5PZpe+WwmQhLkLXoFNDs0UleUmBSMz6WipPerjyrqwqapLX9oS9MW3TMEgniLetrh9KbFcJX2rux1MCPiy3K/f0dBm5B+rxnfBjWotuToZ0j+FGAtajmzYqO6WaBHgU=----ATTACHMENT:----MTE3MTc1ODY5ODU5MjcxNiA1NDA5MTE4NzYzOTk3ODU1IDcwNDIwNjI1MjA0MzcyODM=