← All changes
|
packages/block-serialization-default-parser/class-wp-block-parser.php
+7
-2
23.3.1
→
trunk
View file →
| @@ -84,8 +84,9 @@ | ||
| 84 | 84 | * or breaking out of a level of nesting. |
| 85 | 85 | * |
| 86 | 86 | * @internal |
| 87 | 87 | * @since 5.0.0 |
| 88 | + * | |
| 88 | 89 | * @return bool |
| 89 | 90 | */ |
| 90 | 91 | public function proceed() { |
| 91 | 92 | $next_token = $this->next_token(); |
| @@ -230,8 +231,9 @@ | ||
| 230 | 231 | * |
| 231 | 232 | * @internal |
| 232 | 233 | * @since 5.0.0 |
| 233 | 234 | * @since 4.6.1 fixed a bug in attribute parsing which caused catastrophic backtracking on invalid block comments |
| 235 | + * | |
| 234 | 236 | * @return array |
| 235 | 237 | */ |
| 236 | 238 | public function next_token() { |
| 237 | 239 | $matches = null; |
| @@ -317,12 +319,13 @@ | ||
| 317 | 319 | * to the output list as a freeform block. |
| 318 | 320 | * |
| 319 | 321 | * @internal |
| 320 | 322 | * @since 5.0.0 |
| 323 | + * | |
| 321 | 324 | * @param null $length how many bytes of document text to output. |
| 322 | 325 | */ |
| 323 | 326 | public function add_freeform( $length = null ) { |
| 324 | - $length = $length ? $length : strlen( $this->document ) - $this->offset; | |
| 327 | + $length = $length ?? strlen( $this->document ) - $this->offset; | |
| 325 | 328 | |
| 326 | 329 | if ( 0 === $length ) { |
| 327 | 330 | return; |
| 328 | 331 | } |
| @@ -335,8 +338,9 @@ | ||
| 335 | 338 | * a new block to the output list. |
| 336 | 339 | * |
| 337 | 340 | * @internal |
| 338 | 341 | * @since 5.0.0 |
| 342 | + * | |
| 339 | 343 | * @param WP_Block_Parser_Block $block The block to add to the output. |
| 340 | 344 | * @param int $token_start Byte offset into the document where the first token for the block starts. |
| 341 | 345 | * @param int $token_length Byte length of entire block from start of opening token to end of closing token. |
| 342 | 346 | * @param int|null $last_offset Last byte offset into document if continuing form earlier output. |
| @@ -351,9 +355,9 @@ | ||
| 351 | 355 | $parent->block->innerContent[] = $html; |
| 352 | 356 | } |
| 353 | 357 | |
| 354 | 358 | $parent->block->innerContent[] = null; |
| 355 | - $parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length; | |
| 359 | + $parent->prev_offset = $last_offset ?? $token_start + $token_length; | |
| 356 | 360 | } |
| 357 | 361 | |
| 358 | 362 | /** |
| 359 | 363 | * Pushes the top block from the parsing stack to the output list. |
| @@ -359,8 +363,9 @@ | ||
| 359 | 363 | * Pushes the top block from the parsing stack to the output list. |
| 360 | 364 | * |
| 361 | 365 | * @internal |
| 362 | 366 | * @since 5.0.0 |
| 367 | + * | |
| 363 | 368 | * @param int|null $end_offset byte offset into document for where we should stop sending text output as HTML. |
| 364 | 369 | */ |
| 365 | 370 | public function add_block_from_stack( $end_offset = null ) { |
| 366 | 371 | $stack_top = array_pop( $this->stack ); |