From cf501b35b00561aa8244a4200abdbdc3e73c1560 Mon Sep 17 00:00:00 2001 From: dilipbheda Date: Tue, 8 Apr 2025 15:14:04 +0530 Subject: [PATCH 1/2] fix: minor code and inline docs improvements in class-wp-rest-server.php --- src/wp-includes/rest-api/class-wp-rest-response.php | 4 ++-- src/wp-includes/rest-api/class-wp-rest-server.php | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/rest-api/class-wp-rest-response.php b/src/wp-includes/rest-api/class-wp-rest-response.php index c6ea11be83ee3..c90d01ea3ae70 100644 --- a/src/wp-includes/rest-api/class-wp-rest-response.php +++ b/src/wp-includes/rest-api/class-wp-rest-response.php @@ -76,8 +76,8 @@ public function add_link( $rel, $href, $attributes = array() ) { * * @since 4.4.0 * - * @param string $rel Link relation. Either an IANA registered type, or an absolute URL. - * @param string $href Optional. Only remove links for the relation matching the given href. + * @param string $rel Link relation. Either an IANA registered type, or an absolute URL. + * @param string|null $href Optional. Only remove links for the relation matching the given href. * Default null. */ public function remove_link( $rel, $href = null ) { diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php index 8fe9834a8db33..35f3c13ab39e5 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -224,9 +224,9 @@ protected function error_to_response( $error ) { * * @since 4.4.0 * - * @param string $code WP_Error-style code. - * @param string $message Human-readable message. - * @param int $status Optional. HTTP status code to send. Default null. + * @param string $code WP_Error-style code. + * @param string $message Human-readable message. + * @param int|null $status Optional. HTTP status code to send. Default null. * @return string JSON representation of the error */ protected function json_error( $code, $message, $status = null ) { @@ -278,7 +278,7 @@ protected function get_json_encode_options( WP_REST_Request $request ) { * * @global WP_User $current_user The currently authenticated user. * - * @param string $path Optional. The request route. If not set, `$_SERVER['PATH_INFO']` will be used. + * @param string|null $path Optional. The request route. If not set, `$_SERVER['PATH_INFO']` will be used. * Default null. * @return null|false Null if not served and a HEAD request, false otherwise. */ @@ -659,7 +659,7 @@ public static function get_response_links( $response ) { * * @since 6.7.0 * - * @param array $link + * @param array $link Hints link. * * @return array|null */ @@ -764,6 +764,7 @@ public static function get_compact_response_links( $response ) { * * @param array $data Data from the request. * @param bool|string[] $embed Whether to embed all links or a filtered list of link relations. + * Default true. * @return array { * Data with sub-requests embedded. * @@ -1341,7 +1342,7 @@ protected function respond_to_request( $request, $route, $handler, $response ) { protected function get_json_last_error() { $last_error_code = json_last_error(); - if ( JSON_ERROR_NONE === $last_error_code || empty( $last_error_code ) ) { + if ( empty( $last_error_code ) || JSON_ERROR_NONE === $last_error_code ) { return false; } From 53d5404e0d731e6510d1090c95147eb871f13824 Mon Sep 17 00:00:00 2001 From: dilipbheda Date: Tue, 8 Apr 2025 15:28:03 +0530 Subject: [PATCH 2/2] fix: correct indention --- src/wp-includes/rest-api/class-wp-rest-response.php | 2 +- src/wp-includes/rest-api/class-wp-rest-server.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/rest-api/class-wp-rest-response.php b/src/wp-includes/rest-api/class-wp-rest-response.php index c90d01ea3ae70..4834c813b3b23 100644 --- a/src/wp-includes/rest-api/class-wp-rest-response.php +++ b/src/wp-includes/rest-api/class-wp-rest-response.php @@ -78,7 +78,7 @@ public function add_link( $rel, $href, $attributes = array() ) { * * @param string $rel Link relation. Either an IANA registered type, or an absolute URL. * @param string|null $href Optional. Only remove links for the relation matching the given href. - * Default null. + * Default null. */ public function remove_link( $rel, $href = null ) { if ( ! isset( $this->links[ $rel ] ) ) { diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php index 35f3c13ab39e5..8c157b6d81a45 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -279,7 +279,7 @@ protected function get_json_encode_options( WP_REST_Request $request ) { * @global WP_User $current_user The currently authenticated user. * * @param string|null $path Optional. The request route. If not set, `$_SERVER['PATH_INFO']` will be used. - * Default null. + * Default null. * @return null|false Null if not served and a HEAD request, false otherwise. */ public function serve_request( $path = null ) { @@ -763,8 +763,7 @@ public static function get_compact_response_links( $response ) { * @since 5.4.0 The `$embed` parameter can now contain a list of link relations to include. * * @param array $data Data from the request. - * @param bool|string[] $embed Whether to embed all links or a filtered list of link relations. - * Default true. + * @param bool|string[] $embed Whether to embed all links or a filtered list of link relations. Default true. * @return array { * Data with sub-requests embedded. *