Make WordPress Core

Changeset 60729


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

Location:
trunk/tests/phpunit/tests
Files:
46 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/plugin-dependencies/base.php

    r57658 r60729  
    8383                }
    8484
    85                 self::$reflected_members[ $property ]->setAccessible( true );
     85                if ( PHP_VERSION_ID < 80100 ) {
     86                        self::$reflected_members[ $property ]->setAccessible( true );
     87                }
    8688                self::$reflected_members[ $property ]->setValue( self::$instance, $value );
    87                 self::$reflected_members[ $property ]->setAccessible( false );
     89                if ( PHP_VERSION_ID < 80100 ) {
     90                        self::$reflected_members[ $property ]->setAccessible( false );
     91                }
    8892        }
    8993
     
    99103                }
    100104
    101                 self::$reflected_members[ $property ]->setAccessible( true );
     105                if ( PHP_VERSION_ID < 80100 ) {
     106                        self::$reflected_members[ $property ]->setAccessible( true );
     107                }
    102108                $value = self::$reflected_members[ $property ]->getValue( self::$instance );
    103                 self::$reflected_members[ $property ]->setAccessible( false );
     109                if ( PHP_VERSION_ID < 80100 ) {
     110                        self::$reflected_members[ $property ]->setAccessible( false );
     111                }
    104112
    105113                return $value;
     
    119127                }
    120128
    121                 self::$reflected_members[ $method ]->setAccessible( true );
     129                if ( PHP_VERSION_ID < 80100 ) {
     130                        self::$reflected_members[ $method ]->setAccessible( true );
     131                }
    122132                $value = self::$reflected_members[ $method ]->invokeArgs( self::$instance, $args );
    123                 self::$reflected_members[ $method ]->setAccessible( false );
     133                if ( PHP_VERSION_ID < 80100 ) {
     134                        self::$reflected_members[ $method ]->setAccessible( false );
     135                }
    124136
    125137                return $value;
  • trunk/tests/phpunit/tests/admin/wpAutomaticUpdater.php

    r56971 r60729  
    3131
    3232                self::$send_plugin_theme_email = new ReflectionMethod( self::$updater, 'send_plugin_theme_email' );
    33                 self::$send_plugin_theme_email->setAccessible( true );
     33                if ( PHP_VERSION_ID < 80100 ) {
     34                        self::$send_plugin_theme_email->setAccessible( true );
     35                }
    3436        }
    3537
  • 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() );
  • trunk/tests/phpunit/tests/admin/wpListTable.php

    r58389 r60729  
    7171
    7272                $column_headers = new ReflectionProperty( $list_table, '_column_headers' );
    73                 $column_headers->setAccessible( true );
     73                if ( PHP_VERSION_ID < 80100 ) {
     74                        $column_headers->setAccessible( true );
     75                }
    7476                $column_headers->setValue( $list_table, $headers );
    7577
    7678                $column_info = new ReflectionMethod( $list_table, 'get_column_info' );
    77                 $column_info->setAccessible( true );
     79                if ( PHP_VERSION_ID < 80100 ) {
     80                        $column_info->setAccessible( true );
     81                }
    7882
    7983                $this->assertSame( $expected, $column_info->invoke( $list_table ), 'The actual columns did not match the expected columns' );
     
    161165        public function test_get_views_links( $link_data, $expected ) {
    162166                $get_views_links = new ReflectionMethod( $this->list_table, 'get_views_links' );
    163                 $get_views_links->setAccessible( true );
     167                if ( PHP_VERSION_ID < 80100 ) {
     168                        $get_views_links->setAccessible( true );
     169                }
    164170
    165171                $actual = $get_views_links->invokeArgs( $this->list_table, array( $link_data ) );
     
    276282        public function test_get_views_links_doing_it_wrong( $link_data ) {
    277283                $get_views_links = new ReflectionMethod( $this->list_table, 'get_views_links' );
    278                 $get_views_links->setAccessible( true );
     284                if ( PHP_VERSION_ID < 80100 ) {
     285                        $get_views_links->setAccessible( true );
     286                }
    279287                $get_views_links->invokeArgs( $this->list_table, array( $link_data ) );
    280288        }
  • trunk/tests/phpunit/tests/admin/wpMediaListTable.php

    r56141 r60729  
    7777                self::$detached   = new ReflectionProperty( self::$list_table, 'detached' );
    7878
    79                 self::$is_trash->setAccessible( true );
     79                if ( PHP_VERSION_ID < 80100 ) {
     80                        self::$is_trash->setAccessible( true );
     81                }
    8082                self::$is_trash_original = self::$is_trash->getValue( self::$list_table );
    81                 self::$is_trash->setAccessible( false );
    82 
    83                 self::$detached->setAccessible( true );
     83                if ( PHP_VERSION_ID < 80100 ) {
     84                        self::$is_trash->setAccessible( false );
     85                }
     86
     87                if ( PHP_VERSION_ID < 80100 ) {
     88                        self::$detached->setAccessible( true );
     89                }
    8490                self::$detached_original = self::$detached->getValue( self::$list_table );
    85                 self::$detached->setAccessible( false );
     91                if ( PHP_VERSION_ID < 80100 ) {
     92                        self::$detached->setAccessible( false );
     93                }
    8694
    8795                // Create users.
     
    182190
    183191                $_get_row_actions = new ReflectionMethod( self::$list_table, '_get_row_actions' );
    184                 $_get_row_actions->setAccessible( true );
     192                if ( PHP_VERSION_ID < 80100 ) {
     193                        $_get_row_actions->setAccessible( true );
     194                }
    185195                $actions = $_get_row_actions->invoke( self::$list_table, self::$post, 'att_title' );
    186                 $_get_row_actions->setAccessible( false );
     196                if ( PHP_VERSION_ID < 80100 ) {
     197                        $_get_row_actions->setAccessible( false );
     198                }
    187199
    188200                $this->assertIsArray( $actions, 'An array was not returned.' );
     
    263275
    264276                $_get_row_actions = new ReflectionMethod( self::$list_table, '_get_row_actions' );
    265                 $_get_row_actions->setAccessible( true );
     277                if ( PHP_VERSION_ID < 80100 ) {
     278                        $_get_row_actions->setAccessible( true );
     279                }
    266280                $actions = $_get_row_actions->invoke( self::$list_table, self::$post, 'att_title' );
    267                 $_get_row_actions->setAccessible( false );
     281                if ( PHP_VERSION_ID < 80100 ) {
     282                        $_get_row_actions->setAccessible( false );
     283                }
    268284
    269285                $this->assertIsArray( $actions, 'An array was not returned.' );
     
    356372
    357373                $_get_row_actions = new ReflectionMethod( self::$list_table, '_get_row_actions' );
    358                 $_get_row_actions->setAccessible( true );
     374                if ( PHP_VERSION_ID < 80100 ) {
     375                        $_get_row_actions->setAccessible( true );
     376                }
    359377                $actions = $_get_row_actions->invoke( self::$list_table, self::$post, 'att_title' );
    360                 $_get_row_actions->setAccessible( false );
     378                if ( PHP_VERSION_ID < 80100 ) {
     379                        $_get_row_actions->setAccessible( false );
     380                }
    361381
    362382                $this->assertIsArray( $actions, 'An array was not returned.' );
     
    375395
    376396                $_get_row_actions = new ReflectionMethod( self::$list_table, '_get_row_actions' );
    377                 $_get_row_actions->setAccessible( true );
     397                if ( PHP_VERSION_ID < 80100 ) {
     398                        $_get_row_actions->setAccessible( true );
     399                }
    378400                $actions = $_get_row_actions->invoke( self::$list_table, self::$attachment, 'att_title' );
    379                 $_get_row_actions->setAccessible( false );
     401                if ( PHP_VERSION_ID < 80100 ) {
     402                        $_get_row_actions->setAccessible( false );
     403                }
    380404
    381405                $this->assertIsArray( $actions, 'An array was not returned.' );
     
    398422
    399423                $_get_row_actions = new ReflectionMethod( self::$list_table, '_get_row_actions' );
    400                 $_get_row_actions->setAccessible( true );
     424                if ( PHP_VERSION_ID < 80100 ) {
     425                        $_get_row_actions->setAccessible( true );
     426                }
    401427                $actions = $_get_row_actions->invoke( self::$list_table, self::$attachment, 'att_title' );
    402                 $_get_row_actions->setAccessible( false );
     428                if ( PHP_VERSION_ID < 80100 ) {
     429                        $_get_row_actions->setAccessible( false );
     430                }
    403431
    404432                $this->assertIsArray( $actions, 'An array was not returned.' );
     
    415443        public function test_get_row_actions_should_include_download() {
    416444                $_get_row_actions = new ReflectionMethod( self::$list_table, '_get_row_actions' );
    417                 $_get_row_actions->setAccessible( true );
     445                if ( PHP_VERSION_ID < 80100 ) {
     446                        $_get_row_actions->setAccessible( true );
     447                }
    418448                $actions = $_get_row_actions->invoke( self::$list_table, self::$attachment, 'att_title' );
    419                 $_get_row_actions->setAccessible( false );
     449                if ( PHP_VERSION_ID < 80100 ) {
     450                        $_get_row_actions->setAccessible( false );
     451                }
    420452
    421453                $this->assertIsArray( $actions, 'An array was not returned.' );
     
    436468
    437469                $_get_row_actions = new ReflectionMethod( self::$list_table, '_get_row_actions' );
    438                 $_get_row_actions->setAccessible( true );
     470                if ( PHP_VERSION_ID < 80100 ) {
     471                        $_get_row_actions->setAccessible( true );
     472                }
    439473                $actions = $_get_row_actions->invoke( self::$list_table, self::$attachment, 'att_title' );
    440                 $_get_row_actions->setAccessible( false );
     474                if ( PHP_VERSION_ID < 80100 ) {
     475                        $_get_row_actions->setAccessible( false );
     476                }
    441477
    442478                $this->assertIsArray( $actions, 'An array was not returned.' );
     
    452488         */
    453489        private static function set_is_trash( $is_trash ) {
    454                 self::$is_trash->setAccessible( true );
     490                if ( PHP_VERSION_ID < 80100 ) {
     491                        self::$is_trash->setAccessible( true );
     492                }
    455493                self::$is_trash->setValue( self::$list_table, $is_trash );
    456                 self::$is_trash->setAccessible( false );
     494                if ( PHP_VERSION_ID < 80100 ) {
     495                        self::$is_trash->setAccessible( false );
     496                }
    457497        }
    458498
     
    465505         */
    466506        private static function set_detached( $detached ) {
    467                 self::$detached->setAccessible( true );
     507                if ( PHP_VERSION_ID < 80100 ) {
     508                        self::$detached->setAccessible( true );
     509                }
    468510                self::$detached->setValue( self::$list_table, $detached );
    469                 self::$detached->setAccessible( false );
     511                if ( PHP_VERSION_ID < 80100 ) {
     512                        self::$detached->setAccessible( false );
     513                }
    470514        }
    471515}
  • trunk/tests/phpunit/tests/admin/wpPluginsListTable.php

    r60250 r60729  
    150150                $show_autoupdates = new ReflectionProperty( $list_table, 'show_autoupdates' );
    151151
    152                 $show_autoupdates->setAccessible( true );
     152                if ( PHP_VERSION_ID < 80100 ) {
     153                        $show_autoupdates->setAccessible( true );
     154                }
    153155                $actual = $show_autoupdates->getValue( $list_table );
    154                 $show_autoupdates->setAccessible( false );
     156                if ( PHP_VERSION_ID < 80100 ) {
     157                        $show_autoupdates->setAccessible( false );
     158                }
    155159
    156160                $_REQUEST['plugin_status'] = $original_status;
  • trunk/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php

    r58176 r60729  
    5353                // Set the request type as 'export_personal_data'.
    5454                $reflection_property = $reflection->getProperty( 'request_type' );
    55                 $reflection_property->setAccessible( true );
     55                if ( PHP_VERSION_ID < 80100 ) {
     56                        $reflection_property->setAccessible( true );
     57                }
    5658                $reflection_property->setValue( $instance, 'export_personal_data' );
    5759
    5860                // Set the post type as 'user_request'.
    5961                $reflection_property = $reflection->getProperty( 'post_type' );
    60                 $reflection_property->setAccessible( true );
     62                if ( PHP_VERSION_ID < 80100 ) {
     63                        $reflection_property->setAccessible( true );
     64                }
    6165                $reflection_property->setValue( $instance, 'user_request' );
    6266
  • trunk/tests/phpunit/tests/admin/wpSiteHealth.php

    r58432 r60729  
    4141                $reflection          = new ReflectionClass( $this->instance );
    4242                $reflection_property = $reflection->getProperty( 'mysql_recommended_version' );
    43                 $reflection_property->setAccessible( true );
    44 
     43                if ( PHP_VERSION_ID < 80100 ) {
     44                        $reflection_property->setAccessible( true );
     45                }
    4546                $readme = file_get_contents( ABSPATH . 'readme.html' );
    4647
     
    5758                $reflection          = new ReflectionClass( $this->instance );
    5859                $reflection_property = $reflection->getProperty( 'mariadb_recommended_version' );
    59                 $reflection_property->setAccessible( true );
     60                if ( PHP_VERSION_ID < 80100 ) {
     61                        $reflection_property->setAccessible( true );
     62                }
    6063
    6164                $readme = file_get_contents( ABSPATH . 'readme.html' );
  • trunk/tests/phpunit/tests/admin/wpTermsListTable.php

    r56680 r60729  
    5050        private function call_inaccessible_method( $instance, $method_name, $args = array() ) {
    5151                $method = ( new ReflectionClass( $instance ) )->getMethod( $method_name );
    52                 $method->setAccessible( true );
     52                if ( PHP_VERSION_ID < 80100 ) {
     53                        $method->setAccessible( true );
     54                }
    5355                return $method->invokeArgs( $instance, $args );
    5456        }
  • trunk/tests/phpunit/tests/admin/wpUpgrader.php

    r59257 r60729  
    171171        public function test_flatten_dirlist_should_flatten_the_provided_directory_list( $expected, $nested_files, $path = '' ) {
    172172                $flatten_dirlist = new ReflectionMethod( self::$instance, 'flatten_dirlist' );
    173                 $flatten_dirlist->setAccessible( true );
     173                if ( PHP_VERSION_ID < 80100 ) {
     174                        $flatten_dirlist->setAccessible( true );
     175                }
    174176                $actual = $flatten_dirlist->invoke( self::$instance, $nested_files, $path );
    175                 $flatten_dirlist->setAccessible( false );
     177                if ( PHP_VERSION_ID < 80100 ) {
     178                        $flatten_dirlist->setAccessible( false );
     179                }
    176180
    177181                $this->assertSameSetsWithIndex( $expected, $actual );
  • trunk/tests/phpunit/tests/block-bindings/wp-block-get-block-bindings-processor.php

    r60684 r60729  
    1616        public static function wpSetupBeforeClass() {
    1717                self::$get_block_bindings_processor_method = new ReflectionMethod( 'WP_Block', 'get_block_bindings_processor' );
    18                 self::$get_block_bindings_processor_method->setAccessible( true );
     18                if ( PHP_VERSION_ID < 80100 ) {
     19                        self::$get_block_bindings_processor_method->setAccessible( true );
     20                }
    1921        }
    2022
  • trunk/tests/phpunit/tests/block-supports/duotone.php

    r57652 r60729  
    7979
    8080                $reflection = new ReflectionMethod( 'WP_Duotone', 'get_slug_from_attribute' );
    81                 $reflection->setAccessible( true );
     81                if ( PHP_VERSION_ID < 80100 ) {
     82                        $reflection->setAccessible( true );
     83                }
    8284
    8385                $this->assertSame( $expected, $reflection->invoke( null, $data_attr ) );
     
    129131                $wp_duotone                      = new WP_Duotone();
    130132                $block_css_declarations_property = new ReflectionProperty( 'WP_Duotone', 'block_css_declarations' );
    131                 $block_css_declarations_property->setAccessible( true );
     133                if ( PHP_VERSION_ID < 80100 ) {
     134                        $block_css_declarations_property->setAccessible( true );
     135                }
    132136                $previous_value = $block_css_declarations_property->getValue();
    133137                $block_css_declarations_property->setValue( $wp_duotone, array() );
     
    138142                // Reset the property.
    139143                $block_css_declarations_property->setValue( $wp_duotone, $previous_value );
    140                 $block_css_declarations_property->setAccessible( false );
     144                if ( PHP_VERSION_ID < 80100 ) {
     145                        $block_css_declarations_property->setAccessible( false );
     146                }
    141147
    142148                $this->assertNotEmpty( $actual );
     
    148154        public function test_is_preset( $data_attr, $expected ) {
    149155                $reflection = new ReflectionMethod( 'WP_Duotone', 'is_preset' );
    150                 $reflection->setAccessible( true );
     156                if ( PHP_VERSION_ID < 80100 ) {
     157                        $reflection->setAccessible( true );
     158                }
    151159
    152160                $this->assertSame( $expected, $reflection->invoke( null, $data_attr ) );
     
    174182        public function test_colord_parse_hue( $value, $unit, $expected ) {
    175183                $reflection = new ReflectionMethod( 'WP_Duotone', 'colord_parse_hue' );
    176                 $reflection->setAccessible( true );
     184                if ( PHP_VERSION_ID < 80100 ) {
     185                        $reflection->setAccessible( true );
     186                }
    177187
    178188                $this->assertSame( $expected, $reflection->invoke( null, $value, $unit ) );
  • trunk/tests/phpunit/tests/block-template.php

    r59201 r60729  
    328328                $this->assertSame( $expected, get_block_theme_folders( $theme ), 'Incorrect block theme folders were retrieved.' );
    329329                $reflection = new ReflectionMethod( $wp_theme, 'cache_get' );
    330                 $reflection->setAccessible( true );
     330                if ( PHP_VERSION_ID < 80100 ) {
     331                        $reflection->setAccessible( true );
     332                }
    331333                $theme_cache  = $reflection->invoke( $wp_theme, 'theme' );
    332334                $cached_value = $theme_cache['block_template_folders'];
    333                 $reflection->setAccessible( false );
     335                if ( PHP_VERSION_ID < 80100 ) {
     336                        $reflection->setAccessible( false );
     337                }
    334338
    335339                $this->assertSame( $expected, $cached_value, 'The cached value is incorrect.' );
  • trunk/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php

    r58176 r60729  
    663663                $reflection = new ReflectionClass( $registry );
    664664                $property   = $reflection->getProperty( 'registered_patterns' );
    665                 $property->setAccessible( true );
     665                if ( PHP_VERSION_ID < 80100 ) {
     666                        $property->setAccessible( true );
     667                }
    666668
    667669                // Get the value of the private property.
    668670                $registered_patterns = $property->getValue( $registry );
    669                 $property->setAccessible( false );
     671                if ( PHP_VERSION_ID < 80100 ) {
     672                        $property->setAccessible( false );
     673                }
    670674
    671675                return $registered_patterns;
     
    682686                $reflection = new ReflectionClass( $registry );
    683687                $property   = $reflection->getProperty( 'registered_patterns' );
    684                 $property->setAccessible( true );
     688                if ( PHP_VERSION_ID < 80100 ) {
     689                        $property->setAccessible( true );
     690                }
    685691
    686692                // Set the value of the private property.
    687693                $property->setValue( $registry, $value );
    688                 $property->setAccessible( false );
     694                if ( PHP_VERSION_ID < 80100 ) {
     695                        $property->setAccessible( false );
     696                }
    689697        }
    690698}
  • trunk/tests/phpunit/tests/db.php

    r60622 r60729  
    19881988
    19891989                $property = new ReflectionProperty( $wpdb, 'allow_unsafe_unquoted_parameters' );
    1990                 $property->setAccessible( true );
     1990                if ( PHP_VERSION_ID < 80100 ) {
     1991                        $property->setAccessible( true );
     1992                }
    19911993                $property->setValue( $wpdb, $allow );
    19921994
     
    19961998                // Reset.
    19971999                $property->setValue( $wpdb, $default );
    1998                 $property->setAccessible( false );
     2000                if ( PHP_VERSION_ID < 80100 ) {
     2001                        $property->setAccessible( false );
     2002                }
    19992003
    20002004                $this->assertSame( $expected, $actual );
  • trunk/tests/phpunit/tests/dependencies/scripts.php

    r60728 r60729  
    446446                $wp_scripts_reflection      = new ReflectionClass( WP_Scripts::class );
    447447                $filter_eligible_strategies = $wp_scripts_reflection->getMethod( 'filter_eligible_strategies' );
    448                 $filter_eligible_strategies->setAccessible( true );
     448                if ( PHP_VERSION_ID < 80100 ) {
     449                        $filter_eligible_strategies->setAccessible( true );
     450                }
    449451                $this->assertSame( $expected, $filter_eligible_strategies->invokeArgs( wp_scripts(), array( $handle ) ), 'Expected return value of WP_Scripts::filter_eligible_strategies to match.' );
    450452        }
  • trunk/tests/phpunit/tests/error-protection/wpRecoveryModeCookieService.php

    r51650 r60729  
    3636                $service    = new WP_Recovery_Mode_Cookie_Service();
    3737                $reflection = new ReflectionMethod( $service, 'recovery_mode_hash' );
    38                 $reflection->setAccessible( true );
     38                if ( PHP_VERSION_ID < 80100 ) {
     39                        $reflection->setAccessible( true );
     40                }
    3941
    4042                $to_sign = sprintf( 'recovery_mode|%s|%s', time() - WEEK_IN_SECONDS - 30, wp_generate_password( 20, false ) );
     
    5557                $service    = new WP_Recovery_Mode_Cookie_Service();
    5658                $reflection = new ReflectionMethod( $service, 'generate_cookie' );
    57                 $reflection->setAccessible( true );
     59                if ( PHP_VERSION_ID < 80100 ) {
     60                        $reflection->setAccessible( true );
     61                }
    5862
    5963                $cookie  = $reflection->invoke( $service );
     
    7377                $service    = new WP_Recovery_Mode_Cookie_Service();
    7478                $reflection = new ReflectionMethod( $service, 'recovery_mode_hash' );
    75                 $reflection->setAccessible( true );
     79                if ( PHP_VERSION_ID < 80100 ) {
     80                        $reflection->setAccessible( true );
     81                }
    7682
    7783                $to_sign = sprintf( 'recovery_mode|%s|%s', 'month', wp_generate_password( 20, false ) );
     
    9399                $service    = new WP_Recovery_Mode_Cookie_Service();
    94100                $reflection = new ReflectionMethod( $service, 'generate_cookie' );
    95                 $reflection->setAccessible( true );
     101                if ( PHP_VERSION_ID < 80100 ) {
     102                        $reflection->setAccessible( true );
     103                }
    96104
    97105                $this->assertTrue( $service->validate_cookie( $reflection->invoke( $service ) ) );
  • trunk/tests/phpunit/tests/functions/maybeSerialize.php

    r57735 r60729  
    218218                        $new_value = unserialize( $serialized );
    219219                        $property  = ( new ReflectionClass( 'WpOrg\Requests\Utility\FilteredIterator' ) )->getProperty( 'callback' );
    220                         $property->setAccessible( true );
     220                        if ( PHP_VERSION_ID < 80100 ) {
     221                                $property->setAccessible( true );
     222                        }
    221223                        $callback_value = $property->getValue( $new_value );
    222224
  • trunk/tests/phpunit/tests/hooks/addFilter.php

    r56609 r60729  
    317317                $reflection          = new ReflectionClass( $hook );
    318318                $reflection_property = $reflection->getProperty( 'priorities' );
    319                 $reflection_property->setAccessible( true );
     319                if ( PHP_VERSION_ID < 80100 ) {
     320                        $reflection_property->setAccessible( true );
     321                }
    320322
    321323                return $reflection_property->getValue( $hook );
  • trunk/tests/phpunit/tests/hooks/removeAllFilters.php

    r56609 r60729  
    5858                $reflection          = new ReflectionClass( $hook );
    5959                $reflection_property = $reflection->getProperty( 'priorities' );
    60                 $reflection_property->setAccessible( true );
     60                if ( PHP_VERSION_ID < 80100 ) {
     61                        $reflection_property->setAccessible( true );
     62                }
    6163
    6264                return $reflection_property->getValue( $hook );
  • trunk/tests/phpunit/tests/hooks/removeFilter.php

    r56609 r60729  
    102102                $reflection          = new ReflectionClass( $hook );
    103103                $reflection_property = $reflection->getProperty( 'priorities' );
    104                 $reflection_property->setAccessible( true );
     104                if ( PHP_VERSION_ID < 80100 ) {
     105                        $reflection_property->setAccessible( true );
     106                }
    105107
    106108                return $reflection_property->getValue( $hook );
  • 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
  • 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 );
  • 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();
  • 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        }
  • trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php

    r60070 r60729  
    4242                $interactivity   = new ReflectionClass( $this->interactivity );
    4343                $namespace_stack = $interactivity->getProperty( 'namespace_stack' );
    44                 $namespace_stack->setAccessible( true );
     44                if ( PHP_VERSION_ID < 80100 ) {
     45                        $namespace_stack->setAccessible( true );
     46                }
    4547                $namespace_stack->setValue( $this->interactivity, $stack );
    4648        }
     
    5658                $interactivity = new ReflectionClass( $this->interactivity );
    5759                $context_stack = $interactivity->getProperty( 'context_stack' );
    58                 $context_stack->setAccessible( true );
     60                if ( PHP_VERSION_ID < 80100 ) {
     61                        $context_stack->setAccessible( true );
     62                }
    5963                $context_stack->setValue( $this->interactivity, $stack );
    6064        }
     
    587591        public function test_extract_directive_value() {
    588592                $extract_directive_value = new ReflectionMethod( $this->interactivity, 'extract_directive_value' );
    589                 $extract_directive_value->setAccessible( true );
     593                if ( PHP_VERSION_ID < 80100 ) {
     594                        $extract_directive_value->setAccessible( true );
     595                }
    590596
    591597                $result = $extract_directive_value->invoke( $this->interactivity, 'state.foo', 'myPlugin' );
     
    650656        public function test_extract_directive_value_empty_values() {
    651657                $extract_directive_value = new ReflectionMethod( $this->interactivity, 'extract_directive_value' );
    652                 $extract_directive_value->setAccessible( true );
     658                if ( PHP_VERSION_ID < 80100 ) {
     659                        $extract_directive_value->setAccessible( true );
     660                }
    653661
    654662                $result = $extract_directive_value->invoke( $this->interactivity, '', 'myPlugin' );
     
    684692        public function test_extract_directive_value_invalid_json() {
    685693                $extract_directive_value = new ReflectionMethod( $this->interactivity, 'extract_directive_value' );
    686                 $extract_directive_value->setAccessible( true );
     694                if ( PHP_VERSION_ID < 80100 ) {
     695                        $extract_directive_value->setAccessible( true );
     696                }
    687697
    688698                // Invalid JSON due to missing quotes. Returns the original value.
     
    705715        public function test_extract_prefix_and_suffix() {
    706716                $extract_prefix_and_suffix = new ReflectionMethod( $this->interactivity, 'extract_prefix_and_suffix' );
    707                 $extract_prefix_and_suffix->setAccessible( true );
     717                if ( PHP_VERSION_ID < 80100 ) {
     718                        $extract_prefix_and_suffix->setAccessible( true );
     719                }
    708720
    709721                $result = $extract_prefix_and_suffix->invoke( $this->interactivity, 'data-wp-interactive' );
     
    979991
    980992                $evaluate = new ReflectionMethod( $this->interactivity, 'evaluate' );
    981                 $evaluate->setAccessible( true );
     993                if ( PHP_VERSION_ID < 80100 ) {
     994                        $evaluate->setAccessible( true );
     995                }
    982996
    983997                $result = $evaluate->invokeArgs( $this->interactivity, array( $directive_value ) );
     
    13941408        public function test_kebab_to_camel_case() {
    13951409                $method = new ReflectionMethod( $this->interactivity, 'kebab_to_camel_case' );
    1396                 $method->setAccessible( true );
     1410                if ( PHP_VERSION_ID < 80100 ) {
     1411                        $method->setAccessible( true );
     1412                }
    13971413
    13981414                $this->assertSame( '', $method->invoke( $this->interactivity, '' ) );
  • trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPIFunctions.php

    r58739 r60729  
    283283                $class                = new ReflectionClass( 'WP_Interactivity_API' );
    284284                $directive_processors = $class->getProperty( 'directive_processors' );
    285                 $directive_processors->setAccessible( true );
     285                if ( PHP_VERSION_ID < 80100 ) {
     286                        $directive_processors->setAccessible( true );
     287                }
    286288                $old_directive_processors = $directive_processors->getValue();
    287289                $directive_processors->setValue( null, array( 'data-wp-test' => array( $this, 'data_wp_test_processor' ) ) );
  • trunk/tests/phpunit/tests/menu/walker-nav-menu.php

    r59674 r60729  
    396396                $build_atts_reflection = new ReflectionMethod( $this->walker, 'build_atts' );
    397397
    398                 $build_atts_reflection->setAccessible( true );
     398                if ( PHP_VERSION_ID < 80100 ) {
     399                        $build_atts_reflection->setAccessible( true );
     400                }
    399401                $actual = $build_atts_reflection->invoke( $this->walker, $atts );
    400                 $build_atts_reflection->setAccessible( false );
     402                if ( PHP_VERSION_ID < 80100 ) {
     403                        $build_atts_reflection->setAccessible( false );
     404                }
    401405
    402406                $this->assertSame( $expected, $actual );
  • trunk/tests/phpunit/tests/multisite/network.php

    r60666 r60729  
    158158                $reflection = new ReflectionObject( $network );
    159159                $property   = $reflection->getProperty( 'id' );
    160                 $property->setAccessible( true );
     160                if ( PHP_VERSION_ID < 80100 ) {
     161                        $property->setAccessible( true );
     162                }
    161163
    162164                $this->assertSame( (int) $id, $property->getValue( $network ) );
     
    195197                $reflection = new ReflectionObject( $network );
    196198                $property   = $reflection->getProperty( 'blog_id' );
    197                 $property->setAccessible( true );
     199                if ( PHP_VERSION_ID < 80100 ) {
     200                        $property->setAccessible( true );
     201                }
    198202
    199203                $this->assertIsString( $property->getValue( $network ) );
  • trunk/tests/phpunit/tests/post/query.php

    r57987 r60729  
    727727
    728728                $method = new ReflectionMethod( 'WP_Query', 'set_found_posts' );
    729                 $method->setAccessible( true );
     729                if ( PHP_VERSION_ID < 80100 ) {
     730                        $method->setAccessible( true );
     731                }
    730732                $method->invoke( $q, array( 'no_found_rows' => false ), array() );
    731733
  • trunk/tests/phpunit/tests/query/cacheResults.php

    r59979 r60729  
    103103
    104104                $reflection = new ReflectionMethod( $query1, 'generate_cache_key' );
    105                 $reflection->setAccessible( true );
     105                if ( PHP_VERSION_ID < 80100 ) {
     106                        $reflection->setAccessible( true );
     107                }
    106108
    107109                $cache_key_1 = $reflection->invoke( $query1, $query_vars, $request );
     
    159161
    160162                $reflection = new ReflectionMethod( $query1, 'generate_cache_key' );
    161                 $reflection->setAccessible( true );
     163                if ( PHP_VERSION_ID < 80100 ) {
     164                        $reflection->setAccessible( true );
     165                }
    162166
    163167                $cache_key_1 = $reflection->invoke( $query1, $query_vars, $request );
     
    192196
    193197                $reflection = new ReflectionMethod( $query1, 'generate_cache_key' );
    194                 $reflection->setAccessible( true );
     198                if ( PHP_VERSION_ID < 80100 ) {
     199                        $reflection->setAccessible( true );
     200                }
    195201
    196202                $cache_key_1 = $reflection->invoke( $query1, $query_vars, $request1 );
     
    228234
    229235                $reflection_q1 = new ReflectionProperty( $query1, 'query_cache_key' );
    230                 $reflection_q1->setAccessible( true );
     236                if ( PHP_VERSION_ID < 80100 ) {
     237                        $reflection_q1->setAccessible( true );
     238                }
    231239
    232240                $reflection_q2 = new ReflectionProperty( $query2, 'query_cache_key' );
    233                 $reflection_q2->setAccessible( true );
     241                if ( PHP_VERSION_ID < 80100 ) {
     242                        $reflection_q2->setAccessible( true );
     243                }
    234244
    235245                $this->assertNotSame( $request1, $request2, 'Queries should not match' );
     
    289299
    290300                $reflection_q1 = new ReflectionProperty( $query1, 'query_cache_key' );
    291                 $reflection_q1->setAccessible( true );
     301                if ( PHP_VERSION_ID < 80100 ) {
     302                        $reflection_q1->setAccessible( true );
     303                }
    292304
    293305                $reflection_q2 = new ReflectionProperty( $query2, 'query_cache_key' );
    294                 $reflection_q2->setAccessible( true );
     306                if ( PHP_VERSION_ID < 80100 ) {
     307                        $reflection_q2->setAccessible( true );
     308                }
    295309
    296310                $this->assertNotSame( $request1, $request2, 'Queries should not match' );
     
    346360
    347361                $reflection_q1 = new ReflectionProperty( $query1, 'query_cache_key' );
    348                 $reflection_q1->setAccessible( true );
     362                if ( PHP_VERSION_ID < 80100 ) {
     363                        $reflection_q1->setAccessible( true );
     364                }
    349365
    350366                $reflection_q2 = new ReflectionProperty( $query2, 'query_cache_key' );
    351                 $reflection_q2->setAccessible( true );
     367                if ( PHP_VERSION_ID < 80100 ) {
     368                        $reflection_q2->setAccessible( true );
     369                }
    352370
    353371                $this->assertNotSame( $request1, $request2, 'Queries should not match' );
     
    386404
    387405                $reflection_q1 = new ReflectionProperty( $query1, 'query_cache_key' );
    388                 $reflection_q1->setAccessible( true );
     406                if ( PHP_VERSION_ID < 80100 ) {
     407                        $reflection_q1->setAccessible( true );
     408                }
    389409
    390410                $reflection_q2 = new ReflectionProperty( $query2, 'query_cache_key' );
    391                 $reflection_q2->setAccessible( true );
     411                if ( PHP_VERSION_ID < 80100 ) {
     412                        $reflection_q2->setAccessible( true );
     413                }
    392414
    393415                $this->assertSame( $request1, $request2, 'Queries should match' );
  • trunk/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php

    r59970 r60729  
    708708        public function test_transient_keys_get_generated_correctly( $parameters_1, $parameters_2, $message, $assert_same = true ) {
    709709                $reflection_method = new ReflectionMethod( static::$controller, 'get_transient_key' );
    710                 $reflection_method->setAccessible( true );
     710                if ( PHP_VERSION_ID < 80100 ) {
     711                        $reflection_method->setAccessible( true );
     712                }
    711713
    712714                $result_1 = $reflection_method->invoke( self::$controller, $parameters_1 );
  • trunk/tests/phpunit/tests/rest-api/wpRestBlockPatternCategoriesController.php

    r59970 r60729  
    6464                self::$orig_registry              = WP_Block_Pattern_Categories_Registry::get_instance();
    6565                self::$registry_instance_property = new ReflectionProperty( 'WP_Block_Pattern_Categories_Registry', 'instance' );
    66                 self::$registry_instance_property->setAccessible( true );
     66                if ( PHP_VERSION_ID < 80100 ) {
     67                        self::$registry_instance_property->setAccessible( true );
     68                }
    6769                $test_registry = new WP_Block_Pattern_Categories_Registry();
    6870                self::$registry_instance_property->setValue( null, $test_registry );
     
    9092                // Restore the original registry instance.
    9193                self::$registry_instance_property->setValue( null, self::$orig_registry );
    92                 self::$registry_instance_property->setAccessible( false );
     94
     95                if ( PHP_VERSION_ID < 80100 ) {
     96                        self::$registry_instance_property->setAccessible( false );
     97                }
    9398                self::$registry_instance_property = null;
    9499                self::$orig_registry              = null;
  • trunk/tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php

    r59964 r60729  
    6464                self::$orig_registry              = WP_Block_Patterns_Registry::get_instance();
    6565                self::$registry_instance_property = new ReflectionProperty( 'WP_Block_Patterns_Registry', 'instance' );
    66                 self::$registry_instance_property->setAccessible( true );
     66                if ( PHP_VERSION_ID < 80100 ) {
     67                        self::$registry_instance_property->setAccessible( true );
     68                }
    6769                $test_registry = new WP_Block_Pattern_Categories_Registry();
    6870                self::$registry_instance_property->setValue( null, $test_registry );
     
    108110                // Restore the original registry instance.
    109111                self::$registry_instance_property->setValue( null, self::$orig_registry );
    110                 self::$registry_instance_property->setAccessible( false );
     112                if ( PHP_VERSION_ID < 80100 ) {
     113                        self::$registry_instance_property->setAccessible( false );
     114                }
    111115                self::$registry_instance_property = null;
    112116                self::$orig_registry              = null;
  • trunk/tests/phpunit/tests/rest-api/wpRestTemplatesController.php

    r59970 r60729  
    11421142
    11431143                $prepare_item_for_database = new ReflectionMethod( $endpoint, 'prepare_item_for_database' );
    1144                 $prepare_item_for_database->setAccessible( true );
     1144                if ( PHP_VERSION_ID < 80100 ) {
     1145                        $prepare_item_for_database->setAccessible( true );
     1146                }
    11451147
    11461148                $body_params = array(
     
    11941196
    11951197                $prepare_item_for_database = new ReflectionMethod( $endpoint, 'prepare_item_for_database' );
    1196                 $prepare_item_for_database->setAccessible( true );
     1198                if ( PHP_VERSION_ID < 80100 ) {
     1199                        $prepare_item_for_database->setAccessible( true );
     1200                }
    11971201
    11981202                $id          = get_stylesheet() . '//' . 'my_template_part';
  • trunk/tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php

    r56559 r60729  
    11971197                $class  = new ReflectionClass( WP_REST_URL_Details_Controller::class );
    11981198                $method = $class->getMethod( $method_name );
    1199                 $method->setAccessible( true );
     1199                if ( PHP_VERSION_ID < 80100 ) {
     1200                        $method->setAccessible( true );
     1201                }
    12001202                return $method;
    12011203        }
  • trunk/tests/phpunit/tests/script-modules/wpScriptModules.php

    r60704 r60729  
    876876        public function test_get_src() {
    877877                $get_src = new ReflectionMethod( $this->script_modules, 'get_src' );
    878                 $get_src->setAccessible( true );
     878                if ( PHP_VERSION_ID < 80100 ) {
     879                        $get_src->setAccessible( true );
     880                }
    879881
    880882                $this->script_modules->register(
     
    13511353                $reflection_class    = new ReflectionClass( $script_modules );
    13521354                $registered_property = $reflection_class->getProperty( 'registered' );
    1353                 $registered_property->setAccessible( true );
     1355                if ( PHP_VERSION_ID < 80100 ) {
     1356                        $registered_property->setAccessible( true );
     1357                }
    13541358                return $registered_property->getValue( $script_modules );
    13551359        }
  • trunk/tests/phpunit/tests/term/query.php

    r60661 r60729  
    10691069
    10701070                $reflection = new ReflectionMethod( $query1, 'generate_cache_key' );
    1071                 $reflection->setAccessible( true );
     1071                if ( PHP_VERSION_ID < 80100 ) {
     1072                        $reflection->setAccessible( true );
     1073                }
    10721074
    10731075                $cache_key_1 = $reflection->invoke( $query1, $query_vars, $request );
  • trunk/tests/phpunit/tests/theme.php

    r60251 r60729  
    233233                $reflection = new ReflectionClass( 'WP_Theme' );
    234234                $property   = $reflection->getProperty( 'default_themes' );
    235                 $property->setAccessible( true );
     235                if ( PHP_VERSION_ID < 80100 ) {
     236                        $property->setAccessible( true );
     237                }
    236238
    237239                /*
  • trunk/tests/phpunit/tests/theme/customHeader.php

    r56559 r60729  
    505505                $class    = new ReflectionClass( 'WP_Customize_Manager' );
    506506                $property = $class->getProperty( 'previewing' );
    507                 $property->setAccessible( true );
     507                if ( PHP_VERSION_ID < 80100 ) {
     508                        $property->setAccessible( true );
     509                }
    508510                $property->setValue( $this->customize_manager, $value );
    509511        }
  • trunk/tests/phpunit/tests/theme/wpTheme.php

    r60500 r60729  
    302302                $reflection          = new ReflectionClass( $theme );
    303303                $reflection_property = $reflection->getProperty( 'block_theme' );
    304                 $reflection_property->setAccessible( true );
     304                if ( PHP_VERSION_ID < 80100 ) {
     305                        $reflection_property->setAccessible( true );
     306                }
    305307
    306308                $this->assertSame( $expected, $reflection_property->getValue( $theme ) );
     
    612614                $theme           = new WP_Theme( 'twentytwentytwo', $this->theme_root );
    613615                $sanitize_header = new ReflectionMethod( $theme, 'sanitize_header' );
    614                 $sanitize_header->setAccessible( true );
     616                if ( PHP_VERSION_ID < 80100 ) {
     617                        $sanitize_header->setAccessible( true );
     618                }
    615619
    616620                $actual = $sanitize_header->invoke( $theme, 'UpdateURI', '<?php?><a href="http://example.org">http://example.org</a>' );
  • trunk/tests/phpunit/tests/theme/wpThemeGetBlockPatterns.php

    r58025 r60729  
    4949        private function get_pattern_cache( $wp_theme ) {
    5050                $reflection = new ReflectionMethod( $wp_theme, 'get_pattern_cache' );
    51                 $reflection->setAccessible( true );
     51                if ( PHP_VERSION_ID < 80100 ) {
     52                        $reflection->setAccessible( true );
     53                }
    5254
    5355                $pattern_cache = $reflection->invoke( $wp_theme, 'get_pattern_cache' );
    54                 $reflection->setAccessible( false );
     56                if ( PHP_VERSION_ID < 80100 ) {
     57                        $reflection->setAccessible( false );
     58                }
    5559
    5660                return $pattern_cache;
     
    6569        private function get_cache_hash( $wp_theme ) {
    6670                $reflection = new ReflectionProperty( get_class( $wp_theme ), 'cache_hash' );
    67                 $reflection->setAccessible( true );
     71                if ( PHP_VERSION_ID < 80100 ) {
     72                        $reflection->setAccessible( true );
     73                }
    6874                $cache_hash = $reflection->getValue( $wp_theme );
    69                 $reflection->setAccessible( false );
     75                if ( PHP_VERSION_ID < 80100 ) {
     76                        $reflection->setAccessible( false );
     77                }
    7078                return $cache_hash;
    7179        }
  • trunk/tests/phpunit/tests/theme/wpThemeJson.php

    r59814 r60729  
    24592459
    24602460                $func = $theme_json->getMethod( 'get_block_nodes' );
    2461                 $func->setAccessible( true );
     2461                if ( PHP_VERSION_ID < 81000 ) {
     2462                        $func->setAccessible( true );
     2463                }
    24622464
    24632465                $theme_json = array(
     
    25132515
    25142516                $func = $theme_json->getMethod( 'get_block_nodes' );
    2515                 $func->setAccessible( true );
     2517                if ( PHP_VERSION_ID < 81000 ) {
     2518                        $func->setAccessible( true );
     2519                }
    25162520
    25172521                $theme_json = array(
     
    38523856
    38533857                $get_property_value_method = $reflection_class->getMethod( 'get_property_value' );
    3854                 $get_property_value_method->setAccessible( true );
     3858                if ( PHP_VERSION_ID < 80100 ) {
     3859                        $get_property_value_method->setAccessible( true );
     3860                }
    38553861                $result = $get_property_value_method->invoke( null, $styles, $path );
    38563862
     
    58435849                );
    58445850                $reflection = new ReflectionMethod( $theme_json, 'process_blocks_custom_css' );
    5845                 $reflection->setAccessible( true );
     5851                if ( PHP_VERSION_ID < 80100 ) {
     5852                        $reflection->setAccessible( true );
     5853                }
    58465854
    58475855                $this->assertSame( $expected, $reflection->invoke( $theme_json, $input['css'], $input['selector'] ) );
     
    61786186
    61796187                $func = $theme_json->getMethod( 'get_block_style_variation_selector' );
    6180                 $func->setAccessible( true );
     6188                if ( PHP_VERSION_ID < 80100 ) {
     6189                        $func->setAccessible( true );
     6190                }
    61816191
    61826192                $actual = $func->invoke( null, 'custom', $selector );
     
    62606270
    62616271                $func = $theme_json->getMethod( 'scope_style_node_selectors' );
    6262                 $func->setAccessible( true );
     6272                if ( PHP_VERSION_ID < 80100 ) {
     6273                        $func->setAccessible( true );
     6274                }
    62636275
    62646276                $node = array(
     
    63096321
    63106322                $func = $theme_json->getMethod( 'get_block_nodes' );
    6311                 $func->setAccessible( true );
     6323                if ( PHP_VERSION_ID < 80100 ) {
     6324                        $func->setAccessible( true );
     6325                }
    63126326
    63136327                $theme_json = array(
     
    63456359
    63466360                $func = $theme_json->getMethod( 'get_block_nodes' );
    6347                 $func->setAccessible( true );
     6361                if ( PHP_VERSION_ID < 80100 ) {
     6362                        $func->setAccessible( true );
     6363                }
    63486364
    63496365                $theme_json = array(
  • trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php

    r60234 r60729  
    7878
    7979                static::$property_blocks_cache = new ReflectionProperty( WP_Theme_JSON_Resolver::class, 'blocks_cache' );
    80                 static::$property_blocks_cache->setAccessible( true );
     80                if ( PHP_VERSION_ID < 80100 ) {
     81                        static::$property_blocks_cache->setAccessible( true );
     82                }
    8183                static::$property_blocks_cache_orig_value = static::$property_blocks_cache->getValue();
    8284
    8385                static::$property_core = new ReflectionProperty( WP_Theme_JSON_Resolver::class, 'core' );
    84                 static::$property_core->setAccessible( true );
     86                if ( PHP_VERSION_ID < 80100 ) {
     87                        static::$property_core->setAccessible( true );
     88                }
    8589                static::$property_core_orig_value = static::$property_core->getValue();
    8690        }
     
    307311        public function test_has_same_registered_blocks_when_all_blocks_not_cached( $origin, array $cache = array() ) {
    308312                $has_same_registered_blocks = new ReflectionMethod( WP_Theme_JSON_Resolver::class, 'has_same_registered_blocks' );
    309                 $has_same_registered_blocks->setAccessible( true );
     313                if ( PHP_VERSION_ID < 80100 ) {
     314                        $has_same_registered_blocks->setAccessible( true );
     315                }
    310316                $expected_cache = $this->get_registered_block_names();
    311317
     
    381387        public function test_has_same_registered_blocks_when_all_blocks_are_cached( $origin ) {
    382388                $has_same_registered_blocks = new ReflectionMethod( WP_Theme_JSON_Resolver::class, 'has_same_registered_blocks' );
    383                 $has_same_registered_blocks->setAccessible( true );
     389                if ( PHP_VERSION_ID < 80100 ) {
     390                        $has_same_registered_blocks->setAccessible( true );
     391                }
    384392                $expected_cache = $this->get_registered_block_names();
    385393
     
    837845                // Force-unset $i18n_schema property to "unload" translation schema.
    838846                $property = new ReflectionProperty( $theme_json_resolver, 'i18n_schema' );
    839                 $property->setAccessible( true );
     847                if ( PHP_VERSION_ID < 80100 ) {
     848                        $property->setAccessible( true );
     849                }
    840850                $property->setValue( null, null );
    841851
  • trunk/tests/phpunit/tests/user/queryCache.php

    r58876 r60729  
    772772
    773773                $reflection = new ReflectionMethod( $query1, 'generate_cache_key' );
    774                 $reflection->setAccessible( true );
     774                if ( PHP_VERSION_ID < 80100 ) {
     775                        $reflection->setAccessible( true );
     776                }
    775777
    776778                $cache_key_1 = $reflection->invoke( $query1, $query_vars, $request_with_placeholder );
  • trunk/tests/phpunit/tests/widgets/wpWidgetMedia.php

    r56746 r60729  
    495495                $wp_widget_media = new ReflectionClass( 'WP_Widget_Media' );
    496496                $has_content     = $wp_widget_media->getMethod( 'has_content' );
    497                 $has_content->setAccessible( true );
     497                if ( PHP_VERSION_ID < 80100 ) {
     498                        $has_content->setAccessible( true );
     499                }
    498500
    499501                $result = $has_content->invokeArgs(
Note: See TracChangeset for help on using the changeset viewer.