WordPress at a glance
function is not described

rest_ensure_request() WP 4.4.0

Ensures request arguments are a request object (for consistency).

No Hooks.

Return

WP_REST_Request. REST request instance.

Usage

rest_ensure_request( $request );
$request(array|string|WP_REST_Request) (required)
Request to check.

Changelog

Since 4.4.0 Introduced.
Since 5.3.0 Accept string argument for the request path.

Code of rest_ensure_request() WP 5.7.2

<?php
function rest_ensure_request( $request ) {
	if ( $request instanceof WP_REST_Request ) {
		return $request;
	}

	if ( is_string( $request ) ) {
		return new WP_REST_Request( 'GET', $request );
	}

	return new WP_REST_Request( 'GET', '', $request );
}