@@ -63,10 +63,10 @@ class WP_Block_Parser_Block {
6363 public $ innerContent ;
6464
6565 function __construct ( $ name , $ attrs , $ innerBlocks , $ innerHTML , $ innerContent ) {
66- $ this ->blockName = $ name ;
67- $ this ->attrs = $ attrs ;
68- $ this ->innerBlocks = $ innerBlocks ;
69- $ this ->innerHTML = $ innerHTML ;
66+ $ this ->blockName = $ name ;
67+ $ this ->attrs = $ attrs ;
68+ $ this ->innerBlocks = $ innerBlocks ;
69+ $ this ->innerHTML = $ innerHTML ;
7070 $ this ->innerContent = $ innerContent ;
7171 }
7272}
@@ -269,15 +269,17 @@ function proceed() {
269269 */
270270 if ( 0 === $ stack_depth ) {
271271 if ( isset ( $ leading_html_start ) ) {
272- $ this ->output [] = (array ) self ::freeform ( substr (
273- $ this ->document ,
274- $ leading_html_start ,
275- $ start_offset - $ leading_html_start
276- ) );
272+ $ this ->output [] = (array ) self ::freeform (
273+ substr (
274+ $ this ->document ,
275+ $ leading_html_start ,
276+ $ start_offset - $ leading_html_start
277+ )
278+ );
277279 }
278280
279281 $ this ->output [] = (array ) new WP_Block_Parser_Block ( $ block_name , $ attrs , array (), '' , array () );
280- $ this ->offset = $ start_offset + $ token_length ;
282+ $ this ->offset = $ start_offset + $ token_length ;
281283 return true ;
282284 }
283285
@@ -292,13 +294,16 @@ function proceed() {
292294
293295 case 'block-opener ' :
294296 // track all newly-opened blocks on the stack
295- array_push ( $ this ->stack , new WP_Block_Parser_Frame (
296- new WP_Block_Parser_Block ( $ block_name , $ attrs , array (), '' , array () ),
297- $ start_offset ,
298- $ token_length ,
299- $ start_offset + $ token_length ,
300- $ leading_html_start
301- ) );
297+ array_push (
298+ $ this ->stack ,
299+ new WP_Block_Parser_Frame (
300+ new WP_Block_Parser_Block ( $ block_name , $ attrs , array (), '' , array () ),
301+ $ start_offset ,
302+ $ token_length ,
303+ $ start_offset + $ token_length ,
304+ $ leading_html_start
305+ )
306+ );
302307 $ this ->offset = $ start_offset + $ token_length ;
303308 return true ;
304309
@@ -329,11 +334,11 @@ function proceed() {
329334 * otherwise we're nested and we have to close out the current
330335 * block and add it as a new innerBlock to the parent
331336 */
332- $ stack_top = array_pop ( $ this ->stack );
333- $ html = substr ( $ this ->document , $ stack_top ->prev_offset , $ start_offset - $ stack_top ->prev_offset );
334- $ stack_top ->block ->innerHTML .= $ html ;
337+ $ stack_top = array_pop ( $ this ->stack );
338+ $ html = substr ( $ this ->document , $ stack_top ->prev_offset , $ start_offset - $ stack_top ->prev_offset );
339+ $ stack_top ->block ->innerHTML .= $ html ;
335340 $ stack_top ->block ->innerContent [] = $ html ;
336- $ stack_top ->prev_offset = $ start_offset + $ token_length ;
341+ $ stack_top ->prev_offset = $ start_offset + $ token_length ;
337342
338343 $ this ->add_inner_block (
339344 $ stack_top ->block ,
@@ -391,22 +396,22 @@ function next_token() {
391396 return array ( 'no-more-tokens ' , null , null , null , null );
392397 }
393398
394- list ( $ match , $ started_at ) = $ matches [ 0 ];
399+ list ( $ match , $ started_at ) = $ matches [0 ];
395400
396401 $ length = strlen ( $ match );
397- $ is_closer = isset ( $ matches [ 'closer ' ] ) && -1 !== $ matches [ 'closer ' ][ 1 ];
398- $ is_void = isset ( $ matches [ 'void ' ] ) && -1 !== $ matches [ 'void ' ][ 1 ];
399- $ namespace = $ matches [ 'namespace ' ];
400- $ namespace = ( isset ( $ namespace ) && -1 !== $ namespace [ 1 ] ) ? $ namespace [ 0 ] : 'core/ ' ;
401- $ name = $ namespace . $ matches [ 'name ' ][ 0 ];
402- $ has_attrs = isset ( $ matches [ 'attrs ' ] ) && -1 !== $ matches [ 'attrs ' ][ 1 ];
402+ $ is_closer = isset ( $ matches ['closer ' ] ) && -1 !== $ matches ['closer ' ][ 1 ];
403+ $ is_void = isset ( $ matches ['void ' ] ) && -1 !== $ matches ['void ' ][ 1 ];
404+ $ namespace = $ matches ['namespace ' ];
405+ $ namespace = ( isset ( $ namespace ) && -1 !== $ namespace [1 ] ) ? $ namespace [0 ] : 'core/ ' ;
406+ $ name = $ namespace . $ matches ['name ' ][ 0 ];
407+ $ has_attrs = isset ( $ matches ['attrs ' ] ) && -1 !== $ matches ['attrs ' ][ 1 ];
403408
404409 /*
405410 * Fun fact! It's not trivial in PHP to create "an empty associative array" since all arrays
406411 * are associative arrays. If we use `array()` we get a JSON `[]`
407412 */
408413 $ attrs = $ has_attrs
409- ? json_decode ( $ matches [ 'attrs ' ][ 0 ], /* as-associative */ true )
414+ ? json_decode ( $ matches ['attrs ' ][ 0 ], /* as-associative */ true )
410415 : $ this ->empty_attrs ;
411416
412417 /*
@@ -471,17 +476,17 @@ function add_freeform( $length = null ) {
471476 * @param int|null $last_offset last byte offset into document if continuing form earlier output
472477 */
473478 function add_inner_block ( WP_Block_Parser_Block $ block , $ token_start , $ token_length , $ last_offset = null ) {
474- $ parent = $ this ->stack [ count ( $ this ->stack ) - 1 ];
479+ $ parent = $ this ->stack [ count ( $ this ->stack ) - 1 ];
475480 $ parent ->block ->innerBlocks [] = (array ) $ block ;
476- $ html = substr ( $ this ->document , $ parent ->prev_offset , $ token_start - $ parent ->prev_offset );
481+ $ html = substr ( $ this ->document , $ parent ->prev_offset , $ token_start - $ parent ->prev_offset );
477482
478483 if ( ! empty ( $ html ) ) {
479- $ parent ->block ->innerHTML .= $ html ;
484+ $ parent ->block ->innerHTML .= $ html ;
480485 $ parent ->block ->innerContent [] = $ html ;
481486 }
482487
483488 $ parent ->block ->innerContent [] = null ;
484- $ parent ->prev_offset = $ last_offset ? $ last_offset : $ token_start + $ token_length ;
489+ $ parent ->prev_offset = $ last_offset ? $ last_offset : $ token_start + $ token_length ;
485490 }
486491
487492 /**
@@ -500,16 +505,18 @@ function add_block_from_stack( $end_offset = null ) {
500505 : substr ( $ this ->document , $ prev_offset );
501506
502507 if ( ! empty ( $ html ) ) {
503- $ stack_top ->block ->innerHTML .= $ html ;
508+ $ stack_top ->block ->innerHTML .= $ html ;
504509 $ stack_top ->block ->innerContent [] = $ html ;
505510 }
506511
507512 if ( isset ( $ stack_top ->leading_html_start ) ) {
508- $ this ->output [] = (array ) self ::freeform ( substr (
509- $ this ->document ,
510- $ stack_top ->leading_html_start ,
511- $ stack_top ->token_start - $ stack_top ->leading_html_start
512- ) );
513+ $ this ->output [] = (array ) self ::freeform (
514+ substr (
515+ $ this ->document ,
516+ $ stack_top ->leading_html_start ,
517+ $ stack_top ->token_start - $ stack_top ->leading_html_start
518+ )
519+ );
513520 }
514521
515522 $ this ->output [] = (array ) $ stack_top ->block ;
0 commit comments