Increase Psalm strictness (#909)

* Increase Psalm strictness

* Fix static analysis errors

ERROR: RedundantCast - ../src/Curl/CaseInsensitiveArray.php:91:16 - Redundant cast to bool (see https://psalm.dev/262)
        return (bool) array_key_exists(strtolower($offset), $this->data);

ERROR: RedundantCast - ../src/Curl/CaseInsensitiveArray.php:138:16 - Redundant cast to int<0, max> (see https://psalm.dev/262)
        return (int) count($this->data);

ERROR: RedundantCast - ../src/Curl/CaseInsensitiveArray.php:187:16 - Redundant cast to bool (see https://psalm.dev/262)
        return (bool) (key($this->data) !== null);

ERROR: ForbiddenCode - ../src/Curl/Curl.php:1765:13 - Unsafe var_dump (see https://psalm.dev/002)
            var_dump($value);

ERROR: ForbiddenCode - ../src/Curl/Curl.php:1770:13 - Unsafe var_dump (see https://psalm.dev/002)
            var_dump($value);

ERROR: InvalidOperand - ../src/Curl/Curl.php:1816:35 - Cannot concatenate with a value-of<TArray> (see https://psalm.dev/058)
                return $k . '=' . $v;
This commit is contained in:
Zach Borboa
2025-01-11 23:11:26 -05:00
committed by GitHub
parent 634ee48552
commit bd793d1287
4 changed files with 20 additions and 7 deletions
+3 -3
View File
@@ -88,7 +88,7 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return (bool) array_key_exists(strtolower($offset), $this->data);
return array_key_exists(strtolower($offset), $this->data);
}
/**
@@ -135,7 +135,7 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator
#[\ReturnTypeWillChange]
public function count()
{
return (int) count($this->data);
return count($this->data);
}
/**
@@ -184,7 +184,7 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator
#[\ReturnTypeWillChange]
public function valid()
{
return (bool) (key($this->data) !== null);
return (key($this->data) !== null);
}
/**
+5 -3
View File
@@ -1812,9 +1812,11 @@ class Curl extends BaseCurl
if (count($this->cookies)) {
// Avoid using http_build_query() as unnecessary encoding is performed.
// http_build_query($this->cookies, '', '; ');
$this->setOpt(CURLOPT_COOKIE, implode('; ', array_map(function ($k, $v) {
return $k . '=' . $v;
}, array_keys($this->cookies), array_values($this->cookies))));
$cookies = [];
foreach ($this->cookies as $key => $value) {
$cookies[] = $key . '=' . $value;
}
$this->setOpt(CURLOPT_COOKIE, implode('; ', $cookies));
}
}
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<files>
<file src="../src/Curl/Curl.php">
<ForbiddenCode>
<code><![CDATA[var_dump($value)]]></code>
<code><![CDATA[var_dump($value)]]></code>
</ForbiddenCode>
</file>
</files>
+3 -1
View File
@@ -1,10 +1,12 @@
<?xml version="1.0"?>
<!-- TODO: Use errorLevel="1" -->
<psalm
errorLevel="5"
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="../src" />