protected function unprotect($files, $recursive = false)
    {
        if (!$files instanceof \Traversable) {
            $files = new \ArrayObject(is_array($files) ? $files : array($files));
        }

        foreach ($files as $file) {
            if (is_link($file)) {
                continue;
            } elseif (is_dir($file)) {
                if ((!is_executable($file) || !is_writable($file))
                    && true !== @chmod($file, 0700)) {
                    return false;
                }
                if ($recursive && !$this->unprotect(new \FilesystemIterator($file), true)) {
                    return false;
                }
            } elseif (!is_writable($file) && true !== @chmod($file, 0600)) {
                return false;
            }
        }

        return true;
    }
protected function unprotect($files, $recursive = false)
    {
        if (!$files instanceof \Traversable) {
            $files = new \ArrayObject(is_array($files) ? $files : array($files));
        }

        foreach ($files as $file) {
            if (is_link($file)) {
                continue;
            } elseif (is_dir($file)) {
                if ((!is_executable($file) || !is_writable($file))
                    && true !== @chmod($file, 0700)) {
                    return false;
                }
                if ($recursive && !$this->unprotect(new \FilesystemIterator($file), true)) {
                    return false;
                }
            } elseif (!is_writable($file) && true !== @chmod($file, 0600)) {
                return false;
            }
        }

        return true;
    }
protected function unprotect ( $ files , $ recursive = false ) { if ( ! $ files instanceof \ Traversable ) { $ files = new \ ArrayObject ( is_array ( $ files ) ? $ files : array ( $ files ) ) ; } foreach ( $ files as $ file ) { if ( is_link ( $ file ) ) { continue ; } elseif ( is_dir ( $ file ) ) { if ( ( ! is_executable ( $ file ) || ! is_writable ( $ file ) ) && true !== @ chmod ( $ file , 0700 ) ) { return false ; } if ( $ recursive && ! $ this -> unprotect ( new \ FilesystemIterator ( $ file ) , true ) ) { return false ; } } elseif ( ! is_writable ( $ file ) && true !== @ chmod ( $ file , 0600 ) ) { return false ; } } return true ; }
Make files writable by the current user.

@param string|array|\Traversable $files
A filename, an array of files, or a \Traversable instance.
@param bool $recursive
Whether to change the mode recursively or not.

@return bool
True on success, false on failure.
Make files writable by the current user .