Code Modernization: Update parameter names in the `WP_Block_List` class.

This makes the parameter names consistent with the `ArrayAccess` interface.

Reference: [https://www.php.net/manual/en/class.arrayaccess.php PHP Manual: The ArrayAccess interface].

Follow-up to [48159].

Props rahmohn.
See #58976.
Built from https://develop.svn.wordpress.org/trunk@56803


git-svn-id: http://core.svn.wordpress.org/trunk@56315 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-10-09 11:23:28 +00:00
parent 074d2adb95
commit d1b13a270a
2 changed files with 18 additions and 18 deletions

View File

@ -63,59 +63,59 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable {
} }
/** /**
* Returns true if a block exists by the specified block index, or false * Returns true if a block exists by the specified block offset, or false
* otherwise. * otherwise.
* *
* @since 5.5.0 * @since 5.5.0
* *
* @link https://www.php.net/manual/en/arrayaccess.offsetexists.php * @link https://www.php.net/manual/en/arrayaccess.offsetexists.php
* *
* @param string $index Index of block to check. * @param string $offset Offset of block to check for.
* @return bool Whether block exists. * @return bool Whether block exists.
*/ */
#[ReturnTypeWillChange] #[ReturnTypeWillChange]
public function offsetExists( $index ) { public function offsetExists( $offset ) {
return isset( $this->blocks[ $index ] ); return isset( $this->blocks[ $offset ] );
} }
/** /**
* Returns the value by the specified block index. * Returns the value by the specified block offset.
* *
* @since 5.5.0 * @since 5.5.0
* *
* @link https://www.php.net/manual/en/arrayaccess.offsetget.php * @link https://www.php.net/manual/en/arrayaccess.offsetget.php
* *
* @param string $index Index of block value to retrieve. * @param string $offset Offset of block value to retrieve.
* @return mixed|null Block value if exists, or null. * @return mixed|null Block value if exists, or null.
*/ */
#[ReturnTypeWillChange] #[ReturnTypeWillChange]
public function offsetGet( $index ) { public function offsetGet( $offset ) {
$block = $this->blocks[ $index ]; $block = $this->blocks[ $offset ];
if ( isset( $block ) && is_array( $block ) ) { if ( isset( $block ) && is_array( $block ) ) {
$block = new WP_Block( $block, $this->available_context, $this->registry ); $block = new WP_Block( $block, $this->available_context, $this->registry );
$this->blocks[ $index ] = $block; $this->blocks[ $offset ] = $block;
} }
return $block; return $block;
} }
/** /**
* Assign a block value by the specified block index. * Assign a block value by the specified block offset.
* *
* @since 5.5.0 * @since 5.5.0
* *
* @link https://www.php.net/manual/en/arrayaccess.offsetset.php * @link https://www.php.net/manual/en/arrayaccess.offsetset.php
* *
* @param string $index Index of block value to set. * @param string $offset Offset of block value to set.
* @param mixed $value Block value. * @param mixed $value Block value.
*/ */
#[ReturnTypeWillChange] #[ReturnTypeWillChange]
public function offsetSet( $index, $value ) { public function offsetSet( $offset, $value ) {
if ( is_null( $index ) ) { if ( is_null( $offset ) ) {
$this->blocks[] = $value; $this->blocks[] = $value;
} else { } else {
$this->blocks[ $index ] = $value; $this->blocks[ $offset ] = $value;
} }
} }
@ -126,11 +126,11 @@ class WP_Block_List implements Iterator, ArrayAccess, Countable {
* *
* @link https://www.php.net/manual/en/arrayaccess.offsetunset.php * @link https://www.php.net/manual/en/arrayaccess.offsetunset.php
* *
* @param string $index Index of block value to unset. * @param string $offset Offset of block value to unset.
*/ */
#[ReturnTypeWillChange] #[ReturnTypeWillChange]
public function offsetUnset( $index ) { public function offsetUnset( $offset ) {
unset( $this->blocks[ $index ] ); unset( $this->blocks[ $offset ] );
} }
/** /**

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.4-beta2-56802'; $wp_version = '6.4-beta2-56803';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.