Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor add_inner_block to use array_key_last
  • Loading branch information
mukeshpanchal27 authored Sep 15, 2026
commit 27090fea9efcbee057d6f376748cf67a8b77ba8a
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,14 @@ public function add_freeform( $length = null ) {
* @param int|null $last_offset Last byte offset into document if continuing form earlier output.
*/
public function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) {
$parent = array_last( $this->stack );
/*
* Note: `array_last()` is intentionally not used here. It returns `null` for an
* empty array, which makes static analysis flag the property accesses below.
* Guarding against that is not possible without changing behavior: both callers
* already ensure the stack is not empty, so the guard would be unreachable, and
* this is a public method on a class that can be replaced via `block_parser_class`.
*/
$parent = $this->stack[ array_key_last( $this->stack ) ];
$parent->block->innerBlocks[] = (array) $block;
$html = substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset );

Expand Down
Loading