Make WordPress Core


Ignore:
Timestamp:
07/31/2026 01:08:01 PM (8 weeks ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use array_last() to get the last array element.

This commit replaces $array[ count( $array ) - 1 ] constructs with the array_last() function (added in PHP 8.5 and polyfilled as of WordPress 6.9) for improved readability.

Follow-up to [60672].

Props Soean, westonruter.
See #64897.

File:
1 edited

Legend:

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

    r61995 r62956  
    343343         */
    344344        public function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) {
    345                 $parent                       = $this->stack[ count( $this->stack ) - 1 ];
     345                $parent                       = $this->stack[ array_key_last( $this->stack ) ];
    346346                $parent->block->innerBlocks[] = (array) $block;
    347347                $html                         = substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset );
Note: See TracChangeset for help on using the changeset viewer.