Make WordPress Core


Ignore:
Timestamp:
09/11/2025 02:45:56 PM (13 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/multisite/network.php

    r60666 r60729  
    158158                $reflection = new ReflectionObject( $network );
    159159                $property   = $reflection->getProperty( 'id' );
    160                 $property->setAccessible( true );
     160                if ( PHP_VERSION_ID < 80100 ) {
     161                        $property->setAccessible( true );
     162                }
    161163
    162164                $this->assertSame( (int) $id, $property->getValue( $network ) );
    … …  
    195197                $reflection = new ReflectionObject( $network );
    196198                $property   = $reflection->getProperty( 'blog_id' );
    197                 $property->setAccessible( true );
     199                if ( PHP_VERSION_ID < 80100 ) {
     200                        $property->setAccessible( true );
     201                }
    198202
    199203                $this->assertIsString( $property->getValue( $network ) );
Note: See TracChangeset for help on using the changeset viewer.