Make WordPress Core


Ignore:
Timestamp:
09/09/2021 08:38:20 PM (5 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.

File:
1 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 ) ) {
Note: See TracChangeset for help on using the changeset viewer.