Make WordPress Core


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

    r58049 r60729  
    210210
    211211        $property = new ReflectionProperty( $editor, 'size' );
    212         $property->setAccessible( true );
     212        if ( PHP_VERSION_ID < 80100 ) {
     213            $property->setAccessible( true );
     214        }
    213215        $property->setValue(
    214216            $editor,
     
    256258        );
    257259        $property = new ReflectionProperty( $editor, 'size' );
    258         $property->setAccessible( true );
     260        if ( PHP_VERSION_ID < 80100 ) {
     261            $property->setAccessible( true );
     262        }
    259263        $property->setValue( $editor, $size );
    260264
     
    279283        );
    280284        $property = new ReflectionProperty( $editor, 'size' );
    281         $property->setAccessible( true );
     285        if ( PHP_VERSION_ID < 80100 ) {
     286            $property->setAccessible( true );
     287        }
    282288        $property->setValue( $editor, $size );
    283289
Note: See TracChangeset for help on using the changeset viewer.