Make WordPress Core


Ignore:
Timestamp:
09/11/2025 02:45:56 PM (5 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/admin/wpSiteHealth.php

    r58432 r60729  
    4141        $reflection          = new ReflectionClass( $this->instance );
    4242        $reflection_property = $reflection->getProperty( 'mysql_recommended_version' );
    43         $reflection_property->setAccessible( true );
    44 
     43        if ( PHP_VERSION_ID < 80100 ) {
     44            $reflection_property->setAccessible( true );
     45        }
    4546        $readme = file_get_contents( ABSPATH . 'readme.html' );
    4647
     
    5758        $reflection          = new ReflectionClass( $this->instance );
    5859        $reflection_property = $reflection->getProperty( 'mariadb_recommended_version' );
    59         $reflection_property->setAccessible( true );
     60        if ( PHP_VERSION_ID < 80100 ) {
     61            $reflection_property->setAccessible( true );
     62        }
    6063
    6164        $readme = file_get_contents( ABSPATH . 'readme.html' );
Note: See TracChangeset for help on using the changeset viewer.