wp/wp-includes/class-wp-image-editor-gd.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
--- a/wp/wp-includes/class-wp-image-editor-gd.php	Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/class-wp-image-editor-gd.php	Tue Sep 27 16:37:53 2022 +0200
@@ -70,7 +70,7 @@
 			case 'image/gif':
 				return ( $image_types & IMG_GIF ) != 0;
 			case 'image/webp':
-				return ( $image_types & IMG_WEBP ) != 0; // phpcs:ignore PHPCompatibility.Constants.NewConstants.img_webpFound
+				return ( $image_types & IMG_WEBP ) != 0;
 		}
 
 		return false;
@@ -89,7 +89,7 @@
 		}
 
 		if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) {
-			return new WP_Error( 'error_loading_image', __( 'File doesn’t exist?' ), $this->file );
+			return new WP_Error( 'error_loading_image', __( 'File does not exist?' ), $this->file );
 		}
 
 		// Set artificially high because GD uses uncompressed images in memory.
@@ -98,7 +98,7 @@
 		$file_contents = @file_get_contents( $this->file );
 
 		if ( ! $file_contents ) {
-			return new WP_Error( 'error_loading_image', __( 'File doesn’t exist?' ), $this->file );
+			return new WP_Error( 'error_loading_image', __( 'File does not exist?' ), $this->file );
 		}
 
 		// WebP may not work with imagecreatefromstring().
@@ -233,7 +233,7 @@
 	 *     If one of the two is set to null, the resize will
 	 *     maintain aspect ratio according to the source image.
 	 *
-	 *     @type array $size {
+	 *     @type array ...$0 {
 	 *         Array of height, width values, and whether to crop.
 	 *
 	 *         @type int  $width  Image width. Optional if `$height` is specified.
@@ -423,13 +423,15 @@
 	 * 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'];
@@ -495,6 +497,7 @@
 			'width'     => $this->size['width'],
 			'height'    => $this->size['height'],
 			'mime-type' => $mime_type,
+			'filesize'  => wp_filesize( $filename ),
 		);
 	}
 
@@ -533,16 +536,16 @@
 	 *
 	 * @since 3.5.0
 	 *
-	 * @param string|stream $filename
-	 * @param callable      $function
-	 * @param array         $arguments
+	 * @param string   $filename
+	 * @param callable $callback
+	 * @param array    $arguments
 	 * @return bool
 	 */
-	protected function make_image( $filename, $function, $arguments ) {
+	protected function make_image( $filename, $callback, $arguments ) {
 		if ( wp_is_stream( $filename ) ) {
 			$arguments[1] = null;
 		}
 
-		return parent::make_image( $filename, $function, $arguments );
+		return parent::make_image( $filename, $callback, $arguments );
 	}
 }