Make WordPress Core

Changeset 53137


Ignore:
Timestamp:
04/11/2022 02:19:13 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-site-icon.php

    r50146 r53137  
    8181     * @param string $cropped              Cropped image URL.
    8282     * @param int    $parent_attachment_id Attachment ID of parent image.
    83      * @return array Attachment object.
     83     * @return array An array with attachment object data.
    8484     */
    8585    public function create_attachment_object( $cropped, $parent_attachment_id ) {
     
    9191        $image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
    9292
    93         $object = array(
     93        $attachment = array(
    9494            'ID'             => $parent_attachment_id,
    9595            'post_title'     => wp_basename( $cropped ),
     
    100100        );
    101101
    102         return $object;
     102        return $attachment;
    103103    }
    104104
     
    108108     * @since 4.3.0
    109109     *
    110      * @param array  $object Attachment object.
    111      * @param string $file   File path of the attached image.
    112      * @return int           Attachment ID
    113      */
    114     public function insert_attachment( $object, $file ) {
    115         $attachment_id = wp_insert_attachment( $object, $file );
     110     * @param array  $attachment An array with attachment object data.
     111     * @param string $file       File path of the attached image.
     112     * @return int               Attachment ID.
     113     */
     114    public function insert_attachment( $attachment, $file ) {
     115        $attachment_id = wp_insert_attachment( $attachment, $file );
    116116        $metadata      = wp_generate_attachment_metadata( $attachment_id, $file );
    117117
Note: See TracChangeset for help on using the changeset viewer.