diff --git a/src/PhpseclibV3/StubSftpConnectionProvider.php b/src/PhpseclibV3/StubSftpConnectionProvider.php index 0e673a7ee..3818b876b 100644 --- a/src/PhpseclibV3/StubSftpConnectionProvider.php +++ b/src/PhpseclibV3/StubSftpConnectionProvider.php @@ -25,13 +25,12 @@ public function disconnect(): void { if ($this->connection) { $this->connection->disconnect(); - $this->connection = null; } } public function provideConnection(): SFTP { - if ( ! $this->connection instanceof SFTP) { + if ( ! $this->connection instanceof SFTP || ! $this->connection->isConnected()) { $connection = new SftpStub($this->host, $this->port); $connection->login($this->username, $this->password);