Make WordPress Core


Ignore:
Timestamp:
07/19/2024 11:42:14 PM (12 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-stack-event.php

    r58558 r58769  
    7575     * @param string        $provenance "virtual" or "real".
    7676     */
    77     public function __construct( $token, $operation, $provenance ) {
     77    public function __construct( WP_HTML_Token $token, string $operation, string $provenance ) {
    7878        $this->token      = $token;
    7979        $this->operation  = $operation;
Note: See TracChangeset for help on using the changeset viewer.