Make WordPress Core

Changeset 58742


Ignore:
Timestamp:
07/17/2024 12:51:34 AM (8 months ago)
Author:
dmsnell
Message:

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.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-token-map.php

    r58281 r58742  
    521521     * @since 6.6.0
    522522     *
    523      * @param string  $text                       String in which to search for a lookup key.
    524      * @param int     $offset                     Optional. How many bytes into the string where the lookup key ought to start. Default 0.
    525      * @param ?int    &$matched_token_byte_length Optional. Holds byte-length of found token matched, otherwise not set. Default null.
    526      * @param string  $case_sensitivity           Optional. Pass 'ascii-case-insensitive' to ignore ASCII case when matching. Default 'case-sensitive'.
     523     * @param string   $text                       String in which to search for a lookup key.
     524     * @param int      $offset                     Optional. How many bytes into the string where the lookup key ought to start. Default 0.
     525     * @param int|null &$matched_token_byte_length Optional. Holds byte-length of found token matched, otherwise not set. Default null.
     526     * @param string   $case_sensitivity           Optional. Pass 'ascii-case-insensitive' to ignore ASCII case when matching. Default 'case-sensitive'.
     527     *
    527528     * @return string|null Mapped value of lookup key if found, otherwise `null`.
    528529     */
  • trunk/src/wp-includes/functions.php

    r58715 r58742  
    74987498 * @since 6.6.0
    74997499 *
    7500  * @param ?string $blog_charset Slug representing a text character encoding, or "charset".
    7501  *                              E.g. "UTF-8", "Windows-1252", "ISO-8859-1", "SJIS".
     7500 * @param string|null $blog_charset Optional. Slug representing a text character encoding, or "charset".
     7501 *                                  E.g. "UTF-8", "Windows-1252", "ISO-8859-1", "SJIS".
     7502 *                                  Default value is to infer from "blog_charset" option.
    75027503 * @return bool Whether the slug represents the UTF-8 encoding.
    75037504 */
  • trunk/src/wp-includes/html-api/class-wp-html-open-elements.php

    r58677 r58742  
    500500     * @since 6.5.0 Accepts $above_this_node to start traversal above a given node, if it exists.
    501501     *
    502      * @param ?WP_HTML_Token $above_this_node Start traversing above this node, if provided and if the node exists.
     502     * @param WP_HTML_Token|null $above_this_node Optional. Start traversing above this node,
     503     *                                            if provided and if the node exists.
    503504     */
    504505    public function walk_up( $above_this_node = null ) {
  • trunk/src/wp-includes/html-api/class-wp-html-processor.php

    r58714 r58742  
    242242     * @since 6.6.0
    243243     *
    244      * @var ?WP_HTML_Stack_Event
     244     * @var WP_HTML_Stack_Event|null
    245245     */
    246246    private $current_element = null;
     
    249249     * Context node if created as a fragment parser.
    250250     *
    251      * @var ?WP_HTML_Token
     251     * @var WP_HTML_Token|null
    252252     */
    253253    private $context_node = null;
     
    753753     *       SVG and MathML namespace.
    754754     *
    755      * @param  ?WP_HTML_Token $node Node to examine instead of current node, if provided.
    756      * @return bool Whether to expect a closer for the currently-matched node,
    757      *              or `null` if not matched on any token.
     755     * @param WP_HTML_Token|null $node Optional. Node to examine, if provided.
     756     *                                 Default is to examine current node.
     757     * @return bool|null Whether to expect a closer for the currently-matched node,
     758     *                   or `null` if not matched on any token.
    758759     */
    759760    public function expects_closer( $node = null ) {
  • trunk/tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php

    r58733 r58742  
    276276         * Represents which section of the test case is being parsed.
    277277         *
    278          * @var ?string
     278         * @var string|null
    279279         */
    280280        $state = null;
Note: See TracChangeset for help on using the changeset viewer.