Make WordPress Core

Changeset 56803

Timestamp:
10/09/2023 11:21:30 AM (10 months ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Update parameter names in the WP_Block_List class.

This makes the parameter names consistent with the ArrayAccess interface.

Reference: PHP Manual: The ArrayAccess interface.

Follow-up to [48159].

Props rahmohn.
See #58976.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-list.php

    r56547 r56803  
    6464
    6565    /**
    66      * Returns true if a block exists by the specified block index, or false
     66     * Returns true if a block exists by the specified block , or false
    6767     * otherwise.
    6868     *
     
    7171     * @link https://www.php.net/manual/en/arrayaccess.offsetexists.php
    7272     *
    73      * @param string $index Index of block to check.
     73     * @param string $.
    7474     * @return bool Whether block exists.
    7575     */
    7676    #[ReturnTypeWillChange]
    77     public function offsetExists( $index ) {
    78         return isset( $this->blocks[ $index ] );
    79     }
    80 
    81     /**
    82      * Returns the value by the specified block index.
     77    public function offsetExists( $ ) {
     78        return isset( $this->blocks[ $ ] );
     79    }
     80
     81    /**
     82     * Returns the value by the specified block .
    8383     *
    8484     * @since 5.5.0
     
    8686     * @link https://www.php.net/manual/en/arrayaccess.offsetget.php
    8787     *
    88      * @param string $index Index of block value to retrieve.
     88     * @param string $ of block value to retrieve.
    8989     * @return mixed|null Block value if exists, or null.
    9090     */
    9191    #[ReturnTypeWillChange]
    92     public function offsetGet( $index ) {
    93         $block = $this->blocks[ $index ];
     92    public function offsetGet( $ ) {
     93        $block = $this->blocks[ $ ];
    9494
    9595        if ( isset( $block ) && is_array( $block ) ) {
    9696            $block                  = new WP_Block( $block, $this->available_context, $this->registry );
    97             $this->blocks[ $index ] = $block;
     97            $this->blocks[ $ ] = $block;
    9898        }
    9999
     
    102102
    103103    /**
    104      * Assign a block value by the specified block index.
     104     * Assign a block value by the specified block .
    105105     *
    106106     * @since 5.5.0
     
    108108     * @link https://www.php.net/manual/en/arrayaccess.offsetset.php
    109109     *
    110      * @param string $index Index of block value to set.
     110     * @param string $ of block value to set.
    111111     * @param mixed  $value Block value.
    112112     */
    113113    #[ReturnTypeWillChange]
    114     public function offsetSet( $index, $value ) {
    115         if ( is_null( $index ) ) {
     114    public function offsetSet( $, $value ) {
     115        if ( is_null( $ ) ) {
    116116            $this->blocks[] = $value;
    117117        } else {
    118             $this->blocks[ $index ] = $value;
     118            $this->blocks[ $ ] = $value;
    119119        }
    120120    }
     
    127127     * @link https://www.php.net/manual/en/arrayaccess.offsetunset.php
    128128     *
    129      * @param string $index Index of block value to unset.
    130      */
    131     #[ReturnTypeWillChange]
    132     public function offsetUnset( $index ) {
    133         unset( $this->blocks[ $index ] );
     129     * @param string $ of block value to unset.
     130     */
     131    #[ReturnTypeWillChange]
     132    public function offsetUnset( $ ) {
     133        unset( $this->blocks[ $ ] );
    134134    }
    135135
Note: See TracChangeset for help on using the changeset viewer.