Skip to content

Commit 8f89daf

Browse files
committed
Fix php-curl-class#32: Replace function array dereferencing syntax to avoid syntax errors < PHP 5.4.0
1 parent 5e7b16b commit 8f89daf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Curl.class.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ public function offsetSet($offset, $value)
388388
} else {
389389
$index = array_search(strtolower($offset), array_keys(array_change_key_case($this->container, CASE_LOWER)));
390390
if (!($index === false)) {
391-
unset($this->container[array_keys($this->container)[$index]]);
391+
$keys = array_keys($this->container);
392+
unset($this->container[$keys[$index]]);
392393
}
393394
$this->container[$offset] = $value;
394395
}
@@ -407,7 +408,12 @@ public function offsetUnset($offset)
407408
public function offsetGet($offset)
408409
{
409410
$index = array_search(strtolower($offset), array_keys(array_change_key_case($this->container, CASE_LOWER)));
410-
return $index === false ? null : array_values($this->container)[$index];
411+
if ($index === false) {
412+
return null;
413+
}
414+
415+
$values = array_values($this->container);
416+
return $values[$index];
411417
}
412418

413419
public function count()

0 commit comments

Comments
 (0)