From 6e88683e35f55c3ae37b5ac4ee38df8703daedca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Sun, 29 Mar 2020 12:18:56 +0200 Subject: [PATCH 1/2] Fix: Return early --- .../Package/Version/VersionGuesser.php | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/Composer/Package/Version/VersionGuesser.php b/src/Composer/Package/Version/VersionGuesser.php index f35aabeb2..65c50d586 100644 --- a/src/Composer/Package/Version/VersionGuesser.php +++ b/src/Composer/Package/Version/VersionGuesser.php @@ -63,26 +63,28 @@ class VersionGuesser */ public function guessVersion(array $packageConfig, $path) { - if (function_exists('proc_open')) { - $versionData = $this->guessGitVersion($packageConfig, $path); - if (null !== $versionData && null !== $versionData['version']) { - return $this->postprocess($versionData); - } + if (!function_exists('proc_open')) { + return; + } - $versionData = $this->guessHgVersion($packageConfig, $path); - if (null !== $versionData && null !== $versionData['version']) { - return $this->postprocess($versionData); - } + $versionData = $this->guessGitVersion($packageConfig, $path); + if (null !== $versionData && null !== $versionData['version']) { + return $this->postprocess($versionData); + } - $versionData = $this->guessFossilVersion($packageConfig, $path); - if (null !== $versionData && null !== $versionData['version']) { - return $this->postprocess($versionData); - } + $versionData = $this->guessHgVersion($packageConfig, $path); + if (null !== $versionData && null !== $versionData['version']) { + return $this->postprocess($versionData); + } - $versionData = $this->guessSvnVersion($packageConfig, $path); - if (null !== $versionData && null !== $versionData['version']) { - return $this->postprocess($versionData); - } + $versionData = $this->guessFossilVersion($packageConfig, $path); + if (null !== $versionData && null !== $versionData['version']) { + return $this->postprocess($versionData); + } + + $versionData = $this->guessSvnVersion($packageConfig, $path); + if (null !== $versionData && null !== $versionData['version']) { + return $this->postprocess($versionData); } } From 22a52f58137db34d907f5fdb5db8c0de312c92d7 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 29 Mar 2020 16:59:07 +0200 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Andreas Möller --- src/Composer/Package/Version/VersionGuesser.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Composer/Package/Version/VersionGuesser.php b/src/Composer/Package/Version/VersionGuesser.php index 65c50d586..721887787 100644 --- a/src/Composer/Package/Version/VersionGuesser.php +++ b/src/Composer/Package/Version/VersionGuesser.php @@ -64,7 +64,7 @@ class VersionGuesser public function guessVersion(array $packageConfig, $path) { if (!function_exists('proc_open')) { - return; + return null; } $versionData = $this->guessGitVersion($packageConfig, $path); @@ -86,6 +86,8 @@ class VersionGuesser if (null !== $versionData && null !== $versionData['version']) { return $this->postprocess($versionData); } + + return null; } private function postprocess(array $versionData)