Make WordPress Core


Ignore:
Timestamp:
09/11/2025 02:45:56 PM (6 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/interactivity-api/wpInteractivityAPI-wp-style.php

    r58594 r60729  
    4848    private function merge_style_property( $style_attribute_value, $style_property_name, $style_property_value ) {
    4949        $evaluate = new ReflectionMethod( $this->interactivity, 'merge_style_property' );
    50         $evaluate->setAccessible( true );
     50        if ( PHP_VERSION_ID < 80100 ) {
     51            $evaluate->setAccessible( true );
     52        }
    5153        return $evaluate->invokeArgs( $this->interactivity, array( $style_attribute_value, $style_property_name, $style_property_value ) );
    5254    }
Note: See TracChangeset for help on using the changeset viewer.