Skip to content
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

PHP 8.0: ensure parameter names are aligned with PHP native param names #560

Merged
merged 3 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/Cookie/Jar.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,54 +58,54 @@ public function normalize_cookie($cookie, $key = null) {
/**
* Check if the given item exists
*
* @param string $key Item key
* @param string $offset Item key
* @return boolean Does the item exist?
*/
#[ReturnTypeWillChange]
public function offsetExists($key) {
return isset($this->cookies[$key]);
public function offsetExists($offset) {
return isset($this->cookies[$offset]);
}

/**
* Get the value for the item
*
* @param string $key Item key
* @param string $offset Item key
* @return string|null Item value (null if offsetExists is false)
*/
#[ReturnTypeWillChange]
public function offsetGet($key) {
if (!isset($this->cookies[$key])) {
public function offsetGet($offset) {
if (!isset($this->cookies[$offset])) {
return null;
}

return $this->cookies[$key];
return $this->cookies[$offset];
}

/**
* Set the given item
*
* @throws \WpOrg\Requests\Exception On attempting to use dictionary as list (`invalidset`)
*
* @param string $key Item name
* @param string $offset Item name
* @param string $value Item value
*/
#[ReturnTypeWillChange]
public function offsetSet($key, $value) {
if ($key === null) {
public function offsetSet($offset, $value) {
if ($offset === null) {
throw new Exception('Object is a dictionary, not a list', 'invalidset');
}

$this->cookies[$key] = $value;
$this->cookies[$offset] = $value;
}

/**
* Unset the given header
*
* @param string $key
* @param string $offset
*/
#[ReturnTypeWillChange]
public function offsetUnset($key) {
unset($this->cookies[$key]);
public function offsetUnset($offset) {
unset($this->cookies[$offset]);
}

/**
Expand Down
34 changes: 17 additions & 17 deletions src/Response/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,53 +26,53 @@ class Headers extends CaseInsensitiveDictionary {
* Avoid using this where commas may be used unquoted in values, such as
* Set-Cookie headers.
*
* @param string $key
* @param string $offset
* @return string|null Header value
*/
public function offsetGet($key) {
$key = strtolower($key);
if (!isset($this->data[$key])) {
public function offsetGet($offset) {
$offset = strtolower($offset);
if (!isset($this->data[$offset])) {
return null;
}

return $this->flatten($this->data[$key]);
return $this->flatten($this->data[$offset]);
}

/**
* Set the given item
*
* @throws \WpOrg\Requests\Exception On attempting to use dictionary as list (`invalidset`)
*
* @param string $key Item name
* @param string $offset Item name
* @param string $value Item value
*/
public function offsetSet($key, $value) {
if ($key === null) {
public function offsetSet($offset, $value) {
if ($offset === null) {
throw new Exception('Object is a dictionary, not a list', 'invalidset');
}

$key = strtolower($key);
$offset = strtolower($offset);

if (!isset($this->data[$key])) {
$this->data[$key] = array();
if (!isset($this->data[$offset])) {
$this->data[$offset] = array();
}

$this->data[$key][] = $value;
$this->data[$offset][] = $value;
}

/**
* Get all values for a given header
*
* @param string $key
* @param string $offset
* @return array|null Header values
*/
public function getValues($key) {
$key = strtolower($key);
if (!isset($this->data[$key])) {
public function getValues($offset) {
$offset = strtolower($offset);
if (!isset($this->data[$offset])) {
return null;
}

return $this->data[$key];
return $this->data[$offset];
}

/**
Expand Down
38 changes: 19 additions & 19 deletions src/Utility/CaseInsensitiveDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,65 +34,65 @@ class CaseInsensitiveDictionary implements ArrayAccess, IteratorAggregate {
* @param array $data Dictionary/map to convert to case-insensitive
*/
public function __construct(array $data = array()) {
foreach ($data as $key => $value) {
$this->offsetSet($key, $value);
foreach ($data as $offset => $value) {
$this->offsetSet($offset, $value);
}
}

/**
* Check if the given item exists
*
* @param string $key Item key
* @param string $offset Item key
* @return boolean Does the item exist?
*/
#[ReturnTypeWillChange]
public function offsetExists($key) {
$key = strtolower($key);
return isset($this->data[$key]);
public function offsetExists($offset) {
$offset = strtolower($offset);
return isset($this->data[$offset]);
}

/**
* Get the value for the item
*
* @param string $key Item key
* @param string $offset Item key
* @return string|null Item value (null if offsetExists is false)
*/
#[ReturnTypeWillChange]
public function offsetGet($key) {
$key = strtolower($key);
if (!isset($this->data[$key])) {
public function offsetGet($offset) {
$offset = strtolower($offset);
if (!isset($this->data[$offset])) {
return null;
}

return $this->data[$key];
return $this->data[$offset];
}

/**
* Set the given item
*
* @throws \WpOrg\Requests\Exception On attempting to use dictionary as list (`invalidset`)
*
* @param string $key Item name
* @param string $offset Item name
* @param string $value Item value
*/
#[ReturnTypeWillChange]
public function offsetSet($key, $value) {
if ($key === null) {
public function offsetSet($offset, $value) {
if ($offset === null) {
throw new Exception('Object is a dictionary, not a list', 'invalidset');
}

$key = strtolower($key);
$this->data[$key] = $value;
$offset = strtolower($offset);
$this->data[$offset] = $value;
}

/**
* Unset the given header
*
* @param string $key
* @param string $offset
*/
#[ReturnTypeWillChange]
public function offsetUnset($key) {
unset($this->data[strtolower($key)]);
public function offsetUnset($offset) {
unset($this->data[strtolower($offset)]);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Utility/FilteredIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct($data, $callback) {
* @phpcs:disable PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__unserializeFound
*/
#[ReturnTypeWillChange]
public function __unserialize($serialized) {}
public function __unserialize($data) {}
// phpcs:enable

public function __wakeup() {
Expand All @@ -70,5 +70,5 @@ public function current() {
* @inheritdoc
*/
#[ReturnTypeWillChange]
public function unserialize($serialized) {}
public function unserialize($data) {}
}