wp/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
--- a/wp/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php	Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php	Tue Sep 27 16:37:53 2022 +0200
@@ -106,15 +106,19 @@
 	}
 
 	/**
-	 * Parse block metadata for a block, and prepare it for an API repsonse.
+	 * Parse block metadata for a block, and prepare it for an API response.
 	 *
 	 * @since 5.5.0
+	 * @since 5.9.0 Renamed `$plugin` to `$item` to match parent class for PHP 8 named parameter support.
 	 *
-	 * @param array           $plugin  The plugin metadata.
+	 * @param array           $item    The plugin metadata.
 	 * @param WP_REST_Request $request Request object.
 	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
 	 */
-	public function prepare_item_for_response( $plugin, $request ) {
+	public function prepare_item_for_response( $item, $request ) {
+		// Restores the more descriptive, specific name for use within this method.
+		$plugin = $item;
+
 		// There might be multiple blocks in a plugin. Only the first block is mapped.
 		$block_data = reset( $plugin['blocks'] );
 
@@ -235,7 +239,7 @@
 				),
 				'rating'              => array(
 					'description' => __( 'The star rating of the block.' ),
-					'type'        => 'integer',
+					'type'        => 'number',
 					'context'     => array( 'view' ),
 				),
 				'rating_count'        => array(
@@ -245,12 +249,12 @@
 				),
 				'active_installs'     => array(
 					'description' => __( 'The number sites that have activated this block.' ),
-					'type'        => 'string',
+					'type'        => 'integer',
 					'context'     => array( 'view' ),
 				),
 				'author_block_rating' => array(
 					'description' => __( 'The average rating of blocks published by the same author.' ),
-					'type'        => 'integer',
+					'type'        => 'number',
 					'context'     => array( 'view' ),
 				),
 				'author_block_count'  => array(
@@ -270,7 +274,7 @@
 					'context'     => array( 'view' ),
 				),
 				'last_updated'        => array(
-					'description' => __( 'The date when the block was last updated, in fuzzy human readable format.' ),
+					'description' => __( 'The date when the block was last updated.' ),
 					'type'        => 'string',
 					'format'      => 'date-time',
 					'context'     => array( 'view' ),