wp/wp-includes/rest-api/class-wp-rest-request.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
--- a/wp/wp-includes/rest-api/class-wp-rest-request.php	Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/rest-api/class-wp-rest-request.php	Fri Sep 05 18:40:08 2025 +0200
@@ -14,7 +14,7 @@
  *
  * Note: This implements ArrayAccess, and acts as an array of parameters when
  * used in that manner. It does not use ArrayObject (as we cannot rely on SPL),
- * so be aware it may have non-array behaviour in some cases.
+ * so be aware it may have non-array behavior in some cases.
  *
  * Note: When using features provided by ArrayAccess, be aware that WordPress deliberately
  * does not distinguish between arguments of the same name for different request methods.
@@ -26,6 +26,7 @@
  *
  * @link https://www.php.net/manual/en/class.arrayaccess.php
  */
+#[AllowDynamicProperties]
 class WP_REST_Request implements ArrayAccess {
 
 	/**
@@ -290,16 +291,16 @@
 	}
 
 	/**
-	 * Retrieves the content-type of the request.
+	 * Retrieves the Content-Type of the request.
 	 *
 	 * @since 4.4.0
 	 *
 	 * @return array|null Map containing 'value' and 'parameters' keys
-	 *                    or null when no valid content-type header was
+	 *                    or null when no valid Content-Type header was
 	 *                    available.
 	 */
 	public function get_content_type() {
-		$value = $this->get_header( 'content-type' );
+		$value = $this->get_header( 'Content-Type' );
 		if ( empty( $value ) ) {
 			return null;
 		}
@@ -310,7 +311,7 @@
 		}
 
 		$value = strtolower( $value );
-		if ( false === strpos( $value, '/' ) ) {
+		if ( ! str_contains( $value, '/' ) ) {
 			return null;
 		}
 
@@ -324,11 +325,11 @@
 	}
 
 	/**
-	 * Checks if the request has specified a JSON content-type.
+	 * Checks if the request has specified a JSON Content-Type.
 	 *
 	 * @since 5.6.0
 	 *
-	 * @return bool True if the content-type header is JSON.
+	 * @return bool True if the Content-Type header is JSON.
 	 */
 	public function is_json_content_type() {
 		$content_type = $this->get_content_type();
@@ -472,8 +473,10 @@
 
 		$params = array();
 		foreach ( $order as $type ) {
-			// array_merge() / the "+" operator will mess up
-			// numeric keys, so instead do a manual foreach.
+			/*
+			 * array_merge() / the "+" operator will mess up
+			 * numeric keys, so instead do a manual foreach.
+			 */
 			foreach ( (array) $this->params[ $type ] as $key => $value ) {
 				$params[ $key ] = $value;
 			}
@@ -718,7 +721,7 @@
 		$this->parsed_body = true;
 
 		/*
-		 * Check that we got URL-encoded. Treat a missing content-type as
+		 * Check that we got URL-encoded. Treat a missing Content-Type as
 		 * URL-encoded for maximum compatibility.
 		 */
 		$content_type = $this->get_content_type();
@@ -1030,7 +1033,7 @@
 		}
 
 		$api_root = rest_url();
-		if ( get_option( 'permalink_structure' ) && 0 === strpos( $url, $api_root ) ) {
+		if ( get_option( 'permalink_structure' ) && str_starts_with( $url, $api_root ) ) {
 			// Pretty permalinks on, and URL is under the API root.
 			$api_url_part = substr( $url, strlen( untrailingslashit( $api_root ) ) );
 			$route        = parse_url( $api_url_part, PHP_URL_PATH );