← All changes
|
packages/block-serialization-default-parser/parser.php
+13
-13
12.6.0
→
14.7.0
View file →
| @@ -79,9 +79,9 @@ | ||
| 79 | 79 | * @param array $innerBlocks List of inner blocks (of this same class). |
| 80 | 80 | * @param string $innerHTML Resultant HTML from inside block comment delimiters after removing inner blocks. |
| 81 | 81 | * @param array $innerContent List of string fragments and null markers where inner blocks were found. |
| 82 | 82 | */ |
| 83 | - function __construct( $name, $attrs, $innerBlocks, $innerHTML, $innerContent ) { | |
| 83 | + public function __construct( $name, $attrs, $innerBlocks, $innerHTML, $innerContent ) { | |
| 84 | 84 | $this->blockName = $name; |
| 85 | 85 | $this->attrs = $attrs; |
| 86 | 86 | $this->innerBlocks = $innerBlocks; |
| 87 | 87 | $this->innerHTML = $innerHTML; |
| @@ -151,9 +151,9 @@ | ||
| 151 | 151 | * @param int $token_length Byte length of entire parse token string. |
| 152 | 152 | * @param int $prev_offset Byte offset into document for after parse token ends. |
| 153 | 153 | * @param int $leading_html_start Byte offset into document where leading HTML before token starts. |
| 154 | 154 | */ |
| 155 | - function __construct( $block, $token_start, $token_length, $prev_offset = null, $leading_html_start = null ) { | |
| 155 | + public function __construct( $block, $token_start, $token_length, $prev_offset = null, $leading_html_start = null ) { | |
| 156 | 156 | $this->block = $block; |
| 157 | 157 | $this->token_start = $token_start; |
| 158 | 158 | $this->token_length = $token_length; |
| 159 | 159 | $this->prev_offset = isset( $prev_offset ) ? $prev_offset : $token_start + $token_length; |
| @@ -221,11 +221,11 @@ | ||
| 221 | 221 | * |
| 222 | 222 | * @since 5.0.0 |
| 223 | 223 | * |
| 224 | 224 | * @param string $document Input document being parsed. |
| 225 | - * @return WP_Block_Parser_Block[] | |
| 225 | + * @return array[] | |
| 226 | 226 | */ |
| 227 | - function parse( $document ) { | |
| 227 | + public function parse( $document ) { | |
| 228 | 228 | $this->document = $document; |
| 229 | 229 | $this->offset = 0; |
| 230 | 230 | $this->output = array(); |
| 231 | 231 | $this->stack = array(); |
| @@ -230,11 +230,11 @@ | ||
| 230 | 230 | $this->output = array(); |
| 231 | 231 | $this->stack = array(); |
| 232 | 232 | $this->empty_attrs = json_decode( '{}', true ); |
| 233 | 233 | |
| 234 | - do { | |
| 235 | - // twiddle our thumbs. | |
| 236 | - } while ( $this->proceed() ); | |
| 234 | + while ( $this->proceed() ) { | |
| 235 | + continue; | |
| 236 | + } | |
| 237 | 237 | |
| 238 | 238 | return $this->output; |
| 239 | 239 | } |
| 240 | 240 | |
| @@ -251,9 +251,9 @@ | ||
| 251 | 251 | * @internal |
| 252 | 252 | * @since 5.0.0 |
| 253 | 253 | * @return bool |
| 254 | 254 | */ |
| 255 | - function proceed() { | |
| 255 | + public function proceed() { | |
| 256 | 256 | $next_token = $this->next_token(); |
| 257 | 257 | list( $token_type, $block_name, $attrs, $start_offset, $token_length ) = $next_token; |
| 258 | 258 | $stack_depth = count( $this->stack ); |
| 259 | 259 | |
| @@ -397,9 +397,9 @@ | ||
| 397 | 397 | * @since 5.0.0 |
| 398 | 398 | * @since 4.6.1 fixed a bug in attribute parsing which caused catastrophic backtracking on invalid block comments |
| 399 | 399 | * @return array |
| 400 | 400 | */ |
| 401 | - function next_token() { | |
| 401 | + public function next_token() { | |
| 402 | 402 | $matches = null; |
| 403 | 403 | |
| 404 | 404 | /* |
| 405 | 405 | * aye the magic |
| @@ -472,9 +472,9 @@ | ||
| 472 | 472 | * |
| 473 | 473 | * @param string $innerHTML HTML content of block. |
| 474 | 474 | * @return WP_Block_Parser_Block freeform block object. |
| 475 | 475 | */ |
| 476 | - function freeform( $innerHTML ) { | |
| 476 | + public function freeform( $innerHTML ) { | |
| 477 | 477 | return new WP_Block_Parser_Block( null, $this->empty_attrs, array(), $innerHTML, array( $innerHTML ) ); |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | /** |
| @@ -484,9 +484,9 @@ | ||
| 484 | 484 | * @internal |
| 485 | 485 | * @since 5.0.0 |
| 486 | 486 | * @param null $length how many bytes of document text to output. |
| 487 | 487 | */ |
| 488 | - function add_freeform( $length = null ) { | |
| 488 | + public function add_freeform( $length = null ) { | |
| 489 | 489 | $length = $length ? $length : strlen( $this->document ) - $this->offset; |
| 490 | 490 | |
| 491 | 491 | if ( 0 === $length ) { |
| 492 | 492 | return; |
| @@ -505,9 +505,9 @@ | ||
| 505 | 505 | * @param int $token_start Byte offset into the document where the first token for the block starts. |
| 506 | 506 | * @param int $token_length Byte length of entire block from start of opening token to end of closing token. |
| 507 | 507 | * @param int|null $last_offset Last byte offset into document if continuing form earlier output. |
| 508 | 508 | */ |
| 509 | - function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) { | |
| 509 | + public function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) { | |
| 510 | 510 | $parent = $this->stack[ count( $this->stack ) - 1 ]; |
| 511 | 511 | $parent->block->innerBlocks[] = (array) $block; |
| 512 | 512 | $html = substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset ); |
| 513 | 513 | |
| @@ -526,9 +526,9 @@ | ||
| 526 | 526 | * @internal |
| 527 | 527 | * @since 5.0.0 |
| 528 | 528 | * @param int|null $end_offset byte offset into document for where we should stop sending text output as HTML. |
| 529 | 529 | */ |
| 530 | - function add_block_from_stack( $end_offset = null ) { | |
| 530 | + public function add_block_from_stack( $end_offset = null ) { | |
| 531 | 531 | $stack_top = array_pop( $this->stack ); |
| 532 | 532 | $prev_offset = $stack_top->prev_offset; |
| 533 | 533 | |
| 534 | 534 | $html = isset( $end_offset ) |