From 85c1413c2bcfcec097b6849730cf8b5ba905284f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 3 Aug 2021 11:02:00 +0000 Subject: [PATCH] Code Modernization: Silence the deprecation warnings for missing return type in `WP_Hook`. This fixes the "Deprecated: Return type of `WP_Hook::[METHODNAME]()` should be compatible with `ArrayAccess::[METHODNAME](): type`" 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. Follow-up to [51517], [51529]. Props jrf. See #53635. Built from https://develop.svn.wordpress.org/trunk@51530 git-svn-id: http://core.svn.wordpress.org/trunk@51141 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-hook.php | 9 +++++++++ wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-hook.php b/wp-includes/class-wp-hook.php index 432a01600f..cb49271ba4 100644 --- a/wp-includes/class-wp-hook.php +++ b/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 ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index dc3e5a876b..609c53073e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51529'; +$wp_version = '5.9-alpha-51530'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.