From 289c9c7248f766257a730335189cc4c371e83abe Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 3 Aug 2021 11:07:28 +0000 Subject: [PATCH] Code Modernization: Silence the deprecation warnings for missing return type in `WP_REST_Request`. This fixes the "Deprecated: Return type of `WP_REST_Request::[METHODNAME]($offset)` should be compatible with `ArrayAccess::[METHODNAME](): type`" warnings on PHP 8.1. PHP native interfaces now have declared return types and methods in classes implementing these interfaces need to either have the return type declared (in a covariant compatible manner with the PHP native interface method declaration), or need to silence the deprecation warning using the `#[ReturnTypeWillChange]` attribute. Follow-up to [51517], [51529], [51530]. Props jrf. See #53635. git-svn-id: https://develop.svn.wordpress.org/trunk@51531 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/rest-api/class-wp-rest-request.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-includes/rest-api/class-wp-rest-request.php b/src/wp-includes/rest-api/class-wp-rest-request.php index 7c8d189906..87689a94a5 100644 --- a/src/wp-includes/rest-api/class-wp-rest-request.php +++ b/src/wp-includes/rest-api/class-wp-rest-request.php @@ -957,6 +957,7 @@ class WP_REST_Request implements ArrayAccess { * @param string $offset Parameter name. * @return bool Whether the parameter is set. */ + #[ReturnTypeWillChange] public function offsetExists( $offset ) { $order = $this->get_parameter_order(); @@ -977,6 +978,7 @@ class WP_REST_Request implements ArrayAccess { * @param string $offset Parameter name. * @return mixed|null Value if set, null otherwise. */ + #[ReturnTypeWillChange] public function offsetGet( $offset ) { return $this->get_param( $offset ); } @@ -989,6 +991,7 @@ class WP_REST_Request implements ArrayAccess { * @param string $offset Parameter name. * @param mixed $value Parameter value. */ + #[ReturnTypeWillChange] public function offsetSet( $offset, $value ) { $this->set_param( $offset, $value ); } @@ -1000,6 +1003,7 @@ class WP_REST_Request implements ArrayAccess { * * @param string $offset Parameter name. */ + #[ReturnTypeWillChange] public function offsetUnset( $offset ) { $order = $this->get_parameter_order();