Make WordPress Core


Ignore:
Timestamp:
07/19/2024 11:42:14 PM (18 months ago)
Author:
dmsnell
Message:

HTML API: Add PHP type annotations.

This patch adds type annotations to internal and private methods of the HTML
API and the supporting WP_Token_Map. Annotations have not been added to the
public interfaces where it would likely crash a site if called wrong.

These annotations should help avoid unnecessary type-related bugs (as have
been uncovered in earlier work adding such annotations) and provide additional
guidance to developers when interacting with these classes in an IDE.

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

Props dmsnell, jonsurrell.
See #61399.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/html-api/class-wp-html-text-replacement.php

    r57179 r58769  
    5757     * @param string $text   Span of text to insert in document to replace existing content from start to end.
    5858     */
    59     public function __construct( $start, $length, $text ) {
     59    public function __construct( int $start, int $length, string $text ) {
    6060        $this->start  = $start;
    6161        $this->length = $length;
Note: See TracChangeset for help on using the changeset viewer.