Skip to content

Commit

Permalink
Throw on unhandled token types
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Jan 31, 2024
1 parent 5d0b918 commit 9aef2e5
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,6 @@ public static function build_html5_treelike_string( $fragment_context, $html ) {
$output .= str_repeat( $indent, $indent_level ) . "\"{$processor->get_modifiable_text()}\"\n";
break;

case '#cdata-section':
break;

case '#processing-instruction':
break;

case '#comment':
switch ( $processor->get_comment_type() ) {
case WP_HTML_Processor::COMMENT_AS_ABRUPTLY_CLOSED_COMMENT:
Expand All @@ -201,20 +195,14 @@ public static function build_html5_treelike_string( $fragment_context, $html ) {
break;

default:
throw new Exception( "Unhandled comment type for tree construction: {$processor->get_comment_type()}" );
throw new Error( "Unhandled comment type for tree construction: {$processor->get_comment_type()}" );
}
// Comments must be "<" then "!-- " then the data then " -->".
$output .= str_repeat( $indent, $indent_level ) . "<!-- {$commentTextContent} -->\n";

Check failure on line 201 in tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Variable "$commentTextContent" is not in valid snake_case format, try "$comment_text_content"
break;

case '#doctype':
break;

case '#presumptuous-tag':
break;

case '#funky-comment':
break;
default:
throw new Error( "Unhandled token type for tree construction: {$processor->get_token_type()}" );
}
}

Expand Down

0 comments on commit 9aef2e5

Please sign in to comment.