From fedcc33d272005bfaef76090b3fa545718fcc763 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 3 Aug 2021 11:12:55 +0000 Subject: [PATCH] Code Modernization: Silence the deprecation warnings for missing return type in `WP_Block_List`. This fixes the "Deprecated: Return type of `WP_Block_List::[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], [51530], [51531]. Props jrf. See #53635. Built from https://develop.svn.wordpress.org/trunk@51532 git-svn-id: http://core.svn.wordpress.org/trunk@51143 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-block-list.php | 10 ++++++++++ wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-block-list.php b/wp-includes/class-wp-block-list.php index 378faba578..2b0750bfee 100644 --- a/wp-includes/class-wp-block-list.php +++ b/wp-includes/class-wp-block-list.php @@ -72,6 +72,7 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable { * @param string $index Index of block to check. * @return bool Whether block exists. */ + #[ReturnTypeWillChange] public function offsetExists( $index ) { return isset( $this->blocks[ $index ] ); } @@ -86,6 +87,7 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable { * @param string $index Index of block value to retrieve. * @return mixed|null Block value if exists, or null. */ + #[ReturnTypeWillChange] public function offsetGet( $index ) { $block = $this->blocks[ $index ]; @@ -107,6 +109,7 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable { * @param string $index Index of block value to set. * @param mixed $value Block value. */ + #[ReturnTypeWillChange] public function offsetSet( $index, $value ) { if ( is_null( $index ) ) { $this->blocks[] = $value; @@ -124,6 +127,7 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable { * * @param string $index Index of block value to unset. */ + #[ReturnTypeWillChange] public function offsetUnset( $index ) { unset( $this->blocks[ $index ] ); } @@ -135,6 +139,7 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable { * * @link https://www.php.net/manual/en/iterator.rewind.php */ + #[ReturnTypeWillChange] public function rewind() { reset( $this->blocks ); } @@ -148,6 +153,7 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable { * * @return mixed Current element. */ + #[ReturnTypeWillChange] public function current() { return $this->offsetGet( $this->key() ); } @@ -161,6 +167,7 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable { * * @return mixed Key of the current element. */ + #[ReturnTypeWillChange] public function key() { return key( $this->blocks ); } @@ -172,6 +179,7 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable { * * @link https://www.php.net/manual/en/iterator.next.php */ + #[ReturnTypeWillChange] public function next() { next( $this->blocks ); } @@ -183,6 +191,7 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable { * * @link https://www.php.net/manual/en/iterator.valid.php */ + #[ReturnTypeWillChange] public function valid() { return null !== key( $this->blocks ); } @@ -196,6 +205,7 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable { * * @return int Block count. */ + #[ReturnTypeWillChange] public function count() { return count( $this->blocks ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 01f1b12f9f..aa9217cc06 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51531'; +$wp_version = '5.9-alpha-51532'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.