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.
Built from https://develop.svn.wordpress.org/trunk@51790


git-svn-id: http://core.svn.wordpress.org/trunk@51397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2021-09-09 20:39:58 +00:00
parent 68e0c5e520
commit 1d0e1397fd
4 changed files with 11 additions and 9 deletions

View File

@ -423,13 +423,15 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
* Saves current in-memory image to file.
*
* @since 3.5.0
* @since 5.9.0 Renamed `$filename` to `$destfilename` to match parent class
* for PHP 8 named parameter support.
*
* @param string|null $filename
* @param string|null $mime_type
* @param string|null $destfilename Optional. Destination filename. Default null.
* @param string|null $mime_type Optional. The mime-type. Default null.
* @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
*/
public function save( $filename = null, $mime_type = null ) {
$saved = $this->_save( $this->image, $filename, $mime_type );
public function save( $destfilename = null, $mime_type = null ) {
$saved = $this->_save( $this->image, $destfilename, $mime_type );
if ( ! is_wp_error( $saved ) ) {
$this->file = $saved['path'];

View File

@ -662,8 +662,8 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
*
* @since 3.5.0
*
* @param string $destfilename
* @param string $mime_type
* @param string $destfilename Optional. Destination filename. Default null.
* @param string $mime_type Optional. The mime-type. Default null.
* @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
*/
public function save( $destfilename = null, $mime_type = null ) {

View File

@ -77,8 +77,8 @@ abstract class WP_Image_Editor {
* @since 3.5.0
* @abstract
*
* @param string $destfilename
* @param string $mime_type
* @param string $destfilename Optional. Destination filename. Default null.
* @param string $mime_type Optional. The mime-type. Default null.
* @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
*/
abstract public function save( $destfilename = null, $mime_type = null );

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-51789';
$wp_version = '5.9-alpha-51790';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.