Skip to content

Commit 289c9c7

Browse files
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
1 parent 471edb0 commit 289c9c7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/wp-includes/rest-api/class-wp-rest-request.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,7 @@ public function has_valid_params() {
957957
* @param string $offset Parameter name.
958958
* @return bool Whether the parameter is set.
959959
*/
960+
#[ReturnTypeWillChange]
960961
public function offsetExists( $offset ) {
961962
$order = $this->get_parameter_order();
962963

@@ -977,6 +978,7 @@ public function offsetExists( $offset ) {
977978
* @param string $offset Parameter name.
978979
* @return mixed|null Value if set, null otherwise.
979980
*/
981+
#[ReturnTypeWillChange]
980982
public function offsetGet( $offset ) {
981983
return $this->get_param( $offset );
982984
}
@@ -989,6 +991,7 @@ public function offsetGet( $offset ) {
989991
* @param string $offset Parameter name.
990992
* @param mixed $value Parameter value.
991993
*/
994+
#[ReturnTypeWillChange]
992995
public function offsetSet( $offset, $value ) {
993996
$this->set_param( $offset, $value );
994997
}
@@ -1000,6 +1003,7 @@ public function offsetSet( $offset, $value ) {
10001003
*
10011004
* @param string $offset Parameter name.
10021005
*/
1006+
#[ReturnTypeWillChange]
10031007
public function offsetUnset( $offset ) {
10041008
$order = $this->get_parameter_order();
10051009

0 commit comments

Comments
 (0)