Make WordPress Core

Changeset 51790


Ignore:
Timestamp:
09/09/2021 08:38:20 PM (3 years ago)
Author:
hellofromTonya
Message:

Code Modernization: Fix parameter name mismatches for parent/child classes in WP_Image_Editor::save().

Renames the first parameter in WP_Image_Editor_GD::save() to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Adds @since to clearly specify why the change happened.

Adds parameter descriptions to parent and both child classes.

Follow-up to [22094], [22619], [30681].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.

Location:
trunk/src/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-image-editor-gd.php

    r51298 r51790  
    424424     *
    425425     * @since 3.5.0
    426      *
    427      * @param string|null $filename
    428      * @param string|null $mime_type
     426     * @since 5.9.0 Renamed `$filename` to `$destfilename` to match parent class
     427     *              for PHP 8 named parameter support.
     428     *
     429     * @param string|null $destfilename Optional. Destination filename. Default null.
     430     * @param string|null $mime_type    Optional. The mime-type. Default null.
    429431     * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
    430432     */
    431     public function save( $filename = null, $mime_type = null ) {
    432         $saved = $this->_save( $this->image, $filename, $mime_type );
     433    public function save( $destfilename = null, $mime_type = null ) {
     434        $saved = $this->_save( $this->image, $destfilename, $mime_type );
    433435
    434436        if ( ! is_wp_error( $saved ) ) {
  • trunk/src/wp-includes/class-wp-image-editor-imagick.php

    r51435 r51790  
    663663     * @since 3.5.0
    664664     *
    665      * @param string $destfilename
    666      * @param string $mime_type
     665     * @param string $destfilename Optional. Destination filename. Default null.
     666     * @param string $mime_type    Optional. The mime-type. Default null.
    667667     * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
    668668     */
  • trunk/src/wp-includes/class-wp-image-editor.php

    r51717 r51790  
    7878     * @abstract
    7979     *
    80      * @param string $destfilename
    81      * @param string $mime_type
     80     * @param string $destfilename Optional. Destination filename. Default null.
     81     * @param string $mime_type    Optional. The mime-type. Default null.
    8282     * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
    8383     */
Note: See TracChangeset for help on using the changeset viewer.