Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/09/2022 06:23:32 PM (3 years ago)
Author:
imath
Message:

Avoid PHP 8.1 ArrayAccess Return Type deprecation notices

The BP_Core_BP_Nav_BackCompat is implementing the ArrayAccess class to provide backward compatibility to BuddyPress plugins directly modifying the buddypress()->bp_nav global since BuddyPress 2.3.

PHP 8.1 added a deprecation notice if a class declaration has an incompatible return type (or if the return type lacks: which is the case for BP_Core_BP_Nav_BackCompat) with the parent it extends.

As BuddyPress supports PHP back to version 5.6, we need to use the #ReturnTypeWillChange attribute to maintain compatibility with this version and avoid the deprecation notice in PHP 8.x.

Fixes #8726

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-avatars.php

    r13215 r13311  
    457457    // Use an alias to leave the param unchanged.
    458458    $avatar_classes = $params['class'];
    459     if ( ! is_array( $avatar_classes ) ) {
     459    if ( is_null( $avatar_classes ) ) {
     460        $avatar_classes = array();
     461    } elseif ( ! is_array( $avatar_classes ) ) {
    460462        $avatar_classes = explode( ' ', $avatar_classes );
    461463    }
Note: See TracChangeset for help on using the changeset viewer.