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

    r60667 r60729  
    441441
    442442        $property = new ReflectionProperty( $imagick_image_editor, 'image' );
    443         $property->setAccessible( true );
     443        if ( PHP_VERSION_ID < 80100 ) {
     444            $property->setAccessible( true );
     445        }
    444446
    445447        $color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
     
    460462
    461463        $property = new ReflectionProperty( $imagick_image_editor, 'image' );
    462         $property->setAccessible( true );
     464        if ( PHP_VERSION_ID < 80100 ) {
     465            $property->setAccessible( true );
     466        }
    463467
    464468        $color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
Note: See TracChangeset for help on using the changeset viewer.