diff --git a/src/wp-includes/html-api/class-wp-html-active-formatting-elements.php b/src/wp-includes/html-api/class-wp-html-active-formatting-elements.php
index 90c3bbbd34e3b..d73561843bcb2 100644
--- a/src/wp-includes/html-api/class-wp-html-active-formatting-elements.php
+++ b/src/wp-includes/html-api/class-wp-html-active-formatting-elements.php
@@ -67,7 +67,7 @@ public function contains_node( WP_HTML_Token $token ) {
*
* @since 6.4.0
*
- * @return int How many node are in the stack of active formatting elements.
+ * @return int How many nodes are in the stack of active formatting elements.
*/
public function count() {
return count( $this->stack );
diff --git a/src/wp-includes/html-api/class-wp-html-attribute-token.php b/src/wp-includes/html-api/class-wp-html-attribute-token.php
index fab66d827b451..3cf93b28905af 100644
--- a/src/wp-includes/html-api/class-wp-html-attribute-token.php
+++ b/src/wp-includes/html-api/class-wp-html-attribute-token.php
@@ -32,7 +32,7 @@ class WP_HTML_Attribute_Token {
public $name;
/**
- * Attribute value.
+ * Byte offset in the input HTML where the attribute value starts.
*
* @since 6.2.0
*
@@ -101,7 +101,7 @@ class WP_HTML_Attribute_Token {
* @since 6.5.0 Replaced `end` with `length` to more closely match `substr()`.
*
* @param string $name Attribute name.
- * @param int $value_start Attribute value.
+ * @param int $value_start Byte offset where the attribute value starts.
* @param int $value_length Number of bytes attribute value spans.
* @param int $start The string offset where the attribute name starts.
* @param int $length Byte length of the entire attribute name or name and value pair expression.
diff --git a/src/wp-includes/html-api/class-wp-html-decoder.php b/src/wp-includes/html-api/class-wp-html-decoder.php
index d902f4b7cabc4..0a781a88efc77 100644
--- a/src/wp-includes/html-api/class-wp-html-decoder.php
+++ b/src/wp-includes/html-api/class-wp-html-decoder.php
@@ -83,7 +83,7 @@ public static function attribute_starts_with( $haystack, $search_text, $case_sen
*
* Example:
*
- * 'βπβ' === WP_HTML_Decode::decode_text_node( '😄' );
+ * 'βπβ' === WP_HTML_Decoder::decode_text_node( '😄' );
*
* @since 6.6.0
*
@@ -103,7 +103,7 @@ public static function decode_text_node( $text ): string {
*
* Example:
*
- * 'βπβ' === WP_HTML_Decode::decode_attribute( '😄' );
+ * 'βπβ' === WP_HTML_Decoder::decode_attribute( '😄' );
*
* @since 6.6.0
*
diff --git a/src/wp-includes/html-api/class-wp-html-doctype-info.php b/src/wp-includes/html-api/class-wp-html-doctype-info.php
index 1e57afb3fd550..2e21e033babc1 100644
--- a/src/wp-includes/html-api/class-wp-html-doctype-info.php
+++ b/src/wp-includes/html-api/class-wp-html-doctype-info.php
@@ -138,7 +138,7 @@ class WP_HTML_Doctype_Info {
* indicate one of three possible document compatibility modes:
*
* - "no-quirks" and "limited-quirks" modes (also called "standards" mode).
- * - "quirks" mode (also called `CSS1Compat` mode).
+ * - "quirks" mode (also called `BackCompat` mode).
*
* An appropriate DOCTYPE is one encountered in the "initial" insertion mode,
* before the HTML element has been opened and before finding any other
diff --git a/src/wp-includes/html-api/class-wp-html-open-elements.php b/src/wp-includes/html-api/class-wp-html-open-elements.php
index 0cd1f0fc45e07..aeee107250895 100644
--- a/src/wp-includes/html-api/class-wp-html-open-elements.php
+++ b/src/wp-includes/html-api/class-wp-html-open-elements.php
@@ -78,7 +78,7 @@ class WP_HTML_Open_Elements {
* Sets a pop handler that will be called when an item is popped off the stack of
* open elements.
*
- * The function will be called with the pushed item as its argument.
+ * The function will be called with the popped item as its argument.
*
* @since 6.6.0
*
@@ -103,7 +103,7 @@ public function set_push_handler( Closure $handler ): void {
}
/**
- * Returns the name of the node at the nth position on the stack
+ * Returns the node at the nth position on the stack
* of open elements, or `null` if no such position exists.
*
* Note that this uses a 1-based index, which represents the
@@ -114,7 +114,7 @@ public function set_push_handler( Closure $handler ): void {
*
* @param int $nth Retrieve the nth item on the stack, with 1 being
* the top element, 2 being the second, etc...
- * @return WP_HTML_Token|null Name of the node on the stack at the given location,
+ * @return WP_HTML_Token|null The node on the stack at the given location,
* or `null` if the location isn't on the stack.
*/
public function at( int $nth ): ?WP_HTML_Token {
@@ -168,7 +168,7 @@ public function contains_node( WP_HTML_Token $token ): bool {
*
* @since 6.4.0
*
- * @return int How many node are in the stack of open elements.
+ * @return int How many nodes are in the stack of open elements.
*/
public function count(): int {
return count( $this->stack );
diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php
index 35d91fad3129c..f41c828c5b2c0 100644
--- a/src/wp-includes/html-api/class-wp-html-processor.php
+++ b/src/wp-includes/html-api/class-wp-html-processor.php
@@ -66,7 +66,7 @@
* tags may be found with the shortest-matching breadcrumb query. That is,
* `array( 'IMG' )` matches all IMG elements and `array( 'P', 'IMG' )`
* matches all IMG elements directly inside a P element. To ensure that no
- * partial matches erroneously match it's possible to specify in a query
+ * partial matches erroneously match, it's possible to specify in a query
* the full breadcrumb match all the way down from the root HTML element.
*
* Example:
@@ -341,6 +341,8 @@ public static function create_fragment( $html, $context = '
', $encoding =
* isn't UTF-8, first convert the document to UTF-8, then pass in the
* converted HTML.
*
+ * @since 6.7.0
+ *
* @param string $html Input HTML document to process.
* @param string|null $known_definite_encoding Optional. If provided, specifies the charset used
* in the input byte stream. Currently must be UTF-8.
@@ -621,7 +623,7 @@ private function bail( string $message ) {
*
* Various situations lead to parsing failure but this class will
* return `false` in all those cases. To determine why something
- * failed it's possible to request the last error. This can be
+ * failed, it's possible to request the last error. This can be
* helpful to know to distinguish whether a given tag couldn't
* be found or if content in the document caused the processor
* to give up and abort processing.
@@ -957,7 +959,7 @@ public function matches_breadcrumbs( $breadcrumbs ): bool {
* token, or if it will self-close on the next step.
*
* Most HTML elements expect a closer, such as a P element or
- * a DIV element. Others, like an IMG element are void and don't
+ * a DIV element. Others, like an IMG element, are void and don't
* have a closing tag. Special elements, such as SCRIPT and STYLE,
* are treated just like void tags. Text nodes and self-closing
* foreign content will also act just like a void tag, immediately
@@ -1340,7 +1342,7 @@ public function serialize(): ?string {
* Serializes the currently-matched token.
*
* This method produces a fully-normative HTML string for the currently-matched token,
- * if able. If not matched at any token or if the token doesn't correspond to any HTML
+ * if able. If not matched at any token, or if the token doesn't correspond to any HTML,
* it will return an empty string (for example, presumptuous end tags are ignored).
*
* @see static::serialize()
@@ -5208,7 +5210,7 @@ private function step_in_foreign_content(): bool {
*
* @throws Exception When unable to allocate requested bookmark.
*
- * @return string|false Name of created bookmark, or false if unable to create.
+ * @return string Name of created bookmark.
*/
private function bookmark_token() {
if ( ! parent::set_bookmark( ++$this->bookmark_counter ) ) {
diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php
index 77c1a471db5b1..f11fe9cde5087 100644
--- a/src/wp-includes/html-api/class-wp-html-tag-processor.php
+++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php
@@ -213,7 +213,7 @@
*
* ### Bookmarks
*
- * While scanning through the input HTMl document it's possible to set
+ * While scanning through the input HTML document it's possible to set
* a named bookmark when a particular tag is found. Later on, after
* continuing to scan other tags, it's possible to `seek` to one of
* the set bookmarks and then proceed again from that point forward.
@@ -286,7 +286,7 @@
*
* For these elements the Tag Processor treats the entire sequence as one,
* from the opening tag, including its contents, through its closing tag.
- * This means that the it's not possible to match the closing tag for a
+ * This means that it's not possible to match the closing tag for a
* SCRIPT element unless it's unexpected; the Tag Processor already matched
* it when it found the opening tag.
*
@@ -298,7 +298,7 @@
* closing the SCRIPT from inside a JavaScript string. E.g. `console.log( '' )`.
* - `TITLE` and `TEXTAREA` whose contents are treated as plaintext and then any
* character references are decoded. E.g. `1 < 2 < 3` becomes `1 < 2 < 3`.
- * - `IFRAME`, `NOSCRIPT`, `NOEMBED`, `NOFRAME`, `STYLE` whose contents are treated as
+ * - `IFRAME`, `NOEMBED`, `NOFRAMES`, `STYLE` whose contents are treated as
* raw plaintext and left as-is. E.g. `1 < 2 < 3` remains `1 < 2 < 3`.
*
* #### Other tokens with modifiable text.
@@ -329,7 +329,7 @@
* and disallows "xml" as a name, since it's special. The Tag Processor only recognizes
* target names with an ASCII-representable subset of characters. It also exhibits the
* same constraint as with CDATA sections, in that `>` cannot exist within the token
- * since Processing Instructions do no exist within HTML and their syntax transforms
+ * since Processing Instructions do not exist within HTML and their syntax transforms
* into a bogus comment in the DOM.
*
* ## Design and limitations
@@ -521,7 +521,7 @@ class WP_HTML_Tag_Processor {
* - A TABLE start tag `
` implicitly closes any open `P` element.
*
* - In `QUIRKS_MODE`:
- * - CSS class and ID selectors match match in an ASCII case-insensitive manner.
+ * - CSS class and ID selectors match in an ASCII case-insensitive manner.
* - A TABLE start tag `
` opens a `TABLE` element as a child of a `P`
* element if one is open.
*
@@ -614,12 +614,12 @@ class WP_HTML_Tag_Processor {
* Example:
*
*
...
- * 012345678901234
- * - token length is 14 - 0 = 14
+ * 0123456789012345
+ * - token length is 15 - 0 = 15
*
* a is a token.
* 0123456789 123456789 123456789
- * - token length is 17 - 2 = 15
+ * - token length is 18 - 2 = 16
*
* @since 6.5.0
*
@@ -926,8 +926,6 @@ public function next_tag( $query = null ): bool {
* - a DOCTYPE declaration.
* - a processing instruction, e.g. ``.
*
- * The Tag Processor currently only supports the tag token.
- *
* @since 6.5.0
* @since 6.7.0 Recognizes CDATA sections within foreign content.
*
@@ -1073,7 +1071,7 @@ private function base_class_next_token(): bool {
*
* Preserve the opening tag pointers, as these will be overwritten
* when finding the closing tag. They will be reset after finding
- * the closing to tag to point to the opening of the special atomic
+ * the closing tag to point to the opening of the special atomic
* tag sequence.
*/
$tag_name_starts_at = $this->tag_name_starts_at;
@@ -1149,7 +1147,7 @@ private function base_class_next_token(): bool {
* Example:
*
* $processor = new WP_HTML_Tag_Processor( 'subdivide_text_appropriately();
*
- * $processor = new WP_HTML_Tag_Processor( " \r\n\tMore" );
- * true === $processor->next_token(); // Text is "β€ β€βMore".
- * true === $processor->subdivide_text_appropriately(); // Text is "β€ β€β".
+ * $processor = new WP_HTML_Tag_Processor( "
\r\n\tMore" );
+ * true === $processor->next_token(); // Text is "β ββMore".
+ * true === $processor->subdivide_text_appropriately(); // Text is "β ββ".
* true === $processor->next_token(); // Text is "More".
* false === $processor->subdivide_text_appropriately();
*
@@ -4935,7 +4933,7 @@ public function get_doctype_info(): ?WP_HTML_Doctype_Info {
* 2>
*
* Funky comments are tag closers with invalid tag names. Note
- * that in HTML these are turn into bogus comments. Nonetheless,
+ * that in HTML these are turned into bogus comments. Nonetheless,
* the Tag Processor recognizes them in a stream of HTML and
* exposes them for inspection and modification.
*
diff --git a/src/wp-includes/html-api/class-wp-html-token.php b/src/wp-includes/html-api/class-wp-html-token.php
index d5e51ac29007f..d95f2934c5c78 100644
--- a/src/wp-includes/html-api/class-wp-html-token.php
+++ b/src/wp-includes/html-api/class-wp-html-token.php
@@ -29,7 +29,7 @@ class WP_HTML_Token {
*
* @since 6.4.0
*
- * @var string
+ * @var string|null
*/
public $bookmark_name = null;
diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php b/tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php
index e516addb6c314..52a855d40cff4 100644
--- a/tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php
+++ b/tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php
@@ -138,7 +138,7 @@ public function test_unexpected_closing_tags_are_removed() {
$this->assertSame(
WP_HTML_Processor::normalize( 'one
twothree' ),
'onetwothree',
- 'Should have removed unpected closing tags.'
+ 'Should have removed unexpected closing tags.'
);
}
diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessor.php b/tests/phpunit/tests/html-api/wpHtmlProcessor.php
index a89014282df73..bb18629563493 100644
--- a/tests/phpunit/tests/html-api/wpHtmlProcessor.php
+++ b/tests/phpunit/tests/html-api/wpHtmlProcessor.php
@@ -1071,11 +1071,11 @@ public function test_ensure_next_token_method_extensibility( $html, $expected_to
* @ticket 62427
*/
public function test_next_tag_lowercase_tag_name() {
- // The upper case
is irrelevant but illustrates the case-insentivity.
+ // The upper case
is irrelevant but illustrates the case-insensitivity.
$processor = WP_HTML_Processor::create_fragment( '
' );
$this->assertTrue( $processor->next_tag( array( 'tag_name' => 'div' ) ) );
- // The upper case is irrelevant but illustrates the case-insentivity.
+ // The upper case is irrelevant but illustrates the case-insensitivity.
$processor = WP_HTML_Processor::create_fragment( '
' );
* $processor->next_tag();
* $processor->set_attribute('class', '" onclick="alert');
- * echo $p;
+ * echo $processor->get_updated_html();
* //
* ```
*
- * To prevent it, `set_attribute` calls `esc_attr()` on its given values.
+ * To prevent it, `set_attribute` escapes dangerous characters (`"`, `'`, `<`, `>`, `&`) using HTML character references.
*
* ```php
*
@@ -1523,11 +1523,11 @@ public function test_calling_remove_class_with_all_listed_class_names_removes_th
$this->assertSame(
'
Text
',
$processor->get_updated_html(),
- 'Updated HTML does not reflect class attribute removed via subesequent remove_class() calls'
+ 'Updated HTML does not reflect class attribute removed via subsequent remove_class() calls'
);
$this->assertNull(
$processor->get_attribute( 'class' ),
- "get_attribute( 'class' ) did not return null for class attribute removed via subesequent remove_class() calls"
+ "get_attribute( 'class' ) did not return null for class attribute removed via subsequent remove_class() calls"
);
}
diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php
index f43d1fffaad0e..4a09403b7b23e 100644
--- a/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php
+++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php
@@ -415,7 +415,7 @@ public function test_updates_basic_modifiable_text_on_supported_nodes( string $h
$this->assertSame(
$transformed,
$processor->get_updated_html(),
- "Should have transformed the HTML as expected why modifying the target node's modifiable text."
+ "Should have transformed the HTML as expected when modifying the target node's modifiable text."
);
}