From 8fa0d979977a248aab4ef2f0870de32e5d9e73b2 Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Sat, 14 Oct 2023 00:43:01 +0100 Subject: [PATCH] Remove empty attrs. (#54496) * Remove empty attrs. * Fix linter errors --------- Co-authored-by: Sarah Norris --- .../class-wp-block-parser.php | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/block-serialization-default-parser/class-wp-block-parser.php b/packages/block-serialization-default-parser/class-wp-block-parser.php index 5790e97f8cf29..543f53691ccb1 100644 --- a/packages/block-serialization-default-parser/class-wp-block-parser.php +++ b/packages/block-serialization-default-parser/class-wp-block-parser.php @@ -48,14 +48,6 @@ class WP_Block_Parser { */ public $stack; - /** - * Empty associative array, here due to PHP quirks - * - * @since 4.4.0 - * @var array empty associative array - */ - public $empty_attrs; - /** * Parses a document and returns a list of block structures * @@ -69,11 +61,10 @@ class WP_Block_Parser { * @return array[] */ public function parse( $document ) { - $this->document = $document; - $this->offset = 0; - $this->output = array(); - $this->stack = array(); - $this->empty_attrs = array(); + $this->document = $document; + $this->offset = 0; + $this->output = array(); + $this->stack = array(); while ( $this->proceed() ) { continue; @@ -287,7 +278,7 @@ public function next_token() { */ $attrs = $has_attrs ? json_decode( $matches['attrs'][0], /* as-associative */ true ) - : $this->empty_attrs; + : array(); /* * This state isn't allowed @@ -318,7 +309,7 @@ public function next_token() { * @return WP_Block_Parser_Block freeform block object. */ public function freeform( $inner_html ) { - return new WP_Block_Parser_Block( null, $this->empty_attrs, array(), $inner_html, array( $inner_html ) ); + return new WP_Block_Parser_Block( null, array(), array(), $inner_html, array( $inner_html ) ); } /**