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
This commit is contained in:
parent
68ba315d9a
commit
fedcc33d27
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue