From 96cde4baee616cad006e158730864911d48f1e9d Mon Sep 17 00:00:00 2001 From: ywisax Date: Fri, 20 Dec 2024 01:32:11 +0800 Subject: [PATCH] Update FtpAdapter.php, remove goto statement The goto statement can make the code's flow difficult to follow. PHP code is typically expected to have a more linear and understandable structure. For example, when using goto, it can jump from one part of the code to another in a non - sequential manner. This can lead to confusion for developers who are trying to understand the program's logic, especially in larger codebases. --- src/Ftp/FtpAdapter.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Ftp/FtpAdapter.php b/src/Ftp/FtpAdapter.php index b15add8dc..90d8bbeda 100644 --- a/src/Ftp/FtpAdapter.php +++ b/src/Ftp/FtpAdapter.php @@ -84,18 +84,20 @@ public function __destruct() */ private function connection() { - start: - if ( ! $this->hasFtpConnection()) { - $this->connection = $this->connectionProvider->createConnection($this->connectionOptions); - $this->rootDirectory = $this->resolveConnectionRoot($this->connection); - $this->prefixer = new PathPrefixer($this->rootDirectory); + while (true) { + if ( ! $this->hasFtpConnection()) { + $this->connection = $this->connectionProvider->createConnection($this->connectionOptions); + $this->rootDirectory = $this->resolveConnectionRoot($this->connection); + $this->prefixer = new PathPrefixer($this->rootDirectory); - return $this->connection; - } + return $this->connection; + } - if ($this->connectivityChecker->isConnected($this->connection) === false) { - $this->connection = false; - goto start; + if ($this->connectivityChecker->isConnected($this->connection) === false) { + $this->connection = false; + continue; + } + break; } ftp_chdir($this->connection, $this->rootDirectory);