protected function fallbackForArray(&$data): array
    {
        if (\is_array($data)) {
            return $data;
        }

        if (!$data) {
            return [];
        }

        $isObject = \is_object($data);

        if ($isObject && $data instanceof self) {
            return $data->getArray();
        }

        if ($isObject && $data instanceof \ArrayObject) {
            return $data->getArrayCopy();
        }

        if ($isObject && $data instanceof \Generator) {
            return static::createFromGeneratorImmutable($data)->getArray();
        }

        if ($isObject && $data instanceof \Traversable) {
            return static::createFromObject($data)->getArray();
        }

        if (\is_callable($data)) {
            $this->generator = new ArrayyRewindableGenerator($data);

            return [];
        }

        if ($isObject && \method_exists($data, '__toArray')) {
            return (array) $data->__toArray();
        }

        if (
            \is_string($data)
            ||
            ($isObject && \method_exists($data, '__toString'))
        ) {
            return [(string) $data];
        }

        throw new \InvalidArgumentException(
            'Passed value should be a array'
        );
    }
protected function fallbackForArray(&$data): array
    {
        if (\is_array($data)) {
            return $data;
        }

        if (!$data) {
            return [];
        }

        $isObject = \is_object($data);

        if ($isObject && $data instanceof self) {
            return $data->getArray();
        }

        if ($isObject && $data instanceof \ArrayObject) {
            return $data->getArrayCopy();
        }

        if ($isObject && $data instanceof \Generator) {
            return static::createFromGeneratorImmutable($data)->getArray();
        }

        if ($isObject && $data instanceof \Traversable) {
            return static::createFromObject($data)->getArray();
        }

        if (\is_callable($data)) {
            $this->generator = new ArrayyRewindableGenerator($data);

            return [];
        }

        if ($isObject && \method_exists($data, '__toArray')) {
            return (array) $data->__toArray();
        }

        if (
            \is_string($data)
            ||
            ($isObject && \method_exists($data, '__toString'))
        ) {
            return [(string) $data];
        }

        throw new \InvalidArgumentException(
            'Passed value should be a array'
        );
    }
protected function fallbackForArray ( & $ data ) : array { if ( \ is_array ( $ data ) ) { return $ data ; } if ( ! $ data ) { return [ ] ; } $ isObject = \ is_object ( $ data ) ; if ( $ isObject && $ data instanceof self ) { return $ data -> getArray ( ) ; } if ( $ isObject && $ data instanceof \ ArrayObject ) { return $ data -> getArrayCopy ( ) ; } if ( $ isObject && $ data instanceof \ Generator ) { return static :: createFromGeneratorImmutable ( $ data ) -> getArray ( ) ; } if ( $ isObject && $ data instanceof \ Traversable ) { return static :: createFromObject ( $ data ) -> getArray ( ) ; } if ( \ is_callable ( $ data ) ) { $ this -> generator = new ArrayyRewindableGenerator ( $ data ) ; return [ ] ; } if ( $ isObject && \ method_exists ( $ data , '__toArray' ) ) { return ( array ) $ data -> __toArray ( ) ; } if ( \ is_string ( $ data ) || ( $ isObject && \ method_exists ( $ data , '__toString' ) ) ) { return [ ( string ) $ data ] ; } throw new \ InvalidArgumentException ( 'Passed value should be a array' ) ; }
create a fallback for array

1. use the current array, if it's a array
2. fallback to empty array, if there is nothing
3. call "getArray()" on object, if there is a "Arrayy"-object
4. call "createFromObject()" on object, if there is a "\Traversable"-object
5. call "__toArray()" on object, if the method exists
6. cast a string or object with "__toString()" into an array
7. throw a "InvalidArgumentException"-Exception

@param mixed $data

@throws \InvalidArgumentException

@return array
create a fallback for array