From 7171bcf1c8747ac4b820d37c80a1e14e4860caae Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 2 Nov 2021 13:20:04 -0400 Subject: [PATCH] Code Modernization: Silence the deprecation warning for missing return type in `src/wp-includes/Requests/Cookie/Jar.php`. This fixes the "Deprecated: Return type of `Requests_Cookie_Jar::offsetExists()` should be compatible with `ArrayAccess::offsetExists(): bool`" and similar warnings on PHP 8.1. PHP native interfaces now have declared return types and methods in classes implementing these interfaces need to either have the return type declared (in a covariant compatible manner with the PHP native interface method declaration), or need to silence the deprecation warning using the `#[ReturnTypeWillChange]` attribute. See https://core.trac.wordpress.org/ticket/53635 --- src/wp-includes/Requests/Cookie/Jar.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/Requests/Cookie/Jar.php b/src/wp-includes/Requests/Cookie/Jar.php index a816f90a0ae7f..9446d4f11c772 100644 --- a/src/wp-includes/Requests/Cookie/Jar.php +++ b/src/wp-includes/Requests/Cookie/Jar.php @@ -60,6 +60,7 @@ public function normalizeCookie($cookie, $key = null) { * @param string $key Item key * @return boolean Does the item exist? */ + #[ReturnTypeWillChange] public function offsetExists($key) { return isset($this->cookies[$key]); } @@ -70,6 +71,7 @@ public function offsetExists($key) { * @param string $key Item key * @return string|null Item value (null if offsetExists is false) */ + #[ReturnTypeWillChange] public function offsetGet($key) { if (!isset($this->cookies[$key])) { return null; @@ -86,6 +88,7 @@ public function offsetGet($key) { * @param string $key Item name * @param string $value Item value */ + #[ReturnTypeWillChange] public function offsetSet($key, $value) { if ($key === null) { throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); @@ -99,6 +102,7 @@ public function offsetSet($key, $value) { * * @param string $key */ + #[ReturnTypeWillChange] public function offsetUnset($key) { unset($this->cookies[$key]); } @@ -108,6 +112,7 @@ public function offsetUnset($key) { * * @return ArrayIterator */ + #[ReturnTypeWillChange] public function getIterator() { return new ArrayIterator($this->cookies); }