WordPress.org

Make WordPress Core

Changeset 51531


Ignore:
Timestamp:
08/03/2021 11:07:28 AM (8 weeks ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/class-wp-rest-request.php

    r51518 r51531  
    958958     * @return bool Whether the parameter is set.
    959959     */
     960    #[ReturnTypeWillChange]
    960961    public function offsetExists( $offset ) {
    961962        $order = $this->get_parameter_order();
     
    978979     * @return mixed|null Value if set, null otherwise.
    979980     */
     981    #[ReturnTypeWillChange]
    980982    public function offsetGet( $offset ) {
    981983        return $this->get_param( $offset );
     
    990992     * @param mixed  $value  Parameter value.
    991993     */
     994    #[ReturnTypeWillChange]
    992995    public function offsetSet( $offset, $value ) {
    993996        $this->set_param( $offset, $value );
     
    10011004     * @param string $offset Parameter name.
    10021005     */
     1006    #[ReturnTypeWillChange]
    10031007    public function offsetUnset( $offset ) {
    10041008        $order = $this->get_parameter_order();
Note: See TracChangeset for help on using the changeset viewer.