From 3180ab2cef5680a1a179a51d6fbc1978fdcbe518 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 11 Apr 2022 14:21:09 +0000 Subject: [PATCH] Code Modernization: Rename parameters that use reserved keywords in `wp-admin/includes/class-wp-site-icon.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 `$object` variable to `$attachment` in `WP_Site_Icon::insert_attachment()` and updates the documentation accordingly. Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #55327. Built from https://develop.svn.wordpress.org/trunk@53137 git-svn-id: http://core.svn.wordpress.org/trunk@52726 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-site-icon.php | 16 ++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/wp-admin/includes/class-wp-site-icon.php b/wp-admin/includes/class-wp-site-icon.php index 9aff0f2a8d..d153b6f826 100644 --- a/wp-admin/includes/class-wp-site-icon.php +++ b/wp-admin/includes/class-wp-site-icon.php @@ -80,7 +80,7 @@ class WP_Site_Icon { * * @param string $cropped Cropped image URL. * @param int $parent_attachment_id Attachment ID of parent image. - * @return array Attachment object. + * @return array An array with attachment object data. */ public function create_attachment_object( $cropped, $parent_attachment_id ) { $parent = get_post( $parent_attachment_id ); @@ -90,7 +90,7 @@ class WP_Site_Icon { $size = wp_getimagesize( $cropped ); $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; - $object = array( + $attachment = array( 'ID' => $parent_attachment_id, 'post_title' => wp_basename( $cropped ), 'post_content' => $url, @@ -99,7 +99,7 @@ class WP_Site_Icon { 'context' => 'site-icon', ); - return $object; + return $attachment; } /** @@ -107,12 +107,12 @@ class WP_Site_Icon { * * @since 4.3.0 * - * @param array $object Attachment object. - * @param string $file File path of the attached image. - * @return int Attachment ID + * @param array $attachment An array with attachment object data. + * @param string $file File path of the attached image. + * @return int Attachment ID. */ - public function insert_attachment( $object, $file ) { - $attachment_id = wp_insert_attachment( $object, $file ); + public function insert_attachment( $attachment, $file ) { + $attachment_id = wp_insert_attachment( $attachment, $file ); $metadata = wp_generate_attachment_metadata( $attachment_id, $file ); /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 01b5a0e282..fd1a6e1631 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-53136'; +$wp_version = '6.0-alpha-53137'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.