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/image/editorGd.php

    r54401 r60729  
    555555
    556556        $property = new ReflectionProperty( $gd_image_editor, 'image' );
    557         $property->setAccessible( true );
     557        if ( PHP_VERSION_ID < 80100 ) {
     558            $property->setAccessible( true );
     559        }
    558560
    559561        $color_top_left = imagecolorat( $property->getValue( $gd_image_editor ), 0, 0 );
     
    574576
    575577        $property = new ReflectionProperty( $gd_image_editor, 'image' );
    576         $property->setAccessible( true );
     578        if ( PHP_VERSION_ID < 80100 ) {
     579            $property->setAccessible( true );
     580        }
    577581
    578582        $color_top_left = imagecolorat( $property->getValue( $gd_image_editor ), 0, 0 );
Note: See TracChangeset for help on using the changeset viewer.