src/Miscellaneous.php
public static function cloneArray(array $array): array
    {
        $newArray = [];
        foreach($array as $key => $value) {
            if(\is_object($value)) {
                $newArray[$key] = clone $value;
            } elseif(\is_array($value)) {
                $newArray[$key] = self::cloneArray($value);
            } else {
                $newArray[$key] = $value;
            }
        }
        return $newArray;
    }
public static function cloneArray(array $array): array
    {
        $newArray = [];
        foreach($array as $key => $value) {
            if(\is_object($value)) {
                $newArray[$key] = clone $value;
            } elseif(\is_array($value)) {
                $newArray[$key] = self::cloneArray($value);
            } else {
                $newArray[$key] = $value;
            }
        }
        return $newArray;
    }
public static function cloneArray ( array $ array ) : array { $ newArray = [ ] ; foreach ( $ array as $ key => $ value ) { if ( \ is_object ( $ value ) ) { $ newArray [ $ key ] = clone $ value ; } elseif ( \ is_array ( $ value ) ) { $ newArray [ $ key ] = self :: cloneArray ( $ value ) ; } else { $ newArray [ $ key ] = $ value ; } } return $ newArray ; }
This method clones an array recursively. So all objects contained in this
array will be cloned correctly.

@param array $array
The array to clone
@return array
The cloned array
This method clones an array recursively . So all objects contained in this array will be cloned correctly .