Skip to content

Commit f390433

Browse files
committed
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 WordPress#12022. Follow-up to r50943, r51221, r58849. See #65376, #64896. git-svn-id: https://develop.svn.wordpress.org/trunk@62935 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 42fcdc8 commit f390433

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

‎src/wp-includes/media.php‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6534,7 +6534,7 @@ function wp_high_priority_element_flag( $value = null ): bool {
65346534
*
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
*/
65396539
function wp_get_image_editor_output_format( $filename, $mime_type ) {
65406540
$output_format = array(
@@ -6556,14 +6556,10 @@ function wp_get_image_editor_output_format( $filename, $mime_type ) {
65566556
* @since 6.7.0 The default was changed from an empty array to an array
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 );
65696565
}

0 commit comments

Comments
 (0)