@param iterable $iterable

@return array
@throws \InvalidArgumentException
499098
public static function iterableToArray($iterable): array
    {
        if (is_array($iterable)) {
            return $iterable;
        }

        if ($iterable instanceof \Traversable) {
            return iterator_to_array($iterable);
        }

        throw new \InvalidArgumentException('Iterable is expected.');
    }
725167
protected function getArrayFromXml(SimpleXmlIterator $iterator)
    {
        $result = [];

        for($iterator->rewind(); $iterator->valid(); $iterator->next())
        {
            if($iterator->hasChildren())
            {
                foreach($iterator->getChildren() as $key => $value)
                {
                    if(1 <= $value->count())
                    {
                        $result[$iterator->key()][][$key] = $this->getArrayFromXml($value);
                    }
                    else
                    {
                        if(true === $value->hasChildren())
                        {
                            $result[$iterator->key()][$key] = $this->getArrayFromXml($value);
                        }
                        else
                        {
                            $result[$iterator->key()] = $this->getArrayFromXml($iterator->current());
                        }
                    }
                }
            }
            else
            {
                $result[$iterator->key()] = $this->convertToStringOrBoolean($iterator->current());
            }
        }

        return $result;
    }
867584
public function groupBy(array $collection, Closure $iterator)
    {
        $groups = [];

        foreach ($collection as $node)
        {
            $groups[$iterator($node)][] = $node;
        }

        sort($groups);

        return $groups;
    }
624129
public function addIterableEvent(IterableEvent $iterableEvent): void
    {
        if (!$this->isIterable()) {
            throw new InvalidArgumentException('Not an iterable call.');
        }
        if ($this->endEvent) {
            throw new InvalidArgumentException('Call already completed.');
        }

        $iterableEvent->setCall($this);
        $this->iterableEvents[] = $iterableEvent;
    }
1105412
protected function iterate($values)
    {
        if (!is_object($values) && !is_array($values)) {
            throw new \InvalidArgumentException("Unable to validate provided object");
        }
        $errors = [];
        foreach ($this->ruleset as $field => $rules) {
            $value = $this->access($values, $field);
            $error = $rules->apply($value, $values);
            if ($error !== null) {
                $errors[$field] = count($error) > 1 || count(array_filter(array_keys($error), 'is_string')) > 0 ?
                    $error : current($error);
            }
        }
        return $errors;
    }
805161
public function setOptions(iterable $options)
    {
        if (!is_iterable($options)) {
            throw new Exception\InvalidArgumentException(
                sprintf(
                    '"%s" expects an array or Traversable; received "%s"',
                    __METHOD__,
                    gettype($options)
            )
            );
        }

        foreach ($options as $key => $value) {
            $setter = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
            if (method_exists($this, $setter)) {
                $this->{$setter}($value);
            } elseif (array_key_exists($key, $this->options)) {
                $this->options[$key] = $value;
            } else {
                throw new Exception\InvalidArgumentException(sprintf(
                    'The option "%s" does not have a matching %s setter method or options[%s] array key',
                    $key,
                    $setter,
                    $key
                ));
            }
        }

        return $this;
    }
1162823
public static function get(Throwable $exception)
    {
        return collect(explode("\n", file_get_contents($exception->getFile())))
            ->slice($exception->getLine() - 10, 20)
            ->mapWithKeys(function ($value, $key) {
                return [$key + 1 => $value];
            })->all();
    }
194385
public static function throwableToArray(\Throwable $throwable) : array
    {
        return [
            'type'  => $throwable->getCode(),
            'file'  => $throwable->getFile(),
            'line'  => $throwable->getLine(),
            'class' => get_class($throwable),
            'args'  => [$throwable->getMessage()]
        ];
    }
1123775
protected function parse($callable)
    {
        list($callable, $args) = $this->parseArgs($callable);

        if ($this->isClassMethod($callable)) {
            $callable = $this->parseClassMethod($callable);
        } elseif ($this->isMutatorMethod($callable)) {
            $callable = [$this, $callable];
        } elseif (!function_exists($callable)) {
            throw new InvalidCallableException("Function [{$callable}] not found.");
        }

        return [$callable, $args];
    }
23055
private static <E> List<E> toList(Iterable<E> iterable)
	{
		List<E> list = new ArrayList<>();
		iterable.forEach(list::add);
		return list;
	}
167133
public static function iterator($xs)
    {
        if (is_array($xs)) {
            return new \ArrayIterator($xs);
        }
        if (!$xs instanceof \Iterator) {
            throw new \InvalidArgumentException();
        }
        return $xs;
    }
492677
public function getIterator(): \Generator
    {
        foreach ($this->sourceIterable as $content) {
            try {
                yield $this->stream->write($content);
            } catch (\InvalidArgumentException $ex) {
                throw new \RuntimeException('The iterable generated values that are not writable', 0, $ex);
            }
        }
    }
218161
protected function getArray($row)
    {
        if (!$row instanceof Traversable && !is_array($row)) {
            throw new InvalidArgumentException("The input is not an array or traversable");
        }
        return ($row instanceof Traversable) ? iterator_to_array($row, true) : $row;
    }
911090
@SuppressWarnings("unchecked")
  public static Iterator<Object> iterator(Object iterable) {
    Assert.state(isIterable(iterable.getClass()));
    return iterable.getClass().isArray() ? new ArrayIterator(iterable)
        : ((Iterable<Object>) iterable).iterator();
  }
1121990
public function getIterator() : iterable
    {
        foreach ($this->bufferedChanges as $change) {
            yield $change;
        }

        foreach ($this->unBufferedChanges ?? [] as $change) {
            $this->bufferedChanges[] = $change;

            yield $change;
        }

        $this->unBufferedChanges = null;
    }
19686
def _convert_iterable(self, iterable):
        
        # Return original if _wrapper isn't callable
        if not callable(self._wrapper):
            return iterable

        return [self._wrapper(x) for x in iterable]
756233
protected function iteratorToArray($keys)
    {
        // Already array
        if (is_array($keys)) {
            return $keys;
        }

        // Handle iterable
        if ($keys instanceof Traversable) {
            return iterator_to_array($keys, false);
        }

        // Error
        $keysType = is_object($keys) ? get_class($keys) : gettype($keys);
        throw new InvalidArgumentException("Cache keys must be array or Traversable, \"{$keysType}\" given");
    }