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.
Built from https://develop.svn.wordpress.org/trunk@51531


git-svn-id: http://core.svn.wordpress.org/trunk@51142 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-08-03 11:08:56 +00:00
parent 85c1413c2b
commit 68ba315d9a
2 changed files with 5 additions and 1 deletions

View File

@ -957,6 +957,7 @@ class WP_REST_Request implements ArrayAccess {
* @param string $offset Parameter name. * @param string $offset Parameter name.
* @return bool Whether the parameter is set. * @return bool Whether the parameter is set.
*/ */
#[ReturnTypeWillChange]
public function offsetExists( $offset ) { public function offsetExists( $offset ) {
$order = $this->get_parameter_order(); $order = $this->get_parameter_order();
@ -977,6 +978,7 @@ class WP_REST_Request implements ArrayAccess {
* @param string $offset Parameter name. * @param string $offset Parameter name.
* @return mixed|null Value if set, null otherwise. * @return mixed|null Value if set, null otherwise.
*/ */
#[ReturnTypeWillChange]
public function offsetGet( $offset ) { public function offsetGet( $offset ) {
return $this->get_param( $offset ); return $this->get_param( $offset );
} }
@ -989,6 +991,7 @@ class WP_REST_Request implements ArrayAccess {
* @param string $offset Parameter name. * @param string $offset Parameter name.
* @param mixed $value Parameter value. * @param mixed $value Parameter value.
*/ */
#[ReturnTypeWillChange]
public function offsetSet( $offset, $value ) { public function offsetSet( $offset, $value ) {
$this->set_param( $offset, $value ); $this->set_param( $offset, $value );
} }
@ -1000,6 +1003,7 @@ class WP_REST_Request implements ArrayAccess {
* *
* @param string $offset Parameter name. * @param string $offset Parameter name.
*/ */
#[ReturnTypeWillChange]
public function offsetUnset( $offset ) { public function offsetUnset( $offset ) {
$order = $this->get_parameter_order(); $order = $this->get_parameter_order();

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.9-alpha-51530'; $wp_version = '5.9-alpha-51531';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.