PHPCS: Fix errors.
Fixes errors introduced in [44116]. git-svn-id: https://develop.svn.wordpress.org/trunk@44117 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f8c9698722
commit
6aef7e1966
|
@ -245,15 +245,17 @@ class WP_Block_Parser {
|
||||||
*/
|
*/
|
||||||
if ( 0 === $stack_depth ) {
|
if ( 0 === $stack_depth ) {
|
||||||
if ( isset( $leading_html_start ) ) {
|
if ( isset( $leading_html_start ) ) {
|
||||||
$this->output[] = (array) self::freeform( substr(
|
$this->output[] = (array) self::freeform(
|
||||||
$this->document,
|
substr(
|
||||||
$leading_html_start,
|
$this->document,
|
||||||
$start_offset - $leading_html_start
|
$leading_html_start,
|
||||||
) );
|
$start_offset - $leading_html_start
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '' );
|
$this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '' );
|
||||||
$this->offset = $start_offset + $token_length;
|
$this->offset = $start_offset + $token_length;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,13 +270,16 @@ class WP_Block_Parser {
|
||||||
|
|
||||||
case 'block-opener':
|
case 'block-opener':
|
||||||
// track all newly-opened blocks on the stack
|
// track all newly-opened blocks on the stack
|
||||||
array_push( $this->stack, new WP_Block_Parser_Frame(
|
array_push(
|
||||||
new WP_Block_Parser_Block( $block_name, $attrs, array(), '' ),
|
$this->stack,
|
||||||
$start_offset,
|
new WP_Block_Parser_Frame(
|
||||||
$token_length,
|
new WP_Block_Parser_Block( $block_name, $attrs, array(), '' ),
|
||||||
$start_offset + $token_length,
|
$start_offset,
|
||||||
$leading_html_start
|
$token_length,
|
||||||
) );
|
$start_offset + $token_length,
|
||||||
|
$leading_html_start
|
||||||
|
)
|
||||||
|
);
|
||||||
$this->offset = $start_offset + $token_length;
|
$this->offset = $start_offset + $token_length;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -305,9 +310,9 @@ class WP_Block_Parser {
|
||||||
* otherwise we're nested and we have to close out the current
|
* otherwise we're nested and we have to close out the current
|
||||||
* block and add it as a new innerBlock to the parent
|
* block and add it as a new innerBlock to the parent
|
||||||
*/
|
*/
|
||||||
$stack_top = array_pop( $this->stack );
|
$stack_top = array_pop( $this->stack );
|
||||||
$stack_top->block->innerHTML .= substr( $this->document, $stack_top->prev_offset, $start_offset - $stack_top->prev_offset );
|
$stack_top->block->innerHTML .= substr( $this->document, $stack_top->prev_offset, $start_offset - $stack_top->prev_offset );
|
||||||
$stack_top->prev_offset = $start_offset + $token_length;
|
$stack_top->prev_offset = $start_offset + $token_length;
|
||||||
|
|
||||||
$this->add_inner_block(
|
$this->add_inner_block(
|
||||||
$stack_top->block,
|
$stack_top->block,
|
||||||
|
@ -359,22 +364,22 @@ class WP_Block_Parser {
|
||||||
return array( 'no-more-tokens', null, null, null, null );
|
return array( 'no-more-tokens', null, null, null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
list( $match, $started_at ) = $matches[ 0 ];
|
list( $match, $started_at ) = $matches[0];
|
||||||
|
|
||||||
$length = strlen( $match );
|
$length = strlen( $match );
|
||||||
$is_closer = isset( $matches[ 'closer' ] ) && -1 !== $matches[ 'closer' ][ 1 ];
|
$is_closer = isset( $matches['closer'] ) && -1 !== $matches['closer'][1];
|
||||||
$is_void = isset( $matches[ 'void' ] ) && -1 !== $matches[ 'void' ][ 1 ];
|
$is_void = isset( $matches['void'] ) && -1 !== $matches['void'][1];
|
||||||
$namespace = $matches[ 'namespace' ];
|
$namespace = $matches['namespace'];
|
||||||
$namespace = ( isset( $namespace ) && -1 !== $namespace[ 1 ] ) ? $namespace[ 0 ] : 'core/';
|
$namespace = ( isset( $namespace ) && -1 !== $namespace[1] ) ? $namespace[0] : 'core/';
|
||||||
$name = $namespace . $matches[ 'name' ][ 0 ];
|
$name = $namespace . $matches['name'][0];
|
||||||
$has_attrs = isset( $matches[ 'attrs' ] ) && -1 !== $matches[ 'attrs' ][ 1 ];
|
$has_attrs = isset( $matches['attrs'] ) && -1 !== $matches['attrs'][1];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fun fact! It's not trivial in PHP to create "an empty associative array" since all arrays
|
* Fun fact! It's not trivial in PHP to create "an empty associative array" since all arrays
|
||||||
* are associative arrays. If we use `array()` we get a JSON `[]`
|
* are associative arrays. If we use `array()` we get a JSON `[]`
|
||||||
*/
|
*/
|
||||||
$attrs = $has_attrs
|
$attrs = $has_attrs
|
||||||
? json_decode( $matches[ 'attrs' ][ 0 ], /* as-associative */ true )
|
? json_decode( $matches['attrs'][0], /* as-associative */ true )
|
||||||
: json_decode( '{}', /* don't ask why, just verify in PHP */ false );
|
: json_decode( '{}', /* don't ask why, just verify in PHP */ false );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -439,10 +444,10 @@ class WP_Block_Parser {
|
||||||
* @param int|null $last_offset last byte offset into document if continuing form earlier output
|
* @param int|null $last_offset last byte offset into document if continuing form earlier output
|
||||||
*/
|
*/
|
||||||
function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) {
|
function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) {
|
||||||
$parent = $this->stack[ count( $this->stack ) - 1 ];
|
$parent = $this->stack[ count( $this->stack ) - 1 ];
|
||||||
$parent->block->innerBlocks[] = $block;
|
$parent->block->innerBlocks[] = $block;
|
||||||
$parent->block->innerHTML .= substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset );
|
$parent->block->innerHTML .= substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset );
|
||||||
$parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length;
|
$parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -461,11 +466,13 @@ class WP_Block_Parser {
|
||||||
: substr( $this->document, $prev_offset );
|
: substr( $this->document, $prev_offset );
|
||||||
|
|
||||||
if ( isset( $stack_top->leading_html_start ) ) {
|
if ( isset( $stack_top->leading_html_start ) ) {
|
||||||
$this->output[] = (array) self::freeform( substr(
|
$this->output[] = (array) self::freeform(
|
||||||
$this->document,
|
substr(
|
||||||
$stack_top->leading_html_start,
|
$this->document,
|
||||||
$stack_top->token_start - $stack_top->leading_html_start
|
$stack_top->leading_html_start,
|
||||||
) );
|
$stack_top->token_start - $stack_top->leading_html_start
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->output[] = (array) $stack_top->block;
|
$this->output[] = (array) $stack_top->block;
|
||||||
|
|
Loading…
Reference in New Issue