From 2baa7a2b9136d4d4dc1e56dfc043cc71da3ee1df Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Fri, 20 Nov 2020 20:52:54 +0100 Subject: Make PHPstan stricter Signed-off-by: Sean Molenaar --- lib/Config/FetcherConfig.php | 6 +++--- lib/Config/LegacyConfig.php | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/Config') diff --git a/lib/Config/FetcherConfig.php b/lib/Config/FetcherConfig.php index 7c3e5f3d1..ce2e7db8d 100644 --- a/lib/Config/FetcherConfig.php +++ b/lib/Config/FetcherConfig.php @@ -84,7 +84,7 @@ class FetcherConfig $url = new \Net_URL2($proxy); $creds = $config->getSystemValue('proxyuserpwd', null); - if ($creds) { + if ($creds !== null) { $auth = explode(':', $creds, 2); $url->setUserinfo($auth[0], $auth[1]); } @@ -106,10 +106,10 @@ class FetcherConfig 'headers' => ['User-Agent' => static::DEFAULT_USER_AGENT, 'Accept' => static::DEFAULT_ACCEPT], ]; - if (!empty($this->proxy)) { + if (!is_null($this->proxy)) { $config['proxy'] = $this->proxy; } - if (!empty($this->redirects)) { + if (!is_null($this->redirects)) { $config['redirect.max'] = $this->redirects; } diff --git a/lib/Config/LegacyConfig.php b/lib/Config/LegacyConfig.php index 3267e132e..b0d78f9f1 100644 --- a/lib/Config/LegacyConfig.php +++ b/lib/Config/LegacyConfig.php @@ -69,9 +69,8 @@ class LegacyConfig } else { foreach ($configValues as $key => $value) { if (property_exists($this, $key)) { - $type = gettype($this->$key); - settype($value, $type); - $this->$key = $value; + settype($value, gettype($this->$key)); //@phpstan-ignore-line + $this->$key = $value; //@phpstan-ignore-line } else { $this->logger->warning( 'Configuration value "' . $key . -- cgit v1.2.3