Make WordPress Core


Ignore:
Timestamp:
09/11/2025 02:45:56 PM (4 months ago)
Author:
swissspidy
Message:

Code Modernization: Address reflection no-op function deprecations in PHP 8.5.

Reflection*::setAccessible() methods are no-ops since PHP 8.1. This commit adds conditional checks to only call these functions on older PHP versions.

Reference: PHP RFC: Deprecations for PHP 8.5: Deprecate `Reflection*::setAccessible()`.

Props rishabhwp, swissspidy.
Fixes #63956.
See #63061.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/db.php

    r60622 r60729  
    19881988
    19891989        $property = new ReflectionProperty( $wpdb, 'allow_unsafe_unquoted_parameters' );
    1990         $property->setAccessible( true );
     1990        if ( PHP_VERSION_ID < 80100 ) {
     1991            $property->setAccessible( true );
     1992        }
    19911993        $property->setValue( $wpdb, $allow );
    19921994
     
    19961998        // Reset.
    19971999        $property->setValue( $wpdb, $default );
    1998         $property->setAccessible( false );
     2000        if ( PHP_VERSION_ID < 80100 ) {
     2001            $property->setAccessible( false );
     2002        }
    19992003
    20002004        $this->assertSame( $expected, $actual );
Note: See TracChangeset for help on using the changeset viewer.