Repository navigation
Commit 50f4cdd
committed
Code Quality: Restore
In `WP_Block_Parser::add_inner_block()` the last stack frame is once again read as `$this->stack[ count( $this->stack ) - 1 ]`, undoing the switch to `array_key_last()` made in r62956 and removing the inline comment added in r63624 that explained why `array_last()` is not used. Indexing by `array_key_last()` gives the misleading impression that `$this->stack` could be an associative array, when it is only ever a sequentially indexed list. The original code was already correct, and both callers ensure the stack is not empty.
The `$stack` property is now also documented with `@phpstan-var list<WP_Block_Parser_Frame>`, which tells static analysis that the stack is always sequentially indexed. With that in place, there is nothing prompting a switch to `array_key_last()` or `array_last()`, so the explanatory comment is no longer needed. This mirrors the change made to the parser in Gutenberg via WordPress/gutenberg#82695.
Developed in #13487.
Follow-up to r62956, r63624.
Props mukesh27, westonruter, dmsnell, soean.
See #65818, #65817.
git-svn-id: https://develop.svn.wordpress.org/trunk@63937 602fd350-edb4-49c9-b593-d223f7449a82count() indexing in block parser.1 parent e2f5452 commit 50f4cdd
1 file changed
Lines changed: 2 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
346 | 347 | | |
347 | 348 | | |
348 | 349 | | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
| 350 | + | |
357 | 351 | | |
358 | 352 | | |
359 | 353 | | |
| |||
0 commit comments