Make WordPress Core

Changeset 62935


Ignore:
Timestamp:
07/29/2026 10:01:23 PM (4 months ago)
Author:
westonruter
Message:

Docs: Correct the type of the image_editor_output_format map.

The $output_format array maps a source mime type to a destination mime type, so its keys are mime type strings. Since r51221 it has been documented as string[] (which typically means an integer-keyed array of strings) expanded by a hash-notation block whose @type string ...$0 is the notation core uses for numerically indexed members. Both halves therefore described a list, and nothing in the documentation conveyed that the key is the source mime type, which is the entire point of the array.

Replace both with array<string, string>, which states the key and value types directly and needs no nested block. The @return of wp_get_image_editor_output_format() gets the same correction, having inherited string[] when r58849 moved the canonical docblock into wp-includes/media.php.

This mismatch was surfaced by the PHPStan extensions under development for this ticket, which read hook docblocks in order to type the return of apply_filters(), and which are committed separately.

Developed as subset of ​https://github.com/WordPress/wordpress-develop/pull/12022.
Follow-up to r50943, r51221, r58849.

See #65376, #64896.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r62878 r62935  
    65356535 * @param string $filename  Path to the image.
    65366536 * @param string $mime_type The source image mime type.
    6537  * @return string[] An array of mime type mappings.
     6537 * @return array<string, string> An array of mime type mappings.
    65386538 */
    65396539function wp_get_image_editor_output_format( $filename, $mime_type ) {
    … …  
    65576557         *              containing the HEIC/HEIF images mime types.
    65586558         *
    6559          * @param string[] $output_format {
    6560          *     An array of mime type mappings. Maps a source mime type to a new
    6561          *     destination mime type. By default maps HEIC/HEIF input to JPEG output.
    6562          *
    6563          *     @type string ...$0 The new mime type.
    6564          * }
    6565          * @param string $filename  Path to the image.
    6566          * @param string $mime_type The source image mime type.
     6559         * @param array<string, string> $output_format An array of mime type mappings. Maps a source mime type to a new
     6560         *                                             destination mime type. By default maps HEIC/HEIF input to JPEG output.
     6561         * @param string                $filename      Path to the image.
     6562         * @param string                $mime_type     The source image mime type.
    65676563         */
    65686564        return apply_filters( 'image_editor_output_format', $output_format, $filename, $mime_type );
Note: See TracChangeset for help on using the changeset viewer.