Make WordPress Core

Changeset 56492


Ignore:
Timestamp:
08/30/2023 10:49:27 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Correct uses of ReflectionProperty::setValue() for static properties.

The single parameter signature, which was used for setting the value on a static property, is deprecated since PHP 8.3. A cross-version solution is to pass null as the first parameter.

This commit updates all the instances that use the deprecated signature in WordPress core.

Reference: PHP RFC: Deprecate functions with overloaded signatures: ReflectionProperty::setValue().

Follow-up to [53152], [54493], [54799].

Props jrf, costdev, Tests: Correct uses of ReflectionProperty::setValue() for static properties.

The single parameter signature, which was used for setting the value on a static property, is deprecated since PHP 8.3. A cross-version solution is to pass null as the first parameter.

This commit updates all the instances that use the deprecated signature in WordPress core.

Reference: PHP RFC: Deprecate functions with overloaded signatures: ReflectionProperty::setValue().

Follow-up to [53152], [54493], [54799].

Props jrf, costdev, sc0ttkclark.
See #59231.

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

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/wpRestBlockPatternCategoriesController.php

    r55457 r56492  
    6666                self::$registry_instance_property->setAccessible( true );
    6767                $test_registry = new WP_Block_Pattern_Categories_Registry();
    68                 self::$registry_instance_property->setValue( $test_registry );
     68                self::$registry_instance_property->setValue( null, $test_registry );
    6969
    7070                // Register some categories in the test registry.
     
    8989
    9090                // Restore the original registry instance.
    91                 self::$registry_instance_property->setValue( self::$orig_registry );
     91                self::$registry_instance_property->setValue( null, self::$orig_registry );
    9292                self::$registry_instance_property->setAccessible( false );
    9393                self::$registry_instance_property = null;
  • trunk/tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php

    r56063 r56492  
    6666                self::$registry_instance_property->setAccessible( true );
    6767                $test_registry = new WP_Block_Pattern_Categories_Registry();
    68                 self::$registry_instance_property->setValue( $test_registry );
     68                self::$registry_instance_property->setValue( null, $test_registry );
    6969
    7070                // Register some patterns in the test registry.
     
    107107
    108108                // Restore the original registry instance.
    109                 self::$registry_instance_property->setValue( self::$orig_registry );
     109                self::$registry_instance_property->setValue( null, self::$orig_registry );
    110110                self::$registry_instance_property->setAccessible( false );
    111111                self::$registry_instance_property = null;
  • trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php

    r55822 r56492  
    8282
    8383        public static function tear_down_after_class() {
    84                 static::$property_blocks_cache->setValue( WP_Theme_JSON_Resolver::class, static::$property_blocks_cache_orig_value );
    85                 static::$property_core->setValue( WP_Theme_JSON_Resolver::class, static::$property_core_orig_value );
     84                static::$property_blocks_cache->setValue( null, static::$property_blocks_cache_orig_value );
     85                static::$property_core->setValue( null, static::$property_core_orig_value );
    8686                parent::tear_down_after_class();
    8787        }
     
    760760                $property = new ReflectionProperty( $theme_json_resolver, 'i18n_schema' );
    761761                $property->setAccessible( true );
    762                 $property->setValue( null );
     762                $property->setValue( null, null );
    763763
    764764                // A completely empty theme.json data set still has the 'version' key when parsed.
Note: See TracChangeset for help on using the changeset viewer.