From 5059dc6150b5c182987b1cdf04bfffe145e5de58 Mon Sep 17 00:00:00 2001 From: Pierre du Plessis <93597237+pdples@users.noreply.github.com> Date: Fri, 18 Feb 2022 12:48:07 +0200 Subject: [PATCH 1/2] Handle cases where posix_getpwuid might return false --- src/ClientBuilder.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ClientBuilder.php b/src/ClientBuilder.php index 9002df495c..dcd3397c69 100644 --- a/src/ClientBuilder.php +++ b/src/ClientBuilder.php @@ -86,7 +86,11 @@ class ClientBuilder public function __construct($yamlParser = null, $defaultFilePath = null) { if(function_exists('posix_getpwuid') && function_exists('posix_getuid')) { - $this->defaultFile = posix_getpwuid(posix_getuid())['dir'] . '/' . $this->defaultFile; + $userInfo = posix_getpwuid(posix_getuid()); + + if (false !== $userInfo) { + $this->defaultFile = posix_getpwuid(posix_getuid())['dir'] . '/' . $this->defaultFile; + } } if (null != $defaultFilePath) { $this->defaultFile = $defaultFilePath; From bd618e59c115c9286da98c97320226612d6937ba Mon Sep 17 00:00:00 2001 From: Pierre du Plessis <93597237+pdples@users.noreply.github.com> Date: Fri, 4 Nov 2022 08:40:02 +0200 Subject: [PATCH 2/2] Re-use variable --- src/ClientBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ClientBuilder.php b/src/ClientBuilder.php index dcd3397c69..c480cd7e44 100644 --- a/src/ClientBuilder.php +++ b/src/ClientBuilder.php @@ -89,7 +89,7 @@ public function __construct($yamlParser = null, $defaultFilePath = null) $userInfo = posix_getpwuid(posix_getuid()); if (false !== $userInfo) { - $this->defaultFile = posix_getpwuid(posix_getuid())['dir'] . '/' . $this->defaultFile; + $this->defaultFile = $userInfo['dir'] . '/' . $this->defaultFile; } } if (null != $defaultFilePath) {