From 37f2e311a496e354c5051b9582a0d2a7c32a7a77 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 17 Apr 2022 10:49:10 +0000 Subject: [PATCH] Code Modernization: Rename parameters that use reserved keywords in `wp-admin/includes/media.php`. While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names. This commit renames the `$return` parameter to `$return_type` in `media_sideload_image()`. Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #55327. git-svn-id: https://develop.svn.wordpress.org/trunk@53192 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/media.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 093ee69360..b0c00e847b 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -974,21 +974,21 @@ function wp_media_upload_handler() { * Downloads an image from the specified URL, saves it as an attachment, and optionally attaches it to a post. * * @since 2.6.0 - * @since 4.2.0 Introduced the `$return` parameter. - * @since 4.8.0 Introduced the 'id' option for the `$return` parameter. + * @since 4.2.0 Introduced the `$return_type` parameter. + * @since 4.8.0 Introduced the 'id' option for the `$return_type` parameter. * @since 5.3.0 The `$post_id` parameter was made optional. * @since 5.4.0 The original URL of the attachment is stored in the `_source_url` * post meta value. * - * @param string $file The URL of the image to download. - * @param int $post_id Optional. The post ID the media is to be associated with. - * @param string $desc Optional. Description of the image. - * @param string $return Optional. Accepts 'html' (image tag html) or 'src' (URL), - * or 'id' (attachment ID). Default 'html'. + * @param string $file The URL of the image to download. + * @param int $post_id Optional. The post ID the media is to be associated with. + * @param string $desc Optional. Description of the image. + * @param string $return_type Optional. Accepts 'html' (image tag html) or 'src' (URL), + * or 'id' (attachment ID). Default 'html'. * @return string|int|WP_Error Populated HTML img tag, attachment ID, or attachment source * on success, WP_Error object otherwise. */ -function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'html' ) { +function media_sideload_image( $file, $post_id = 0, $desc = null, $return_type = 'html' ) { if ( ! empty( $file ) ) { $allowed_extensions = array( 'jpg', 'jpeg', 'jpe', 'png', 'gif', 'webp' ); @@ -1043,7 +1043,7 @@ function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'htm add_post_meta( $id, '_source_url', $file ); // If attachment ID was requested, return it. - if ( 'id' === $return ) { + if ( 'id' === $return_type ) { return $id; } @@ -1052,7 +1052,7 @@ function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'htm // Finally, check to make sure the file has been saved, then return the HTML. if ( ! empty( $src ) ) { - if ( 'src' === $return ) { + if ( 'src' === $return_type ) { return $src; }