Task/InputIteratorTask.php
protected function handleIteratorFromInput(ProcessState $state)
    {
        if ($this->iterator instanceof \Iterator) {
            if ($this->iterator->valid()) {
                // No action needed, execution is in progress
                return;
            }
            // Cleanup invalid iterator => prepare for new iteration cycle
            $this->iterator = null;
        }

        // This should never be reached
        if (null !== $this->iterator) {
            throw new \UnexpectedValueException(
                "At this point iterator should have been null, maybe it's a wrong type..."
            );
        }

        // Create iterator
        if ($state->getInput() instanceof \Iterator) {
            $this->iterator = $state->getInput();
        } elseif (\is_array($state->getInput())) {
            $this->iterator = new \ArrayIterator($state->getInput());
        }

        // Assert iterator is OK
        if (!$this->iterator instanceof \Iterator) {
            throw new \UnexpectedValueException('Cannot create iterator from input');
        }
    }
protected function handleIteratorFromInput(ProcessState $state)
    {
        if ($this->iterator instanceof \Iterator) {
            if ($this->iterator->valid()) {
                // No action needed, execution is in progress
                return;
            }
            // Cleanup invalid iterator => prepare for new iteration cycle
            $this->iterator = null;
        }

        // This should never be reached
        if (null !== $this->iterator) {
            throw new \UnexpectedValueException(
                "At this point iterator should have been null, maybe it's a wrong type..."
            );
        }

        // Create iterator
        if ($state->getInput() instanceof \Iterator) {
            $this->iterator = $state->getInput();
        } elseif (\is_array($state->getInput())) {
            $this->iterator = new \ArrayIterator($state->getInput());
        }

        // Assert iterator is OK
        if (!$this->iterator instanceof \Iterator) {
            throw new \UnexpectedValueException('Cannot create iterator from input');
        }
    }
Create or recreate an iterator from input

@param ProcessState $state