src/Filesystem/MountManager.php
public function forceRename(string $path, string $newpath)
    {
        $deleted = true;
        if ($this->has($newpath)) {
            try {
                $deleted = $this->delete($newpath);
            } catch (FileNotFoundException $e) {
                // The destination path does not exist. That's ok.
                $deleted = true;
            }
        }

        if ($deleted) {
            return $this->move($path, $newpath);
        }

        return false;
    }
public function forceRename(string $path, string $newpath)
    {
        $deleted = true;
        if ($this->has($newpath)) {
            try {
                $deleted = $this->delete($newpath);
            } catch (FileNotFoundException $e) {
                // The destination path does not exist. That's ok.
                $deleted = true;
            }
        }

        if ($deleted) {
            return $this->move($path, $newpath);
        }

        return false;
    }
public function forceRename ( string $ path , string $ newpath ) { $ deleted = true ; if ( $ this -> has ( $ newpath ) ) { try { $ deleted = $ this -> delete ( $ newpath ) ; } catch ( FileNotFoundException $ e ) { // The destination path does not exist. That's ok. $ deleted = true ; } } if ( $ deleted ) { return $ this -> move ( $ path , $ newpath ) ; } return false ; }
Renames a file, overwriting the destination if it exists.

@param string $path    Path to the existing file.
@param string $newpath The new path of the file.

@return bool True on success, false on failure.
@throws FileNotFoundException Thrown if $path does not exist.
@throws FilesystemNotFoundException
@throws FileExistsException
Renames a file overwriting the destination if it exists .