22
33namespace WordPress \DataLiberation \BlockMarkup ;
44
5- use WP_Block_Parser_Error ;
5+ use WP_Error ;
66use WP_HTML_Tag_Processor ;
77
88/**
@@ -113,9 +113,9 @@ public function get_token_type(): ?string {
113113 /**
114114 * Gets the most recent error encountered while parsing blocks
115115 *
116- * @return WP_Block_Parser_Error |null The error message or null if no error
116+ * @return WP_Error |null The error message or null if no error
117117 */
118- public function get_last_error (): ?WP_Block_Parser_Error {
118+ public function get_last_error (): ?WP_Error {
119119 return $ this ->last_block_error ;
120120 }
121121
@@ -362,9 +362,9 @@ public function next_token(): bool {
362362 $ name_length = strspn ( $ text , 'abcdefghijklmnopqrstuwxvyzABCDEFGHIJKLMNOPRQSTUWXVYZ0123456789_- ' , $ at );
363363 if ( 0 === $ name_length ) {
364364 // This wasn't a block after all, just a regular comment.
365- $ this ->last_block_error = new WP_Block_Parser_Error (
366- sprintf ( ' An HTML comment started with "wp:" that was not followed by a valid block name: %s ' , $ text ) ,
367- WP_Block_Parser_Error:: TYPE_SUSPICIOUS_DELIMITER
365+ $ this ->last_block_error = new WP_Error (
366+ ' suspicious-delimiter ' ,
367+ sprintf ( ' An HTML comment started with "wp:" that was not followed by a valid block name: %s ' , $ text )
368368 );
369369
370370 return true ;
@@ -404,9 +404,9 @@ public function next_token(): bool {
404404 if ( null === $ attributes || ! is_array ( $ attributes ) ) {
405405 // This comment looked like a block comment, but the attributes didn't
406406 // parse as a JSON array. This means it wasn't a block after all.
407- $ this ->last_block_error = new WP_Block_Parser_Error (
408- sprintf ( ' %s could be parsed as a delimiter but JSON attributes were malformed: %s. ' , $ name , $ json_maybe ) ,
409- WP_Block_Parser_Error:: TYPE_SUSPICIOUS_DELIMITER
407+ $ this ->last_block_error = new WP_Error (
408+ ' suspicious- delimiter' ,
409+ sprintf ( ' %s could be parsed as a delimiter but JSON attributes were malformed: %s. ' , $ name , $ json_maybe )
410410 );
411411
412412 return true ;
@@ -423,9 +423,9 @@ public function next_token(): bool {
423423 if ( $ this ->block_closer ) {
424424 $ popped = array_pop ( $ this ->stack_of_open_blocks );
425425 if ( $ popped !== $ name ) {
426- $ this ->last_block_error = new WP_Block_Parser_Error (
427- sprintf ( ' Block closer %s does not match the last opened block %s. ' , $ name , $ popped ) ,
428- WP_Block_Parser_Error:: TYPE_MISMATCHED_CLOSER
426+ $ this ->last_block_error = new WP_Error (
427+ ' mismatched- closer' ,
428+ sprintf ( ' Block closer %s does not match the last opened block %s. ' , $ name , $ popped )
429429 );
430430
431431 return false ;
0 commit comments