Fix phpdoc nullable types in some files.

It was found that in several places in the HTML API and its supporting files,
the wrong form of type annotation was used for optional parameters.

Instead of using `?type`, this patch uses `type|type-of-default-value` instead,
noting where important if the parameter is optional, and if so, what its default
value is.

Developed in https://github.com/WordPress/wordpress-develop/pull/7031
Discussed in https://core.trac.wordpress.org/ticket/61399

Props dmsnell, jonsurrell.
See #61399.

Built from https://develop.svn.wordpress.org/trunk@58742


git-svn-id: http://core.svn.wordpress.org/trunk@58144 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dmsnell
2024-07-17 00:53:17 +00:00
parent c0f074c7ce
commit b7b504dc0d
5 changed files with 17 additions and 13 deletions

View File

@@ -241,14 +241,14 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
*
* @since 6.6.0
*
* @var ?WP_HTML_Stack_Event
* @var WP_HTML_Stack_Event|null
*/
private $current_element = null;
/**
* Context node if created as a fragment parser.
*
* @var ?WP_HTML_Token
* @var WP_HTML_Token|null
*/
private $context_node = null;
@@ -752,9 +752,10 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
* this returns false for self-closing elements in the
* SVG and MathML namespace.
*
* @param ?WP_HTML_Token $node Node to examine instead of current node, if provided.
* @return bool Whether to expect a closer for the currently-matched node,
* or `null` if not matched on any token.
* @param WP_HTML_Token|null $node Optional. Node to examine, if provided.
* Default is to examine current node.
* @return bool|null Whether to expect a closer for the currently-matched node,
* or `null` if not matched on any token.
*/
public function expects_closer( $node = null ) {
$token_name = $node->node_name ?? $this->get_token_name();