From aece6360350e463641869cc7d7b537dfca7242c4 Mon Sep 17 00:00:00 2001 From: tg666 Date: Sat, 30 Apr 2022 16:39:46 +0200 Subject: [PATCH] Fixed method `GitDirectory::__toString()` --- src/Repository/LocalDirectory/GitDirectory.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Repository/LocalDirectory/GitDirectory.php b/src/Repository/LocalDirectory/GitDirectory.php index ec90bb6..adc8446 100644 --- a/src/Repository/LocalDirectory/GitDirectory.php +++ b/src/Repository/LocalDirectory/GitDirectory.php @@ -12,7 +12,7 @@ final class GitDirectory private ?string $workingDirectoryPath = NULL; - private ?string $gitDirectory = NULL; + private ?string $gitDirectory; private string $directoryName; @@ -68,7 +68,7 @@ public function __toString(): string $workingDirectory = $this->getWorkingDirectoryPath(); - while (FALSE !== $workingDirectory) { + do { $currentDirectory = $workingDirectory; $gitDirectory = $workingDirectory . DIRECTORY_SEPARATOR . $this->directoryName; @@ -76,14 +76,10 @@ public function __toString(): string return $this->gitDirectory = $gitDirectory; } - $workingDirectory = dirname($workingDirectory) . ''; + $workingDirectory = dirname($workingDirectory); + } while ($workingDirectory !== $currentDirectory); - if ($workingDirectory === $currentDirectory) { - break; - } - } - - throw GitDirectoryException::gitDirectoryNotFound($this->workingDirectory); + throw GitDirectoryException::gitDirectoryNotFound($workingDirectory); } /**