Skip to content

Commit 77ab452

Browse files
authored
Merge pull request thephpleague#1864 from qdequippe/disconnect-on-destruct
Add option to disconnect on destruct
2 parents a5b7369 + 33e9c01 commit 77ab452

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/PhpseclibV3/SftpAdapter.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function __construct(
4141
?VisibilityConverter $visibilityConverter = null,
4242
?MimeTypeDetector $mimeTypeDetector = null,
4343
private bool $detectMimeTypeUsingPath = false,
44+
private bool $disconnectOnDestruct = false,
4445
) {
4546
$this->prefixer = new PathPrefixer($root);
4647
$this->visibilityConverter = $visibilityConverter ?? new PortableVisibilityConverter();
@@ -360,4 +361,11 @@ public function copy(string $source, string $destination, Config $config): void
360361
throw UnableToCopyFile::fromLocationTo($source, $destination, $exception);
361362
}
362363
}
364+
365+
public function __destruct()
366+
{
367+
if ($this->disconnectOnDestruct) {
368+
$this->connectionProvider->disconnect();
369+
}
370+
}
363371
}

0 commit comments

Comments
 (0)