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/admin/wpCommunityEvents.php

    r55337 r60729  
    300300    public function test_trim_expired_events() {
    301301        $trim_events = new ReflectionMethod( $this->instance, 'trim_events' );
    302         $trim_events->setAccessible( true );
     302        if ( PHP_VERSION_ID < 80100 ) {
     303            $trim_events->setAccessible( true );
     304        }
    303305
    304306        $events = $this->get_valid_events();
     
    329331    public function test_trim_events_pin_wordcamp() {
    330332        $trim_events = new ReflectionMethod( $this->instance, 'trim_events' );
    331         $trim_events->setAccessible( true );
     333        if ( PHP_VERSION_ID < 80100 ) {
     334            $trim_events->setAccessible( true );
     335        }
    332336
    333337        $actual = $trim_events->invoke( $this->instance, $this->_events_with_unpinned_wordcamp() );
     
    434438    public function test_trim_events_dont_pin_multiple_wordcamps() {
    435439        $trim_events = new ReflectionMethod( $this->instance, 'trim_events' );
    436         $trim_events->setAccessible( true );
     440        if ( PHP_VERSION_ID < 80100 ) {
     441            $trim_events->setAccessible( true );
     442        }
    437443
    438444        $actual = $trim_events->invoke( $this->instance, $this->_events_with_multiple_wordcamps() );
Note: See TracChangeset for help on using the changeset viewer.