From 44417765ecda8602296d5e8474152175464d63b5 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Fri, 23 Jul 2021 03:12:26 +0200
Subject: [PATCH 1/2] PHP 8.1: WP_Hook: silence return type missing deprecation
 warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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) òr need to silence the deprecation warning using an attribute.
---
 src/wp-includes/class-wp-hook.php | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/wp-includes/class-wp-hook.php b/src/wp-includes/class-wp-hook.php
index 432a01600f..cb49271ba4 100644
--- a/src/wp-includes/class-wp-hook.php
+++ b/src/wp-includes/class-wp-hook.php
@@ -437,6 +437,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
 	 * @param mixed $offset An offset to check for.
 	 * @return bool True if the offset exists, false otherwise.
 	 */
+	#[ReturnTypeWillChange]
 	public function offsetExists( $offset ) {
 		return isset( $this->callbacks[ $offset ] );
 	}
@@ -451,6 +452,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
 	 * @param mixed $offset The offset to retrieve.
 	 * @return mixed If set, the value at the specified offset, null otherwise.
 	 */
+	#[ReturnTypeWillChange]
 	public function offsetGet( $offset ) {
 		return isset( $this->callbacks[ $offset ] ) ? $this->callbacks[ $offset ] : null;
 	}
@@ -465,6 +467,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
 	 * @param mixed $offset The offset to assign the value to.
 	 * @param mixed $value The value to set.
 	 */
+	#[ReturnTypeWillChange]
 	public function offsetSet( $offset, $value ) {
 		if ( is_null( $offset ) ) {
 			$this->callbacks[] = $value;
@@ -482,6 +485,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
 	 *
 	 * @param mixed $offset The offset to unset.
 	 */
+	#[ReturnTypeWillChange]
 	public function offsetUnset( $offset ) {
 		unset( $this->callbacks[ $offset ] );
 	}
@@ -495,6 +499,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
 	 *
 	 * @return array Of callbacks at current priority.
 	 */
+	#[ReturnTypeWillChange]
 	public function current() {
 		return current( $this->callbacks );
 	}
@@ -508,6 +513,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
 	 *
 	 * @return array Of callbacks at next priority.
 	 */
+	#[ReturnTypeWillChange]
 	public function next() {
 		return next( $this->callbacks );
 	}
@@ -521,6 +527,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
 	 *
 	 * @return mixed Returns current priority on success, or NULL on failure
 	 */
+	#[ReturnTypeWillChange]
 	public function key() {
 		return key( $this->callbacks );
 	}
@@ -534,6 +541,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
 	 *
 	 * @return bool Whether the current position is valid.
 	 */
+	#[ReturnTypeWillChange]
 	public function valid() {
 		return key( $this->callbacks ) !== null;
 	}
@@ -545,6 +553,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
 	 *
 	 * @link https://www.php.net/manual/en/iterator.rewind.php
 	 */
+	#[ReturnTypeWillChange]
 	public function rewind() {
 		reset( $this->callbacks );
 	}
-- 
2.32.0.windows.2

