@@ -461,7 +461,7 @@ class WP_Block_Processor {
461461 * @see self::INCOMPLETE_INPUT
462462 * @see self::COMPLETE
463463 *
464- * @since 6.9.0}
464+ * @since 6.9.0
465465 *
466466 * @var string
467467 */
@@ -520,7 +520,7 @@ class WP_Block_Processor {
520520 * For every open block, in hierarchical order, this stores the byte length
521521 * of the block’s block type in the source text. For HTML spans this is 0.
522522 *
523- * @seince 6.9.0
523+ * @since 6.9.0
524524 *
525525 * @see self::$open_blocks_at
526526 *
@@ -628,7 +628,7 @@ public function __construct( string $source_text ) {
628628 * Default is to stop at any block regardless of its type.
629629 * @return bool Whether an opening delimiter for a block was found.
630630 */
631- public function next_block ( $ block_type = null ) {
631+ public function next_block ( ? string $ block_type = null ): bool {
632632 while ( $ this ->next_delimiter ( $ block_type ) ) {
633633 if ( self ::CLOSER !== $ this ->get_delimiter_type () ) {
634634 return true ;
@@ -679,7 +679,7 @@ public function next_block( $block_type = null ) {
679679 * Defaults to visit every block regardless of type.
680680 * @return bool Whether a block delimiter was matched.
681681 */
682- public function next_delimiter ( ?string $ block_name = null ) {
682+ public function next_delimiter ( ?string $ block_name = null ): bool {
683683 if ( ! isset ( $ block_name ) ) {
684684 while ( $ this ->next_token () ) {
685685 if ( ! $ this ->is_html () ) {
@@ -733,7 +733,7 @@ public function next_delimiter( ?string $block_name = null ) {
733733 *
734734 * @return bool Whether a token was matched or the end of the document was reached without finding any.
735735 */
736- public function next_token () {
736+ public function next_token (): bool {
737737 if ( $ this ->last_error || self ::COMPLETE === $ this ->state || self ::INCOMPLETE_INPUT === $ this ->state ) {
738738 return false ;
739739 }
@@ -1166,9 +1166,9 @@ public function next_token() {
11661166 *
11671167 * @since 6.9.0
11681168 *
1169- * @return array
1169+ * @return string[]
11701170 */
1171- public function get_breadcrumbs () {
1171+ public function get_breadcrumbs (): array {
11721172 $ breadcrumbs = array_fill ( 0 , count ( $ this ->open_blocks_at ), null );
11731173
11741174 /*
@@ -1196,9 +1196,9 @@ public function get_breadcrumbs() {
11961196 *
11971197 * @since 6.9.0
11981198 *
1199- * @return int|null
1199+ * @return int
12001200 */
1201- public function get_depth () {
1201+ public function get_depth (): int {
12021202 return count ( $ this ->open_blocks_at );
12031203 }
12041204
@@ -1213,6 +1213,8 @@ public function get_depth() {
12131213 * Once this function returns, the parser will be matched on token following the close
12141214 * of the given block.
12151215 *
1216+ * The return type of this method is compatible with the return of {@see \parse_blocks()}.
1217+ *
12161218 * Example:
12171219 *
12181220 * $processor = new WP_Block_Processor( $post_content );
@@ -1236,9 +1238,23 @@ public function get_depth() {
12361238 *
12371239 * @since 6.9.0
12381240 *
1239- * @return array|null Array compatible with {@see \parse_blocks()} for the given block.
1241+ * @return array[]|null {
1242+ * Array of block structures.
1243+ *
1244+ * @type array ...$0 {
1245+ * An associative array of a single parsed block object. See WP_Block_Parser_Block.
1246+ *
1247+ * @type string|null $blockName Name of block.
1248+ * @type array $attrs Attributes from block comment delimiters.
1249+ * @type array[] $innerBlocks List of inner blocks. An array of arrays that
1250+ * have the same structure as this one.
1251+ * @type string $innerHTML HTML from inside block comment delimiters.
1252+ * @type array $innerContent List of string fragments and null markers where
1253+ * inner blocks were found.
1254+ * }
1255+ * }
12401256 */
1241- public function extract_block () {
1257+ public function extract_block (): ? array {
12421258 if ( $ this ->is_html () ) {
12431259 $ chunk = $ this ->get_html_content_and_advance ();
12441260
@@ -1462,7 +1478,7 @@ public function is_block_type( string $block_type ): bool {
14621478 * @param int $b_length Byte length of second block type.
14631479 * @return bool Whether the spans of text represent identical block types, normalized for namespacing.
14641480 */
1465- public static function are_equal_block_types ( $ a_text , $ a_at , $ a_length , $ b_text , $ b_at , $ b_length ): bool {
1481+ public static function are_equal_block_types ( string $ a_text , int $ a_at , int $ a_length , string $ b_text , int $ b_at , int $ b_length ): bool {
14661482 $ a_ns_length = strcspn ( $ a_text , '/ ' , $ a_at , $ a_length );
14671483 $ b_ns_length = strcspn ( $ b_text , '/ ' , $ b_at , $ b_length );
14681484
@@ -1676,8 +1692,8 @@ public function get_html_content_and_advance(): ?string {
16761692 *
16771693 * @see self::are_equal_block_types()
16781694 *
1679- * @return string Fully-qualified block namespace and type, e.g. "core/paragraph",
1680- * if matched on an explicit delimiter, otherwise `null`.
1695+ * @return string|null Fully-qualified block namespace and type, e.g. "core/paragraph",
1696+ * if matched on an explicit delimiter, otherwise `null`.
16811697 */
16821698 public function get_block_type (): ?string {
16831699 if (
@@ -1730,8 +1746,8 @@ public function get_block_type(): ?string {
17301746 *
17311747 * @see self::are_equal_block_types()
17321748 *
1733- * @return string Fully-qualified block namespace and type, e.g. "core/paragraph",
1734- * if matched on an explicit delimiter or freeform block, otherwise `null`.
1749+ * @return string|null Fully-qualified block namespace and type, e.g. "core/paragraph",
1750+ * if matched on an explicit delimiter or freeform block, otherwise `null`.
17351751 */
17361752 public function get_printable_block_type (): ?string {
17371753 if (
@@ -1925,7 +1941,7 @@ public function get_span(): ?WP_HTML_Span {
19251941 *
19261942 * @see self::$state
19271943 *
1928- * @since 6.9.0}
1944+ * @since 6.9.0
19291945 */
19301946 const READY = 'processor-ready ' ;
19311947
0 commit comments