Skip to content

Commit f12eb44

Browse files
authored
Fixed PHPStan error in Mage_HTTP_Client_Socket and Mage_HTTP_Client_Curl (#3205)
1 parent 7055d19 commit f12eb44

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

lib/Mage/HTTP/Client/Curl.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,11 @@ public function getCookies()
264264
if (!$c) {
265265
continue;
266266
}
267-
list($key, $val) = explode("=", $values[0]);
268-
if (is_null($val)) {
267+
list($key, $val) = array_pad(array_map('trim', explode('=', $values[0])), 2, null);
268+
if (is_null($val) || !strlen($key)) {
269269
continue;
270270
}
271-
$out[trim($key)] = trim($val);
271+
$out[$key] = $val;
272272
}
273273
return $out;
274274
}
@@ -290,11 +290,11 @@ public function getCookiesFull()
290290
if (!$c) {
291291
continue;
292292
}
293-
list($key, $val) = explode("=", $values[0]);
294-
if (is_null($val)) {
293+
list($key, $val) = array_pad(array_map('trim', explode('=', $values[0])), 2, null);
294+
if (is_null($val) || !strlen($key)) {
295295
continue;
296296
}
297-
$out[trim($key)] = ['value' => trim($val)];
297+
$out[$key] = ['value' => $val];
298298
array_shift($values);
299299
$c--;
300300
if (!$c) {

lib/Mage/HTTP/Client/Socket.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ public function getCookies()
303303
if (!$c) {
304304
continue;
305305
}
306-
list($key, $val) = explode("=", $values[0]);
307-
if (is_null($val)) {
306+
list($key, $val) = array_pad(array_map('trim', explode('=', $values[0])), 2, null);
307+
if (is_null($val) || !strlen($key)) {
308308
continue;
309309
}
310-
$out[trim($key)] = trim($val);
310+
$out[$key] = $val;
311311
}
312312
return $out;
313313
}
@@ -329,11 +329,11 @@ public function getCookiesFull()
329329
if (!$c) {
330330
continue;
331331
}
332-
list($key, $val) = explode("=", $values[0]);
333-
if (is_null($val)) {
332+
list($key, $val) = array_pad(array_map('trim', explode('=', $values[0])), 2, null);
333+
if (is_null($val) || !strlen($key)) {
334334
continue;
335335
}
336-
$out[trim($key)] = ['value' => trim($val)];
336+
$out[$key] = ['value' => $val];
337337
array_shift($values);
338338
$c--;
339339
if (!$c) {

phpstan.dist.issues.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,3 @@ parameters:
55
-
66
message: "#Call to function is_null\\(\\) with bool will always evaluate to false.$#"
77
path: app/code/core/Mage/Newsletter/Model/Subscriber.php
8-
-
9-
message: "#Call to function is_null\\(\\) with string will always evaluate to false.$#"
10-
path: lib/Mage/HTTP/Client/Curl.php
11-
-
12-
message: "#Call to function is_null\\(\\) with string will always evaluate to false.$#"
13-
path: lib/Mage/HTTP/Client/Socket.php

0 commit comments

Comments
 (0)