-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: prevent using empty()
on CURLRequest
#9195
base: develop
Are you sure you want to change the base?
Conversation
@@ -469,7 +469,7 @@ protected function applyMethod(string $method, array $curlOptions): array | |||
*/ | |||
protected function applyBody(array $curlOptions = []): array | |||
{ | |||
if (! empty($this->body)) { | |||
if ($this->body !== '' && $this->body !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just cast to string then check against empty string?
system/HTTP/CURLRequest.php
Outdated
@@ -518,18 +518,18 @@ protected function setResponseHeaders(array $headers = []) | |||
protected function setCURLOptions(array $curlOptions = [], array $config = []) | |||
{ | |||
// Auth Headers | |||
if (! empty($config['auth'])) { | |||
if (array_key_exists('auth', $config) && $config['auth']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the right side of && can we be specific what we are checking against?
$curlOptions[CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST; | ||
} else { | ||
$curlOptions[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC; | ||
} | ||
} | ||
|
||
// Certificate | ||
if (! empty($config['cert'])) { | ||
if (array_key_exists('cert', $config) && $config['cert']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for right side of && we can check against empty array or empty string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:532 Result of || is always true.
🪪 booleanOr.alwaysTrue
:532 Strict comparison using !== between array{} and '' will always evaluate to true.
🪪 notIdentical.alwaysTrue
@@ -575,7 +575,7 @@ protected function setCURLOptions(array $curlOptions = [], array $config = []) | |||
} | |||
|
|||
// Decode Content | |||
if (! empty($config['decode_content'])) { | |||
if (array_key_exists('decode_content', $config) && $config['decode_content']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for right side, pls be more specific what we are checking against
@@ -650,7 +650,7 @@ protected function setCURLOptions(array $curlOptions = [], array $config = []) | |||
} | |||
|
|||
// version | |||
if (! empty($config['version'])) { | |||
if (array_key_exists('version', $config) && $config['version']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right side change to is_string and !== ''?
Description
Decrease PHPStan baseline.
Checklist: