Skip to content

Commit 4aeb284

Browse files
committed
Editor: Update block-serialization-default-parser package for WP 6.3 Beta 1.
Update the `@wordpress/block-serialization-default-parser` to 4.35.1 for WordPress 6.3 Beta 1. These changes split the following classes in to their own files in order to match the WordPress PHP coding standards: * `WP_Block_Parser_Block` * `WP_Block_Parser_Frame` * `WP_Block_Parser` These classes were previously all included in the `src/wp-includes/class-wp-block-parser.php` file. In order to maintain backward compatibly for developers requiring the file directly, the relocated classes are replaced with `require_once` calls in the original file. In order to retain the commit history of the new files, they have been created using the `svn copy` command. Props aristath, rajanpanchal2028, jrf, SergeyBiryukov, costdev, manfcarlo, spacedmonkey, mukesh27, isabel_brison, dd32. Fixes #57832. See #58623. git-svn-id: https://develop.svn.wordpress.org/trunk@56048 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a7a32c3 commit 4aeb284

8 files changed

Lines changed: 206 additions & 165 deletions

File tree

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"@wordpress/block-directory": "4.3.13",
8686
"@wordpress/block-editor": "11.3.10",
8787
"@wordpress/block-library": "8.3.13",
88-
"@wordpress/block-serialization-default-parser": "4.26.1",
88+
"@wordpress/block-serialization-default-parser": "4.35.1",
8989
"@wordpress/blocks": "12.3.3",
9090
"@wordpress/components": "23.3.7",
9191
"@wordpress/compose": "6.3.3",

phpcs.xml.dist

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
<exclude-pattern>/src/wp-includes/class-requests\.php</exclude-pattern>
119119
<exclude-pattern>/src/wp-includes/class-simplepie\.php</exclude-pattern>
120120
<exclude-pattern>/src/wp-includes/class-snoopy\.php</exclude-pattern>
121-
<exclude-pattern>/src/wp-includes/class-wp-block-parser\.php</exclude-pattern>
122121
<exclude-pattern>/src/wp-includes/deprecated\.php</exclude-pattern>
123122
<exclude-pattern>/src/wp-includes/ms-deprecated\.php</exclude-pattern>
124123
<exclude-pattern>/src/wp-includes/pluggable-deprecated\.php</exclude-pattern>
@@ -187,6 +186,18 @@
187186
<exclude-pattern>/tests/phpunit/tests/multisite/site\.php</exclude-pattern>
188187
</rule>
189188

189+
<!-- Allow non-snake-case vars & properties for block-related classes. -->
190+
<rule ref="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase">
191+
<exclude-pattern>/src/wp-includes/class-wp-block-parser\.php</exclude-pattern>
192+
<exclude-pattern>/src/wp-includes/class-wp-block-parser-block\.php</exclude-pattern>
193+
</rule>
194+
<rule ref="WordPress.NamingConventions.ValidVariableName.PropertyNotSnakeCase">
195+
<exclude-pattern>/src/wp-includes/class-wp-block-parser-block\.php</exclude-pattern>
196+
</rule>
197+
<rule ref="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase">
198+
<exclude-pattern>/src/wp-includes/class-wp-block-parser-block\.php</exclude-pattern>
199+
</rule>
200+
190201
<!-- Allow the I18n functions file for issues identified by the I18n sniff
191202
(such as calling the low-level translate() function). -->
192203
<rule ref="WordPress.WP.I18n">
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
/**
3+
* Block Serialization Parser
4+
*
5+
* @package WordPress
6+
*/
7+
8+
/**
9+
* Class WP_Block_Parser_Block
10+
*
11+
* Holds the block structure in memory
12+
*
13+
* @since 5.0.0
14+
*/
15+
class WP_Block_Parser_Block {
16+
/**
17+
* Name of block
18+
*
19+
* @example "core/paragraph"
20+
*
21+
* @since 5.0.0
22+
* @var string
23+
*/
24+
public $blockName; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
25+
26+
/**
27+
* Optional set of attributes from block comment delimiters
28+
*
29+
* @example null
30+
* @example array( 'columns' => 3 )
31+
*
32+
* @since 5.0.0
33+
* @var array|null
34+
*/
35+
public $attrs;
36+
37+
/**
38+
* List of inner blocks (of this same class)
39+
*
40+
* @since 5.0.0
41+
* @var WP_Block_Parser_Block[]
42+
*/
43+
public $innerBlocks; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
44+
45+
/**
46+
* Resultant HTML from inside block comment delimiters
47+
* after removing inner blocks
48+
*
49+
* @example "...Just <!-- wp:test /--> testing..." -> "Just testing..."
50+
*
51+
* @since 5.0.0
52+
* @var string
53+
*/
54+
public $innerHTML; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
55+
56+
/**
57+
* List of string fragments and null markers where inner blocks were found
58+
*
59+
* @example array(
60+
* 'innerHTML' => 'BeforeInnerAfter',
61+
* 'innerBlocks' => array( block, block ),
62+
* 'innerContent' => array( 'Before', null, 'Inner', null, 'After' ),
63+
* )
64+
*
65+
* @since 4.2.0
66+
* @var array
67+
*/
68+
public $innerContent; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
69+
70+
/**
71+
* Constructor.
72+
*
73+
* Will populate object properties from the provided arguments.
74+
*
75+
* @since 5.0.0
76+
*
77+
* @param string $name Name of block.
78+
* @param array $attrs Optional set of attributes from block comment delimiters.
79+
* @param array $inner_blocks List of inner blocks (of this same class).
80+
* @param string $inner_html Resultant HTML from inside block comment delimiters after removing inner blocks.
81+
* @param array $inner_content List of string fragments and null markers where inner blocks were found.
82+
*/
83+
public function __construct( $name, $attrs, $inner_blocks, $inner_html, $inner_content ) {
84+
$this->blockName = $name; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
85+
$this->attrs = $attrs;
86+
$this->innerBlocks = $inner_blocks; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
87+
$this->innerHTML = $inner_html; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
88+
$this->innerContent = $inner_content; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
89+
}
90+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Block Serialization Parser
4+
*
5+
* @package WordPress
6+
*/
7+
8+
/**
9+
* Class WP_Block_Parser_Frame
10+
*
11+
* Holds partial blocks in memory while parsing
12+
*
13+
* @internal
14+
* @since 5.0.0
15+
*/
16+
class WP_Block_Parser_Frame {
17+
/**
18+
* Full or partial block
19+
*
20+
* @since 5.0.0
21+
* @var WP_Block_Parser_Block
22+
*/
23+
public $block;
24+
25+
/**
26+
* Byte offset into document for start of parse token
27+
*
28+
* @since 5.0.0
29+
* @var int
30+
*/
31+
public $token_start;
32+
33+
/**
34+
* Byte length of entire parse token string
35+
*
36+
* @since 5.0.0
37+
* @var int
38+
*/
39+
public $token_length;
40+
41+
/**
42+
* Byte offset into document for after parse token ends
43+
* (used during reconstruction of stack into parse production)
44+
*
45+
* @since 5.0.0
46+
* @var int
47+
*/
48+
public $prev_offset;
49+
50+
/**
51+
* Byte offset into document where leading HTML before token starts
52+
*
53+
* @since 5.0.0
54+
* @var int
55+
*/
56+
public $leading_html_start;
57+
58+
/**
59+
* Constructor
60+
*
61+
* Will populate object properties from the provided arguments.
62+
*
63+
* @since 5.0.0
64+
*
65+
* @param WP_Block_Parser_Block $block Full or partial block.
66+
* @param int $token_start Byte offset into document for start of parse token.
67+
* @param int $token_length Byte length of entire parse token string.
68+
* @param int $prev_offset Byte offset into document for after parse token ends.
69+
* @param int $leading_html_start Byte offset into document where leading HTML before token starts.
70+
*/
71+
public function __construct( $block, $token_start, $token_length, $prev_offset = null, $leading_html_start = null ) {
72+
$this->block = $block;
73+
$this->token_start = $token_start;
74+
$this->token_length = $token_length;
75+
$this->prev_offset = isset( $prev_offset ) ? $prev_offset : $token_start + $token_length;
76+
$this->leading_html_start = $leading_html_start;
77+
}
78+
}

0 commit comments

Comments
 (0)