Skip to content

Commit b898f18

Browse files
committed
Docs: Improve the documented return type for parsed blocks.
The `blockName` property can be null, for example when a section of HTML outside of a block is encountered. This corrects the docs to reflect that. Props jeremyfelt, pmbaldha, johnbillion. Fixes #63663 git-svn-id: https://develop.svn.wordpress.org/trunk@60511 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 981086b commit b898f18

File tree

2 files changed

+63
-63
lines changed

2 files changed

+63
-63
lines changed

src/wp-includes/blocks.php

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,13 +1676,13 @@ function get_comment_delimited_block_content( $block_name, $block_attributes, $b
16761676
* @param array $block {
16771677
* An associative array of a single parsed block object. See WP_Block_Parser_Block.
16781678
*
1679-
* @type string $blockName Name of block.
1680-
* @type array $attrs Attributes from block comment delimiters.
1681-
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
1682-
* have the same structure as this one.
1683-
* @type string $innerHTML HTML from inside block comment delimiters.
1684-
* @type array $innerContent List of string fragments and null markers where
1685-
* inner blocks were found.
1679+
* @type string|null $blockName Name of block.
1680+
* @type array $attrs Attributes from block comment delimiters.
1681+
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
1682+
* have the same structure as this one.
1683+
* @type string $innerHTML HTML from inside block comment delimiters.
1684+
* @type array $innerContent List of string fragments and null markers where
1685+
* inner blocks were found.
16861686
* }
16871687
* @return string String of rendered HTML.
16881688
*/
@@ -1717,13 +1717,13 @@ function serialize_block( $block ) {
17171717
* @type array ...$0 {
17181718
* An associative array of a single parsed block object. See WP_Block_Parser_Block.
17191719
*
1720-
* @type string $blockName Name of block.
1721-
* @type array $attrs Attributes from block comment delimiters.
1722-
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
1723-
* have the same structure as this one.
1724-
* @type string $innerHTML HTML from inside block comment delimiters.
1725-
* @type array $innerContent List of string fragments and null markers where
1726-
* inner blocks were found.
1720+
* @type string|null $blockName Name of block.
1721+
* @type array $attrs Attributes from block comment delimiters.
1722+
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
1723+
* have the same structure as this one.
1724+
* @type string $innerHTML HTML from inside block comment delimiters.
1725+
* @type array $innerContent List of string fragments and null markers where
1726+
* inner blocks were found.
17271727
* }
17281728
* }
17291729
* @return string String of rendered HTML.
@@ -2244,13 +2244,13 @@ function _excerpt_render_inner_blocks( $parsed_block, $allowed_blocks ) {
22442244
* @param array $parsed_block {
22452245
* An associative array of the block being rendered. See WP_Block_Parser_Block.
22462246
*
2247-
* @type string $blockName Name of block.
2248-
* @type array $attrs Attributes from block comment delimiters.
2249-
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2250-
* have the same structure as this one.
2251-
* @type string $innerHTML HTML from inside block comment delimiters.
2252-
* @type array $innerContent List of string fragments and null markers where
2253-
* inner blocks were found.
2247+
* @type string|null $blockName Name of block.
2248+
* @type array $attrs Attributes from block comment delimiters.
2249+
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2250+
* have the same structure as this one.
2251+
* @type string $innerHTML HTML from inside block comment delimiters.
2252+
* @type array $innerContent List of string fragments and null markers where
2253+
* inner blocks were found.
22542254
* }
22552255
* @return string String of rendered HTML.
22562256
*/
@@ -2268,13 +2268,13 @@ function render_block( $parsed_block ) {
22682268
* @param array $parsed_block {
22692269
* An associative array of the block being rendered. See WP_Block_Parser_Block.
22702270
*
2271-
* @type string $blockName Name of block.
2272-
* @type array $attrs Attributes from block comment delimiters.
2273-
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2274-
* have the same structure as this one.
2275-
* @type string $innerHTML HTML from inside block comment delimiters.
2276-
* @type array $innerContent List of string fragments and null markers where
2277-
* inner blocks were found.
2271+
* @type string|null $blockName Name of block.
2272+
* @type array $attrs Attributes from block comment delimiters.
2273+
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2274+
* have the same structure as this one.
2275+
* @type string $innerHTML HTML from inside block comment delimiters.
2276+
* @type array $innerContent List of string fragments and null markers where
2277+
* inner blocks were found.
22782278
* }
22792279
* @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block.
22802280
*/
@@ -2294,25 +2294,25 @@ function render_block( $parsed_block ) {
22942294
* @param array $parsed_block {
22952295
* An associative array of the block being rendered. See WP_Block_Parser_Block.
22962296
*
2297-
* @type string $blockName Name of block.
2298-
* @type array $attrs Attributes from block comment delimiters.
2299-
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2300-
* have the same structure as this one.
2301-
* @type string $innerHTML HTML from inside block comment delimiters.
2302-
* @type array $innerContent List of string fragments and null markers where
2303-
* inner blocks were found.
2297+
* @type string|null $blockName Name of block.
2298+
* @type array $attrs Attributes from block comment delimiters.
2299+
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2300+
* have the same structure as this one.
2301+
* @type string $innerHTML HTML from inside block comment delimiters.
2302+
* @type array $innerContent List of string fragments and null markers where
2303+
* inner blocks were found.
23042304
* }
23052305
* @param array $source_block {
23062306
* An un-modified copy of `$parsed_block`, as it appeared in the source content.
23072307
* See WP_Block_Parser_Block.
23082308
*
2309-
* @type string $blockName Name of block.
2310-
* @type array $attrs Attributes from block comment delimiters.
2311-
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2312-
* have the same structure as this one.
2313-
* @type string $innerHTML HTML from inside block comment delimiters.
2314-
* @type array $innerContent List of string fragments and null markers where
2315-
* inner blocks were found.
2309+
* @type string|null $blockName Name of block.
2310+
* @type array $attrs Attributes from block comment delimiters.
2311+
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2312+
* have the same structure as this one.
2313+
* @type string $innerHTML HTML from inside block comment delimiters.
2314+
* @type array $innerContent List of string fragments and null markers where
2315+
* inner blocks were found.
23162316
* }
23172317
* @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block.
23182318
*/
@@ -2342,13 +2342,13 @@ function render_block( $parsed_block ) {
23422342
* @param array $parsed_block {
23432343
* An associative array of the block being rendered. See WP_Block_Parser_Block.
23442344
*
2345-
* @type string $blockName Name of block.
2346-
* @type array $attrs Attributes from block comment delimiters.
2347-
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2348-
* have the same structure as this one.
2349-
* @type string $innerHTML HTML from inside block comment delimiters.
2350-
* @type array $innerContent List of string fragments and null markers where
2351-
* inner blocks were found.
2345+
* @type string|null $blockName Name of block.
2346+
* @type array $attrs Attributes from block comment delimiters.
2347+
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2348+
* have the same structure as this one.
2349+
* @type string $innerHTML HTML from inside block comment delimiters.
2350+
* @type array $innerContent List of string fragments and null markers where
2351+
* inner blocks were found.
23522352
* }
23532353
* @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block.
23542354
*/
@@ -2371,13 +2371,13 @@ function render_block( $parsed_block ) {
23712371
* @type array ...$0 {
23722372
* An associative array of a single parsed block object. See WP_Block_Parser_Block.
23732373
*
2374-
* @type string $blockName Name of block.
2375-
* @type array $attrs Attributes from block comment delimiters.
2376-
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2377-
* have the same structure as this one.
2378-
* @type string $innerHTML HTML from inside block comment delimiters.
2379-
* @type array $innerContent List of string fragments and null markers where
2380-
* inner blocks were found.
2374+
* @type string|null $blockName Name of block.
2375+
* @type array $attrs Attributes from block comment delimiters.
2376+
* @type array[] $innerBlocks List of inner blocks. An array of arrays that
2377+
* have the same structure as this one.
2378+
* @type string $innerHTML HTML from inside block comment delimiters.
2379+
* @type array $innerContent List of string fragments and null markers where
2380+
* inner blocks were found.
23812381
* }
23822382
* }
23832383
*/

src/wp-includes/class-wp-block.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class WP_Block {
2929
* @example "core/paragraph"
3030
*
3131
* @since 5.5.0
32-
* @var string
32+
* @var string|null
3333
*/
3434
public $name;
3535

@@ -114,12 +114,12 @@ class WP_Block {
114114
* @param array $block {
115115
* An associative array of a single parsed block object. See WP_Block_Parser_Block.
116116
*
117-
* @type string $blockName Name of block.
118-
* @type array $attrs Attributes from block comment delimiters.
119-
* @type array $innerBlocks List of inner blocks. An array of arrays that
120-
* have the same structure as this one.
121-
* @type string $innerHTML HTML from inside block comment delimiters.
122-
* @type array $innerContent List of string fragments and null markers where inner blocks were found.
117+
* @type string|null $blockName Name of block.
118+
* @type array $attrs Attributes from block comment delimiters.
119+
* @type array $innerBlocks List of inner blocks. An array of arrays that
120+
* have the same structure as this one.
121+
* @type string $innerHTML HTML from inside block comment delimiters.
122+
* @type array $innerContent List of string fragments and null markers where inner blocks were found.
123123
* }
124124
* @param array $available_context Optional array of ancestry context values.
125125
* @param WP_Block_Type_Registry $registry Optional block type registry.

0 commit comments

Comments
 (0)