protected function toAssocRecursive($input, SplObjectStorage $list): array
    {
        $values = is_iterable($input)
            ? i\iterable_to_array($input)
            : object_get_properties($input, $input instanceof stdClass || $input instanceof DynamicEntity);

        foreach ($values as $key => &$value) {
            if ($value instanceof Entity) {
                $value = $list->contains($value) ? $list[$value] : $this->toAssocEntity($value, $list);

                if ($value === null && !is_int($key)) {
                    unset($values[$key]);
                }
            } elseif (is_iterable($value) || $value instanceof stdClass) {
                $value = $this->toAssocRecursive($value, $list);
            }
        }

        return $values;
    }
protected function toAssocRecursive($input, SplObjectStorage $list): array
    {
        $values = is_iterable($input)
            ? i\iterable_to_array($input)
            : object_get_properties($input, $input instanceof stdClass || $input instanceof DynamicEntity);

        foreach ($values as $key => &$value) {
            if ($value instanceof Entity) {
                $value = $list->contains($value) ? $list[$value] : $this->toAssocEntity($value, $list);

                if ($value === null && !is_int($key)) {
                    unset($values[$key]);
                }
            } elseif (is_iterable($value) || $value instanceof stdClass) {
                $value = $this->toAssocRecursive($value, $list);
            }
        }

        return $values;
    }
protected function toAssocRecursive ( $ input , SplObjectStorage $ list ) : array { $ values = is_iterable ( $ input ) ? i \ iterable_to_array ( $ input ) : object_get_properties ( $ input , $ input instanceof stdClass || $ input instanceof DynamicEntity ) ; foreach ( $ values as $ key => & $ value ) { if ( $ value instanceof Entity ) { $ value = $ list -> contains ( $ value ) ? $ list [ $ value ] : $ this -> toAssocEntity ( $ value , $ list ) ; if ( $ value === null && ! is_int ( $ key ) ) { unset ( $ values [ $ key ] ) ; } } elseif ( is_iterable ( $ value ) || $ value instanceof stdClass ) { $ value = $ this -> toAssocRecursive ( $ value , $ list ) ; } } return $ values ; }
Recursively cast to associative arrays.

@param iterable|object   $input
@param SplObjectStorage  $list   Entity / assoc map for entities that already have been converted
@return array
Recursively cast to associative arrays .