From 68dd26a4c09e3ad252f2a382b2c63e2a87f003e4 Mon Sep 17 00:00:00 2001 From: Anton Timmermans Date: Mon, 24 Dec 2018 13:44:05 +0000 Subject: [PATCH] Build tools: Fix the `grunt format:php` build. Re-add variable that was removed on accident by [44359]. Also run `grunt format:php` to adjust the code style. .--This line, and those below, will be ignored-- M Gruntfile.js M src/index.php M src/wp-admin/index.php M src/wp-includes/class-wp-block-parser.php git-svn-id: https://develop.svn.wordpress.org/trunk@44360 602fd350-edb4-49c9-b593-d223f7449a82 --- Gruntfile.js | 5 +- src/index.php | 18 ++--- src/wp-admin/index.php | 26 +++---- src/wp-includes/class-wp-block-parser.php | 85 ++++++++++++----------- 4 files changed, 72 insertions(+), 62 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 8b60d65861..d93a3c331e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -25,7 +25,10 @@ module.exports = function(grunt) { 'wp-content/plugins/index.php', 'wp-content/plugins/hello.php', 'wp-content/plugins/akismet/**' - ]; + ], + changedFiles = { + php: [] + }; if ( 'watch:phpunit' === grunt.cli.tasks[ 0 ] && ! phpUnitWatchGroup ) { grunt.log.writeln(); diff --git a/src/index.php b/src/index.php index 64938e2453..9510b83e2f 100644 --- a/src/index.php +++ b/src/index.php @@ -36,25 +36,25 @@ $die = sprintf( 'WordPress' ) . '

'; -$die .= '

' . __( 'Before running any grunt tasks you need to make sure the dependencies are installed. You can install these by running '); +$die .= '

' . __( 'Before running any grunt tasks you need to make sure the dependencies are installed. You can install these by running ' ); $die .= 'npm install.

'; $die .= ''; diff --git a/src/wp-admin/index.php b/src/wp-admin/index.php index a24d7b1d6f..3bc73fa827 100644 --- a/src/wp-admin/index.php +++ b/src/wp-admin/index.php @@ -36,25 +36,25 @@ $die = sprintf( 'WordPress' ) . '

'; -$die .= '

' . __( 'Before running any grunt tasks you need to make sure the dependencies are installed. You can install these by running '); +$die .= '

' . __( 'Before running any grunt tasks you need to make sure the dependencies are installed. You can install these by running ' ); $die .= 'npm install.

'; $die .= ''; @@ -62,9 +62,9 @@ $die .= ''; $die .= '

' . sprintf( /* translators: %1$s: NPM URL, %2$s: Grunt URL */ __( 'This requires NPM and Grunt. Read more about setting up your local development environment.' ), - 'https://www.npmjs.com/', - 'https://gruntjs.com/', - __( 'https://make.wordpress.org/core/handbook/tutorials/installing-wordpress-locally/' ) - ) . '

'; + 'https://www.npmjs.com/', + 'https://gruntjs.com/', + __( 'https://make.wordpress.org/core/handbook/tutorials/installing-wordpress-locally/' ) +) . '

'; wp_die( $die, __( 'WordPress › Error' ) ); diff --git a/src/wp-includes/class-wp-block-parser.php b/src/wp-includes/class-wp-block-parser.php index 216cb9a5f7..439a2ce32b 100644 --- a/src/wp-includes/class-wp-block-parser.php +++ b/src/wp-includes/class-wp-block-parser.php @@ -63,10 +63,10 @@ class WP_Block_Parser_Block { public $innerContent; function __construct( $name, $attrs, $innerBlocks, $innerHTML, $innerContent ) { - $this->blockName = $name; - $this->attrs = $attrs; - $this->innerBlocks = $innerBlocks; - $this->innerHTML = $innerHTML; + $this->blockName = $name; + $this->attrs = $attrs; + $this->innerBlocks = $innerBlocks; + $this->innerHTML = $innerHTML; $this->innerContent = $innerContent; } } @@ -269,15 +269,17 @@ class WP_Block_Parser { */ if ( 0 === $stack_depth ) { if ( isset( $leading_html_start ) ) { - $this->output[] = (array) self::freeform( substr( - $this->document, - $leading_html_start, - $start_offset - $leading_html_start - ) ); + $this->output[] = (array) self::freeform( + substr( + $this->document, + $leading_html_start, + $start_offset - $leading_html_start + ) + ); } $this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ); - $this->offset = $start_offset + $token_length; + $this->offset = $start_offset + $token_length; return true; } @@ -292,13 +294,16 @@ class WP_Block_Parser { case 'block-opener': // track all newly-opened blocks on the stack - array_push( $this->stack, new WP_Block_Parser_Frame( - new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ), - $start_offset, - $token_length, - $start_offset + $token_length, - $leading_html_start - ) ); + array_push( + $this->stack, + new WP_Block_Parser_Frame( + new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ), + $start_offset, + $token_length, + $start_offset + $token_length, + $leading_html_start + ) + ); $this->offset = $start_offset + $token_length; return true; @@ -329,11 +334,11 @@ class WP_Block_Parser { * otherwise we're nested and we have to close out the current * block and add it as a new innerBlock to the parent */ - $stack_top = array_pop( $this->stack ); - $html = substr( $this->document, $stack_top->prev_offset, $start_offset - $stack_top->prev_offset ); - $stack_top->block->innerHTML .= $html; + $stack_top = array_pop( $this->stack ); + $html = substr( $this->document, $stack_top->prev_offset, $start_offset - $stack_top->prev_offset ); + $stack_top->block->innerHTML .= $html; $stack_top->block->innerContent[] = $html; - $stack_top->prev_offset = $start_offset + $token_length; + $stack_top->prev_offset = $start_offset + $token_length; $this->add_inner_block( $stack_top->block, @@ -391,22 +396,22 @@ class WP_Block_Parser { return array( 'no-more-tokens', null, null, null, null ); } - list( $match, $started_at ) = $matches[ 0 ]; + list( $match, $started_at ) = $matches[0]; $length = strlen( $match ); - $is_closer = isset( $matches[ 'closer' ] ) && -1 !== $matches[ 'closer' ][ 1 ]; - $is_void = isset( $matches[ 'void' ] ) && -1 !== $matches[ 'void' ][ 1 ]; - $namespace = $matches[ 'namespace' ]; - $namespace = ( isset( $namespace ) && -1 !== $namespace[ 1 ] ) ? $namespace[ 0 ] : 'core/'; - $name = $namespace . $matches[ 'name' ][ 0 ]; - $has_attrs = isset( $matches[ 'attrs' ] ) && -1 !== $matches[ 'attrs' ][ 1 ]; + $is_closer = isset( $matches['closer'] ) && -1 !== $matches['closer'][1]; + $is_void = isset( $matches['void'] ) && -1 !== $matches['void'][1]; + $namespace = $matches['namespace']; + $namespace = ( isset( $namespace ) && -1 !== $namespace[1] ) ? $namespace[0] : 'core/'; + $name = $namespace . $matches['name'][0]; + $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 * are associative arrays. If we use `array()` we get a JSON `[]` */ $attrs = $has_attrs - ? json_decode( $matches[ 'attrs' ][ 0 ], /* as-associative */ true ) + ? json_decode( $matches['attrs'][0], /* as-associative */ true ) : $this->empty_attrs; /* @@ -471,17 +476,17 @@ class WP_Block_Parser { * @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 ) { - $parent = $this->stack[ count( $this->stack ) - 1 ]; + $parent = $this->stack[ count( $this->stack ) - 1 ]; $parent->block->innerBlocks[] = (array) $block; - $html = substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset ); + $html = substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset ); if ( ! empty( $html ) ) { - $parent->block->innerHTML .= $html; + $parent->block->innerHTML .= $html; $parent->block->innerContent[] = $html; } $parent->block->innerContent[] = null; - $parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length; + $parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length; } /** @@ -500,16 +505,18 @@ class WP_Block_Parser { : substr( $this->document, $prev_offset ); if ( ! empty( $html ) ) { - $stack_top->block->innerHTML .= $html; + $stack_top->block->innerHTML .= $html; $stack_top->block->innerContent[] = $html; } if ( isset( $stack_top->leading_html_start ) ) { - $this->output[] = (array) self::freeform( substr( - $this->document, - $stack_top->leading_html_start, - $stack_top->token_start - $stack_top->leading_html_start - ) ); + $this->output[] = (array) self::freeform( + substr( + $this->document, + $stack_top->leading_html_start, + $stack_top->token_start - $stack_top->leading_html_start + ) + ); } $this->output[] = (array) $stack_top->block;